summaryrefslogtreecommitdiff
path: root/xload.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2006-06-20 19:25:51 +0000
committerMatthieu Herrb <matthieu.herrb@laas.fr>2006-06-20 19:25:51 +0000
commit1dbb7df5ccec3e3d9fecded33850730486d6374d (patch)
tree0682acb4b363e3e6bb3c8b1b4f74ac0f66701294 /xload.c
parent382ca2392d31870cfb4b8b01cd2751040c479f86 (diff)
Check setuid() return value. Bugzilla #7116.
Diffstat (limited to 'xload.c')
-rw-r--r--xload.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/xload.c b/xload.c
index 65595f0..2dc1cb3 100644
--- a/xload.c
+++ b/xload.c
@@ -34,7 +34,7 @@ from the X Consortium.
* xload - display system load average in a window
*/
-
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -162,8 +162,17 @@ main(int argc, char **argv)
/* For security reasons, we reset our uid/gid after doing the necessary
system initialization and before calling any X routines. */
InitLoadPoint();
- setgid(getgid()); /* reset gid first while still (maybe) root */
- setuid(getuid());
+ /* reset gid first while still (maybe) root */
+ if (setgid(getgid()) == -1) {
+ fprintf(stderr, "%s: setgid failed: %s\n",
+ ProgramName, strerror(errno));
+ exit(1);
+ }
+ if (setuid(getuid()) == -1) {
+ fprintf(stderr, "%s: setuid failed: %s\n",
+ ProgramName, strerror(errno));
+ exit(1);
+ }
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);