From: Arran Cudbard-Bell Date: Mon, 10 Dec 2012 19:02:23 +0000 (+0000) Subject: Add increment operator for LDAP X-Git-Tag: release_3_0_0_beta1~1392 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e421de584dd2819e093715e17cfc2526be3e48e;p=thirdparty%2Ffreeradius-server.git Add increment operator for LDAP --- diff --git a/raddb/mods-available/ldap b/raddb/mods-available/ldap index ca2772ba908..74abddec77d 100644 --- a/raddb/mods-available/ldap +++ b/raddb/mods-available/ldap @@ -126,7 +126,8 @@ ldap { # # Where: # : The LDAP attribute to add modify or delete. - # : One of the assignment operators (:=, +=, -=). + # : One of the assignment operators + # (:=, +=, -=, ++). # Note: '=' is *not* supported. # : The value to add modify or delete. # diff --git a/src/include/token.h b/src/include/token.h index b6097430e9e..f7d81f4a3de 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -41,24 +41,25 @@ typedef enum fr_token_t { T_COMMA, /* , */ T_SEMICOLON, /* ; */ + T_OP_INCRM, /* ++ */ T_OP_ADD, /* += */ - T_OP_SUB, /* -= */ - T_OP_SET, /* := 10 */ + T_OP_SUB, /* -= 10 */ + T_OP_SET, /* := */ T_OP_EQ, /* = */ T_OP_NE, /* != */ T_OP_GE, /* >= */ - T_OP_GT, /* > */ - T_OP_LE, /* <= 15 */ + T_OP_GT, /* > 15 */ + T_OP_LE, /* <= */ T_OP_LT, /* < */ T_OP_REG_EQ, /* =~ */ T_OP_REG_NE, /* !~ */ - T_OP_CMP_TRUE, /* =* */ - T_OP_CMP_FALSE, /* !* 20 */ + T_OP_CMP_TRUE, /* =* 20 */ + T_OP_CMP_FALSE, /* !* */ T_OP_CMP_EQ, /* == */ T_HASH, /* # */ T_BARE_WORD, /* bare word */ - T_DOUBLE_QUOTED_STRING, /* "foo" */ - T_SINGLE_QUOTED_STRING, /* 'foo' 25 */ + T_DOUBLE_QUOTED_STRING, /* "foo" 25 */ + T_SINGLE_QUOTED_STRING, /* 'foo' */ T_BACK_QUOTED_STRING, /* `foo` */ T_TOKEN_LAST } FR_TOKEN; diff --git a/src/lib/token.c b/src/lib/token.c index 14355e92723..63333471842 100644 --- a/src/lib/token.c +++ b/src/lib/token.c @@ -37,6 +37,7 @@ const FR_NAME_NUMBER fr_tokens[] = { { "(", T_LBRACE, }, { ")", T_RBRACE, }, { ",", T_COMMA, }, + { "++", T_OP_INCRM, }, { "+=", T_OP_ADD, }, { "-=", T_OP_SUB, }, { ":=", T_OP_SET, }, diff --git a/src/main/conffile.c b/src/main/conffile.c index b7f2f17ffd7..219d95ad7ac 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -1703,6 +1703,7 @@ static int cf_section_read(const char *filename, int *lineno, FILE *fp, value = NULL; goto do_set; + case T_OP_INCRM: case T_OP_ADD: case T_OP_CMP_EQ: case T_OP_SUB: diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index b063e3e26a4..abed6dc4d24 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -2266,7 +2266,7 @@ static int user_modify(ldap_instance *inst, REQUEST *request, * Now we know the value is ok, copy the pointers into * the ldapmod struct. */ - memcpy(&(mod_s[total].mod_type), &(attr), + memcpy(&(mod_s[total].mod_type), &(attr), sizeof(mod_s[total].mod_type)); op = cf_pair_operator(cp); @@ -2285,6 +2285,11 @@ static int user_modify(ldap_instance *inst, REQUEST *request, case T_OP_SUB: mod_s[total].mod_op = LDAP_MOD_DELETE; break; +#ifdef LDAP_MOD_INCREMENT + case T_OP_INCRM: + mod_s[total].mod_op = LDAP_MOD_INCREMENT; + break; +#endif default: radlog(L_ERR, "rlm_ldap (%s): Operator '%s' " "is not supported for LDAP modify "