1 --- xc/programs/Xserver/hw/xfree86/common/xf86Init.c 14 Dec 2005 20:12:00 -0000 1.29
2 +++ xc/programs/Xserver/hw/xfree86/common/xf86Init.c 5 Jun 2006 10:35:19 -0000
4 FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno));
8 + if (setuid(getuid()) == -1) {
9 + xf86Msg(X_ERROR, "xf86RunVtInit: setuid failed (%s)\n",
13 /* set stdin, stdout to the consoleFd */
14 for (i = 0; i < 2; i++) {
15 if (xf86Info.consoleFd != i) {
16 --- xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c 3 Jul 2005 08:53:48 -0000 1.9
17 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c 5 Jun 2006 10:35:19 -0000
18 @@ -1270,7 +1270,10 @@
19 #ifndef SELF_CONTAINED_WRAPPER
23 + if (setuid(getuid()) == -1) {
24 + ErrorF("xf86Execl: setuid() failed: %s\n", strerror(errno));
27 #if !defined(SELF_CONTAINED_WRAPPER)
28 /* set stdin, stdout to the consoleFD, and leave stderr alone */
29 for (i = 0; i < 2; i++)
30 --- xc/programs/Xserver/hw/xfree86/parser/write.c 3 Jul 2005 07:01:37 -0000 1.3
31 +++ xc/programs/Xserver/hw/xfree86/parser/write.c 5 Jun 2006 10:35:19 -0000
37 + if (setuid(getuid() == -1)
38 + FatalError("xf86writeConfigFile(): "
39 + "setuid failed(%s)\n",
41 ret = doWriteConfigFile(filename, cptr);
44 --- xc/programs/Xserver/os/utils.c 8 Nov 2005 06:33:30 -0000 1.21
45 +++ xc/programs/Xserver/os/utils.c 5 Jun 2006 10:35:20 -0000
46 @@ -1718,8 +1718,10 @@
52 + if (setgid(getgid()) == -1)
54 + if (setuid(getuid()) == -1)
56 execl("/bin/sh", "sh", "-c", command, (char *)NULL);
59 @@ -1770,8 +1772,10 @@
65 + if (setgid(getgid()) == -1)
67 + if (setuid(getuid()) == -1)
72 @@ -1845,8 +1849,10 @@
78 + if (setgid(getgid()) == -1)
80 + if (setuid(getuid()) == -1)
85 --- xc/programs/xdm/session.c 8 Nov 2005 06:33:31 -0000 1.3
86 +++ xc/programs/xdm/session.c 5 Jun 2006 10:35:21 -0000
91 - setgid (verify.gid);
92 - setuid (verify.uid);
93 + if (setgid (verify.gid) == -1) {
94 + LogError( "SessionExit: setgid: %s\n", strerror(errno));
97 + if (setuid (verify.uid) == -1) {
98 + LogError( "SessionExit: setuid: %s\n", strerror(errno));
101 RemoveUserAuthorization (d, &verify);
103 /* do like "kdestroy" program */
104 --- xc/programs/xdm/xdmshell.c 14 Jul 2005 22:58:25 -0000 1.3
105 +++ xc/programs/xdm/xdmshell.c 5 Jun 2006 10:35:21 -0000
109 /* make xdm run in a non-setuid environment */
110 - setuid (geteuid());
111 + if (setuid (geteuid()) == -1) {
112 + fprintf(stderr, "%s: cannot setuid (error %d, %s)\r\n",
113 + ProgramName, errno, strerror(errno));
118 * exec /usr/bin/X11/xdm -nodaemon -udpPort 0
119 --- xc/programs/xf86dga/dga.c 23 Apr 2004 19:54:47 -0000 1.2
120 +++ xc/programs/xf86dga/dga.c 5 Jun 2006 10:35:21 -0000
123 #include <X11/extensions/xf86dga.h>
132 /* Give up root privs */
134 + if (setuid(getuid()) == -1) {
135 + fprintf(stderr, "Unable to change uid: %s\n", strerror(errno));
140 XF86DGASetViewPort(dis, DefaultScreen(dis), 0, 0);
141 --- xc/programs/xinit/xinit.c 4 Oct 2005 01:27:34 -0000 1.4
142 +++ xc/programs/xinit/xinit.c 5 Jun 2006 10:35:21 -0000
144 startClient(char *client[])
146 if ((clientpid = vfork()) == 0) {
148 + if (setuid(getuid()) == -1) {
149 + Error("cannot change uid: %s\n", strerror(errno));
152 setpgrp(0, getpid());
153 environ = newenviron;
155 --- xc/programs/xload/xload.c 23 Apr 2004 19:54:57 -0000 1.2
156 +++ xc/programs/xload/xload.c 5 Jun 2006 10:35:21 -0000
158 * xload - display system load average in a window
167 /* For security reasons, we reset our uid/gid after doing the necessary
168 system initialization and before calling any X routines. */
170 - setgid(getgid()); /* reset gid first while still (maybe) root */
172 + /* reset gid first while still (maybe) root */
173 + if (setgid(getgid()) == -1) {
174 + fprintf(stderr, "%s: setgid failed: %s\n",
175 + ProgramName, strerror(errno));
178 + if (setuid(getuid()) == -1) {
179 + fprintf(stderr, "%s: setuid failed: %s\n",
180 + ProgramName, strerror(errno));
184 XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
186 --- xc/programs/xterm/main.c 14 Dec 2005 23:28:27 -0000 1.8
187 +++ xc/programs/xterm/main.c 5 Jun 2006 10:35:22 -0000
188 @@ -1592,8 +1592,10 @@
189 Window winToEmbedInto = None;
191 #ifdef DISABLE_SETUID
194 + if (seteuid(getuid()) == -1)
196 + if (setuid(getuid()) == -1)
200 ProgramName = argv[0];
201 @@ -1619,8 +1621,16 @@
203 #if defined(USE_UTMP_SETGID)
207 + if (seteuid(getuid()) == -1) {
209 + "%s: unable to change back euid\n", ProgramName);
212 + if (setuid(getuid()) == -1) {
214 + "%s: unable to change back uid\n", ProgramName);
217 #define get_pty(pty, from) really_get_pty(pty, from)
220 --- xc/programs/xterm/misc.c 14 Dec 2005 23:28:27 -0000 1.6
221 +++ xc/programs/xterm/misc.c 5 Jun 2006 10:35:22 -0000
222 @@ -1094,8 +1094,10 @@
228 + if (setgid(gid) == -1)
229 + _exit(ERROR_SETUID);
230 + if (setuid(uid) == -1)
231 + _exit(ERROR_SETUID);
233 O_WRONLY | O_CREAT | (append ? O_APPEND : O_EXCL),
235 @@ -1262,8 +1264,10 @@
236 signal(SIGCHLD, SIG_DFL);
238 /* (this is redundant) */
239 - setgid(screen->gid);
240 - setuid(screen->uid);
241 + if (setgid(screen->gid) == -1)
242 + exit(ERROR_SETUID);
243 + if (setuid(screen->uid) == -1)
244 + exit(ERROR_SETUID);
246 execl(shell, shell, "-c", &screen->logfile[1], (void *) 0);
248 --- xc/programs/xterm/print.c 5 Aug 2005 16:13:04 -0000 1.5
249 +++ xc/programs/xterm/print.c 5 Jun 2006 10:35:22 -0000
251 dup2(fileno(stderr), 2);
252 close(fileno(stderr));
255 - setgid(screen->gid); /* don't want privileges! */
256 - setuid(screen->uid);
257 + /* don't want privileges! */
258 + if (setgid(screen->gid) == -1)
260 + if (setuid(screen->uid) == -1)
263 Printer = popen(screen->printer_command, "w");
264 input = fdopen(my_pipe[0], "r");