]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: simplify removal of device fds
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Apr 2019 09:51:50 +0000 (11:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Apr 2019 09:51:50 +0000 (11:51 +0200)
let's use sd_notifyf(). Let's also stop validating the session ID here.
This is the destructor. if it contains a dash, we are already too late
here anyway.

src/login/logind-session-device.c

index f358524ebcaae8484a006bfbbab927c9c8ccf473..7c79a4afdcf197da346a0aad5eaab8f322ea5751 100644 (file)
@@ -387,21 +387,11 @@ void session_device_free(SessionDevice *sd) {
         assert(sd);
 
         /* Make sure to remove the pushed fd. */
-        if (sd->pushed_fd) {
-                _cleanup_free_ char *m = NULL;
-                const char *id;
-                int r;
-
-                /* Session ID does not contain separators. */
-                id = sd->session->id;
-                assert(*(id + strcspn(id, "-\n")) == '\0');
-
-                r = asprintf(&m, "FDSTOREREMOVE=1\n"
-                                 "FDNAME=session-%s-device-%u-%u\n",
-                                 id, major(sd->dev), minor(sd->dev));
-                if (r >= 0)
-                        (void) sd_notify(false, m);
-        }
+        if (sd->pushed_fd)
+                (void) sd_notifyf(false,
+                                  "FDSTOREREMOVE=1\n"
+                                  "FDNAME=session-%s-device-%u-%u",
+                                  sd->session->id, major(sd->dev), minor(sd->dev));
 
         session_device_stop(sd);
         session_device_notify(sd, SESSION_DEVICE_RELEASE);