mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 02:20:30 +01:00
weston: Drop priviledges early, and seteuid when needed
This commit is contained in:
parent
67b11f7a8d
commit
f7968296c6
1 changed files with 6 additions and 0 deletions
|
|
@ -20,6 +20,8 @@
|
|||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -439,6 +441,7 @@ evdev_input_device_create(struct evdev_input *master,
|
|||
struct evdev_input_device *device;
|
||||
struct wl_event_loop *loop;
|
||||
struct weston_compositor *ec;
|
||||
uid_t saved_uid, uid, euid;
|
||||
|
||||
device = malloc(sizeof *device);
|
||||
if (device == NULL)
|
||||
|
|
@ -456,7 +459,10 @@ evdev_input_device_create(struct evdev_input *master,
|
|||
device->rel.dx = 0;
|
||||
device->rel.dy = 0;
|
||||
|
||||
getresuid(&uid, &euid, &saved_uid);
|
||||
seteuid(saved_uid);
|
||||
device->fd = open(path, O_RDONLY);
|
||||
seteuid(euid);
|
||||
if (device->fd < 0)
|
||||
goto err0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue