xserver: Branch 'master'
Matthieu Herrb
herrb at kemper.freedesktop.org
Tue Jun 20 22:08:08 EEST 2006
hw/xfree86/common/xf86Init.c | 6 +++++-
hw/xfree86/os-support/shared/libc_wrapper.c | 5 ++++-
hw/xfree86/parser/write.c | 5 ++++-
os/utils.c | 20 +++++++++++++-------
4 files changed, 26 insertions(+), 10 deletions(-)
New commits:
diff-tree 2b58685402e70f123e131fd8146e6083ff5214a4 (from 4365d16c8629e824973ee0c357efdfbfd28b672c)
Author: Matthieu Herrb <matthieu at deville.herrb.com>
Date: Tue Jun 20 21:07:53 2006 +0200
Check setuid() return value. Bugzilla #7116.
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 9bb2bf8..3aed369 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1896,7 +1896,11 @@ xf86RunVtInit(void)
FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno));
break;
case 0: /* child */
- setuid(getuid());
+ if (setuid(getuid()) == -1) {
+ xf86Msg(X_ERROR, "xf86RunVtInit: setuid failed (%s)\n",
+ strerror(errno));
+ exit(255);
+ }
/* set stdin, stdout to the consoleFd */
for (i = 0; i < 2; i++) {
if (xf86Info.consoleFd != i) {
diff --git a/hw/xfree86/os-support/shared/libc_wrapper.c b/hw/xfree86/os-support/shared/libc_wrapper.c
index fc4edc3..1663893 100644
--- a/hw/xfree86/os-support/shared/libc_wrapper.c
+++ b/hw/xfree86/os-support/shared/libc_wrapper.c
@@ -1270,7 +1270,10 @@ xf86execl(const char *pathname, const ch
#ifndef SELF_CONTAINED_WRAPPER
xf86DisableIO();
#endif
- setuid(getuid());
+ if (setuid(getuid()) == -1) {
+ ErrorF("xf86Execl: setuid() failed: %s\n", strerror(errno));
+ exit(255);
+ }
#if !defined(SELF_CONTAINED_WRAPPER)
/* set stdin, stdout to the consoleFD, and leave stderr alone */
for (i = 0; i < 2; i++)
diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index 285080d..82baa5a 100644
--- a/hw/xfree86/parser/write.c
+++ b/hw/xfree86/parser/write.c
@@ -170,7 +170,10 @@ xf86writeConfigFile (const char *filenam
strerror(errno));
return 0;
case 0: /* child */
- setuid(getuid());
+ if (setuid(getuid() == -1)
+ FatalError("xf86writeConfigFile(): "
+ "setuid failed(%s)\n",
+ strerror(errno));
ret = doWriteConfigFile(filename, cptr);
exit(ret);
break;
diff --git a/os/utils.c b/os/utils.c
index 43c6365..617d201 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xserver/xorg/os/utils.c,v 1.25 2006/03/25 19:52:05 ajax Exp $ */
+/* $XdotOrg: xserver/xorg/os/utils.c,v 1.26 2006-06-01 22:06:41 daniels Exp $ */
/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */
/*
@@ -1713,8 +1713,10 @@ System(char *command)
case -1: /* error */
p = -1;
case 0: /* child */
- setgid(getgid());
- setuid(getuid());
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
execl("/bin/sh", "sh", "-c", command, (char *)NULL);
_exit(127);
default: /* parent */
@@ -1765,8 +1767,10 @@ Popen(char *command, char *type)
xfree(cur);
return NULL;
case 0: /* child */
- setgid(getgid());
- setuid(getuid());
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
if (*type == 'r') {
if (pdes[1] != 1) {
/* stdout */
@@ -1840,8 +1844,10 @@ Fopen(char *file, char *type)
xfree(cur);
return NULL;
case 0: /* child */
- setgid(getgid());
- setuid(getuid());
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
if (*type == 'r') {
if (pdes[1] != 1) {
/* stdout */
More information about the xorg-commit
mailing list