mirror of
https://github.com/omar-polo/gmid.git
synced 2024-09-30 06:21:19 +02:00
mark every open file as close-on-exec
This commit is contained in:
parent
72342dc960
commit
e8cac16e03
5
gmid.c
5
gmid.c
@ -310,7 +310,8 @@ open_file(char *path, struct pollfd *fds, struct client *c)
|
|||||||
fpath[0] = '.';
|
fpath[0] = '.';
|
||||||
strlcat(fpath, path, PATHBUF);
|
strlcat(fpath, path, PATHBUF);
|
||||||
|
|
||||||
if ((c->fd = openat(dirfd, fpath, O_RDONLY | O_NOFOLLOW)) == -1) {
|
if ((c->fd = openat(dirfd, fpath,
|
||||||
|
O_RDONLY | O_NOFOLLOW | O_CLOEXEC)) == -1) {
|
||||||
LOG(c, "open failed: %s", fpath);
|
LOG(c, "open failed: %s", fpath);
|
||||||
if (!start_reply(fds, c, NOT_FOUND, "not found"))
|
if (!start_reply(fds, c, NOT_FOUND, "not found"))
|
||||||
return 0;
|
return 0;
|
||||||
@ -831,7 +832,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
/* open log file or create it with 644 */
|
/* open log file or create it with 644 */
|
||||||
if ((logfd = open(optarg, O_WRONLY | O_CREAT,
|
if ((logfd = open(optarg, O_WRONLY | O_CREAT | O_CLOEXEC,
|
||||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWOTH)) == -1)
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IWOTH)) == -1)
|
||||||
err(1, "%s", optarg);
|
err(1, "%s", optarg);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user