From fd961d2ea0eea2cc60f4af1aca6b6e7711d43995 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Fri, 12 Jul 2024 00:51:12 +0200 Subject: openrc-user: init script for users adds a new multiplexed script for starting user sessions. it also sets up XDG_RUNTIME_DIR. Signed-off-by: Anna (navi) Figueiredo Gomes --- src/user_init/meson.build | 5 +++++ src/user_init/user_init.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/user_init/meson.build create mode 100644 src/user_init/user_init.c (limited to 'src/user_init') diff --git a/src/user_init/meson.build b/src/user_init/meson.build new file mode 100644 index 00000000..838805fb --- /dev/null +++ b/src/user_init/meson.build @@ -0,0 +1,5 @@ +executable('user_init', ['user_init.c'], + include_directories: [incdir, einfo_incdir, rc_incdir], + link_with: [libeinfo, librc], + install: true, + install_dir: rc_bindir) diff --git a/src/user_init/user_init.c b/src/user_init/user_init.c new file mode 100644 index 00000000..1f79ec90 --- /dev/null +++ b/src/user_init/user_init.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +#include "rc.h" + +#define USERINIT RC_LIBEXECDIR "/sh/user-init.sh" + +int main(int argc, char **argv) { + struct passwd *user; + if (argc < 3) + return 1; + + user = getpwnam(argv[1]); + if (!user || initgroups(user->pw_name, user->pw_gid) == -1 + || setgid(user->pw_gid) == -1 + || setuid(user->pw_uid) == -1) + return 1; + + execl(user->pw_shell, "-", "-c", USERINIT, argv[2], NULL); +} -- cgit v1.2.3