diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2001-03-13 17:56:32 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2001-03-13 17:56:32 +0000 |
commit | 62dd2ca3ab0015cbc9da641a7853828cdef86035 (patch) | |
tree | ba2f3206978456a9753083fa96cf8367776e73dd | |
parent | ad44be95f7a5ef9274c5a84127de4ed475670a94 (diff) |
Somewhere along the line we stopped using the configuration file defaults
properly. Make them work again. (niklas@ ok)
-rw-r--r-- | sbin/isakmpd/conf.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/sbin/isakmpd/conf.c b/sbin/isakmpd/conf.c index 09347b268db..5e23c65dc13 100644 --- a/sbin/isakmpd/conf.c +++ b/sbin/isakmpd/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.28 2001/02/28 08:49:43 angelos Exp $ */ +/* $OpenBSD: conf.c,v 1.29 2001/03/13 17:56:31 ho Exp $ */ /* $EOM: conf.c,v 1.48 2000/12/04 02:04:29 angelos Exp $ */ /* @@ -202,7 +202,7 @@ conf_set_now (char *section, char *tag, char *value, int override, node->is_default = is_default; LIST_INSERT_HEAD (&conf_bindings[conf_hash (section)], node, link); - LOG_DBG ((LOG_MISC, 70, "[%s]:%s->%s", node->section, node->tag, + LOG_DBG ((LOG_MISC, 70, "conf_set: [%s]:%s->%s", node->section, node->tag, node->value)); return 0; } @@ -316,6 +316,25 @@ conf_parse (int trans, char *buf, size_t sz) * XXX No EC2N DH support here yet. */ +/* Find the value for a section+tag in the transaction list */ +char * +conf_get_trans_str (int trans, char *section, char *tag) +{ + struct conf_trans *node, *nf = 0; + + for (node = TAILQ_FIRST (&conf_trans_queue); node; + node = TAILQ_NEXT (node, link)) + if (node->trans == trans && strcmp (section, node->section) == 0 && + strcmp (tag, node->tag) == 0) + { + if (!nf) + nf = node; + else if (node->override) + nf = node; + } + return nf ? nf->value : NULL; +} + int conf_find_trans_xf (int phase, char *xf) { @@ -325,8 +344,8 @@ conf_find_trans_xf (int phase, char *xf) /* Find the relevant transforms and suites, if any. */ for (node = TAILQ_FIRST (&conf_trans_queue); node; node = TAILQ_NEXT (node, link)) - if (( phase == 1 && !strcmp ("Transforms", node->tag)) || - ( phase == 2 && !strcmp ("Suites", node->tag))) + if ((phase == 1 && strcmp ("Transforms", node->tag) == 0) || + (phase == 2 && strcmp ("Suites", node->tag) == 0)) { p = node->value; while ((p = strstr (p, xf)) != NULL) @@ -383,14 +402,14 @@ conf_load_defaults (int tr) 0, 1); #endif - /* Lifetimes. XXX p1/p2 vs main/quick mode may be unclear. */ - dflt = conf_get_str ("General", "Default-phase-1-lifetime"); + /* Lifetimes. XXX p1/p2 vs main/quick mode may be unclear. */ + dflt = conf_get_trans_str (tr, "General", "Default-phase-1-lifetime"); conf_set (tr, CONF_DFLT_TAG_LIFE_MAIN_MODE, "LIFE_TYPE", CONF_DFLT_TYPE_LIFE_MAIN_MODE, 0, 1); conf_set (tr, CONF_DFLT_TAG_LIFE_MAIN_MODE, "LIFE_DURATION", (dflt ? dflt : CONF_DFLT_VAL_LIFE_MAIN_MODE), 0, 1); - dflt = conf_get_str ("General", "Default-phase-2-lifetime"); + dflt = conf_get_trans_str (tr, "General", "Default-phase-2-lifetime"); conf_set (tr, CONF_DFLT_TAG_LIFE_QUICK_MODE, "LIFE_TYPE", CONF_DFLT_TYPE_LIFE_QUICK_MODE, 0, 1); conf_set (tr, CONF_DFLT_TAG_LIFE_QUICK_MODE, "LIFE_DURATION", @@ -412,7 +431,7 @@ conf_load_defaults (int tr) LOG_DBG ((LOG_MISC, 40, "conf_load_defaults : main mode %s", sect)); conf_set (tr, sect, "ENCRYPTION_ALGORITHM", mm_enc[enc], 0, 1); - if (!strcmp (mm_enc[enc], "BLOWFISH_CBC")) + if (strcmp (mm_enc[enc], "BLOWFISH_CBC") == 0) conf_set (tr, sect, "KEY_LENGTH", CONF_DFLT_VAL_BLF_KEYLEN, 0, 1); conf_set (tr, sect, "HASH_ALGORITHM", mm_hash[hash], 0, 1); @@ -430,7 +449,7 @@ conf_load_defaults (int tr) conf_set (tr, "Default-phase-1", "Phase", "1", 0, 1); conf_set (tr, "Default-phase-1", "Configuration", "Default-phase-1-configuration", 0, 1); - dflt = conf_get_str ("General", "Default-phase-1-ID"); + dflt = conf_get_trans_str (tr, "General", "Default-phase-1-ID"); if (dflt) conf_set (tr, "Default-phase-1", "ID", dflt, 0, 1); @@ -445,8 +464,7 @@ conf_load_defaults (int tr) for (mode = 0; mode < 2; mode ++) for (pfs = 0; pfs < 2; pfs ++) for (hash = 0; qm_hash[hash]; hash ++) - if ((proto == 1 && /* AH */ - !strcmp (qm_hash[hash], "NONE"))) + if ((proto == 1 && strcmp (qm_hash[hash], "NONE") == 0)) /* AH */ continue; else { @@ -479,7 +497,7 @@ conf_load_defaults (int tr) conf_set (tr, sect, "TRANSFORM_ID", qm_enc[enc], 0, 1); - if (!strcmp (qm_enc[enc], "BLOWFISH")) + if (strcmp (qm_enc[enc], "BLOWFISH") == 0) conf_set (tr, sect, "KEY_LENGTH", CONF_DFLT_VAL_BLF_KEYLEN, 0, 1); @@ -754,7 +772,7 @@ conf_decode_base64 (u_int8_t *out, u_int32_t *len, u_char *buf) if (c2 & 0xF) return 0; - if (!strcmp (buf, "==")) + if (strcmp (buf, "==") == 0) buf++; else return 0; |