mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-02 07:15:27 +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;
|
break;
|
||||||
case T_TUPLE:
|
case T_TUPLE:
|
||||||
for (def = cur->values; def->sval; def++) {
|
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);
|
sudo_printf(SUDO_CONV_INFO_MSG, desc, def->sval);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -672,18 +672,16 @@ store_tuple(char *val, struct sudo_defs_types *def, int op)
|
|||||||
debug_decl(store_tuple, SUDO_DEBUG_DEFAULTS)
|
debug_decl(store_tuple, SUDO_DEBUG_DEFAULTS)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since enums are really just ints we store the value as an ival.
|
* Look up tuple value by name to find enum def_tuple value.
|
||||||
* In the future, there may be multiple enums for different tuple
|
* For negation to work the first element of enum def_tuple
|
||||||
* types we want to avoid and special knowledge of the tuple type.
|
* must be equivalent to boolean false.
|
||||||
* This does assume that the first entry in the tuple enum will
|
|
||||||
* be the equivalent to a boolean "false".
|
|
||||||
*/
|
*/
|
||||||
if (!val) {
|
if (!val) {
|
||||||
def->sd_un.ival = (op == false) ? 0 : 1;
|
def->sd_un.ival = (op == false) ? 0 : 1;
|
||||||
} else {
|
} else {
|
||||||
for (v = def->values; v->sval != NULL; v++) {
|
for (v = def->values; v->sval != NULL; v++) {
|
||||||
if (strcmp(v->sval, val) == 0) {
|
if (strcmp(v->sval, val) == 0) {
|
||||||
def->sd_un.ival = v->ival;
|
def->sd_un.tuple = v->nval;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,17 +31,18 @@ struct list_member {
|
|||||||
|
|
||||||
SLIST_HEAD(list_members, list_member);
|
SLIST_HEAD(list_members, list_member);
|
||||||
|
|
||||||
struct def_values {
|
|
||||||
char *sval; /* string value */
|
|
||||||
int ival; /* actually an enum */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum list_ops {
|
enum list_ops {
|
||||||
add,
|
add,
|
||||||
delete,
|
delete,
|
||||||
freeall
|
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.
|
* Structure describing compile-time and run-time options.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user