1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

shared/user-record-nss: shorten code a bit

free_and_strdup() already does comparison internally.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-01-15 10:04:30 +01:00
parent c7d26acce6
commit 192aee3cae

View File

@ -31,29 +31,18 @@ int nss_passwd_to_user_record(
if (r < 0)
return r;
if (isempty(pwd->pw_gecos) || streq_ptr(pwd->pw_gecos, hr->user_name))
hr->real_name = mfree(hr->real_name);
else {
r = free_and_strdup(&hr->real_name, pwd->pw_gecos);
if (r < 0)
return r;
}
r = free_and_strdup(&hr->real_name,
streq_ptr(pwd->pw_gecos, hr->user_name) ? NULL : empty_to_null(pwd->pw_gecos));
if (r < 0)
return r;
if (isempty(pwd->pw_dir))
hr->home_directory = mfree(hr->home_directory);
else {
r = free_and_strdup(&hr->home_directory, pwd->pw_dir);
if (r < 0)
return r;
}
r = free_and_strdup(&hr->home_directory, empty_to_null(pwd->pw_dir));
if (r < 0)
return r;
if (isempty(pwd->pw_shell))
hr->shell = mfree(hr->shell);
else {
r = free_and_strdup(&hr->shell, pwd->pw_shell);
if (r < 0)
return r;
}
r = free_and_strdup(&hr->shell, empty_to_null(pwd->pw_shell));
if (r < 0)
return r;
hr->uid = pwd->pw_uid;
hr->gid = pwd->pw_gid;