diff options
author | Danny Baumann <dannybaumann@web.de> | 2008-11-05 08:56:23 +0100 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2008-11-05 08:56:23 +0100 |
commit | 580bddbeb41aae68f96a7c71ad256b8e1dea0f96 (patch) | |
tree | 84772a2be1371912cd25faa26127b960bf5fe0e0 /src | |
parent | daa1e7dca19b06bad4c78aef8098c86c5a7f4fb5 (diff) |
SM spec says that SmUserID is a required property.
Diffstat (limited to 'src')
-rw-r--r-- | src/session.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/session.c b/src/session.c index 4f0f118f..1a75557d 100644 --- a/src/session.c +++ b/src/session.c @@ -33,6 +33,7 @@ #include <unistd.h> #include <fcntl.h> #include <string.h> +#include <pwd.h> #include <X11/SM/SMlib.h> #include <X11/ICE/ICElib.h> @@ -136,14 +137,17 @@ setRestartStyle (SmcConn connection, } static void -setProgram (SmcConn connection, - const char *program, - pid_t pid) +setProgramInfo (SmcConn connection, + const char *program, + pid_t pid, + uid_t uid) { - SmProp progProp, pidProp; - SmPropValue progVal, pidVal; - SmProp *props[2]; - char pidBuffer[32]; + SmProp progProp, pidProp, userProp; + SmPropValue progVal, pidVal, userVal; + SmProp *props[3]; + char pidBuffer[32]; + unsigned int count = 0; + struct passwd *pw; progProp.name = SmProgram; progProp.type = SmARRAY8; @@ -152,6 +156,8 @@ setProgram (SmcConn connection, progVal.value = (SmPointer) program; progVal.length = strlen (program); + props[count++] = &progProp; + snprintf (pidBuffer, sizeof (pidBuffer), "%d", pid); pidProp.name = SmProcessID; @@ -161,10 +167,22 @@ setProgram (SmcConn connection, pidVal.value = (SmPointer) pidBuffer; pidVal.length = strlen (pidBuffer); - props[0] = &progProp; - props[1] = &pidProp; + props[count++] = &pidProp; + + pw = getpwuid (uid); + if (pw) + { + userProp.name = SmUserID; + userProp.type = SmARRAY8; + userProp.num_vals = 1; + userProp.vals = &userVal; + userVal.value = (SmPointer) pw->pw_name; + userVal.length = strlen (pw->pw_name); + + props[count++] = &userProp; + } - SmcSetProperties (connection, 2, props); + SmcSetProperties (connection, count, props); } static void @@ -197,7 +215,7 @@ saveYourselfCallback (SmcConn connection, setCloneRestartCommands (connection); setRestartStyle (connection, SmRestartImmediately); - setProgram (connection, programName, getpid ()); + setProgramInfo (connection, programName, getpid (), getuid ()); SmcSaveYourselfDone (connection, 1); } |