diff options
author | Simon Rettberg | 2019-10-21 15:05:53 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-10-21 15:05:53 +0200 |
commit | 6b48cd4b57211fbb75e91cb80771c6e0aa4b8e9f (patch) | |
tree | 8d0f0666752e07d868830f2f646078005bed3fbd /src | |
parent | Add feature to clean up user processes after logout (diff) | |
download | idle-daemon-6b48cd4b57211fbb75e91cb80771c6e0aa4b8e9f.tar.gz idle-daemon-6b48cd4b57211fbb75e91cb80771c6e0aa4b8e9f.tar.xz idle-daemon-6b48cd4b57211fbb75e91cb80771c6e0aa4b8e9f.zip |
Guess proper dbus socket
Diffstat (limited to 'src')
-rw-r--r-- | src/warn.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -2,6 +2,10 @@ #include "util.h" #include <stdio.h> #include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <pwd.h> struct action { const char *message; @@ -66,7 +70,20 @@ void warn_showCustomWarning( const struct user *usr, const char *title, const ch if ( *usr->display ) { // notify-send if ( doublefork() ) { + char buf[300]; + uid_t uid; + struct passwd *u = getpwnam( usr->user ); + struct stat tmp; + if ( u == NULL ) { + uid = geteuid(); + } else { + uid = u->pw_uid; + } switchUserSafe( usr->user ); + snprintf( buf, sizeof(buf), "unix:path=/run/user/%u/bus", (unsigned int)uid ); + if ( stat( buf + 10, &tmp ) == 0 ) { + setenv( "DBUS_SESSION_BUS_ADDRESS", buf, 1 ); + } setenv( "DISPLAY", usr->display, 1 ); if ( usr->xauth[0] != '\0' && usr->xauth[0] != '-' ) { setenv( "XAUTHORITY", usr->xauth, 1 ); |