diff options
author | Daniel Golle <daniel@makrotopia.org> | 2020-10-19 13:43:23 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2020-10-19 15:48:30 +0100 |
commit | 31214674545c3703c1171a02a1949a5d3162bdee (patch) | |
tree | 5cc8b6c7d279ecec872ada1a9d730dc0059a33b3 /state.c | |
parent | 5ade5673d9a0c9cc1e178f71bd4a20e8c392ec6f (diff) | |
download | procd-31214674545c3703c1171a02a1949a5d3162bdee.tar.gz |
early: run ubusd non-root as user ubus, group ubus
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'state.c')
-rw-r--r-- | state.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -13,6 +13,7 @@ */ #include <fcntl.h> +#include <pwd.h> #include <sys/reboot.h> #include <stdio.h> #include <stdlib.h> @@ -125,6 +126,7 @@ static void perform_halt() static void state_enter(void) { char ubus_cmd[] = "/sbin/ubusd"; + struct passwd *p; switch (state) { case STATE_EARLY: @@ -139,8 +141,13 @@ static void state_enter(void) watchdog_init(0); set_stdio("console"); LOG("- ubus -\n"); + p = getpwnam("ubus"); + if (p) { + mkdir(p->pw_dir, 0755); + chown(p->pw_dir, p->pw_uid, p->pw_gid); + } procd_connect_ubus(); - service_start_early("ubus", ubus_cmd); + service_start_early("ubus", ubus_cmd, p?"ubus":NULL, p?"ubus":NULL); break; case STATE_INIT: |