summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2019-10-21 15:05:53 +0200
committerSimon Rettberg2019-10-21 15:05:53 +0200
commit6b48cd4b57211fbb75e91cb80771c6e0aa4b8e9f (patch)
tree8d0f0666752e07d868830f2f646078005bed3fbd /src
parentAdd feature to clean up user processes after logout (diff)
downloadidle-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.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/warn.c b/src/warn.c
index c02829e..b3f6460 100644
--- a/src/warn.c
+++ b/src/warn.c
@@ -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 );