|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xl: close nullfd after dup2'ing it to stdin
commit bb1372884283100ad65efde1b6b66cc7669505e9
Author: Ian Campbell <ian.campbell@xxxxxxxxxx>
AuthorDate: Wed Feb 17 10:39:40 2016 +0000
Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Tue Mar 1 13:38:50 2016 +0000
xl: close nullfd after dup2'ing it to stdin
We assert that nullfd if not std{in,out,err} since that would result
in closing one of the just dup2'd fds. For this to happen
std{in,out,err} would have needed to be closed, at which point all
sorts of other things could go wrong.
CID: 1130519
It was previously hypothesised[0] that fixing 1130516 would solve this
too, but that appears to not have been the case.
Compile tested only.
[0]
http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg02931.html
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: andrew.cooper3@xxxxxxxxxx
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
tools/libxl/xl_cmdimpl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 09037ca..80d8781 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -499,12 +499,17 @@ static int do_daemonize(char *name, const char *pidfile)
CHK_SYSCALL(logfile = open(fullname, O_WRONLY|O_CREAT|O_APPEND, 0644));
free(fullname);
+ assert(logfile >= 3);
CHK_SYSCALL(nullfd = open("/dev/null", O_RDONLY));
+ assert(nullfd >= 3);
+
dup2(nullfd, 0);
dup2(logfile, 1);
dup2(logfile, 2);
+ close(nullfd);
+
CHK_SYSCALL(daemon(0, 1));
if (pidfile) {
--
generated by git-patchbot for /home/xen/git/xen.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |