Store column number for aliases, defaults and userspecs too.
This is used to provided the column number along with the line number in error messages. For aliases we store the column of the alias name, not the value since that is what visudo generally needs.
This commit is contained in:
@@ -114,7 +114,7 @@ alias_put(struct alias *a)
|
||||
*/
|
||||
const char *
|
||||
alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type,
|
||||
char *file, int lineno, struct member *members)
|
||||
char *file, int line, int column, struct member *members)
|
||||
{
|
||||
static char errbuf[512];
|
||||
struct alias *a;
|
||||
@@ -136,7 +136,8 @@ alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type,
|
||||
a->type = type;
|
||||
/* a->used = false; */
|
||||
a->file = rcstr_addref(file);
|
||||
a->lineno = lineno;
|
||||
a->line = line;
|
||||
a->column = column;
|
||||
HLTQ_TO_TAILQ(&a->members, members, entries);
|
||||
switch (rbinsert(parse_tree->aliases, a, NULL)) {
|
||||
case 1:
|
||||
|
@@ -180,8 +180,8 @@ print_global_defaults_ldif(FILE *fp, struct sudoers_parse_tree *parse_tree,
|
||||
lbuf.len = 0;
|
||||
sudo_lbuf_append(&lbuf, "# ");
|
||||
sudoers_format_default_line(&lbuf, parse_tree, opt, false, true);
|
||||
fprintf(fp, "# Unable to translate %s:%d\n%s\n",
|
||||
opt->file, opt->lineno, lbuf.buf);
|
||||
fprintf(fp, "# Unable to translate %s:%d:%d:\n%s\n",
|
||||
opt->file, opt->line, opt->column, lbuf.buf);
|
||||
}
|
||||
}
|
||||
sudo_lbuf_destroy(&lbuf);
|
||||
|
@@ -68,7 +68,7 @@ static bool store_tuple(const char *str, union sudo_defs_val *sd_un, struct def_
|
||||
static bool store_uint(const char *str, union sudo_defs_val *sd_un);
|
||||
static bool store_timespec(const char *str, union sudo_defs_val *sd_un);
|
||||
static bool list_op(const char *str, size_t, union sudo_defs_val *sd_un, enum list_ops op);
|
||||
static bool valid_path(struct sudo_defs_types *def, const char *val, const char *file, int lineno, bool quiet);
|
||||
static bool valid_path(struct sudo_defs_types *def, const char *val, const char *file, int line, int column, bool quiet);
|
||||
|
||||
/*
|
||||
* Table describing compile-time and run-time options.
|
||||
@@ -171,7 +171,7 @@ dump_defaults(void)
|
||||
* On success, returns the matching index or -1 on failure.
|
||||
*/
|
||||
static int
|
||||
find_default(const char *name, const char *file, int lineno, bool quiet)
|
||||
find_default(const char *name, const char *file, int line, int column, bool quiet)
|
||||
{
|
||||
int i;
|
||||
debug_decl(find_default, SUDOERS_DEBUG_DEFAULTS);
|
||||
@@ -181,9 +181,9 @@ find_default(const char *name, const char *file, int lineno, bool quiet)
|
||||
debug_return_int(i);
|
||||
}
|
||||
if (!quiet && !def_ignore_unknown_defaults) {
|
||||
if (lineno > 0) {
|
||||
sudo_warnx(U_("%s:%d: unknown defaults entry \"%s\""),
|
||||
file, lineno, name);
|
||||
if (line > 0) {
|
||||
sudo_warnx(U_("%s:%d:%d: unknown defaults entry \"%s\""),
|
||||
file, line, column + 1, name);
|
||||
} else {
|
||||
sudo_warnx(U_("%s: unknown defaults entry \"%s\""),
|
||||
file, name);
|
||||
@@ -201,13 +201,13 @@ find_default(const char *name, const char *file, int lineno, bool quiet)
|
||||
*/
|
||||
static bool
|
||||
parse_default_entry(struct sudo_defs_types *def, const char *val, int op,
|
||||
const char *file, int lineno, bool quiet)
|
||||
const char *file, int line, int column, bool quiet)
|
||||
{
|
||||
int rc;
|
||||
debug_decl(parse_default_entry, SUDOERS_DEBUG_DEFAULTS);
|
||||
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: %s:%d: %s=%s op=%d",
|
||||
__func__, file, lineno, def->name, val ? val : "", op);
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: %s:%d:%d: %s=%s op=%d",
|
||||
__func__, file, line, column, def->name, val ? val : "", op);
|
||||
|
||||
/*
|
||||
* If no value specified, the boolean flag must be set for non-flags.
|
||||
@@ -230,9 +230,9 @@ parse_default_entry(struct sudo_defs_types *def, const char *val, int op,
|
||||
default:
|
||||
if (!ISSET(def->type, T_BOOL) || op != false) {
|
||||
if (!quiet) {
|
||||
if (lineno > 0) {
|
||||
sudo_warnx(U_("%s:%d: no value specified for \"%s\""),
|
||||
file, lineno, def->name);
|
||||
if (line > 0) {
|
||||
sudo_warnx(U_("%s:%d:%d: no value specified for \"%s\""),
|
||||
file, line, column, def->name);
|
||||
} else {
|
||||
sudo_warnx(U_("%s: no value specified for \"%s\""),
|
||||
file, def->name);
|
||||
@@ -252,7 +252,7 @@ parse_default_entry(struct sudo_defs_types *def, const char *val, int op,
|
||||
break;
|
||||
case T_STR:
|
||||
if (val != NULL && ISSET(def->type, T_PATH|T_CHPATH)) {
|
||||
if (!valid_path(def, val, file, lineno, quiet)) {
|
||||
if (!valid_path(def, val, file, line, column, quiet)) {
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
@@ -271,9 +271,9 @@ parse_default_entry(struct sudo_defs_types *def, const char *val, int op,
|
||||
case T_FLAG:
|
||||
if (val != NULL) {
|
||||
if (!quiet) {
|
||||
if (lineno > 0) {
|
||||
sudo_warnx(U_("%s:%d: option \"%s\" does not take a value"),
|
||||
file, lineno, def->name);
|
||||
if (line > 0) {
|
||||
sudo_warnx(U_("%s:%d:%d: option \"%s\" does not take a value"),
|
||||
file, line, column, def->name);
|
||||
} else {
|
||||
sudo_warnx(U_("%s: option \"%s\" does not take a value"),
|
||||
file, def->name);
|
||||
@@ -299,9 +299,9 @@ parse_default_entry(struct sudo_defs_types *def, const char *val, int op,
|
||||
break;
|
||||
default:
|
||||
if (!quiet) {
|
||||
if (lineno > 0) {
|
||||
sudo_warnx(U_("%s:%d: invalid Defaults type 0x%x for option \"%s\""),
|
||||
file, lineno, def->type, def->name);
|
||||
if (line > 0) {
|
||||
sudo_warnx(U_("%s:%d:%d: invalid Defaults type 0x%x for option \"%s\""),
|
||||
file, line, column, def->type, def->name);
|
||||
} else {
|
||||
sudo_warnx(U_("%s: invalid Defaults type 0x%x for option \"%s\""),
|
||||
file, def->type, def->name);
|
||||
@@ -312,9 +312,9 @@ parse_default_entry(struct sudo_defs_types *def, const char *val, int op,
|
||||
}
|
||||
if (rc == false) {
|
||||
if (!quiet) {
|
||||
if (lineno > 0) {
|
||||
sudo_warnx(U_("%s:%d: value \"%s\" is invalid for option \"%s\""),
|
||||
file, lineno, val, def->name);
|
||||
if (line > 0) {
|
||||
sudo_warnx(U_("%s:%d:%d: value \"%s\" is invalid for option \"%s\""),
|
||||
file, line, column, val, def->name);
|
||||
} else {
|
||||
sudo_warnx(U_("%s: value \"%s\" is invalid for option \"%s\""),
|
||||
file, val, def->name);
|
||||
@@ -354,7 +354,7 @@ run_callback(struct sudo_defs_types *def)
|
||||
*/
|
||||
bool
|
||||
set_default(const char *var, const char *val, int op, const char *file,
|
||||
int lineno, bool quiet)
|
||||
int line, int column, bool quiet)
|
||||
{
|
||||
int idx;
|
||||
debug_decl(set_default, SUDOERS_DEBUG_DEFAULTS);
|
||||
@@ -362,11 +362,11 @@ set_default(const char *var, const char *val, int op, const char *file,
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||
"%s: setting Defaults %s -> %s", __func__, var, val ? val : "false");
|
||||
|
||||
idx = find_default(var, file, lineno, quiet);
|
||||
idx = find_default(var, file, line, column, quiet);
|
||||
if (idx != -1) {
|
||||
/* Set parsed value in sudo_defs_table and run callback (if any). */
|
||||
struct sudo_defs_types *def = &sudo_defs_table[idx];
|
||||
if (parse_default_entry(def, val, op, file, lineno, quiet))
|
||||
if (parse_default_entry(def, val, op, file, line, column, quiet))
|
||||
debug_return_bool(run_callback(def));
|
||||
}
|
||||
debug_return_bool(false);
|
||||
@@ -378,16 +378,16 @@ set_default(const char *var, const char *val, int op, const char *file,
|
||||
*/
|
||||
bool
|
||||
set_early_default(const char *var, const char *val, int op, const char *file,
|
||||
int lineno, bool quiet, struct early_default *early)
|
||||
int line, int column, bool quiet, struct early_default *early)
|
||||
{
|
||||
int idx;
|
||||
debug_decl(set_early_default, SUDOERS_DEBUG_DEFAULTS);
|
||||
|
||||
idx = find_default(var, file, lineno, quiet);
|
||||
idx = find_default(var, file, line, column, quiet);
|
||||
if (idx != -1) {
|
||||
/* Set parsed value in sudo_defs_table but defer callback (if any). */
|
||||
struct sudo_defs_types *def = &sudo_defs_table[idx];
|
||||
if (parse_default_entry(def, val, op, file, lineno, quiet)) {
|
||||
if (parse_default_entry(def, val, op, file, line, column, quiet)) {
|
||||
early->run_callback = true;
|
||||
debug_return_bool(true);
|
||||
}
|
||||
@@ -732,8 +732,8 @@ update_defaults(struct sudoers_parse_tree *parse_tree,
|
||||
continue;
|
||||
|
||||
/* Copy the value to sudo_defs_table and mark as early. */
|
||||
if (!set_early_default(d->var, d->val, d->op, d->file, d->lineno,
|
||||
quiet, early))
|
||||
if (!set_early_default(d->var, d->val, d->op, d->file, d->line,
|
||||
d->column, quiet, early))
|
||||
ret = false;
|
||||
}
|
||||
/* Run callbacks for early defaults (if any) */
|
||||
@@ -754,7 +754,7 @@ update_defaults(struct sudoers_parse_tree *parse_tree,
|
||||
continue;
|
||||
|
||||
/* Copy the value to sudo_defs_table and run callback (if any) */
|
||||
if (!set_default(d->var, d->val, d->op, d->file, d->lineno, quiet))
|
||||
if (!set_default(d->var, d->val, d->op, d->file, d->line, d->column, quiet))
|
||||
ret = false;
|
||||
}
|
||||
|
||||
@@ -773,12 +773,12 @@ check_defaults(struct sudoers_parse_tree *parse_tree, bool quiet)
|
||||
debug_decl(check_defaults, SUDOERS_DEBUG_DEFAULTS);
|
||||
|
||||
TAILQ_FOREACH(d, &parse_tree->defaults, entries) {
|
||||
idx = find_default(d->var, d->file, d->lineno, quiet);
|
||||
idx = find_default(d->var, d->file, d->line, d->column, quiet);
|
||||
if (idx != -1) {
|
||||
struct sudo_defs_types def = sudo_defs_table[idx];
|
||||
memset(&def.sd_un, 0, sizeof(def.sd_un));
|
||||
if (parse_default_entry(&def, d->val, d->op, d->file,
|
||||
d->lineno, quiet)) {
|
||||
d->line, d->column, quiet)) {
|
||||
free_defs_val(def.type, &def.sd_un);
|
||||
continue;
|
||||
}
|
||||
@@ -1017,7 +1017,7 @@ store_timeout(const char *str, union sudo_defs_val *sd_un)
|
||||
|
||||
static bool
|
||||
valid_path(struct sudo_defs_types *def, const char *val,
|
||||
const char *file, int lineno, bool quiet)
|
||||
const char *file, int line, int column, bool quiet)
|
||||
{
|
||||
bool ret = true;
|
||||
debug_decl(valid_path, SUDOERS_DEBUG_DEFAULTS);
|
||||
@@ -1025,10 +1025,10 @@ valid_path(struct sudo_defs_types *def, const char *val,
|
||||
if (ISSET(def->type, T_CHPATH)) {
|
||||
if (val[0] != '/' && val[0] != '~' && (val[0] != '*' || val[1] != '\0')) {
|
||||
if (!quiet) {
|
||||
if (lineno > 0) {
|
||||
if (line > 0) {
|
||||
sudo_warnx(
|
||||
U_("%s:%d: values for \"%s\" must start with a '/', '~', or '*'"),
|
||||
file, lineno, def->name);
|
||||
U_("%s:%d:%d: values for \"%s\" must start with a '/', '~', or '*'"),
|
||||
file, line, column, def->name);
|
||||
} else {
|
||||
sudo_warnx(
|
||||
U_("%s: values for \"%s\" must start with a '/', '~', or '*'"),
|
||||
@@ -1040,10 +1040,10 @@ valid_path(struct sudo_defs_types *def, const char *val,
|
||||
} else {
|
||||
if (val[0] != '/') {
|
||||
if (!quiet) {
|
||||
if (lineno > 0) {
|
||||
if (line > 0) {
|
||||
sudo_warnx(
|
||||
U_("%s:%d: values for \"%s\" must start with a '/'"),
|
||||
file, lineno, def->name);
|
||||
U_("%s:%d:%d: values for \"%s\" must start with a '/'"),
|
||||
file, line, column, def->name);
|
||||
} else {
|
||||
sudo_warnx(
|
||||
U_("%s: values for \"%s\" must start with a '/'"),
|
||||
|
@@ -133,8 +133,8 @@ void dump_default(void);
|
||||
bool init_defaults(void);
|
||||
struct early_default *is_early_default(const char *name);
|
||||
bool run_early_defaults(void);
|
||||
bool set_early_default(const char *var, const char *val, int op, const char *file, int lineno, bool quiet, struct early_default *early);
|
||||
bool set_default(const char *var, const char *val, int op, const char *file, int lineno, bool quiet);
|
||||
bool set_early_default(const char *var, const char *val, int op, const char *file, int line, int column, bool quiet, struct early_default *early);
|
||||
bool set_default(const char *var, const char *val, int op, const char *file, int line, int column, bool quiet);
|
||||
bool update_defaults(struct sudoers_parse_tree *parse_tree, struct defaults_list *defs, int what, bool quiet);
|
||||
bool check_defaults(struct sudoers_parse_tree *parse_tree, bool quiet);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -158,7 +158,7 @@ extern int sudoersdebug;
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 77 "gram.y" /* yacc.c:1921 */
|
||||
#line 79 "gram.y" /* yacc.c:1921 */
|
||||
|
||||
struct cmndspec *cmndspec;
|
||||
struct defaults *defaults;
|
||||
|
@@ -54,6 +54,8 @@ bool parse_error = false;
|
||||
int errorlineno = -1;
|
||||
char *errorfile = NULL;
|
||||
|
||||
static int alias_line, alias_column;
|
||||
|
||||
struct sudoers_parse_tree parsed_policy = {
|
||||
TAILQ_HEAD_INITIALIZER(parsed_policy.userspecs),
|
||||
TAILQ_HEAD_INITIALIZER(parsed_policy.defaults),
|
||||
@@ -859,10 +861,13 @@ hostaliases : hostalias
|
||||
| hostaliases ':' hostalias
|
||||
;
|
||||
|
||||
hostalias : ALIAS '=' hostlist {
|
||||
hostalias : ALIAS {
|
||||
alias_line = this_lineno;
|
||||
alias_column = sudolinebuf.toke_start + 1;
|
||||
} '=' hostlist {
|
||||
const char *s;
|
||||
s = alias_add(&parsed_policy, $1, HOSTALIAS,
|
||||
sudoers, this_lineno, $3);
|
||||
sudoers, alias_line, alias_column, $4);
|
||||
if (s != NULL) {
|
||||
sudoerserror(s);
|
||||
YYERROR;
|
||||
@@ -882,10 +887,13 @@ cmndaliases : cmndalias
|
||||
| cmndaliases ':' cmndalias
|
||||
;
|
||||
|
||||
cmndalias : ALIAS '=' cmndlist {
|
||||
cmndalias : ALIAS {
|
||||
alias_line = this_lineno;
|
||||
alias_column = sudolinebuf.toke_start + 1;
|
||||
} '=' cmndlist {
|
||||
const char *s;
|
||||
s = alias_add(&parsed_policy, $1, CMNDALIAS,
|
||||
sudoers, this_lineno, $3);
|
||||
sudoers, alias_line, alias_column, $4);
|
||||
if (s != NULL) {
|
||||
sudoerserror(s);
|
||||
YYERROR;
|
||||
@@ -905,10 +913,13 @@ runasaliases : runasalias
|
||||
| runasaliases ':' runasalias
|
||||
;
|
||||
|
||||
runasalias : ALIAS '=' userlist {
|
||||
runasalias : ALIAS {
|
||||
alias_line = this_lineno;
|
||||
alias_column = sudolinebuf.toke_start + 1;
|
||||
} '=' userlist {
|
||||
const char *s;
|
||||
s = alias_add(&parsed_policy, $1, RUNASALIAS,
|
||||
sudoers, this_lineno, $3);
|
||||
sudoers, alias_line, alias_column, $4);
|
||||
if (s != NULL) {
|
||||
sudoerserror(s);
|
||||
YYERROR;
|
||||
@@ -921,10 +932,13 @@ useraliases : useralias
|
||||
| useraliases ':' useralias
|
||||
;
|
||||
|
||||
useralias : ALIAS '=' userlist {
|
||||
useralias : ALIAS {
|
||||
alias_line = this_lineno;
|
||||
alias_column = sudolinebuf.toke_start + 1;
|
||||
} '=' userlist {
|
||||
const char *s;
|
||||
s = alias_add(&parsed_policy, $1, USERALIAS,
|
||||
sudoers, this_lineno, $3);
|
||||
sudoers, alias_line, alias_column, $4);
|
||||
if (s != NULL) {
|
||||
sudoerserror(s);
|
||||
YYERROR;
|
||||
@@ -1095,7 +1109,8 @@ new_default(char *var, char *val, short op)
|
||||
/* d->type = 0; */
|
||||
d->op = op;
|
||||
/* d->binding = NULL */
|
||||
d->lineno = this_lineno;
|
||||
d->line = this_lineno;
|
||||
d->column = sudolinebuf.toke_start + 1;
|
||||
d->file = rcstr_addref(sudoers);
|
||||
HLTQ_INIT(d, entries);
|
||||
|
||||
@@ -1222,7 +1237,8 @@ add_userspec(struct member *members, struct privilege *privs)
|
||||
"unable to allocate memory");
|
||||
debug_return_bool(false);
|
||||
}
|
||||
u->lineno = this_lineno;
|
||||
u->line = this_lineno;
|
||||
u->column = sudolinebuf.toke_start + 1;
|
||||
u->file = rcstr_addref(sudoers);
|
||||
HLTQ_TO_TAILQ(&u->users, members, entries);
|
||||
HLTQ_TO_TAILQ(&u->privileges, privs, entries);
|
||||
|
@@ -165,8 +165,8 @@ sudoers_lookup_check(struct sudo_nss *nss, struct passwd *pw,
|
||||
*matching_cs = cs;
|
||||
*defs = &priv->defaults;
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||
"userspec matched @ %s:%d: %s",
|
||||
us->file ? us->file : "???", us->lineno,
|
||||
"userspec matched @ %s:%d:%d: %s",
|
||||
us->file ? us->file : "???", us->line, us->column,
|
||||
cmnd_match ? "allowed" : "denied");
|
||||
debug_return_int(cmnd_match);
|
||||
}
|
||||
|
@@ -176,7 +176,8 @@ struct userspec {
|
||||
struct member_list users; /* list of users */
|
||||
struct privilege_list privileges; /* list of privileges */
|
||||
struct comment_list comments; /* optional comments */
|
||||
int lineno; /* line number in sudoers */
|
||||
int line; /* line number in sudoers */
|
||||
int column; /* column number in sudoers */
|
||||
char *file; /* name of sudoers file */
|
||||
};
|
||||
|
||||
@@ -252,7 +253,8 @@ struct alias {
|
||||
char *name; /* alias name */
|
||||
unsigned short type; /* {USER,HOST,RUNAS,CMND}ALIAS */
|
||||
short used; /* "used" flag for cycle detection */
|
||||
int lineno; /* line number of alias entry */
|
||||
int line; /* line number of alias entry */
|
||||
int column; /* column number of alias entry */
|
||||
char *file; /* file the alias entry was in */
|
||||
struct member_list members; /* list of alias members */
|
||||
};
|
||||
@@ -269,7 +271,8 @@ struct defaults {
|
||||
short type; /* DEFAULTS{,_USER,_RUNAS,_HOST} */
|
||||
char op; /* true, false, '+', '-' */
|
||||
char error; /* parse error flag */
|
||||
int lineno; /* line number of Defaults entry */
|
||||
int line; /* line number of Defaults entry */
|
||||
int column; /* column number of Defaults entry */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -295,7 +298,7 @@ struct cmnd_info {
|
||||
struct rbtree *alloc_aliases(void);
|
||||
void free_aliases(struct rbtree *aliases);
|
||||
bool no_aliases(struct sudoers_parse_tree *parse_tree);
|
||||
const char *alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type, char *file, int lineno, struct member *members);
|
||||
const char *alias_add(struct sudoers_parse_tree *parse_tree, char *name, int type, char *file, int line, int column, struct member *members);
|
||||
const char *alias_type_to_string(int alias_type);
|
||||
struct alias *alias_get(struct sudoers_parse_tree *parse_tree, const char *name, int type);
|
||||
struct alias *alias_remove(struct sudoers_parse_tree *parse_tree, char *name, int type);
|
||||
|
@@ -6,5 +6,5 @@ WORD(6) ALL = CMND_TIMEOUT = WORD(6) <*> COMMAND
|
||||
WORD(6) ALL = CMND_TIMEOUT = WORD(6) <*> COMMAND
|
||||
WORD(6) ALL = CMND_TIMEOUT = WORD(6) <*> COMMAND
|
||||
WORD(6) ALL = CMND_TIMEOUT = WORD(6) <*> COMMAND
|
||||
testsudoers: sudoers:2: value "2d8h10m59ss" is invalid for option "command_timeout"
|
||||
testsudoers: sudoers:3: value "15f" is invalid for option "command_timeout"
|
||||
testsudoers: sudoers:2:26: value "2d8h10m59ss" is invalid for option "command_timeout"
|
||||
testsudoers: sudoers:3:31: value "15f" is invalid for option "command_timeout"
|
||||
|
@@ -1,28 +1,28 @@
|
||||
# Unable to translate stdin:26
|
||||
# Unable to translate stdin:26:29:
|
||||
# Defaults@somehost set_home
|
||||
|
||||
# Unable to translate stdin:27
|
||||
# Unable to translate stdin:27:29:
|
||||
# Defaults@quoted\" set_home
|
||||
|
||||
# Unable to translate stdin:30
|
||||
# Unable to translate stdin:30:24:
|
||||
# Defaults:you set_home
|
||||
|
||||
# Unable to translate stdin:31
|
||||
# Unable to translate stdin:31:25:
|
||||
# Defaults:us\" set_home
|
||||
|
||||
# Unable to translate stdin:32
|
||||
# Unable to translate stdin:32:26:
|
||||
# Defaults:%them set_home
|
||||
|
||||
# Unable to translate stdin:33
|
||||
# Unable to translate stdin:33:36:
|
||||
# Defaults:"%: non UNIX 0 c" set_home
|
||||
|
||||
# Unable to translate stdin:34
|
||||
# Unable to translate stdin:34:25:
|
||||
# Defaults:+net set_home
|
||||
|
||||
# Unable to translate stdin:37
|
||||
# Unable to translate stdin:37:28:
|
||||
# Defaults>someone set_home
|
||||
|
||||
# Unable to translate stdin:38
|
||||
# Unable to translate stdin:38:29:
|
||||
# Defaults>"some one" set_home
|
||||
|
||||
dn: cn=foo,ou=SUDOers,dc=sudo,dc=ws
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# Unable to translate stdin:3
|
||||
# Unable to translate stdin:3:23:
|
||||
# Defaults:foo, bar env_reset
|
||||
|
||||
# Unable to translate stdin:4
|
||||
# Unable to translate stdin:4:27:
|
||||
# Defaults:foo, bar env_reset
|
||||
|
||||
# Unable to translate stdin:5
|
||||
# Unable to translate stdin:5:29:
|
||||
# Defaults:foo, " bar" env_reset
|
||||
|
||||
# Unable to translate stdin:6
|
||||
# Unable to translate stdin:6:28:
|
||||
# Defaults:foo, bar env_reset
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
# Unable to translate stdin:2
|
||||
# Unable to translate stdin:2:23:
|
||||
# Defaults:#123 set_home
|
||||
|
||||
# Unable to translate stdin:3
|
||||
# Unable to translate stdin:3:23:
|
||||
# Defaults>#123 set_home
|
||||
|
||||
# Unable to translate stdin:4
|
||||
# Unable to translate stdin:4:25:
|
||||
# Defaults:#123 set_home
|
||||
|
||||
# Unable to translate stdin:5
|
||||
# Unable to translate stdin:5:25:
|
||||
# Defaults>#123 set_home
|
||||
|
||||
dn: cn=\#0,ou=SUDOers,dc=sudo,dc=ws
|
||||
|
@@ -1 +1 @@
|
||||
Error: stdin:1: cycle in User_Alias "FOO"
|
||||
Error: stdin:1:12: cycle in User_Alias "FOO"
|
||||
|
@@ -1,2 +1,2 @@
|
||||
Warning: stdin:1: unused User_Alias "A"
|
||||
Warning: stdin:2: unused User_Alias "B"
|
||||
Warning: stdin:1:12: unused User_Alias "A"
|
||||
Warning: stdin:2:12: unused User_Alias "B"
|
||||
|
@@ -564,7 +564,7 @@ check_defaults_and_aliases(bool strict, bool quiet)
|
||||
if (d->error) {
|
||||
/* Defaults parse error, set errorfile/errorlineno. */
|
||||
errorfile = rcstr_addref(d->file);
|
||||
errorlineno = d->lineno;
|
||||
errorlineno = d->line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1067,8 @@ open_sudoers(const char *path, bool doedit, bool *keepopen)
|
||||
}
|
||||
|
||||
static int
|
||||
check_alias(char *name, int type, char *file, int lineno, bool strict, bool quiet)
|
||||
check_alias(char *name, int type, char *file, int line, int column,
|
||||
bool strict, bool quiet)
|
||||
{
|
||||
struct member *m;
|
||||
struct alias *a;
|
||||
@@ -1079,26 +1080,27 @@ check_alias(char *name, int type, char *file, int lineno, bool strict, bool quie
|
||||
TAILQ_FOREACH(m, &a->members, entries) {
|
||||
if (m->type != ALIAS)
|
||||
continue;
|
||||
errors += check_alias(m->name, type, a->file, a->lineno, strict, quiet);
|
||||
errors += check_alias(m->name, type, a->file, a->line, a->column,
|
||||
strict, quiet);
|
||||
}
|
||||
alias_put(a);
|
||||
} else {
|
||||
if (!quiet) {
|
||||
if (errno == ELOOP) {
|
||||
fprintf(stderr, strict ?
|
||||
U_("Error: %s:%d: cycle in %s \"%s\"") :
|
||||
U_("Warning: %s:%d: cycle in %s \"%s\""),
|
||||
file, lineno, alias_type_to_string(type), name);
|
||||
U_("Error: %s:%d:%d: cycle in %s \"%s\"") :
|
||||
U_("Warning: %s:%d:%d: cycle in %s \"%s\""),
|
||||
file, line, column, alias_type_to_string(type), name);
|
||||
} else {
|
||||
fprintf(stderr, strict ?
|
||||
U_("Error: %s:%d: %s \"%s\" referenced but not defined") :
|
||||
U_("Warning: %s:%d: %s \"%s\" referenced but not defined"),
|
||||
file, lineno, alias_type_to_string(type), name);
|
||||
U_("Error: %s:%d:%d: %s \"%s\" referenced but not defined") :
|
||||
U_("Warning: %s:%d:%d: %s \"%s\" referenced but not defined"),
|
||||
file, line, column, alias_type_to_string(type), name);
|
||||
}
|
||||
fputc('\n', stderr);
|
||||
if (strict && errorfile == NULL) {
|
||||
errorfile = rcstr_addref(file);
|
||||
errorlineno = lineno;
|
||||
errorlineno = line;
|
||||
}
|
||||
}
|
||||
errors++;
|
||||
@@ -1133,14 +1135,14 @@ check_aliases(bool strict, bool quiet)
|
||||
TAILQ_FOREACH(m, &us->users, entries) {
|
||||
if (m->type == ALIAS) {
|
||||
errors += check_alias(m->name, USERALIAS,
|
||||
us->file, us->lineno, strict, quiet);
|
||||
us->file, us->line, us->column, strict, quiet);
|
||||
}
|
||||
}
|
||||
TAILQ_FOREACH(priv, &us->privileges, entries) {
|
||||
TAILQ_FOREACH(m, &priv->hostlist, entries) {
|
||||
if (m->type == ALIAS) {
|
||||
errors += check_alias(m->name, HOSTALIAS,
|
||||
us->file, us->lineno, strict, quiet);
|
||||
us->file, us->line, us->column, strict, quiet);
|
||||
}
|
||||
}
|
||||
TAILQ_FOREACH(cs, &priv->cmndlist, entries) {
|
||||
@@ -1148,7 +1150,7 @@ check_aliases(bool strict, bool quiet)
|
||||
TAILQ_FOREACH(m, cs->runasuserlist, entries) {
|
||||
if (m->type == ALIAS) {
|
||||
errors += check_alias(m->name, RUNASALIAS,
|
||||
us->file, us->lineno, strict, quiet);
|
||||
us->file, us->line, us->column, strict, quiet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1156,13 +1158,13 @@ check_aliases(bool strict, bool quiet)
|
||||
TAILQ_FOREACH(m, cs->runasgrouplist, entries) {
|
||||
if (m->type == ALIAS) {
|
||||
errors += check_alias(m->name, RUNASALIAS,
|
||||
us->file, us->lineno, strict, quiet);
|
||||
us->file, us->line, us->column, strict, quiet);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((m = cs->cmnd)->type == ALIAS) {
|
||||
errors += check_alias(m->name, CMNDALIAS,
|
||||
us->file, us->lineno, strict, quiet);
|
||||
us->file, us->line, us->column, strict, quiet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1183,8 +1185,8 @@ check_aliases(bool strict, bool quiet)
|
||||
static int
|
||||
print_unused(struct sudoers_parse_tree *parse_tree, struct alias *a, void *v)
|
||||
{
|
||||
fprintf(stderr, U_("Warning: %s:%d: unused %s \"%s\""),
|
||||
a->file, a->lineno, alias_type_to_string(a->type), a->name);
|
||||
fprintf(stderr, U_("Warning: %s:%d:%d: unused %s \"%s\""),
|
||||
a->file, a->line, a->column, alias_type_to_string(a->type), a->name);
|
||||
fputc('\n', stderr);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user