mirror of
https://github.com/systemd/systemd.git
synced 2025-08-30 05:49:54 +03:00
shared/user-record-nss: shorten code a bit
free_and_strdup() already does comparison internally.
This commit is contained in:
@ -31,29 +31,18 @@ int nss_passwd_to_user_record(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (isempty(pwd->pw_gecos) || streq_ptr(pwd->pw_gecos, hr->user_name))
|
r = free_and_strdup(&hr->real_name,
|
||||||
hr->real_name = mfree(hr->real_name);
|
streq_ptr(pwd->pw_gecos, hr->user_name) ? NULL : empty_to_null(pwd->pw_gecos));
|
||||||
else {
|
if (r < 0)
|
||||||
r = free_and_strdup(&hr->real_name, pwd->pw_gecos);
|
return r;
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isempty(pwd->pw_dir))
|
r = free_and_strdup(&hr->home_directory, empty_to_null(pwd->pw_dir));
|
||||||
hr->home_directory = mfree(hr->home_directory);
|
if (r < 0)
|
||||||
else {
|
return r;
|
||||||
r = free_and_strdup(&hr->home_directory, pwd->pw_dir);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isempty(pwd->pw_shell))
|
r = free_and_strdup(&hr->shell, empty_to_null(pwd->pw_shell));
|
||||||
hr->shell = mfree(hr->shell);
|
if (r < 0)
|
||||||
else {
|
return r;
|
||||||
r = free_and_strdup(&hr->shell, pwd->pw_shell);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr->uid = pwd->pw_uid;
|
hr->uid = pwd->pw_uid;
|
||||||
hr->gid = pwd->pw_gid;
|
hr->gid = pwd->pw_gid;
|
||||||
|
Reference in New Issue
Block a user