diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-08-12 14:06:43 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-08-12 14:06:43 +0000 |
commit | dc0b0b584c59f7c41cf33dc90aaba9cafa5a9004 (patch) | |
tree | 93187690b54ac4758f75f6bfbb592cffbc769a5d /xserver/os | |
parent | 4717a0e99c56ee9dfdb3da179740cb7ab6c3cd12 (diff) |
Fix a logic introducred in rev 1.23. The parent pid is initialized
by the main X server too late in the privsep case (already in the
unpriviliged child). So keep the early init for this case.
Diffstat (limited to 'xserver/os')
-rw-r--r-- | xserver/os/privsep.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/xserver/os/privsep.c b/xserver/os/privsep.c index 6cc8cda47..112adc914 100644 --- a/xserver/os/privsep.c +++ b/xserver/os/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.23 2012/08/07 20:16:12 matthieu Exp $ */ +/* $OpenBSD: privsep.c,v 1.24 2012/08/12 14:06:42 matthieu Exp $ */ /* * Copyright 2001 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -123,7 +123,7 @@ struct okdev { /* return 1 if allowed to open said path */ static struct okdev * -open_ok(const char *path) +open_ok(const char *path) { struct okdev *p; struct stat sb; @@ -175,7 +175,7 @@ send_fd(int s, int fd) vec.iov_len = sizeof(int); msg.msg_iov = &vec; msg.msg_iovlen = 1; - + if ((n = sendmsg(s, &msg, 0)) == -1) warn("%s: sendmsg(%d)", __func__, s); if (n != sizeof(int)) @@ -240,6 +240,8 @@ priv_init(uid_t uid, gid_t gid) priv_cmd_t cmd; struct okdev *dev; + parent_pid = getppid(); + /* Create sockets */ if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, socks) == -1) { return -1; @@ -259,14 +261,14 @@ priv_init(uid_t uid, gid_t gid) return -1; if (seteuid(uid) == -1) return -1; - if (setuid(uid) == -1) + if (setuid(uid) == -1) return -1; close(socks[0]); priv_fd = socks[1]; return 0; } /* son */ - for (i = 1; i <= _NSIG; i++) + for (i = 1; i <= _NSIG; i++) signal(i, SIG_DFL); setproctitle("[priv]"); close(socks[1]); @@ -285,7 +287,7 @@ priv_init(uid_t uid, gid_t gid) errno = EPERM; } send_fd(socks[0], fd); - if (fd >= 0) + if (fd >= 0) close(fd); break; case PRIV_SIG_PARENT: @@ -335,10 +337,8 @@ priv_signal_parent(void) priv_cmd_t cmd; if (priv_fd != -1) { - if (parent_pid == -1) { - warnx("parent_pid == -1"); - return -1; - } + if (parent_pid == -1) + warnx("parent_pid == -1\n"); cmd.cmd = PRIV_SIG_PARENT; write(priv_fd, &cmd, sizeof(cmd)); } else |