diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-02-27 19:15:28 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-02-28 20:08:53 +0100 |
commit | b5c4862abfe8d72efa094ee498c50a7af8a2830b (patch) | |
tree | 438fbe36fd89dc224e4dad7a1d1ce26930dcfeeb /src | |
parent | 63c180a63657bc7dd55bab423ea0c2751c87310b (diff) |
afm-user-session: Start target from user session
Start the afm-user-session@%i.target from the
user session after pam_sytemd session started.
Change-Id: I5aeb8f01426b3cee2cbfad6ba30ecf37fe21abca
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/afm-user-session.c | 21 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6a1b497..6aff23e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -177,7 +177,7 @@ if(libsystemd_FOUND AND AFB_FOUND) install(TARGETS afm-binding LIBRARY DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/afm) add_executable(afm-user-session afm-user-session.c) - install(TARGETS afm-user-session DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS afm-user-session DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS SETUID OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) else() MESSAGE(STATUS "Not creating daemons") endif() diff --git a/src/afm-user-session.c b/src/afm-user-session.c index 51acafe..445db91 100644 --- a/src/afm-user-session.c +++ b/src/afm-user-session.c @@ -16,23 +16,20 @@ limitations under the License. */ -#include <signal.h> +#include <stdio.h> +#include <unistd.h> #include <systemd/sd-daemon.h> +extern char **environ; + int main() { - sigset_t ass, bss; - - sigemptyset(&ass); - sigaddset(&ass, SIGTERM); - - sigfillset(&bss); - sigdelset(&bss, SIGTERM); + char buffer[100]; + char *args[] = { "/bin/systemctl", "--wait", "start", buffer, 0 }; + sprintf(buffer, "afm-user-session@%d.target", (int)getuid()); sd_notify(0, "READY=1"); - sigprocmask(SIG_SETMASK, &bss, 0); - sigwaitinfo(&ass, 0); - - return 0; + execve(args[0], args, environ); + return 1; } |