This function returns uintmax_t
Use this function to convert to gid_t/uid_t
PROG= pw
MAN= pw.conf.5 pw.8
SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
PROG= pw
MAN= pw.conf.5 pw.8
SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
- grupd.c pwupd.c psdate.c bitmap.c cpdir.c rm_r.c
+ grupd.c pwupd.c psdate.c bitmap.c cpdir.c rm_r.c strtounum.c
cmdhelp(mode, which);
else if (which != -1 && mode != -1) {
if (strspn(argv[1], "0123456789") == strlen(argv[1])) {
cmdhelp(mode, which);
else if (which != -1 && mode != -1) {
if (strspn(argv[1], "0123456789") == strlen(argv[1])) {
- id = strtonum(argv[1], 0, LONG_MAX, &errstr);
+ id = strtounum(argv[1], 0, UID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s",
argv[1], errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s",
argv[1], errstr);
}
if (strspn(optarg, "0123456789") != strlen(optarg))
errx(EX_USAGE, "-g expects a number");
}
if (strspn(optarg, "0123456789") != strlen(optarg))
errx(EX_USAGE, "-g expects a number");
- id = strtonum(optarg, 0, GID_MAX, &errstr);
+ id = strtounum(optarg, 0, GID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);
addarg(&arglist, 'u', optarg);
break;
}
addarg(&arglist, 'u', optarg);
break;
}
- id = strtonum(optarg, 0, UID_MAX, &errstr);
+ id = strtounum(optarg, 0, UID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
extern const char *Modes[];
extern const char *Which[];
extern const char *Modes[];
extern const char *Which[];
+
+uintmax_t strtounum(const char *numstr, uintmax_t minval, uintmax_t maxval,
+ const char **errmsg);