add pledge support and error messages
This commit is contained in:
parent
4152e1651f
commit
39f3aa2ab6
13
xmem.c
13
xmem.c
@ -7,8 +7,10 @@
|
|||||||
* $XConsortium: xload.c,v 1.36 91/05/24 16:57:46 converse Exp $
|
* $XConsortium: xload.c,v 1.36 91/05/24 16:57:46 converse Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <X11/Intrinsic.h>
|
#include <X11/Intrinsic.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/StringDefs.h>
|
#include <X11/StringDefs.h>
|
||||||
@ -157,8 +159,10 @@ int main(int argc, char **argv)
|
|||||||
/* For security reasons, we reset our uid/gid after doing the necessary
|
/* For security reasons, we reset our uid/gid after doing the necessary
|
||||||
system initialization and before calling any X routines. */
|
system initialization and before calling any X routines. */
|
||||||
|
|
||||||
setgid(getgid()); /* reset gid first while still (maybe) root */
|
if (setgid(getgid()) == -1)
|
||||||
setuid(getuid());
|
errx(1, "%s: setgid failed: %s\n", argv[0], strerror(errno));
|
||||||
|
if (setuid(getuid()) == -1)
|
||||||
|
errx(1, "%s: setuid failed: %s\n", argv[0], strerror(errno));
|
||||||
|
|
||||||
toplevel = XtAppInitialize(&app_con, "XMem", options_mem, XtNumber(options_mem),
|
toplevel = XtAppInitialize(&app_con, "XMem", options_mem, XtNumber(options_mem),
|
||||||
&argc, argv, NULL, NULL, (Cardinal) 0);
|
&argc, argv, NULL, NULL, (Cardinal) 0);
|
||||||
@ -219,6 +223,9 @@ int main(int argc, char **argv)
|
|||||||
(void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
|
(void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
|
||||||
&wm_delete_window, 1);
|
&wm_delete_window, 1);
|
||||||
|
|
||||||
|
if (pledge("ps vminfo stdio", NULL) == -1)
|
||||||
|
errx(1, "pledge failed: %s", strerror(errno));
|
||||||
|
|
||||||
XtAppMainLoop(app_con);
|
XtAppMainLoop(app_con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user