loginctl: enable-linger does not need fallback to XDG_SESSION_ID

To maintain consistency with `loginctl user-status`, drop the fallback to
XDG_SESSION_ID for `loginctl enable-linger`.  The fallback was unnecessary
and also incorrect: it passed the numeric value of the session identifier
as a UID value.
This commit is contained in:
Alan Jenkins 2017-09-18 18:04:59 +01:00
parent 7b33c6228f
commit 545f779f5c

View file

@ -1164,11 +1164,11 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
b = streq(argv[0], "enable-linger");
if (argc < 2) {
/* No argument? Let's either use $XDG_SESSION_ID (if specified), or an empty
* session name, in which case logind will try to guess our session. */
/* No argument? Let's use an empty user name,
* then logind will use our user. */
short_argv[0] = argv[0];
short_argv[1] = getenv("XDG_SESSION_ID") ?: (char*) "";
short_argv[1] = (char*) "";
short_argv[2] = NULL;
argv = short_argv;
argc = 2;