user-record-nss: make return values optional

If we only want to know if some user ID/user name is already allocated,
we don't care for the returned data.
This commit is contained in:
Lennart Poettering
2023-03-14 17:23:25 +01:00
parent c8ab89e569
commit eb3641fc3c

View File

@@ -44,7 +44,6 @@ int nss_passwd_to_user_record(
int r;
assert(pwd);
assert(ret);
if (isempty(pwd->pw_name))
return -EINVAL;
@@ -161,7 +160,8 @@ int nss_passwd_to_user_record(
hr->mask = USER_RECORD_REGULAR |
(!strv_isempty(hr->hashed_password) ? USER_RECORD_PRIVILEGED : 0);
*ret = TAKE_PTR(hr);
if (ret)
*ret = TAKE_PTR(hr);
return 0;
}
@@ -216,7 +216,6 @@ int nss_user_record_by_name(
int r;
assert(name);
assert(ret);
for (;;) {
buf = malloc(buflen);
@@ -257,7 +256,8 @@ int nss_user_record_by_name(
if (r < 0)
return r;
(*ret)->incomplete = incomplete;
if (ret)
(*ret)->incomplete = incomplete;
return 0;
}
@@ -273,8 +273,6 @@ int nss_user_record_by_uid(
struct spwd spwd, *sresult = NULL;
int r;
assert(ret);
for (;;) {
buf = malloc(buflen);
if (!buf)
@@ -313,7 +311,8 @@ int nss_user_record_by_uid(
if (r < 0)
return r;
(*ret)->incomplete = incomplete;
if (ret)
(*ret)->incomplete = incomplete;
return 0;
}
@@ -326,7 +325,6 @@ int nss_group_to_group_record(
int r;
assert(grp);
assert(ret);
if (isempty(grp->gr_name))
return -EINVAL;
@@ -376,7 +374,8 @@ int nss_group_to_group_record(
g->mask = USER_RECORD_REGULAR |
(!strv_isempty(g->hashed_password) ? USER_RECORD_PRIVILEGED : 0);
*ret = TAKE_PTR(g);
if (ret)
*ret = TAKE_PTR(g);
return 0;
}
@@ -431,7 +430,6 @@ int nss_group_record_by_name(
int r;
assert(name);
assert(ret);
for (;;) {
buf = malloc(buflen);
@@ -471,7 +469,8 @@ int nss_group_record_by_name(
if (r < 0)
return r;
(*ret)->incomplete = incomplete;
if (ret)
(*ret)->incomplete = incomplete;
return 0;
}
@@ -487,8 +486,6 @@ int nss_group_record_by_gid(
struct sgrp sgrp, *sresult = NULL;
int r;
assert(ret);
for (;;) {
buf = malloc(buflen);
if (!buf)
@@ -526,6 +523,7 @@ int nss_group_record_by_gid(
if (r < 0)
return r;
(*ret)->incomplete = incomplete;
if (ret)
(*ret)->incomplete = incomplete;
return 0;
}