Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sandbox:master commit in: /, libsandbox/
Date: Wed, 07 Mar 2012 05:28:35
Message-Id: 1331098081.00e64315a17b5f681c5a9f0114ac18eb002faa27.vapier@gentoo
1 commit: 00e64315a17b5f681c5a9f0114ac18eb002faa27
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 7 05:22:55 2012 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 7 05:28:01 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commit;h=00e64315
7
8 libsandbox: mark internal fds with O_CLOEXEC
9
10 We don't want to bleed these across forks/execs.
11
12 Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
13
14 ---
15 libsandbox/libsandbox.c | 4 ++--
16 localdecls.h | 4 ++++
17 2 files changed, 6 insertions(+), 2 deletions(-)
18
19 diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
20 index a36e190..77a2415 100644
21 --- a/libsandbox/libsandbox.c
22 +++ b/libsandbox/libsandbox.c
23 @@ -386,7 +386,7 @@ static int sb_copy_file_to_fd(const char *file, int ofd)
24 {
25 int ret = -1;
26
27 - int ifd = sb_open(file, O_RDONLY, 0);
28 + int ifd = sb_open(file, O_RDONLY|O_CLOEXEC, 0);
29 if (ifd == -1)
30 return ret;
31
32 @@ -480,7 +480,7 @@ static bool write_logfile(const char *logfile, const char *func, const char *pat
33 }
34
35 logfd = sb_open(logfile,
36 - O_APPEND | O_WRONLY | O_CREAT,
37 + O_APPEND | O_WRONLY | O_CREAT | O_CLOEXEC,
38 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
39 if (logfd == -1) {
40 SB_EERROR("ISE:write_logfile ", "unable to append logfile\n");
41
42 diff --git a/localdecls.h b/localdecls.h
43 index 590654d..674e848 100644
44 --- a/localdecls.h
45 +++ b/localdecls.h
46 @@ -49,6 +49,10 @@
47 # define MAP_ANONYMOUS MAP_ANON
48 #endif
49
50 +#ifndef O_CLOEXEC
51 +# define O_CLOEXEC 0
52 +#endif
53 +
54 #if !HAVE_DECL_ENVIRON
55 extern char **environ;
56 #endif