diff options
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 ); |