diff options
author | Thomas Klausner <wiz@NetBSD.org> | 2015-02-25 22:22:50 +0100 |
---|---|---|
committer | Thomas Klausner <wiz@NetBSD.org> | 2015-02-28 18:19:52 +0100 |
commit | 6c335e1c315a68283b1303afb06a3d5a34adab83 (patch) | |
tree | d2b09dcf66bbae97a29130ee2d9ed3e731053f57 | |
parent | 0caed2fbce401e48d55ebfeda968e9ea8012f01d (diff) |
Close file descriptors on exec.
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
-rw-r--r-- | auth.c | 4 | ||||
-rw-r--r-- | choose.c | 2 | ||||
-rw-r--r-- | lock.c | 1 | ||||
-rw-r--r-- | remote.c | 3 | ||||
-rw-r--r-- | restart.c | 1 | ||||
-rw-r--r-- | saveutil.c | 3 |
6 files changed, 13 insertions, 1 deletions
@@ -156,24 +156,28 @@ SetAuthentication(int count, IceListenObj *listenObjs, if (!(addfp = fopen (addAuthFile, "w"))) goto bad; + fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC); if ((remAuthFile = unique_filename (path, ".xsm")) == NULL) goto bad; if (!(removefp = fopen (remAuthFile, "w"))) goto bad; + fcntl(fileno(removefp), F_SETFD, FD_CLOEXEC); #else if ((addAuthFile = unique_filename (path, ".xsm", &fd)) == NULL) goto bad; if (!(addfp = fdopen(fd, "wb"))) goto bad; + fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC); if ((remAuthFile = unique_filename (path, ".xsm", &fd)) == NULL) goto bad; if (!(removefp = fdopen(fd, "wb"))) goto bad; + fcntl(fileno(removefp), F_SETFD, FD_CLOEXEC); #endif if ((*authDataEntries = (IceAuthDataEntry *) XtMalloc ( @@ -98,6 +98,8 @@ GetSessionNames(int *count_ret, String **short_names_ret, if ((dir = opendir (path)) == NULL) return 0; + fcntl(dirfd(dir), F_SETFD, FD_CLOEXEC); + count = 0; while ((entry = readdir (dir)) != NULL) @@ -121,6 +121,7 @@ GetLockId(const char *session_name) { return (NULL); } + fcntl(fileno(fp), F_SETFD, FD_CLOEXEC); buf[0] = '\0'; fscanf (fp, "%255s\n", buf); @@ -111,7 +111,8 @@ remote_start(const char *restart_protocol, const char *restart_machine, default: /* parent */ close (pipefd[0]); - fp = (FILE *) fdopen (pipefd[1], "w"); + fcntl(pipefd[1], F_SETFD, FD_CLOEXEC); + fp = fdopen (pipefd[1], "w"); fprintf (fp, "CONTEXT X\n"); fprintf (fp, "DIR %s\n", cwd); @@ -543,6 +543,7 @@ StartDefaultApps (void) exit (1); } } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); buf = NULL; buflen = 0; @@ -72,6 +72,7 @@ ReadSave(const char *session_name, char **sm_id) *sm_id = NULL; return 0; } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); if (verbose) printf("Reading session save file...\n"); @@ -319,6 +320,7 @@ WriteSave(const char *sm_id) } else { + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); fprintf (f, "%d\n", SAVEFILE_VERSION); fprintf (f, "%s\n", sm_id); @@ -431,6 +433,7 @@ DeleteSession(const char *session_name) if(!f) { return (0); } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); buf = NULL; buflen = 0; |