]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: comment use of *_get_session()
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Sun, 17 Sep 2017 14:49:12 +0000 (15:49 +0100)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 14 Nov 2017 18:15:33 +0000 (18:15 +0000)
The manpages tell that such calls have quite limited meaning.  logind has
a few in the implementation of what remains of the session concept.

At the same time, logind basically exposes sd_pid_get_session() as public
API.  This is absolutely required, to retain compatability e.g. with Xorg.
But client code will work in more situations if it avoids assuming that it
runs in a session itself.

Its use inside the login session could be replaced with $XDG_SESSION_ID
(which pam_systemd sets).  I don't know whether it would be useful to
change Xorg at this point or not.  But if you were building something new,
you would think about whether you want to support running it in a systemd
service.

Comment these logind API features, acknowledging the reason they exist is
based in history.  I.e. help readers avoid drawing implications from their
existence which apply to history, but not the current general case.

Finally, searching these revealed a call to sd_pid_get_session() in
implementing some types of logind inhibitors.  So these inhibitors don't
work as intended when taken from inside a systemd user service :(.  Comment
this as well, deferring it as ticket #6852.

src/login/logind-dbus.c
src/login/logind-inhibit.c

index 5b5fdf443bbdb7ab15ed0141b446d05dba57f299..a023546b4e45e922e319ce26d5f52addb1c28c90 100644 (file)
@@ -57,6 +57,9 @@ static int get_sender_session(Manager *m, sd_bus_message *message, sd_bus_error
         Session *session;
         int r;
 
+        /* Get client login session.  This is not what you are looking for these days,
+         * as apps may instead belong to a user service unit.  This includes terminal
+         * emulators and hence command-line apps. */
         r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_SESSION|SD_BUS_CREDS_AUGMENT, &creds);
         if (r < 0)
                 return r;
@@ -364,6 +367,9 @@ static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_er
         return sd_bus_reply_method_return(message, "o", p);
 }
 
+/* Get login session of a process.  This is not what you are looking for these days,
+ * as apps may instead belong to a user service unit.  This includes terminal
+ * emulators and hence command-line apps. */
 static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
         _cleanup_free_ char *p = NULL;
         Session *session = NULL;
index c1a319b87d900d3c48d733eb6bd606b9bf72092c..f97e2370197cc51c67e0b69f6691c96bb9a5f78c 100644 (file)
@@ -357,6 +357,8 @@ static int pid_is_active(Manager *m, pid_t pid) {
         Session *s;
         int r;
 
+        /* Get client session.  This is not what you are looking for these days.
+         * FIXME #6852 */
         r = manager_get_session_by_pid(m, pid, &s);
         if (r < 0)
                 return r;