Move the error messages to the option parsing
This commit is contained in:
parent
b6aa1c857c
commit
40a1beabe0
@ -91,27 +91,20 @@ static struct passwd *get_user (char **name)
|
|||||||
else
|
else
|
||||||
pw = getpwuid (tid);
|
pw = getpwuid (tid);
|
||||||
|
|
||||||
if (! pw)
|
if (pw)
|
||||||
eerrorx ("%s: user `%s' not found", applet, token);
|
*name = p;
|
||||||
|
|
||||||
*name = p;
|
|
||||||
return (pw);
|
return (pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct group *get_group (const char *name)
|
static struct group *get_group (const char *name)
|
||||||
{
|
{
|
||||||
struct group *gr;
|
|
||||||
int tid;
|
int tid;
|
||||||
|
|
||||||
if (sscanf (name, "%d", &tid) != 1)
|
if (sscanf (name, "%d", &tid) != 1)
|
||||||
gr = getgrnam (name);
|
return (getgrnam (name));
|
||||||
else
|
else
|
||||||
gr = getgrgid (tid);
|
return (getgrgid (tid));
|
||||||
|
|
||||||
if (! gr)
|
|
||||||
eerrorx ("%s: group `%s' not found", applet, name);
|
|
||||||
|
|
||||||
return (gr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
@ -149,13 +142,15 @@ int checkown (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
p = optarg;
|
p = optarg;
|
||||||
pw = get_user (&p);
|
if (! (pw = get_user (&p)))
|
||||||
|
eerrorx ("%s: user `%s' not found", applet, optarg);
|
||||||
if (p && *p)
|
if (p && *p)
|
||||||
optarg = p;
|
optarg = p;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
gr = get_group (optarg);
|
if (! (gr = get_group (optarg)))
|
||||||
|
eerrorx ("%s: group `%s' not found", applet, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
|
Loading…
Reference in New Issue
Block a user