Navigation


Changeset 162:79768bf7d208 in freeDiameter


Ignore:
Timestamp:
Jan 26, 2010, 1:23:03 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Completed whitelist extension

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • doc/acl_wl.conf.sample

    r161 r162  
    1616# It is specified for example as:
    1717# ALLOW_IPSEC vpn.example.net vpn2.example.net *.vpn.example.net
     18# These flag take effect from their position, until the end of the line.
    1819
  • extensions/acl_wl/CMakeLists.txt

    r161 r162  
    88
    99# List of source files
    10 SET( APP_TEST_SRC
     10SET( ACL_WL_SRC
    1111        acl_wl.h
    1212        acl_wl.c
     
    1818
    1919# Compile as a module
    20 FD_ADD_EXTENSION(acl_wl ${APP_TEST_SRC})
     20FD_ADD_EXTENSION(acl_wl ${ACL_WL_SRC})
  • extensions/acl_wl/acl_wl.c

    r161 r162  
    7171       
    7272        /* Now, if we did not specify any flag, reject */
     73        if (res == 0) {
     74                TRACE_DEBUG(INFO, "Peer '%s' rejected, only TLS-protected connection is whitelisted.", info->pi_diamid);
     75                /* We don't actually set *auth = -1, leave space for a further extension to validate the peer */
     76                return 0;
     77        }
    7378       
    74 
     79        /* Check the Inband-Security-Id value */
     80        res &= info->runtime.pir_isi;
     81        if (res == 0) {
     82                TRACE_DEBUG(INFO, "Peer '%s' rejected, remotely advertised Inband-Security-Id is not compatible with whitelist flags.", info->pi_diamid);
     83                /* We don't actually set *auth = -1, leave space for a further extension to validate the peer */
     84                return 0;
     85        }
     86       
     87        /* Ok, the peer is whitelisted */
     88        *auth = 1;
     89       
     90        /* Now, configure the peer for the authorized mechanism */
     91        if ((res & PI_SEC_NONE) && (res & PI_SEC_TLS_OLD))
     92                res = PI_SEC_NONE; /* If we authorized it, we must have an IPsec tunnel setup, no need for TLS in this case */
     93       
     94        /* Save information about the security mechanism to use after CER/CEA exchange */
     95        info->config.pic_flags.sec = res;
     96        return 0;
    7597}
    7698
     
    79101{
    80102        TRACE_ENTRY("%p", conffile);
    81        
    82103        CHECK_PARAMS(conffile);
    83104       
     
    86107       
    87108        TRACE_DEBUG(INFO, "Extension ACL_wl initialized with configuration: '%s'", conffile);
    88         aw_tree_dump();
     109        if (TRACE_BOOL(ANNOYING)) {
     110                aw_tree_dump();
     111        }
    89112       
    90113        /* Register the validator function */
    91        
     114        CHECK_FCT( fd_peer_validate_register ( aw_validate ) );
     115
    92116        return 0;
    93117}
     
    96120void fd_ext_fini(void)
    97121{
    98         /* Unregister the validator function */
    99 
    100122        /* Destroy the tree */
    101 
     123        aw_tree_destroy();
    102124}
    103125
  • extensions/acl_wl/aw_tree.c

    r161 r162  
    230230                ti = (struct tree_item *)(senti->next);
    231231                if (ti->str == NULL) {
    232                         fd_log_debug("[acl_wl] Warning: entry '%s' is superseeded by a generic entry at level %d, ignoring.\n", name, lbl);
     232                        fd_log_debug("[acl_wl] Warning: entry '%s' is superseeded by a generic entry at label %d, ignoring.\n", name, lbl + 1);
    233233                        return 0;
    234234                }
     
    287287                        ti = (struct tree_item *)(senti->next);
    288288                        if (ti->str == NULL) {
    289                                 fd_log_debug("[acl_wl] Warning: entry '%s' is superseeded by a generic entry at level 0, ignoring.\n", name);
     289                                fd_log_debug("[acl_wl] Warning: entry '%s' is superseeded by a generic entry at label 1, ignoring.\n", name);
    290290                                return 0;
    291291                        }
     
    367367                ti = (struct tree_item *)(senti->next);
    368368                if (ti->str == NULL) {
    369                         TRACE_DEBUG(FULL, "[acl_wl] %s matched at level %d with a generic entry.", name, lbl);
     369                        TRACE_DEBUG(ANNOYING, "[acl_wl] %s matched at label %d with a generic entry.", name, lbl + 1);
    370370                        *result = ti->flags;
    371371                        return 0;
     
    407407                return 0;
    408408       
    409         TRACE_DEBUG(FULL, "[acl_wl] %s matched exactly.", name);
     409        TRACE_DEBUG(ANNOYING, "[acl_wl] %s matched exactly.", name);
    410410        *result = ti->flags;
    411411        return 0;
  • freeDiameter/p_ce.c

    r160 r162  
    782782        }
    783783       
    784         /* Do we send ISI back ? */
     784        /* Do we agree on ISI ? */
    785785        if ( ! fd_cnx_getTLS(peer->p_cnxctx) ) {
    786                 if (peer->p_hdr.info.config.pic_flags.sec & PI_SEC_NONE)
    787                         isi = PI_SEC_NONE; /* Maybe we should also look at peer->p_hdr.info.runtime.pir_isi here ? */
    788                 else
     786                /* In case of responder, the validate callback must have set the config.pic_flags.sec value already */
     787                if (!peer->p_hdr.info.config.pic_flags.sec) {
     788                        /* The peer did not send the Inband-Security-Id AVP, reject */
     789                        TRACE_DEBUG(INFO, "No security mechanism advertised by peer '%s', sending DIAMETER_NO_COMMON_SECURITY", peer->p_hdr.info.pi_diamid);
     790                        ec = "DIAMETER_NO_COMMON_SECURITY";
     791                        fatal = 1;
     792                        goto error_abort;
     793                }
     794               
     795                /* Now, check if we agree on the value IPsec */
     796                if ((peer->p_hdr.info.config.pic_flags.sec & PI_SEC_NONE) && (peer->p_hdr.info.runtime.pir_isi & PI_SEC_NONE)) {
     797                        isi = PI_SEC_NONE;
     798                } else if ((peer->p_hdr.info.config.pic_flags.sec & PI_SEC_TLS_OLD) && (peer->p_hdr.info.runtime.pir_isi & PI_SEC_TLS_OLD)) {
    789799                        isi = PI_SEC_TLS_OLD;
     800                }
     801               
     802                /* If we did not find an agreement */
     803                if (!isi) {
     804                        TRACE_DEBUG(INFO, "No common security mechanism with '%s', sending DIAMETER_NO_COMMON_SECURITY", peer->p_hdr.info.pi_diamid);
     805                        ec = "DIAMETER_NO_COMMON_SECURITY";
     806                        fatal = 1;
     807                        goto error_abort;
     808                }
    790809        }
    791810       
  • include/freeDiameter/freeDiameter.h

    r142 r162  
    303303
    304304/*
    305  * FUNCTION:    peer_validate_register
     305 * FUNCTION:    fd_peer_validate_register
    306306 *
    307307 * PARAMETERS:
     
    342342 * or an error code otherwise. If the error code is received, the connection is closed and the
    343343 * peer is destroyed.
     344 * Note that freeDiameter already achieves some usual checks. The callback may be used to enforce
     345 * additional restrictions.
    344346 *
    345347 * RETURN VALUE:
Note: See TracChangeset for help on using the changeset viewer.