summaryrefslogtreecommitdiff
path: root/src/nss-systemd/nss-systemd.c
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2016-12-29 10:42:22 +0100
committerGitHub <noreply@github.com>2016-12-29 10:42:22 +0100
commit2a4e5c629e24f2f3a62c567b57b22ed7d6c75019 (patch)
tree9fee725f5c8321fa8c52d36e63f432a10277f1c4 /src/nss-systemd/nss-systemd.c
parent4d1fe20a585caadce57ef2d6a631a0d8029d2518 (diff)
parentd6c575e303520ffdcee1590a4181410024d5f917 (diff)
Merge pull request #4989 from poettering/nss-einval
nss user/group name validation fixes
Diffstat (limited to 'src/nss-systemd/nss-systemd.c')
-rw-r--r--src/nss-systemd/nss-systemd.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/nss-systemd/nss-systemd.c b/src/nss-systemd/nss-systemd.c
index c80972742b..fd5064c937 100644
--- a/src/nss-systemd/nss-systemd.c
+++ b/src/nss-systemd/nss-systemd.c
@@ -123,10 +123,10 @@ enum nss_status _nss_systemd_getpwnam_r(
assert(name);
assert(pwd);
- if (!valid_user_group_name(name)) {
- r = -EINVAL;
- goto fail;
- }
+ /* If the username is not valid, then we don't know it. Ideally libc would filter these for us anyway. We don't
+ * generate EINVAL here, because it isn't really out business to complain about invalid user names. */
+ if (!valid_user_group_name(name))
+ goto not_found;
/* Synthesize entries for the root and nobody users, in case they are missing in /etc/passwd */
if (streq(name, root_passwd.pw_name)) {
@@ -227,10 +227,8 @@ enum nss_status _nss_systemd_getpwuid_r(
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
- if (!uid_is_valid(uid)) {
- r = -EINVAL;
- goto fail;
- }
+ if (!uid_is_valid(uid))
+ goto not_found;
/* Synthesize data for the root user and for nobody in case they are missing from /etc/passwd */
if (uid == root_passwd.pw_uid) {
@@ -329,10 +327,8 @@ enum nss_status _nss_systemd_getgrnam_r(
assert(name);
assert(gr);
- if (!valid_user_group_name(name)) {
- r = -EINVAL;
- goto fail;
- }
+ if (!valid_user_group_name(name))
+ goto not_found;
/* Synthesize records for root and nobody, in case they are missing form /etc/group */
if (streq(name, root_group.gr_name)) {
@@ -430,10 +426,8 @@ enum nss_status _nss_systemd_getgrgid_r(
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
- if (!gid_is_valid(gid)) {
- r = -EINVAL;
- goto fail;
- }
+ if (!gid_is_valid(gid))
+ goto not_found;
/* Synthesize records for root and nobody, in case they are missing from /etc/group */
if (gid == root_group.gr_gid) {