summaryrefslogtreecommitdiff
blob: 96d2d0a3225a6758da70ea5bec59d4800263a693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Index: hw/xfree86/common/xf86Init.c
===================================================================
RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Init.c,v
retrieving revision 1.33.2.2
diff -u -u -r1.33.2.2 xf86Init.c
--- hw/xfree86/common/xf86Init.c	9 May 2006 18:04:19 -0000	1.33.2.2
+++ hw/xfree86/common/xf86Init.c	20 Jun 2006 08:33:03 -0000
@@ -1905,7 +1905,11 @@
           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) {
Index: hw/xfree86/os-support/shared/libc_wrapper.c
===================================================================
RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/shared/libc_wrapper.c,v
retrieving revision 1.11
diff -u -u -r1.11 libc_wrapper.c
--- hw/xfree86/os-support/shared/libc_wrapper.c	25 Mar 2006 19:52:04 -0000	1.11
+++ hw/xfree86/os-support/shared/libc_wrapper.c	20 Jun 2006 08:33:03 -0000
@@ -1270,7 +1270,10 @@
 #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++)
Index: hw/xfree86/parser/write.c
===================================================================
RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/parser/write.c,v
retrieving revision 1.3
diff -u -u -r1.3 write.c
--- hw/xfree86/parser/write.c	3 Jul 2005 07:01:37 -0000	1.3
+++ hw/xfree86/parser/write.c	20 Jun 2006 08:33:03 -0000
@@ -170,7 +170,10 @@
 					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;
Index: os/utils.c
===================================================================
RCS file: /cvs/xorg/xserver/xorg/os/utils.c,v
retrieving revision 1.25
diff -u -u -r1.25 utils.c
--- os/utils.c	25 Mar 2006 19:52:05 -0000	1.25
+++ os/utils.c	20 Jun 2006 08:33:04 -0000
@@ -1721,8 +1721,10 @@
     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 */
@@ -1773,8 +1775,10 @@
 	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 */
@@ -1848,8 +1852,10 @@
 	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 */