[systemd-commits] 2 commits - src/libsystemd-bus src/login

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Thu Nov 7 01:51:03 CET 2013


 src/libsystemd-bus/bus-message.c   |    2 -
 src/libsystemd-bus/test-bus-chat.c |    4 +++
 src/login/logind-session-dbus.c    |    9 ++++++++
 src/login/pam-module.c             |   41 ++++++++++++++++++-------------------
 4 files changed, 35 insertions(+), 21 deletions(-)

New commits:
commit ba341e7c3c18e81a6faa58883e178a60af317a40
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Nov 6 19:14:35 2013 -0500

    bus: add forgotten _public_

diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index aaa19df..67f7d58 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -4424,7 +4424,7 @@ int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
         return 0;
 }
 
-int sd_bus_message_read_strv(sd_bus_message *m, char ***l) {
+_public_ int sd_bus_message_read_strv(sd_bus_message *m, char ***l) {
         char **strv = NULL;
         int r;
 

commit 5a330cda0ce47bd333a4cf2c559031788a26e62a
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Nov 6 17:24:16 2013 -0500

    pam_systemd: dup the fd received from logind
    
    Otherwise sd_bus_message cleanup would close it.

diff --git a/src/libsystemd-bus/test-bus-chat.c b/src/libsystemd-bus/test-bus-chat.c
index efc19c6..a29fbdf 100644
--- a/src/libsystemd-bus/test-bus-chat.c
+++ b/src/libsystemd-bus/test-bus-chat.c
@@ -228,6 +228,8 @@ static int server(sd_bus *bus) {
                                 goto fail;
                         }
 
+                        log_info("Received fd=%d", fd);
+
                         if (write(fd, &x, 1) < 0) {
                                 log_error("Failed to write to fd: %m");
                                 close_nointr_nofail(fd);
@@ -307,6 +309,8 @@ static void* client1(void*p) {
                 goto finish;
         }
 
+        log_info("Sending fd=%d", pp[1]);
+
         r = sd_bus_call_method(
                         bus,
                         "org.freedesktop.systemd.test",
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index a559e60..167d2ab 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -656,6 +656,15 @@ int session_send_create_reply(Session *s, sd_bus_error *error) {
         if (!p)
                 return -ENOMEM;
 
+        log_debug("Sending reply about created session: "
+                  "id=%s object_path=%s runtime_path=%s session_fd=%d seat=%s vtnr=%u",
+                  s->id,
+                  p,
+                  s->user->runtime_path,
+                  fifo_fd,
+                  s->seat ? s->seat->id : "",
+                  (uint32_t) s->vtnr);
+
         return sd_bus_reply_method_return(
                         s->manager->bus, c,
                         "soshsub",
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index 0be39de..58f9742 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -206,14 +206,14 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         if (parse_argv(handle,
                        argc, argv,
                        &class_pam,
-                       &debug) < 0) {
-                r = PAM_SESSION_ERR;
-                goto finish;
-        }
+                       &debug) < 0)
+                return PAM_SESSION_ERR;
 
         r = get_user_data(handle, &username, &pw);
-        if (r != PAM_SUCCESS)
-                goto finish;
+        if (r != PAM_SUCCESS) {
+                pam_syslog(handle, LOG_ERR, "Failed to get user data.");
+                return r;
+        }
 
         /* Make sure we don't enter a loop by talking to
          * systemd-logind when it is actually waiting for the
@@ -321,6 +321,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 !streq(remote_host, "localhost.localdomain");
 
         /* Talk to logind over the message bus */
+
         r = sd_bus_open_system(&bus);
         if (r < 0) {
                 pam_syslog(handle, LOG_ERR, "Failed to connect to system bus: %s", strerror(-r));
@@ -373,8 +374,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                                 &existing);
         if (r < 0) {
                 pam_syslog(handle, LOG_ERR, "Failed to parse message: %s", strerror(-r));
-                r = PAM_SESSION_ERR;
-                goto finish;
+                return PAM_SESSION_ERR;
         }
 
         if (debug)
@@ -385,20 +385,20 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         r = pam_misc_setenv(handle, "XDG_SESSION_ID", id, 0);
         if (r != PAM_SUCCESS) {
                 pam_syslog(handle, LOG_ERR, "Failed to set session id.");
-                goto finish;
+                return r;
         }
 
         r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", runtime_path, 0);
         if (r != PAM_SUCCESS) {
                 pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
-                goto finish;
+                return r;
         }
 
         if (!isempty(seat)) {
                 r = pam_misc_setenv(handle, "XDG_SEAT", seat, 0);
                 if (r != PAM_SUCCESS) {
                         pam_syslog(handle, LOG_ERR, "Failed to set seat.");
-                        goto finish;
+                        return r;
                 }
         }
 
@@ -410,31 +410,32 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 r = pam_misc_setenv(handle, "XDG_VTNR", buf, 0);
                 if (r != PAM_SUCCESS) {
                         pam_syslog(handle, LOG_ERR, "Failed to set virtual terminal number.");
-                        goto finish;
+                        return r;
                 }
         }
 
         r = pam_set_data(handle, "systemd.existing", INT_TO_PTR(!!existing), NULL);
         if (r != PAM_SUCCESS) {
                 pam_syslog(handle, LOG_ERR, "Failed to install existing flag.");
-                goto finish;
+                return r;
         }
 
         if (session_fd >= 0) {
+                session_fd = dup(session_fd);
+                if (session_fd < 0) {
+                        pam_syslog(handle, LOG_ERR, "Failed to dup session fd: %m");
+                        return PAM_SESSION_ERR;
+                }
+
                 r = pam_set_data(handle, "systemd.session-fd", INT_TO_PTR(session_fd+1), NULL);
                 if (r != PAM_SUCCESS) {
                         pam_syslog(handle, LOG_ERR, "Failed to install session fd.");
-                        goto finish;
+                        close_nointr_nofail(session_fd);
+                        return r;
                 }
         }
 
         return PAM_SUCCESS;
-
-finish:
-        if (session_fd >= 0)
-                close_nointr_nofail(session_fd);
-
-        return r;
 }
 
 _public_ PAM_EXTERN int pam_sm_close_session(



More information about the systemd-commits mailing list