]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Autoload rlm_cram attributes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 1 Apr 2018 18:43:56 +0000 (19:43 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 1 Apr 2018 18:43:56 +0000 (19:43 +0100)
share/dictionary
share/dictionary.sandy [new file with mode: 0644]
src/modules/rlm_cram/rlm_cram.c

index febc1d5a9748540763142b3ddf01f3bb3d809f5d..b9bde60d86ae366b57de50ea16245455befa9e8e 100644 (file)
@@ -256,6 +256,7 @@ $INCLUDE dictionary.riverstone
 $INCLUDE dictionary.roaringpenguin
 $INCLUDE dictionary.ruggedcom
 $INCLUDE dictionary.ruckus
+$INCLUDE dictionary.sandy
 $INCLUDE dictionary.sangoma
 $INCLUDE dictionary.shasta
 $INCLUDE dictionary.sg
diff --git a/share/dictionary.sandy b/share/dictionary.sandy
new file mode 100644 (file)
index 0000000..ff37d88
--- /dev/null
@@ -0,0 +1,54 @@
+#
+#      The SANDY Vendor-Specific dictionary.
+#
+# Version:     $Id$
+#
+#      For a complete list of Private Enterprise Codes, see:
+#
+#      http://www.isi.edu/in-notes/iana/assignments/enterprise-numbers
+#
+
+VENDOR         Sandy           11406
+
+BEGIN-VENDOR Sandy
+
+ATTRIBUTE      Sandy-User-Id           1       integer
+ATTRIBUTE      Sandy-Group-Id          2       integer
+ATTRIBUTE      Sandy-GECOS             3       string
+ATTRIBUTE      Sandy-Shell             4       string
+ATTRIBUTE      Sandy-Home              5       string
+
+ATTRIBUTE      Sandy-Mail-Service      100     integer
+ATTRIBUTE      Sandy-Mail-Authtype     101     integer
+ATTRIBUTE      Sandy-Mail-Challenge    102     string
+ATTRIBUTE      Sandy-Mail-Response     103     octets
+ATTRIBUTE      Sandy-Mail-Address      104     string
+ATTRIBUTE      Sandy-Mail-Spamcontrol  105     integer
+ATTRIBUTE      Sandy-Mail-Notification 106     octets
+ATTRIBUTE      Sandy-Mail-Box          107     string
+ATTRIBUTE      Sandy-Mail-Quota        108     integer
+ATTRIBUTE      Sandy-Mail-Filter       109     octets
+ATTRIBUTE      Sandy-Mail-Box-Control  110     integer
+ATTRIBUTE      Sandy-Mail-Client-IP    111     ipaddr
+ATTRIBUTE      Sandy-Mail-Client-Helo  110     string
+
+
+VALUE  Sandy-Mail-Service              Transfer        1
+VALUE  Sandy-Mail-Service              Delivery        2
+VALUE  Sandy-Mail-Service              POP             3
+VALUE  Sandy-Mail-Service              IMAP            4
+VALUE  Sandy-Mail-Service              WEBMAIL         5
+VALUE  Sandy-Mail-Service              Control         6
+
+VALUE  Sandy-Mail-Authtype     NONE            0
+VALUE  Sandy-Mail-Authtype     PLAIN           1
+VALUE  Sandy-Mail-Authtype     CRAM-MD5        2
+VALUE  Sandy-Mail-Authtype     APOP            3
+VALUE  Sandy-Mail-Authtype     KRB4            4
+VALUE  Sandy-Mail-Authtype     KRB5            5
+VALUE  Sandy-Mail-Authtype     NTLM            6
+VALUE  Sandy-Mail-Authtype     NTLM2           7
+VALUE  Sandy-Mail-Authtype     CRAM-MD4        8
+VALUE  Sandy-Mail-Authtype     CRAM-SHA1       9
+
+END-VENDOR Sandy
\ No newline at end of file
index 41622dfea6ec8c435b7eefe52bcc2191c43171bf..e24cd3bd92b54826768c253ae3117fcc4f942481 100644 (file)
@@ -44,10 +44,32 @@ RCSID("$Id$")
 
 #include <ctype.h>
 
-#define VENDORPEC_SM  11406
-#define        SM_AUTHTYPE     101
-#define        SM_CHALLENGE    102
-#define        SM_RESPONSE     103
+static fr_dict_t const *dict_freeradius;
+static fr_dict_t const *dict_radius;
+
+static fr_dict_attr_t const *attr_cleartext_password;
+
+static fr_dict_attr_t const *attr_sandy_mail_authtype;
+static fr_dict_attr_t const *attr_sandy_mail_challenge;
+static fr_dict_attr_t const *attr_sandy_mail_response;
+
+extern fr_dict_attr_autoload_t rlm_cram_dict_attr[];
+fr_dict_attr_autoload_t rlm_cram_dict_attr[] = {
+       { .out = &attr_cleartext_password, .name = "Cleartext-Password", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
+
+       { .out = &attr_sandy_mail_authtype, .name = "Sandy-Mail-Authtype", .type = FR_TYPE_UINT32, .dict = &dict_radius },
+       { .out = &attr_sandy_mail_challenge, .name = "Sandy-Mail-Challenge", .type = FR_TYPE_STRING, .dict = &dict_radius },
+       { .out = &attr_sandy_mail_response, .name = "Sandy-Mail-Response", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+
+       { NULL }
+};
+
+extern fr_dict_autoload_t rlm_cram_dict[];
+fr_dict_autoload_t rlm_cram_dict[] = {
+       { .out = &dict_freeradius, .proto = "freeradius" },
+       { .out = &dict_radius, .proto = "radius" },
+       { NULL }
+};
 
 static void calc_apop_digest(uint8_t *buffer, uint8_t const *challenge,
                             size_t challen, char const *password)
@@ -128,25 +150,25 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(UNUSED void *instance, UNUS
        VALUE_PAIR *authtype, *challenge, *response, *password;
 
 
-       password = fr_pair_find_by_num(request->control, 0, FR_CLEARTEXT_PASSWORD, TAG_ANY);
+       password = fr_pair_find_by_da(request->control, attr_cleartext_password, TAG_ANY);
        if (!password) {
                REDEBUG("&Cleartext-Password is required for authentication");
                return RLM_MODULE_INVALID;
        }
-       authtype = fr_pair_find_by_num(request->packet->vps, VENDORPEC_SM, SM_AUTHTYPE, TAG_ANY);
 
+       authtype = fr_pair_find_by_da(request->packet->vps, attr_sandy_mail_authtype, TAG_ANY);
        if (!authtype) {
                REDEBUG("Required attribute &Sandy-Mail-Authtype missing");
                return RLM_MODULE_INVALID;
        }
-       challenge = fr_pair_find_by_num(request->packet->vps, VENDORPEC_SM, SM_CHALLENGE, TAG_ANY);
 
+       challenge = fr_pair_find_by_da(request->packet->vps, attr_sandy_mail_challenge, TAG_ANY);
        if (!challenge) {
                REDEBUG("Required attribute &Sandy-Mail-Challenge missing");
                return RLM_MODULE_INVALID;
        }
-       response = fr_pair_find_by_num(request->packet->vps, VENDORPEC_SM, SM_RESPONSE, TAG_ANY);
 
+       response = fr_pair_find_by_da(request->packet->vps, attr_sandy_mail_response, TAG_ANY);
        if (!response) {
                REDEBUG("Required attribute &Sandy-Mail-Response missing");
                return RLM_MODULE_INVALID;