ifupdown: normalize keys using - or _ (debian #609831)

This commit is contained in:
Michael Biebl 2011-03-07 09:57:05 -06:00 committed by Dan Williams
parent 96044f7d94
commit f2f406b316
2 changed files with 7 additions and 1 deletions

View file

@ -51,6 +51,7 @@ void add_block(const char *type, const char* name)
void add_data(const char *key,const char *data)
{
if_data *ret;
char *idx;
// Check if there is a block where we can attach our data
if (first == NULL)
@ -58,6 +59,11 @@ void add_data(const char *key,const char *data)
ret = (if_data*) calloc(1,sizeof(struct _if_data));
ret->key = g_strdup(key);
// Normalize keys. Convert '_' to '-', as ifupdown accepts both variants.
// When querying keys via ifparser_getkey(), use '-'.
while ((idx = strrchr(ret->key, '_'))) {
*idx = '-';
}
ret->data = g_strdup(data);
if (last->info == NULL)

View file

@ -366,7 +366,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
/* Bridge configuration */
if(!strncmp ("br", block->name, 2)) {
/* Try to find bridge ports */
const char *ports = ifparser_getkey (block, "bridge_ports");
const char *ports = ifparser_getkey (block, "bridge-ports");
if (ports) {
int i;
int state = 0;