1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

logind: simplify removal of device fds

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.
This commit is contained in:
Lennart Poettering 2019-04-02 11:51:50 +02:00
parent 924426a703
commit 883d1b01b0

View 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);