mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-03 07:45:47 +00:00
Don't use int where we really mean enum def_tuple. When this code
was written it was assumed that we may have multiple tuple types. However, that hasn't happened and probably never will.
This commit is contained in:
@@ -172,7 +172,7 @@ dump_defaults(void)
|
||||
break;
|
||||
case T_TUPLE:
|
||||
for (def = cur->values; def->sval; def++) {
|
||||
if (cur->sd_un.ival == def->ival) {
|
||||
if (cur->sd_un.tuple == def->nval) {
|
||||
sudo_printf(SUDO_CONV_INFO_MSG, desc, def->sval);
|
||||
break;
|
||||
}
|
||||
@@ -672,18 +672,16 @@ store_tuple(char *val, struct sudo_defs_types *def, int op)
|
||||
debug_decl(store_tuple, SUDO_DEBUG_DEFAULTS)
|
||||
|
||||
/*
|
||||
* Since enums are really just ints we store the value as an ival.
|
||||
* In the future, there may be multiple enums for different tuple
|
||||
* types we want to avoid and special knowledge of the tuple type.
|
||||
* This does assume that the first entry in the tuple enum will
|
||||
* be the equivalent to a boolean "false".
|
||||
* Look up tuple value by name to find enum def_tuple value.
|
||||
* For negation to work the first element of enum def_tuple
|
||||
* must be equivalent to boolean false.
|
||||
*/
|
||||
if (!val) {
|
||||
def->sd_un.ival = (op == false) ? 0 : 1;
|
||||
} else {
|
||||
for (v = def->values; v->sval != NULL; v++) {
|
||||
if (strcmp(v->sval, val) == 0) {
|
||||
def->sd_un.ival = v->ival;
|
||||
def->sd_un.tuple = v->nval;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -31,17 +31,18 @@ struct list_member {
|
||||
|
||||
SLIST_HEAD(list_members, list_member);
|
||||
|
||||
struct def_values {
|
||||
char *sval; /* string value */
|
||||
int ival; /* actually an enum */
|
||||
};
|
||||
|
||||
enum list_ops {
|
||||
add,
|
||||
delete,
|
||||
freeall
|
||||
};
|
||||
|
||||
/* Mapping of tuple string value to enum def_tuple. */
|
||||
struct def_values {
|
||||
char *sval; /* string value */
|
||||
enum def_tuple nval;/* numeric value */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure describing compile-time and run-time options.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user