mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-12-16 18:03:19 +00:00
drop permissions
This commit is contained in:
parent
79b7e755b0
commit
6259c5f5d3
19
dwl.c
19
dwl.c
@ -1117,6 +1117,23 @@ dirtomon(enum wlr_direction dir)
|
||||
return selmon;
|
||||
}
|
||||
|
||||
static void
|
||||
drop_permissions(void)
|
||||
{
|
||||
if (getuid() != geteuid() || getgid() != getegid()) {
|
||||
/* Set the gid and uid in the correct order. */
|
||||
if (setgid(getgid()) != 0) {
|
||||
die("Unable to drop root group, refusing to start");
|
||||
}
|
||||
if (setuid(getuid()) != 0) {
|
||||
die("Unable to drop root user, refusing to start");
|
||||
}
|
||||
}
|
||||
if (setgid(0) != -1 || setuid(0) != -1) {
|
||||
die("Unable to drop root, refusing to start");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
focusclient(Client *c, int lift)
|
||||
{
|
||||
@ -1929,6 +1946,8 @@ setup(void)
|
||||
if (!(backend = wlr_backend_autocreate(dpy)))
|
||||
die("couldn't create backend");
|
||||
|
||||
drop_permissions();
|
||||
|
||||
/* Initialize the scene graph used to lay out windows */
|
||||
scene = wlr_scene_create();
|
||||
layers[LyrBg] = &wlr_scene_tree_create(&scene->node)->node;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user