diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-12-20 21:02:31 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-12-20 21:02:31 -0500 |
commit | b23b74b9bd204ce432109f92f6dd5468e07daeba (patch) | |
tree | 255a7602973908cb92fa01165e42fa5384c22888 /parse.c | |
parent | 8fad779ae21b1052268af0befa930c75d1dd780b (diff) | |
download | bfs-b23b74b9bd204ce432109f92f6dd5468e07daeba.tar.xz |
Don't check errno after get{gr,pw}nam()
Turns out it doesn't always keep errno 0, even if the only problem is a
failed lookup. This was observed on a machine with Kerberos auth.
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 30 |
1 files changed, 6 insertions, 24 deletions
@@ -991,31 +991,22 @@ static struct expr *parse_group(struct parser_state *state, int arg1, int arg2) return NULL; } - const char *error; - - errno = 0; struct group *grp = getgrnam(expr->sdata); if (grp) { expr->idata = grp->gr_gid; - } else if (errno != 0) { - error = strerror(errno); - goto error; } else if (isdigit(expr->sdata[0])) { if (!parse_int(state, expr->sdata, &expr->idata, IF_LONG_LONG)) { goto fail; } } else { - error = "No such group"; - goto error; + pretty_error(state->cmdline->stderr_colors, + "error: %s %s: No such group.\n", arg, expr->sdata); + goto fail; } expr->cmp_flag = CMP_EXACT; return expr; -error: - pretty_error(state->cmdline->stderr_colors, - "error: %s %s: %s.\n", arg, expr->sdata, error); - fail: free_expr(expr); return NULL; @@ -1046,31 +1037,22 @@ static struct expr *parse_user(struct parser_state *state, int arg1, int arg2) { return NULL; } - const char *error; - - errno = 0; struct passwd *pwd = getpwnam(expr->sdata); if (pwd) { expr->idata = pwd->pw_uid; - } else if (errno != 0) { - error = strerror(errno); - goto error; } else if (isdigit(expr->sdata[0])) { if (!parse_int(state, expr->sdata, &expr->idata, IF_LONG_LONG)) { goto fail; } } else { - error = "No such user"; - goto error; + pretty_error(state->cmdline->stderr_colors, + "error: %s %s: No such user.\n", arg, expr->sdata); + goto fail; } expr->cmp_flag = CMP_EXACT; return expr; -error: - pretty_error(state->cmdline->stderr_colors, - "error: %s %s: %s.\n", arg, expr->sdata, error); - fail: free_expr(expr); return NULL; |