summaryrefslogtreecommitdiff
path: root/src/shared/user-record-nss.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-14 17:23:25 +0100
committerLennart Poettering <lennart@poettering.net>2023-04-25 14:00:57 +0200
commiteb3641fc3c825122fb0e5b00eff0f24abb120ab3 (patch)
treec0bde33fc35c5496ac9dbd2dba765d0af621ecc2 /src/shared/user-record-nss.c
parentc8ab89e569e156f968b1797aa0abce41f924afb6 (diff)
downloadsystemd-eb3641fc3c825122fb0e5b00eff0f24abb120ab3.tar.gz
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.
Diffstat (limited to 'src/shared/user-record-nss.c')
-rw-r--r--src/shared/user-record-nss.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c
index 88b8fc2f8f..ea1bc9faac 100644
--- a/src/shared/user-record-nss.c
+++ b/src/shared/user-record-nss.c
@@ -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;
}