]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/login/logind-dbus.c
user-util: add get{pw,gr}{uid,gid,name}_malloc() helpers
[thirdparty/systemd.git] / src / login / logind-dbus.c
index 8f70253ef6342c1aee0326c7257a1d5dde12d242..3bb8527703f081668caaf2c98ff66a0144f97f4b 100644 (file)
@@ -1419,10 +1419,10 @@ static int method_terminate_seat(sd_bus_message *message, void *userdata, sd_bus
 
 static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bus_error *error) {
         _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
+        _cleanup_free_ struct passwd *pw = NULL;
         _cleanup_free_ char *cc = NULL;
         Manager *m = ASSERT_PTR(userdata);
         int r, b, interactive;
-        struct passwd *pw;
         const char *path;
         uint32_t uid, auth_uid;
 
@@ -1450,10 +1450,9 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
         if (r < 0)
                 return r;
 
-        errno = 0;
-        pw = getpwuid(uid);
-        if (!pw)
-                return errno_or_else(ENOENT);
+        r = getpwuid_malloc(uid, &pw);
+        if (r < 0)
+                return r;
 
         r = bus_verify_polkit_async_full(
                         message,