diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2010-06-02 11:51:53 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2010-06-02 11:52:17 +0200 |
commit | c77f4b305e33116756478f42ca80a6b50ef6e253 (patch) | |
tree | f6dfe2965ade3f9fc65afc2f3d60527d429f2f07 /src/libhydra/plugins/attr_sql | |
parent | 2f57e6da0e83a3e64e36dd2559b2579b9b1e32a2 (diff) | |
download | strongswan-c77f4b305e33116756478f42ca80a6b50ef6e253.tar.bz2 strongswan-c77f4b305e33116756478f42ca80a6b50ef6e253.tar.xz |
fixed configuration attribute type determination
Diffstat (limited to 'src/libhydra/plugins/attr_sql')
-rw-r--r-- | src/libhydra/plugins/attr_sql/pool_attributes.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/libhydra/plugins/attr_sql/pool_attributes.c b/src/libhydra/plugins/attr_sql/pool_attributes.c index 51e0a97c6..d59ca67d0 100644 --- a/src/libhydra/plugins/attr_sql/pool_attributes.c +++ b/src/libhydra/plugins/attr_sql/pool_attributes.c @@ -46,14 +46,14 @@ struct attr_info_t { }; static const attr_info_t attr_info[] = { - { "internal_ip4_dns", VALUE_ADDR, INTERNAL_IP4_DNS, 0 }, - { "internal_ip6_dns", VALUE_ADDR, INTERNAL_IP6_DNS, 0 }, - { "dns", VALUE_ADDR, INTERNAL_IP4_DNS, - INTERNAL_IP6_DNS }, { "internal_ip4_netmask", VALUE_ADDR, INTERNAL_IP4_NETMASK, 0 }, { "internal_ip6_netmask", VALUE_ADDR, INTERNAL_IP6_NETMASK, 0 }, { "netmask", VALUE_ADDR, INTERNAL_IP4_NETMASK, INTERNAL_IP6_NETMASK }, + { "internal_ip4_dns", VALUE_ADDR, INTERNAL_IP4_DNS, 0 }, + { "internal_ip6_dns", VALUE_ADDR, INTERNAL_IP6_DNS, 0 }, + { "dns", VALUE_ADDR, INTERNAL_IP4_DNS, + INTERNAL_IP6_DNS }, { "internal_ip4_nbns", VALUE_ADDR, INTERNAL_IP4_NBNS, 0 }, { "internal_ip6_nbns", VALUE_ADDR, INTERNAL_IP6_NBNS, 0 }, { "nbns", VALUE_ADDR, INTERNAL_IP4_NBNS, @@ -172,13 +172,15 @@ static bool parse_attributes(char *name, char *value, value_type_t *value_type, { if (strcaseeq(name, attr_info[i].keyword)) { + *type = attr_info[i].type; + *type_ip6 = attr_info[i].type_ip6; + if (*value_type == VALUE_NONE) { *value_type = attr_info[i].value_type; - *type = attr_info[i].type; - *type_ip6 = attr_info[i].type_ip6; return TRUE; } + if (*value_type != attr_info[i].value_type && *value_type != VALUE_HEX) { @@ -206,27 +208,24 @@ static bool parse_attributes(char *name, char *value, value_type_t *value_type, free(blob->ptr); return FALSE; } + if (*value_type == VALUE_ADDR) { *type = (addr->get_family(addr) == AF_INET) ? attr_info[i].type : attr_info[i].type_ip6; addr->destroy(addr); } - if (*value_type == VALUE_HEX) + else if (*value_type == VALUE_HEX) { *value_type = attr_info[i].value_type; if (*value_type == VALUE_ADDR) { - if (blob->len == 4) - { - *type = attr_info[i].type; - } - else if (blob->len == 16) + if (blob->len == 16) { *type = attr_info[i].type_ip6; } - else + else if (blob->len != 4) { fprintf(stderr, "the %s attribute requires " "a valid IP address.\n", name); @@ -234,14 +233,6 @@ static bool parse_attributes(char *name, char *value, value_type_t *value_type, return FALSE; } } - else - { - *type = attr_info[i].type; - } - } - else - { - *type = attr_info[i].type; } return TRUE; } @@ -291,6 +282,7 @@ void add_attr(char *name, char *value, value_type_t value_type) { exit(EXIT_FAILURE); } + success = db->execute(db, NULL, "INSERT INTO attributes (type, value) VALUES (?, ?)", DB_INT, type, DB_BLOB, blob) == 1; @@ -324,6 +316,7 @@ void del_attr(char *name, char *value, value_type_t value_type) { exit(EXIT_FAILURE); } + if (blob.len > 0) { query = db->query(db, @@ -442,7 +435,7 @@ void del_attr(char *name, char *value, value_type_t value_type) } else { - fprintf(stderr, "the %s attribute (%N) with value '%*.s' " + fprintf(stderr, "the %s attribute (%N) with value '%.*s' " "was not found.\n", name, configuration_attribute_type_names, type, blob.len, blob.ptr); |