NULL
};
+ if (mode == M_LOCK || mode == M_UNLOCK)
+ errx(EX_USAGE, "'lock' command is not available for groups");
+
/*
* With M_NEXT, we only need to return the
* next gid to stdout
*/
- if (mode == M_NEXT)
- {
+ if (mode == M_NEXT) {
gid_t next = gr_gidpolicy(cnf, args);
if (getarg(args, 'q'))
return next;
if (a_name == NULL)
errx(EX_DATAERR, "group name or id required");
- if (mode != M_ADD && grp == NULL && isdigit(*a_name->val)) {
+ if (mode != M_ADD && grp == NULL && isdigit((unsigned char)*a_name->val)) {
(a_gid = a_name)->ch = 'g';
a_name = NULL;
}
if (rc == -1)
err(EX_IOERR, "group '%s' not available (NIS?)", grp->gr_name);
else if (rc != 0) {
- warnc(rc, "group update");
+ warn("group update");
return EX_IOERR;
}
pw_log(cnf, mode, W_GROUP, "%s(%ld) removed", a_name->val, (long) gid);
* software.
*/
- if ((arg = getarg(args, 'h')) != NULL) {
+ if ((arg = getarg(args, 'h')) != NULL ||
+ (arg = getarg(args, 'H')) != NULL) {
if (strcmp(arg->val, "-") == 0)
grp->gr_passwd = "*"; /* No access */
else {
int fd = atoi(arg->val);
+ int precrypt = (arg->ch == 'H');
int b;
int istty = isatty(fd);
struct termios t;
*p = '\0';
if (!*line)
errx(EX_DATAERR, "empty password read on file descriptor %d", fd);
- grp->gr_passwd = pw_pwcrypt(line);
+ if (precrypt) {
+ if (strchr(line, ':') != NULL)
+ return EX_DATAERR;
+ grp->gr_passwd = line;
+ } else
+ grp->gr_passwd = pw_pwcrypt(line);
}
}
int k = 0;
while (grp->gr_mem[k] != NULL) {
- if (extendarray(&members, &grmembers, i + 2) != -1) {
+ if (extendarray(&members, &grmembers, i + 2) != -1)
members[i++] = grp->gr_mem[k];
- }
k++;
}
}
for (p = strtok(arg->val, ", \t"); p != NULL; p = strtok(NULL, ", \t")) {
int j;
if ((pwd = GETPWNAM(p)) == NULL) {
- if (!isdigit(*p) || (pwd = getpwuid((uid_t) atoi(p))) == NULL)
+ if (!isdigit((unsigned char)*p) || (pwd = getpwuid((uid_t) atoi(p))) == NULL)
errx(EX_NOUSER, "user `%s' does not exist", p);
}
/*
if (rc == -1)
warnx("group '%s' not available (NIS?)", grp->gr_name);
else
- warnc(rc, "group update");
+ warn("group update");
return EX_IOERR;
}
/* grp may have been invalidated */
*/
SETGRENT();
while ((grp = GETGRENT()) != NULL)
- if (grp->gr_gid >= (int) cnf->min_gid && grp->gr_gid <= (int) cnf->max_gid)
+ if ((gid_t)grp->gr_gid >= (gid_t)cnf->min_gid &&
+ (gid_t)grp->gr_gid <= (gid_t)cnf->max_gid)
bm_setbit(&bm, grp->gr_gid - cnf->min_gid);
ENDGRENT();