mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-04-07 08:21:07 -04:00
drop permissions
This commit is contained in:
parent
79b7e755b0
commit
6259c5f5d3
1 changed files with 19 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue