atobool -> sudo_strtobool
atoid-> sudo_strtoid atomode -> sudo_strtomode
This commit is contained in:
@@ -141,14 +141,14 @@ __dso_public int aix_prep_user(char *user, const char *tty);
|
|||||||
__dso_public int aix_restoreauthdb(void);
|
__dso_public int aix_restoreauthdb(void);
|
||||||
__dso_public int aix_setauthdb(char *user);
|
__dso_public int aix_setauthdb(char *user);
|
||||||
|
|
||||||
/* atobool.c */
|
/* strtobool.c */
|
||||||
__dso_public int atobool(const char *str);
|
__dso_public int sudo_strtobool(const char *str);
|
||||||
|
|
||||||
/* atoid.c */
|
/* strtoid.c */
|
||||||
__dso_public id_t atoid(const char *str, const char *sep, char **endp, const char **errstr);
|
__dso_public id_t sudo_strtoid(const char *str, const char *sep, char **endp, const char **errstr);
|
||||||
|
|
||||||
/* atomode.c */
|
/* strtomode.c */
|
||||||
__dso_public int atomode(const char *cp, const char **errstr);
|
__dso_public int sudo_strtomode(const char *cp, const char **errstr);
|
||||||
|
|
||||||
/* gidlist.c */
|
/* gidlist.c */
|
||||||
__dso_public int sudo_parse_gids(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp);
|
__dso_public int sudo_parse_gids(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp);
|
||||||
|
@@ -95,10 +95,10 @@ DEVEL = @DEVEL@
|
|||||||
|
|
||||||
SHELL = @SHELL@
|
SHELL = @SHELL@
|
||||||
|
|
||||||
LTOBJS = alloc.lo atobool.lo atoid.lo atomode.lo event.lo fatal.lo key_val.lo \
|
LTOBJS = alloc.lo event.lo fatal.lo key_val.lo gidlist.lo lbuf.lo locking.lo \
|
||||||
gidlist.lo lbuf.lo locking.lo parseln.lo progname.lo secure_path.lo \
|
parseln.lo progname.lo secure_path.lo setgroups.lo strtobool.lo \
|
||||||
setgroups.lo sudo_conf.lo sudo_debug.lo sudo_dso.lo sudo_printf.lo \
|
strtoid.lo strtomode.lo sudo_conf.lo sudo_debug.lo sudo_dso.lo \
|
||||||
term.lo ttysize.lo @COMMON_OBJS@ @LTLIBOBJS@
|
sudo_printf.lo term.lo ttysize.lo @COMMON_OBJS@ @LTLIBOBJS@
|
||||||
|
|
||||||
ATOFOO_TEST_OBJS = atofoo_test.lo locale_stub.lo
|
ATOFOO_TEST_OBJS = atofoo_test.lo locale_stub.lo
|
||||||
|
|
||||||
@@ -287,23 +287,11 @@ aix.lo: $(srcdir)/aix.c $(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
|||||||
alloc.lo: $(srcdir)/alloc.c $(incdir)/fatal.h $(incdir)/gettext.h \
|
alloc.lo: $(srcdir)/alloc.c $(incdir)/fatal.h $(incdir)/gettext.h \
|
||||||
$(incdir)/missing.h $(incdir)/sudo_alloc.h $(top_builddir)/config.h
|
$(incdir)/missing.h $(incdir)/sudo_alloc.h $(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/alloc.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/alloc.c
|
||||||
atobool.lo: $(srcdir)/atobool.c $(incdir)/compat/stdbool.h $(incdir)/missing.h \
|
|
||||||
$(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
|
||||||
$(top_builddir)/config.h
|
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/atobool.c
|
|
||||||
atofoo_test.lo: $(srcdir)/regress/atofoo/atofoo_test.c \
|
atofoo_test.lo: $(srcdir)/regress/atofoo/atofoo_test.c \
|
||||||
$(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
$(incdir)/compat/stdbool.h $(incdir)/fatal.h \
|
||||||
$(incdir)/missing.h $(incdir)/sudo_util.h \
|
$(incdir)/missing.h $(incdir)/sudo_util.h \
|
||||||
$(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/regress/atofoo/atofoo_test.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/regress/atofoo/atofoo_test.c
|
||||||
atoid.lo: $(srcdir)/atoid.c $(incdir)/compat/stdbool.h $(incdir)/gettext.h \
|
|
||||||
$(incdir)/missing.h $(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
|
||||||
$(top_builddir)/config.h
|
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/atoid.c
|
|
||||||
atomode.lo: $(srcdir)/atomode.c $(incdir)/compat/stdbool.h $(incdir)/gettext.h \
|
|
||||||
$(incdir)/missing.h $(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
|
||||||
$(top_builddir)/config.h
|
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/atomode.c
|
|
||||||
clock_gettime.lo: $(srcdir)/clock_gettime.c $(incdir)/compat/timespec.h \
|
clock_gettime.lo: $(srcdir)/clock_gettime.c $(incdir)/compat/timespec.h \
|
||||||
$(incdir)/missing.h $(top_builddir)/config.h
|
$(incdir)/missing.h $(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/clock_gettime.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/clock_gettime.c
|
||||||
@@ -441,6 +429,18 @@ strlcpy.lo: $(srcdir)/strlcpy.c $(incdir)/missing.h $(top_builddir)/config.h
|
|||||||
strsignal.lo: $(srcdir)/strsignal.c $(incdir)/gettext.h $(incdir)/missing.h \
|
strsignal.lo: $(srcdir)/strsignal.c $(incdir)/gettext.h $(incdir)/missing.h \
|
||||||
$(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strsignal.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strsignal.c
|
||||||
|
strtobool.lo: $(srcdir)/strtobool.c $(incdir)/compat/stdbool.h \
|
||||||
|
$(incdir)/missing.h $(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
||||||
|
$(top_builddir)/config.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strtobool.c
|
||||||
|
strtoid.lo: $(srcdir)/strtoid.c $(incdir)/compat/stdbool.h $(incdir)/gettext.h \
|
||||||
|
$(incdir)/missing.h $(incdir)/sudo_debug.h $(incdir)/sudo_util.h \
|
||||||
|
$(top_builddir)/config.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strtoid.c
|
||||||
|
strtomode.lo: $(srcdir)/strtomode.c $(incdir)/compat/stdbool.h \
|
||||||
|
$(incdir)/gettext.h $(incdir)/missing.h $(incdir)/sudo_debug.h \
|
||||||
|
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strtomode.c
|
||||||
strtonum.lo: $(srcdir)/strtonum.c $(incdir)/gettext.h $(incdir)/missing.h \
|
strtonum.lo: $(srcdir)/strtonum.c $(incdir)/gettext.h $(incdir)/missing.h \
|
||||||
$(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strtonum.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strtonum.c
|
||||||
|
@@ -73,7 +73,7 @@ sudo_getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp)
|
|||||||
if ((grset = getgrset(name)) != NULL) {
|
if ((grset = getgrset(name)) != NULL) {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
for (cp = strtok(grset, ","); cp != NULL; cp = strtok(NULL, ",")) {
|
for (cp = strtok(grset, ","); cp != NULL; cp = strtok(NULL, ",")) {
|
||||||
gid = atoid(cp, NULL, NULL, &errstr);
|
gid = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL && gid != basegid) {
|
if (errstr == NULL && gid != basegid) {
|
||||||
if (ngroups == grpsize)
|
if (ngroups == grpsize)
|
||||||
goto done;
|
goto done;
|
||||||
|
@@ -73,7 +73,7 @@ sudo_parse_gids(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp)
|
|||||||
gids[ngids++] = *basegid;
|
gids[ngids++] = *basegid;
|
||||||
cp = gidstr;
|
cp = gidstr;
|
||||||
do {
|
do {
|
||||||
gids[ngids] = (GETGROUPS_T) atoid(cp, ",", &ep, &errstr);
|
gids[ngids] = (GETGROUPS_T) sudo_strtoid(cp, ",", &ep, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), cp, U_(errstr));
|
sudo_warnx(U_("%s: %s"), cp, U_(errstr));
|
||||||
free(gids);
|
free(gids);
|
||||||
|
@@ -38,11 +38,11 @@
|
|||||||
|
|
||||||
__dso_public int main(int argc, char *argv[]);
|
__dso_public int main(int argc, char *argv[]);
|
||||||
|
|
||||||
/* atobool() tests */
|
/* sudo_strtobool() tests */
|
||||||
static struct atobool_data {
|
static struct strtobool_data {
|
||||||
const char *bool_str;
|
const char *bool_str;
|
||||||
int value;
|
int value;
|
||||||
} atobool_data[] = {
|
} strtobool_data[] = {
|
||||||
{ "true", true },
|
{ "true", true },
|
||||||
{ "false", false },
|
{ "false", false },
|
||||||
{ "TrUe", true },
|
{ "TrUe", true },
|
||||||
@@ -61,15 +61,15 @@ static struct atobool_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_atobool(int *ntests)
|
test_strtobool(int *ntests)
|
||||||
{
|
{
|
||||||
struct atobool_data *d;
|
struct strtobool_data *d;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
for (d = atobool_data; d->bool_str != NULL; d++) {
|
for (d = strtobool_data; d->bool_str != NULL; d++) {
|
||||||
(*ntests)++;
|
(*ntests)++;
|
||||||
value = atobool(d->bool_str);
|
value = sudo_strtobool(d->bool_str);
|
||||||
if (value != d->value) {
|
if (value != d->value) {
|
||||||
sudo_warnx_nodebug("FAIL: %s != %d", d->bool_str, d->value);
|
sudo_warnx_nodebug("FAIL: %s != %d", d->bool_str, d->value);
|
||||||
errors++;
|
errors++;
|
||||||
@@ -79,13 +79,13 @@ test_atobool(int *ntests)
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* atoid() tests */
|
/* sudo_strtoid() tests */
|
||||||
static struct atoid_data {
|
static struct strtoid_data {
|
||||||
const char *idstr;
|
const char *idstr;
|
||||||
id_t id;
|
id_t id;
|
||||||
const char *sep;
|
const char *sep;
|
||||||
const char *ep;
|
const char *ep;
|
||||||
} atoid_data[] = {
|
} strtoid_data[] = {
|
||||||
{ "0,1", 0, ",", "," },
|
{ "0,1", 0, ",", "," },
|
||||||
{ "10", 10, NULL, NULL },
|
{ "10", 10, NULL, NULL },
|
||||||
{ "-2", -2, NULL, NULL },
|
{ "-2", -2, NULL, NULL },
|
||||||
@@ -95,18 +95,18 @@ static struct atoid_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_atoid(int *ntests)
|
test_strtoid(int *ntests)
|
||||||
{
|
{
|
||||||
struct atoid_data *d;
|
struct strtoid_data *d;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
char *ep;
|
char *ep;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
id_t value;
|
id_t value;
|
||||||
|
|
||||||
for (d = atoid_data; d->idstr != NULL; d++) {
|
for (d = strtoid_data; d->idstr != NULL; d++) {
|
||||||
(*ntests)++;
|
(*ntests)++;
|
||||||
errstr = "some error";
|
errstr = "some error";
|
||||||
value = atoid(d->idstr, d->sep, &ep, &errstr);
|
value = sudo_strtoid(d->idstr, d->sep, &ep, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
if (d->id != (id_t)-1) {
|
if (d->id != (id_t)-1) {
|
||||||
sudo_warnx_nodebug("FAIL: %s: %s", d->idstr, errstr);
|
sudo_warnx_nodebug("FAIL: %s: %s", d->idstr, errstr);
|
||||||
@@ -125,11 +125,11 @@ test_atoid(int *ntests)
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* atomode() tests */
|
/* sudo_strtomode() tests */
|
||||||
static struct atomode_data {
|
static struct strtomode_data {
|
||||||
const char *mode_str;
|
const char *mode_str;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
} atomode_data[] = {
|
} strtomode_data[] = {
|
||||||
{ "755", 0755 },
|
{ "755", 0755 },
|
||||||
{ "007", 007 },
|
{ "007", 007 },
|
||||||
{ "7", 7 },
|
{ "7", 7 },
|
||||||
@@ -138,17 +138,17 @@ static struct atomode_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_atomode(int *ntests)
|
test_strtomode(int *ntests)
|
||||||
{
|
{
|
||||||
struct atomode_data *d;
|
struct strtomode_data *d;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
|
|
||||||
for (d = atomode_data; d->mode_str != NULL; d++) {
|
for (d = strtomode_data; d->mode_str != NULL; d++) {
|
||||||
(*ntests)++;
|
(*ntests)++;
|
||||||
errstr = "some error";
|
errstr = "some error";
|
||||||
mode = atomode(d->mode_str, &errstr);
|
mode = sudo_strtomode(d->mode_str, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
if (d->mode != (mode_t)-1) {
|
if (d->mode != (mode_t)-1) {
|
||||||
sudo_warnx_nodebug("FAIL: %s: %s", d->mode_str, errstr);
|
sudo_warnx_nodebug("FAIL: %s: %s", d->mode_str, errstr);
|
||||||
@@ -165,7 +165,7 @@ test_atomode(int *ntests)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple tests for atobool(), atoid(), atomode().
|
* Simple tests for sudo_strtobool(), sudo_strtoid(), sudo_strtomode().
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
@@ -175,9 +175,9 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
initprogname(argc > 0 ? argv[0] : "atofoo");
|
initprogname(argc > 0 ? argv[0] : "atofoo");
|
||||||
|
|
||||||
errors += test_atobool(&ntests);
|
errors += test_strtobool(&ntests);
|
||||||
errors += test_atoid(&ntests);
|
errors += test_strtoid(&ntests);
|
||||||
errors += test_atomode(&ntests);
|
errors += test_strtomode(&ntests);
|
||||||
|
|
||||||
printf("%s: %d tests run, %d errors, %d%% success rate\n", getprogname(),
|
printf("%s: %d tests run, %d errors, %d%% success rate\n", getprogname(),
|
||||||
ntests, errors, (ntests - errors) * 100 / ntests);
|
ntests, errors, (ntests - errors) * 100 / ntests);
|
||||||
|
@@ -42,9 +42,9 @@
|
|||||||
#include "sudo_util.h"
|
#include "sudo_util.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
atobool(const char *str)
|
sudo_strtobool(const char *str)
|
||||||
{
|
{
|
||||||
debug_decl(atobool, SUDO_DEBUG_UTIL)
|
debug_decl(sudo_strtobool, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
switch (*str) {
|
switch (*str) {
|
||||||
case '0':
|
case '0':
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -55,12 +55,12 @@
|
|||||||
* On error, returns 0 and sets errstr.
|
* On error, returns 0 and sets errstr.
|
||||||
*/
|
*/
|
||||||
id_t
|
id_t
|
||||||
atoid(const char *p, const char *sep, char **endp, const char **errstr)
|
sudo_strtoid(const char *p, const char *sep, char **endp, const char **errstr)
|
||||||
{
|
{
|
||||||
char *ep;
|
char *ep;
|
||||||
id_t rval = 0;
|
id_t rval = 0;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
debug_decl(atoid, SUDO_DEBUG_UTIL)
|
debug_decl(sudo_strtoid, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
if (sep == NULL)
|
if (sep == NULL)
|
||||||
sep = "";
|
sep = "";
|
@@ -42,11 +42,11 @@
|
|||||||
* On error, returns 0 and sets errstr.
|
* On error, returns 0 and sets errstr.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
atomode(const char *cp, const char **errstr)
|
sudo_strtomode(const char *cp, const char **errstr)
|
||||||
{
|
{
|
||||||
char *ep;
|
char *ep;
|
||||||
long lval;
|
long lval;
|
||||||
debug_decl(atomode, SUDO_DEBUG_UTIL)
|
debug_decl(sudo_strtomode, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
lval = strtol(cp, &ep, 8);
|
lval = strtol(cp, &ep, 8);
|
@@ -160,7 +160,7 @@ set_variable(const char *entry, const char *conf_file)
|
|||||||
static void
|
static void
|
||||||
set_var_disable_coredump(const char *entry, const char *conf_file)
|
set_var_disable_coredump(const char *entry, const char *conf_file)
|
||||||
{
|
{
|
||||||
int val = atobool(entry);
|
int val = sudo_strtobool(entry);
|
||||||
|
|
||||||
if (val != -1)
|
if (val != -1)
|
||||||
sudo_conf_data.disable_coredump = val;
|
sudo_conf_data.disable_coredump = val;
|
||||||
@@ -198,7 +198,7 @@ set_var_max_groups(const char *entry, const char *conf_file)
|
|||||||
static void
|
static void
|
||||||
set_var_probe_interfaces(const char *entry, const char *conf_file)
|
set_var_probe_interfaces(const char *entry, const char *conf_file)
|
||||||
{
|
{
|
||||||
int val = atobool(entry);
|
int val = sudo_strtobool(entry);
|
||||||
|
|
||||||
if (val != -1)
|
if (val != -1)
|
||||||
sudo_conf_data.probe_interfaces = val;
|
sudo_conf_data.probe_interfaces = val;
|
||||||
|
@@ -22,9 +22,6 @@ _sudo_printf
|
|||||||
aix_prep_user
|
aix_prep_user
|
||||||
aix_restoreauthdb
|
aix_restoreauthdb
|
||||||
aix_setauthdb
|
aix_setauthdb
|
||||||
atobool
|
|
||||||
atoid
|
|
||||||
atomode
|
|
||||||
closefrom_fallback
|
closefrom_fallback
|
||||||
getprogname
|
getprogname
|
||||||
initprogname
|
initprogname
|
||||||
@@ -131,6 +128,9 @@ sudo_snprintf
|
|||||||
sudo_strlcat
|
sudo_strlcat
|
||||||
sudo_strlcpy
|
sudo_strlcpy
|
||||||
sudo_strsignal
|
sudo_strsignal
|
||||||
|
sudo_strtobool
|
||||||
|
sudo_strtoid
|
||||||
|
sudo_strtomode
|
||||||
sudo_strtonum
|
sudo_strtonum
|
||||||
sudo_term_cbreak
|
sudo_term_cbreak
|
||||||
sudo_term_copy
|
sudo_term_copy
|
||||||
|
@@ -123,7 +123,7 @@ next_entry:
|
|||||||
if ((colon = strchr(cp = colon, ':')) == NULL)
|
if ((colon = strchr(cp = colon, ':')) == NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
*colon++ = '\0';
|
*colon++ = '\0';
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
gr.gr_gid = (gid_t)id;
|
gr.gr_gid = (gid_t)id;
|
||||||
|
@@ -823,7 +823,7 @@ store_mode(char *val, struct sudo_defs_types *def, int op)
|
|||||||
if (op == false) {
|
if (op == false) {
|
||||||
def->sd_un.mode = 0777;
|
def->sd_un.mode = 0777;
|
||||||
} else {
|
} else {
|
||||||
mode = atomode(val, &errstr);
|
mode = sudo_strtomode(val, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s is %s", val, errstr);
|
"%s is %s", val, errstr);
|
||||||
|
@@ -426,32 +426,32 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "iolog_stdin=", sizeof("iolog_stdin=") - 1) == 0) {
|
if (strncmp(*cur, "iolog_stdin=", sizeof("iolog_stdin=") - 1) == 0) {
|
||||||
if (atobool(*cur + sizeof("iolog_stdin=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("iolog_stdin=") - 1) == true)
|
||||||
io_log_files[IOFD_STDIN].enabled = true;
|
io_log_files[IOFD_STDIN].enabled = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "iolog_stdout=", sizeof("iolog_stdout=") - 1) == 0) {
|
if (strncmp(*cur, "iolog_stdout=", sizeof("iolog_stdout=") - 1) == 0) {
|
||||||
if (atobool(*cur + sizeof("iolog_stdout=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("iolog_stdout=") - 1) == true)
|
||||||
io_log_files[IOFD_STDOUT].enabled = true;
|
io_log_files[IOFD_STDOUT].enabled = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "iolog_stderr=", sizeof("iolog_stderr=") - 1) == 0) {
|
if (strncmp(*cur, "iolog_stderr=", sizeof("iolog_stderr=") - 1) == 0) {
|
||||||
if (atobool(*cur + sizeof("iolog_stderr=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("iolog_stderr=") - 1) == true)
|
||||||
io_log_files[IOFD_STDERR].enabled = true;
|
io_log_files[IOFD_STDERR].enabled = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "iolog_ttyin=", sizeof("iolog_ttyin=") - 1) == 0) {
|
if (strncmp(*cur, "iolog_ttyin=", sizeof("iolog_ttyin=") - 1) == 0) {
|
||||||
if (atobool(*cur + sizeof("iolog_ttyin=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("iolog_ttyin=") - 1) == true)
|
||||||
io_log_files[IOFD_TTYIN].enabled = true;
|
io_log_files[IOFD_TTYIN].enabled = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "iolog_ttyout=", sizeof("iolog_ttyout=") - 1) == 0) {
|
if (strncmp(*cur, "iolog_ttyout=", sizeof("iolog_ttyout=") - 1) == 0) {
|
||||||
if (atobool(*cur + sizeof("iolog_ttyout=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("iolog_ttyout=") - 1) == true)
|
||||||
io_log_files[IOFD_TTYOUT].enabled = true;
|
io_log_files[IOFD_TTYOUT].enabled = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "iolog_compress=", sizeof("iolog_compress=") - 1) == 0) {
|
if (strncmp(*cur, "iolog_compress=", sizeof("iolog_compress=") - 1) == 0) {
|
||||||
if (atobool(*cur + sizeof("iolog_compress=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("iolog_compress=") - 1) == true)
|
||||||
iolog_compress = true; /* must be global */
|
iolog_compress = true; /* must be global */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
|
|||||||
if (runas_euid_str != NULL)
|
if (runas_euid_str != NULL)
|
||||||
runas_uid_str = runas_euid_str;
|
runas_uid_str = runas_euid_str;
|
||||||
if (runas_uid_str != NULL) {
|
if (runas_uid_str != NULL) {
|
||||||
id = atoid(runas_uid_str, NULL, NULL, &errstr);
|
id = sudo_strtoid(runas_uid_str, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_warnx("runas uid %s: %s", runas_uid_str, U_(errstr));
|
sudo_warnx("runas uid %s: %s", runas_uid_str, U_(errstr));
|
||||||
else
|
else
|
||||||
@@ -498,7 +498,7 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
|
|||||||
if (runas_egid_str != NULL)
|
if (runas_egid_str != NULL)
|
||||||
runas_gid_str = runas_egid_str;
|
runas_gid_str = runas_egid_str;
|
||||||
if (runas_gid_str != NULL) {
|
if (runas_gid_str != NULL) {
|
||||||
id = atoid(runas_gid_str, NULL, NULL, &errstr);
|
id = sudo_strtoid(runas_gid_str, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_warnx("runas gid %s: %s", runas_gid_str, U_(errstr));
|
sudo_warnx("runas gid %s: %s", runas_gid_str, U_(errstr));
|
||||||
else
|
else
|
||||||
|
@@ -1431,7 +1431,7 @@ sudo_ldap_parse_keyword(const char *keyword, const char *value,
|
|||||||
*(int *)(cur->valp) = LDAP_DEREF_NEVER;
|
*(int *)(cur->valp) = LDAP_DEREF_NEVER;
|
||||||
break;
|
break;
|
||||||
case CONF_BOOL:
|
case CONF_BOOL:
|
||||||
*(int *)(cur->valp) = atobool(value) == true;
|
*(int *)(cur->valp) = sudo_strtobool(value) == true;
|
||||||
break;
|
break;
|
||||||
case CONF_INT:
|
case CONF_INT:
|
||||||
*(int *)(cur->valp) = strtonum(value, INT_MIN, INT_MAX, &errstr);
|
*(int *)(cur->valp) = strtonum(value, INT_MIN, INT_MAX, &errstr);
|
||||||
@@ -1662,7 +1662,7 @@ sudo_ldap_read_config(void)
|
|||||||
if (ldap_conf.ssl != NULL) {
|
if (ldap_conf.ssl != NULL) {
|
||||||
if (strcasecmp(ldap_conf.ssl, "start_tls") == 0)
|
if (strcasecmp(ldap_conf.ssl, "start_tls") == 0)
|
||||||
ldap_conf.ssl_mode = SUDO_LDAP_STARTTLS;
|
ldap_conf.ssl_mode = SUDO_LDAP_STARTTLS;
|
||||||
else if (atobool(ldap_conf.ssl) == true)
|
else if (sudo_strtobool(ldap_conf.ssl) == true)
|
||||||
ldap_conf.ssl_mode = SUDO_LDAP_SSL;
|
ldap_conf.ssl_mode = SUDO_LDAP_SSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -811,7 +811,7 @@ userpw_matches(const char *sudoers_user, const char *user, const struct passwd *
|
|||||||
debug_decl(userpw_matches, SUDO_DEBUG_MATCH)
|
debug_decl(userpw_matches, SUDO_DEBUG_MATCH)
|
||||||
|
|
||||||
if (pw != NULL && *sudoers_user == '#') {
|
if (pw != NULL && *sudoers_user == '#') {
|
||||||
uid = (uid_t) atoid(sudoers_user + 1, NULL, NULL, &errstr);
|
uid = (uid_t) sudo_strtoid(sudoers_user + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL && uid == pw->pw_uid) {
|
if (errstr == NULL && uid == pw->pw_uid) {
|
||||||
rc = true;
|
rc = true;
|
||||||
goto done;
|
goto done;
|
||||||
@@ -838,7 +838,7 @@ group_matches(const char *sudoers_group, const struct group *gr)
|
|||||||
debug_decl(group_matches, SUDO_DEBUG_MATCH)
|
debug_decl(group_matches, SUDO_DEBUG_MATCH)
|
||||||
|
|
||||||
if (*sudoers_group == '#') {
|
if (*sudoers_group == '#') {
|
||||||
gid = (gid_t) atoid(sudoers_group + 1, NULL, NULL, &errstr);
|
gid = (gid_t) sudo_strtoid(sudoers_group + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL && gid == gr->gr_gid) {
|
if (errstr == NULL && gid == gr->gr_gid) {
|
||||||
rc = true;
|
rc = true;
|
||||||
goto done;
|
goto done;
|
||||||
|
@@ -104,7 +104,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
}
|
}
|
||||||
if (MATCHES(*cur, "sudoers_uid=")) {
|
if (MATCHES(*cur, "sudoers_uid=")) {
|
||||||
p = *cur + sizeof("sudoers_uid=") - 1;
|
p = *cur + sizeof("sudoers_uid=") - 1;
|
||||||
sudoers_uid = (uid_t) atoid(p, NULL, NULL, &errstr);
|
sudoers_uid = (uid_t) sudo_strtoid(p, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -113,7 +113,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
}
|
}
|
||||||
if (MATCHES(*cur, "sudoers_gid=")) {
|
if (MATCHES(*cur, "sudoers_gid=")) {
|
||||||
p = *cur + sizeof("sudoers_gid=") - 1;
|
p = *cur + sizeof("sudoers_gid=") - 1;
|
||||||
sudoers_gid = (gid_t) atoid(p, NULL, NULL, &errstr);
|
sudoers_gid = (gid_t) sudo_strtoid(p, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -122,7 +122,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
}
|
}
|
||||||
if (MATCHES(*cur, "sudoers_mode=")) {
|
if (MATCHES(*cur, "sudoers_mode=")) {
|
||||||
p = *cur + sizeof("sudoers_mode=") - 1;
|
p = *cur + sizeof("sudoers_mode=") - 1;
|
||||||
sudoers_mode = atomode(p, &errstr);
|
sudoers_mode = sudo_strtomode(p, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -173,49 +173,49 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "set_home=")) {
|
if (MATCHES(*cur, "set_home=")) {
|
||||||
if (atobool(*cur + sizeof("set_home=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("set_home=") - 1) == true)
|
||||||
SET(flags, MODE_RESET_HOME);
|
SET(flags, MODE_RESET_HOME);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "preserve_environment=")) {
|
if (MATCHES(*cur, "preserve_environment=")) {
|
||||||
if (atobool(*cur + sizeof("preserve_environment=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("preserve_environment=") - 1) == true)
|
||||||
SET(flags, MODE_PRESERVE_ENV);
|
SET(flags, MODE_PRESERVE_ENV);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "run_shell=")) {
|
if (MATCHES(*cur, "run_shell=")) {
|
||||||
if (atobool(*cur + sizeof("run_shell=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("run_shell=") - 1) == true)
|
||||||
SET(flags, MODE_SHELL);
|
SET(flags, MODE_SHELL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "login_shell=")) {
|
if (MATCHES(*cur, "login_shell=")) {
|
||||||
if (atobool(*cur + sizeof("login_shell=") - 1) == true) {
|
if (sudo_strtobool(*cur + sizeof("login_shell=") - 1) == true) {
|
||||||
SET(flags, MODE_LOGIN_SHELL);
|
SET(flags, MODE_LOGIN_SHELL);
|
||||||
def_env_reset = true;
|
def_env_reset = true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "implied_shell=")) {
|
if (MATCHES(*cur, "implied_shell=")) {
|
||||||
if (atobool(*cur + sizeof("implied_shell=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("implied_shell=") - 1) == true)
|
||||||
SET(flags, MODE_IMPLIED_SHELL);
|
SET(flags, MODE_IMPLIED_SHELL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "preserve_groups=")) {
|
if (MATCHES(*cur, "preserve_groups=")) {
|
||||||
if (atobool(*cur + sizeof("preserve_groups=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("preserve_groups=") - 1) == true)
|
||||||
SET(flags, MODE_PRESERVE_GROUPS);
|
SET(flags, MODE_PRESERVE_GROUPS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "ignore_ticket=")) {
|
if (MATCHES(*cur, "ignore_ticket=")) {
|
||||||
if (atobool(*cur + sizeof("ignore_ticket=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("ignore_ticket=") - 1) == true)
|
||||||
SET(flags, MODE_IGNORE_TICKET);
|
SET(flags, MODE_IGNORE_TICKET);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "noninteractive=")) {
|
if (MATCHES(*cur, "noninteractive=")) {
|
||||||
if (atobool(*cur + sizeof("noninteractive=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("noninteractive=") - 1) == true)
|
||||||
SET(flags, MODE_NONINTERACTIVE);
|
SET(flags, MODE_NONINTERACTIVE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "sudoedit=")) {
|
if (MATCHES(*cur, "sudoedit=")) {
|
||||||
if (atobool(*cur + sizeof("sudoedit=") - 1) == true)
|
if (sudo_strtobool(*cur + sizeof("sudoedit=") - 1) == true)
|
||||||
SET(flags, MODE_EDIT);
|
SET(flags, MODE_EDIT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
}
|
}
|
||||||
if (MATCHES(*cur, "uid=")) {
|
if (MATCHES(*cur, "uid=")) {
|
||||||
p = *cur + sizeof("uid=") - 1;
|
p = *cur + sizeof("uid=") - 1;
|
||||||
user_uid = (uid_t) atoid(p, NULL, NULL, &errstr);
|
user_uid = (uid_t) sudo_strtoid(p, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -291,7 +291,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
}
|
}
|
||||||
if (MATCHES(*cur, "gid=")) {
|
if (MATCHES(*cur, "gid=")) {
|
||||||
p = *cur + sizeof("gid=") - 1;
|
p = *cur + sizeof("gid=") - 1;
|
||||||
user_gid = (gid_t) atoid(p, NULL, NULL, &errstr);
|
user_gid = (gid_t) sudo_strtoid(p, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -340,7 +340,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
}
|
}
|
||||||
if (MATCHES(*cur, "sid=")) {
|
if (MATCHES(*cur, "sid=")) {
|
||||||
p = *cur + sizeof("sid=") - 1;
|
p = *cur + sizeof("sid=") - 1;
|
||||||
sudo_user.sid = (pid_t) atoid(p, NULL, NULL, &errstr);
|
sudo_user.sid = (pid_t) sudo_strtoid(p, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
|
@@ -280,7 +280,7 @@ sudo_fakepwnam(const char *user, gid_t gid)
|
|||||||
uid_t uid;
|
uid_t uid;
|
||||||
debug_decl(sudo_fakepwnam, SUDO_DEBUG_NSS)
|
debug_decl(sudo_fakepwnam, SUDO_DEBUG_NSS)
|
||||||
|
|
||||||
uid = (uid_t) atoid(user + 1, NULL, NULL, &errstr);
|
uid = (uid_t) sudo_strtoid(user + 1, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_DIAG,
|
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_DIAG,
|
||||||
"uid %s %s", user, errstr);
|
"uid %s %s", user, errstr);
|
||||||
@@ -464,7 +464,7 @@ sudo_fakegrnam(const char *group)
|
|||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
gritem = sudo_ecalloc(1, len);
|
gritem = sudo_ecalloc(1, len);
|
||||||
gr = &gritem->gr;
|
gr = &gritem->gr;
|
||||||
gr->gr_gid = (gid_t) atoid(group + 1, NULL, NULL, &errstr);
|
gr->gr_gid = (gid_t) sudo_strtoid(group + 1, NULL, NULL, &errstr);
|
||||||
gr->gr_name = (char *)(gritem + 1);
|
gr->gr_name = (char *)(gritem + 1);
|
||||||
memcpy(gr->gr_name, group, name_len + 1);
|
memcpy(gr->gr_name, group, name_len + 1);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
@@ -651,7 +651,7 @@ user_in_group(const struct passwd *pw, const char *group)
|
|||||||
* If it could be a sudo-style group ID check gids first.
|
* If it could be a sudo-style group ID check gids first.
|
||||||
*/
|
*/
|
||||||
if (group[0] == '#') {
|
if (group[0] == '#') {
|
||||||
gid_t gid = (gid_t) atoid(group + 1, NULL, NULL, &errstr);
|
gid_t gid = (gid_t) sudo_strtoid(group + 1, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_DIAG,
|
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_DIAG,
|
||||||
"gid %s %s", group, errstr);
|
"gid %s %s", group, errstr);
|
||||||
|
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
|
|||||||
user_name = strdup(line);
|
user_name = strdup(line);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
user_gid = (gid_t)atoid(line, NULL, NULL, &errstr);
|
user_gid = (gid_t)sudo_strtoid(line, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx("group ID %s: %s", line, errstr);
|
sudo_fatalx("group ID %s: %s", line, errstr);
|
||||||
break;
|
break;
|
||||||
@@ -162,7 +162,7 @@ main(int argc, char *argv[])
|
|||||||
runas_pw->pw_name = strdup(line);
|
runas_pw->pw_name = strdup(line);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
runas_pw->pw_gid = (gid_t)atoid(line, NULL, NULL, &errstr);
|
runas_pw->pw_gid = (gid_t)sudo_strtoid(line, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx("group ID %s: %s", line, errstr);
|
sudo_fatalx("group ID %s: %s", line, errstr);
|
||||||
break;
|
break;
|
||||||
|
@@ -323,7 +323,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
|||||||
|
|
||||||
if (*def_timestampowner == '#') {
|
if (*def_timestampowner == '#') {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
uid_t uid = atoid(def_timestampowner + 1, NULL, NULL, &errstr);
|
uid_t uid = sudo_strtoid(def_timestampowner + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL)
|
if (errstr == NULL)
|
||||||
pw = sudo_getpwuid(uid);
|
pw = sudo_getpwuid(uid);
|
||||||
}
|
}
|
||||||
@@ -905,7 +905,7 @@ set_runaspw(const char *user, bool quiet)
|
|||||||
|
|
||||||
if (*user == '#') {
|
if (*user == '#') {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
uid_t uid = atoid(user + 1, NULL, NULL, &errstr);
|
uid_t uid = sudo_strtoid(user + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
if ((pw = sudo_getpwuid(uid)) == NULL)
|
if ((pw = sudo_getpwuid(uid)) == NULL)
|
||||||
pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
|
pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
|
||||||
@@ -936,7 +936,7 @@ set_runasgr(const char *group, bool quiet)
|
|||||||
|
|
||||||
if (*group == '#') {
|
if (*group == '#') {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
gid_t gid = atoid(group + 1, NULL, NULL, &errstr);
|
gid_t gid = sudo_strtoid(group + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
if ((gr = sudo_getgrgid(gid)) == NULL)
|
if ((gr = sudo_getgrgid(gid)) == NULL)
|
||||||
gr = sudo_fakegrnam(group);
|
gr = sudo_fakegrnam(group);
|
||||||
|
@@ -153,7 +153,7 @@ main(int argc, char *argv[])
|
|||||||
user_host = optarg;
|
user_host = optarg;
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
sudoers_gid = (gid_t)atoid(optarg, NULL, NULL, &errstr);
|
sudoers_gid = (gid_t)sudo_strtoid(optarg, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx("group ID %s: %s", optarg, errstr);
|
sudo_fatalx("group ID %s: %s", optarg, errstr);
|
||||||
break;
|
break;
|
||||||
@@ -170,7 +170,7 @@ main(int argc, char *argv[])
|
|||||||
trace_print = testsudoers_print;
|
trace_print = testsudoers_print;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
sudoers_uid = (uid_t)atoid(optarg, NULL, NULL, &errstr);
|
sudoers_uid = (uid_t)sudo_strtoid(optarg, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx("user ID %s: %s", optarg, errstr);
|
sudo_fatalx("user ID %s: %s", optarg, errstr);
|
||||||
break;
|
break;
|
||||||
@@ -353,7 +353,7 @@ set_runaspw(const char *user)
|
|||||||
|
|
||||||
if (*user == '#') {
|
if (*user == '#') {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
uid_t uid = atoid(user + 1, NULL, NULL, &errstr);
|
uid_t uid = sudo_strtoid(user + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
if ((pw = sudo_getpwuid(uid)) == NULL)
|
if ((pw = sudo_getpwuid(uid)) == NULL)
|
||||||
pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
|
pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
|
||||||
@@ -377,7 +377,7 @@ set_runasgr(const char *group)
|
|||||||
|
|
||||||
if (*group == '#') {
|
if (*group == '#') {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
gid_t gid = atoid(group + 1, NULL, NULL, &errstr);
|
gid_t gid = sudo_strtoid(group + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
if ((gr = sudo_getgrgid(gid)) == NULL)
|
if ((gr = sudo_getgrgid(gid)) == NULL)
|
||||||
gr = sudo_fakegrnam(group);
|
gr = sudo_fakegrnam(group);
|
||||||
|
@@ -143,14 +143,14 @@ next_entry:
|
|||||||
if ((colon = strchr(cp = colon, ':')) == NULL)
|
if ((colon = strchr(cp = colon, ':')) == NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
*colon++ = '\0';
|
*colon++ = '\0';
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
pw.pw_uid = (uid_t)id;
|
pw.pw_uid = (uid_t)id;
|
||||||
if ((colon = strchr(cp = colon, ':')) == NULL)
|
if ((colon = strchr(cp = colon, ':')) == NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
*colon++ = '\0';
|
*colon++ = '\0';
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
pw.pw_gid = (gid_t)id;
|
pw.pw_gid = (gid_t)id;
|
||||||
@@ -273,7 +273,7 @@ next_entry:
|
|||||||
if ((colon = strchr(cp = colon, ':')) == NULL)
|
if ((colon = strchr(cp = colon, ':')) == NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
*colon++ = '\0';
|
*colon++ = '\0';
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
goto next_entry;
|
goto next_entry;
|
||||||
gr.gr_gid = (gid_t)id;
|
gr.gr_gid = (gid_t)id;
|
||||||
|
@@ -375,7 +375,7 @@ print_member_json(FILE *fp, struct member *m, enum word_type word_type,
|
|||||||
value.u.string++;
|
value.u.string++;
|
||||||
typestr = "nonunixgroup";
|
typestr = "nonunixgroup";
|
||||||
if (*value.u.string == '#') {
|
if (*value.u.string == '#') {
|
||||||
id = atoid(m->name + 3, NULL, NULL, &errstr);
|
id = sudo_strtoid(m->name + 3, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx("internal error: non-Unix group ID %s: \"%s\"",
|
sudo_warnx("internal error: non-Unix group ID %s: \"%s\"",
|
||||||
errstr, m->name);
|
errstr, m->name);
|
||||||
@@ -388,7 +388,7 @@ print_member_json(FILE *fp, struct member *m, enum word_type word_type,
|
|||||||
} else {
|
} else {
|
||||||
typestr = "usergroup";
|
typestr = "usergroup";
|
||||||
if (*value.u.string == '#') {
|
if (*value.u.string == '#') {
|
||||||
id = atoid(m->name + 2, NULL, NULL, &errstr);
|
id = sudo_strtoid(m->name + 2, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx("internal error: group ID %s: \"%s\"",
|
sudo_warnx("internal error: group ID %s: \"%s\"",
|
||||||
errstr, m->name);
|
errstr, m->name);
|
||||||
@@ -422,7 +422,7 @@ print_member_json(FILE *fp, struct member *m, enum word_type word_type,
|
|||||||
case TYPE_USERNAME:
|
case TYPE_USERNAME:
|
||||||
typestr = "username";
|
typestr = "username";
|
||||||
if (*value.u.string == '#') {
|
if (*value.u.string == '#') {
|
||||||
id = atoid(m->name + 1, NULL, NULL, &errstr);
|
id = sudo_strtoid(m->name + 1, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx("internal error: user ID %s: \"%s\"",
|
sudo_warnx("internal error: user ID %s: \"%s\"",
|
||||||
errstr, m->name);
|
errstr, m->name);
|
||||||
|
@@ -135,7 +135,7 @@ sysgroup_query(const char *user, const char *group, const struct passwd *pwd)
|
|||||||
grp = sysgroup_getgrnam(group);
|
grp = sysgroup_getgrnam(group);
|
||||||
if (grp == NULL && group[0] == '#' && group[1] != '\0') {
|
if (grp == NULL && group[0] == '#' && group[1] != '\0') {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
gid_t gid = atoid(group + 1, NULL, NULL, &errstr);
|
gid_t gid = sudo_strtoid(group + 1, NULL, NULL, &errstr);
|
||||||
if (errstr == NULL)
|
if (errstr == NULL)
|
||||||
grp = sysgroup_getgrgid(gid);
|
grp = sysgroup_getgrgid(gid);
|
||||||
}
|
}
|
||||||
|
22
src/sudo.c
22
src/sudo.c
@@ -562,7 +562,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
if (strncmp("exec_background=", info[i], sizeof("exec_background=") - 1) == 0) {
|
if (strncmp("exec_background=", info[i], sizeof("exec_background=") - 1) == 0) {
|
||||||
if (atobool(info[i] + sizeof("exec_background=") - 1) == true)
|
if (sudo_strtobool(info[i] + sizeof("exec_background=") - 1) == true)
|
||||||
SET(details->flags, CD_EXEC_BG);
|
SET(details->flags, CD_EXEC_BG);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -580,14 +580,14 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strncmp("noexec=", info[i], sizeof("noexec=") - 1) == 0) {
|
if (strncmp("noexec=", info[i], sizeof("noexec=") - 1) == 0) {
|
||||||
if (atobool(info[i] + sizeof("noexec=") - 1) == true)
|
if (sudo_strtobool(info[i] + sizeof("noexec=") - 1) == true)
|
||||||
SET(details->flags, CD_NOEXEC);
|
SET(details->flags, CD_NOEXEC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (strncmp("preserve_groups=", info[i], sizeof("preserve_groups=") - 1) == 0) {
|
if (strncmp("preserve_groups=", info[i], sizeof("preserve_groups=") - 1) == 0) {
|
||||||
if (atobool(info[i] + sizeof("preserve_groups=") - 1) == true)
|
if (sudo_strtobool(info[i] + sizeof("preserve_groups=") - 1) == true)
|
||||||
SET(details->flags, CD_PRESERVE_GROUPS);
|
SET(details->flags, CD_PRESERVE_GROUPS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -600,7 +600,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
case 'r':
|
case 'r':
|
||||||
if (strncmp("runas_egid=", info[i], sizeof("runas_egid=") - 1) == 0) {
|
if (strncmp("runas_egid=", info[i], sizeof("runas_egid=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("runas_egid=") - 1;
|
cp = info[i] + sizeof("runas_egid=") - 1;
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
details->egid = (gid_t)id;
|
details->egid = (gid_t)id;
|
||||||
@@ -609,7 +609,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
}
|
}
|
||||||
if (strncmp("runas_euid=", info[i], sizeof("runas_euid=") - 1) == 0) {
|
if (strncmp("runas_euid=", info[i], sizeof("runas_euid=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("runas_euid=") - 1;
|
cp = info[i] + sizeof("runas_euid=") - 1;
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
details->euid = (uid_t)id;
|
details->euid = (uid_t)id;
|
||||||
@@ -618,7 +618,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
}
|
}
|
||||||
if (strncmp("runas_gid=", info[i], sizeof("runas_gid=") - 1) == 0) {
|
if (strncmp("runas_gid=", info[i], sizeof("runas_gid=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("runas_gid=") - 1;
|
cp = info[i] + sizeof("runas_gid=") - 1;
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
details->gid = (gid_t)id;
|
details->gid = (gid_t)id;
|
||||||
@@ -635,7 +635,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
}
|
}
|
||||||
if (strncmp("runas_uid=", info[i], sizeof("runas_uid=") - 1) == 0) {
|
if (strncmp("runas_uid=", info[i], sizeof("runas_uid=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("runas_uid=") - 1;
|
cp = info[i] + sizeof("runas_uid=") - 1;
|
||||||
id = atoid(cp, NULL, NULL, &errstr);
|
id = sudo_strtoid(cp, NULL, NULL, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
details->uid = (uid_t)id;
|
details->uid = (uid_t)id;
|
||||||
@@ -669,12 +669,12 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
SET_STRING("selinux_role=", selinux_role)
|
SET_STRING("selinux_role=", selinux_role)
|
||||||
SET_STRING("selinux_type=", selinux_type)
|
SET_STRING("selinux_type=", selinux_type)
|
||||||
if (strncmp("set_utmp=", info[i], sizeof("set_utmp=") - 1) == 0) {
|
if (strncmp("set_utmp=", info[i], sizeof("set_utmp=") - 1) == 0) {
|
||||||
if (atobool(info[i] + sizeof("set_utmp=") - 1) == true)
|
if (sudo_strtobool(info[i] + sizeof("set_utmp=") - 1) == true)
|
||||||
SET(details->flags, CD_SET_UTMP);
|
SET(details->flags, CD_SET_UTMP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strncmp("sudoedit=", info[i], sizeof("sudoedit=") - 1) == 0) {
|
if (strncmp("sudoedit=", info[i], sizeof("sudoedit=") - 1) == 0) {
|
||||||
if (atobool(info[i] + sizeof("sudoedit=") - 1) == true)
|
if (sudo_strtobool(info[i] + sizeof("sudoedit=") - 1) == true)
|
||||||
SET(details->flags, CD_SUDOEDIT);
|
SET(details->flags, CD_SUDOEDIT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -692,14 +692,14 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
case 'u':
|
case 'u':
|
||||||
if (strncmp("umask=", info[i], sizeof("umask=") - 1) == 0) {
|
if (strncmp("umask=", info[i], sizeof("umask=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("umask=") - 1;
|
cp = info[i] + sizeof("umask=") - 1;
|
||||||
details->umask = atomode(cp, &errstr);
|
details->umask = sudo_strtomode(cp, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
SET(details->flags, CD_SET_UMASK);
|
SET(details->flags, CD_SET_UMASK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strncmp("use_pty=", info[i], sizeof("use_pty=") - 1) == 0) {
|
if (strncmp("use_pty=", info[i], sizeof("use_pty=") - 1) == 0) {
|
||||||
if (atobool(info[i] + sizeof("use_pty=") - 1) == true)
|
if (sudo_strtobool(info[i] + sizeof("use_pty=") - 1) == true)
|
||||||
SET(details->flags, CD_USE_PTY);
|
SET(details->flags, CD_USE_PTY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user