perl -i -npe "s/[ \t]+$//g" `find src -name "*.[ch]" -print`
authoraland <aland>
Thu, 26 Feb 2004 19:04:19 +0000 (19:04 +0000)
committeraland <aland>
Thu, 26 Feb 2004 19:04:19 +0000 (19:04 +0000)
Whitespace changes only, from a fresh checkout.

For bug # 13

152 files changed:
src/include/conffile.h
src/include/modcall.h
src/include/modpriv.h
src/include/radius.h
src/include/radius_snmp.h
src/include/smux.h
src/include/token.h
src/lib/crypt.c
src/lib/dict.c
src/lib/filters.c
src/lib/hmac.c
src/lib/hmacsha1.c
src/lib/isaac.c
src/lib/misc.c
src/lib/missing.c
src/lib/print.c
src/lib/radius.c
src/lib/rbtree.c
src/lib/sha1.c
src/lib/smbdes.c
src/lib/snprintf.c
src/lib/udpfromto.c
src/lib/valuepair.c
src/main/acct.c
src/main/auth.c
src/main/client.c
src/main/conffile.c
src/main/exec.c
src/main/files.c
src/main/log.c
src/main/mainconfig.c
src/main/modcall.c
src/main/modules.c
src/main/nas.c
src/main/proxy.c
src/main/radclient.c
src/main/radius_snmp.c
src/main/radiusd.c
src/main/radrelay.c
src/main/radwho.c
src/main/radzap.c
src/main/request_list.c
src/main/smux.c
src/main/threads.c
src/main/timestr.c
src/main/util.c
src/main/valuepair.c
src/main/xlat.c
src/modules/rlm_acct_unique/rlm_acct_unique.c
src/modules/rlm_always/rlm_always.c
src/modules/rlm_attr_filter/rlm_attr_filter.c
src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c
src/modules/rlm_chap/rlm_chap.c
src/modules/rlm_checkval/rlm_checkval.c
src/modules/rlm_counter/rlm_counter.c
src/modules/rlm_cram/rlm_cram.c
src/modules/rlm_dbm/rlm_dbm.c
src/modules/rlm_dbm/rlm_dbm_cat.c
src/modules/rlm_dbm/rlm_dbm_parser.c
src/modules/rlm_detail/rlm_detail.c
src/modules/rlm_digest/rlm_digest.c
src/modules/rlm_eap/eap.c
src/modules/rlm_eap/eap.h
src/modules/rlm_eap/libeap/eap_sim.h
src/modules/rlm_eap/libeap/eapcommon.c
src/modules/rlm_eap/libeap/eapcrypto.c
src/modules/rlm_eap/libeap/eapsimlib.c
src/modules/rlm_eap/libeap/fips186prf.c
src/modules/rlm_eap/mem.c
src/modules/rlm_eap/radeapclient.c
src/modules/rlm_eap/rlm_eap.c
src/modules/rlm_eap/state.c
src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c
src/modules/rlm_eap/types/rlm_eap_leap/eap_leap.c
src/modules/rlm_eap/types/rlm_eap_leap/eap_leap.h
src/modules/rlm_eap/types/rlm_eap_leap/rlm_eap_leap.c
src/modules/rlm_eap/types/rlm_eap_md5/eap_md5.c
src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c
src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c
src/modules/rlm_eap/types/rlm_eap_peap/eap_peap.h
src/modules/rlm_eap/types/rlm_eap_peap/peap.c
src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c
src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c
src/modules/rlm_eap/types/rlm_eap_tls/cb.c
src/modules/rlm_eap/types/rlm_eap_tls/eap_tls.c
src/modules/rlm_eap/types/rlm_eap_tls/eap_tls.h
src/modules/rlm_eap/types/rlm_eap_tls/mppe_keys.c
src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c
src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.h
src/modules/rlm_eap/types/rlm_eap_tls/tls.c
src/modules/rlm_eap/types/rlm_eap_ttls/eap_ttls.h
src/modules/rlm_eap/types/rlm_eap_ttls/rlm_eap_ttls.c
src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c
src/modules/rlm_example/other.c
src/modules/rlm_example/rlm_example.c
src/modules/rlm_exec/rlm_exec.c
src/modules/rlm_expr/rlm_expr.c
src/modules/rlm_fastusers/rlm_fastusers.c
src/modules/rlm_files/rlm_files.c
src/modules/rlm_ippool/rlm_ippool.c
src/modules/rlm_ippool/rlm_ippool_tool.c
src/modules/rlm_krb5/rlm_krb5.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_mschap/smbencrypt.c
src/modules/rlm_ns_mta_md5/rlm_ns_mta_md5.c
src/modules/rlm_pam/rlm_pam.c
src/modules/rlm_pap/rlm_pap.c
src/modules/rlm_passwd/rlm_passwd.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_preprocess/rlm_preprocess.c
src/modules/rlm_python/rlm_python.c
src/modules/rlm_radutmp/rlm_radutmp.c
src/modules/rlm_realm/rlm_realm.c
src/modules/rlm_sim_files/rlm_sim_files.c
src/modules/rlm_smb/byteorder.h
src/modules/rlm_smb/rfcnb-common.h
src/modules/rlm_smb/rfcnb-error.h
src/modules/rlm_smb/rfcnb-io.c
src/modules/rlm_smb/rfcnb-io.h
src/modules/rlm_smb/rfcnb-priv.h
src/modules/rlm_smb/rfcnb-util.c
src/modules/rlm_smb/rfcnb-util.h
src/modules/rlm_smb/rfcnb.h
src/modules/rlm_smb/rlm_smb.c
src/modules/rlm_smb/session.c
src/modules/rlm_smb/smbdes.c
src/modules/rlm_smb/smbencrypt.c
src/modules/rlm_smb/smblib-common.h
src/modules/rlm_smb/smblib-priv.h
src/modules/rlm_smb/smblib-util.c
src/modules/rlm_smb/smblib.c
src/modules/rlm_smb/smblib.h
src/modules/rlm_smb/std-includes.h
src/modules/rlm_smb/valid.c
src/modules/rlm_sql/drivers/rlm_sql_db2/sql_db2.c
src/modules/rlm_sql/drivers/rlm_sql_iodbc/sql_iodbc.c
src/modules/rlm_sql/drivers/rlm_sql_oracle/sql_oracle.c
src/modules/rlm_sql/drivers/rlm_sql_postgresql/sql_postgresql.c
src/modules/rlm_sql/drivers/rlm_sql_sybase/sql_sybase.c
src/modules/rlm_sql/drivers/rlm_sql_unixodbc/sql_unixodbc.c
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sql/sql.c
src/modules/rlm_sqlcounter/rlm_sqlcounter.c
src/modules/rlm_unix/cache.c
src/modules/rlm_unix/cache.h
src/modules/rlm_unix/compat.c
src/modules/rlm_unix/compat.h
src/modules/rlm_unix/rlm_unix.c
src/modules/rlm_x99_token/crcalc.c
src/modules/rlm_x99_token/x99_rlm.c
src/modules/rlm_x99_token/x99_util.c

index 970ffdb..dd2548c 100644 (file)
@@ -47,10 +47,10 @@ void                cf_pair_free(CONF_PAIR **cp);
 void           cf_section_free(CONF_SECTION **cp);
 int            cf_section_parse(CONF_SECTION *cs, void *base, const CONF_PARSER *variables);
 
-CONF_SECTION *conf_read(const char *fromfile, int fromline, 
+CONF_SECTION *conf_read(const char *fromfile, int fromline,
                        const char *conffile, CONF_SECTION *parent);
 
-               
+
 CONF_PAIR      *cf_pair_find(CONF_SECTION *section, const char *name);
 CONF_PAIR      *cf_pair_find_next(CONF_SECTION *section, CONF_PAIR *pair, const char *name);
 CONF_SECTION   *cf_section_find(const char *name);
index 88ddb89..adb472f 100644 (file)
@@ -1,7 +1,7 @@
 /* modcall.h: the outside interface to the module-calling tree. Includes
  * functions to build the tree from the config file, and to call it by
  * feeding it REQUESTs.
- * 
+ *
  * Version: $Id$ */
 
 #include "conffile.h" /* Need CONF_* definitions */
index 4780e3d..0aef7ff 100644 (file)
@@ -18,7 +18,7 @@ typedef struct module_list_t {
 
 /*
  *     Per-instance data structure, to correlate the modules
- *     with the instance names (may NOT be the module names!), 
+ *     with the instance names (may NOT be the module names!),
  *     and the per-instance data structures.
  */
 typedef struct module_instance_t {
index 8ecc5a5..0f938d9 100644 (file)
 #define PW_NAS_PROMPT_USER             7
 #define PW_AUTHENTICATE_ONLY           8
 #define PW_CALLBACK_NAS_PROMPT         9
-             
+
 /*     Framed Protocols        */
 
 #define        PW_PPP                          1
index 1955b04..0be5578 100644 (file)
@@ -96,7 +96,7 @@ extern rad_snmp_t     rad_snmp;
 
 
 #else
-#define  RAD_SNMP_INC(_x) 
+#define  RAD_SNMP_INC(_x)
 #define RAD_SNMP_FD_INC(_fd, _x)
 
 #endif /* WITH_SNMP */
index 913ad8b..5e0c04c 100644 (file)
@@ -5,7 +5,7 @@
  * You should have received a copy of the GNU General Public License
  * along with GNU Zebra; see the file COPYING.  If not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.  
+ * 02111-1307, USA.
  */
 
 #ifndef _SMUX_H
@@ -128,7 +128,7 @@ void smux_init(oid [], size_t);
 void smux_start(void);
 void smux_stop(void);
 void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t);
-int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *, 
+int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *,
     WriteMethod **);
 int smux_open(void);
 int smux_str2oid (char *str, oid *my_oid, size_t *oid_len);
index a678d47..1cda314 100644 (file)
@@ -32,7 +32,7 @@ typedef enum lrad_token_t {
   T_RBRACE,                    /* ) */
   T_COMMA,                     /* , */
   T_SEMICOLON,                 /* ; */
-  
+
   T_OP_ADD,                    /* += */
   T_OP_SUB,                    /* -= */
   T_OP_SET,                    /* := */
index 9ba43cd..a40ff5e 100644 (file)
@@ -44,7 +44,7 @@ int lrad_crypt_check(const char *key, const char *crypted)
 {
        char *passwd;
        int cmp = 0;
-       
+
 #ifdef HAVE_PTHREAD_H
        /*
         *      Ensure we're thread-safe, as crypt() isn't.
@@ -53,10 +53,10 @@ int lrad_crypt_check(const char *key, const char *crypted)
                pthread_mutex_init(&lrad_crypt_mutex, NULL);
                lrad_crypt_init = 1;
        }
-       
+
        pthread_mutex_lock(&lrad_crypt_mutex);
 #endif
-       
+
        passwd = crypt(key, crypted);
 
        /*
@@ -67,11 +67,11 @@ int lrad_crypt_check(const char *key, const char *crypted)
        if (passwd) {
                cmp = strcmp(crypted, passwd);
        }
-       
+
 #ifdef HAVE_PTHREAD_H
        pthread_mutex_unlock(&lrad_crypt_mutex);
 #endif
-       
+
        /*
         *      Error.
         */
index 470fff3..5c8a27c 100644 (file)
@@ -269,7 +269,7 @@ int dict_addvalue(const char *namestr, char *attrstr, int value)
                rbtree_insert(values_fixup, dval);
                return 0;
        }
-       
+
        /*
         *      Add the value into the dictionary.
         */
@@ -348,7 +348,7 @@ static int process_attribute(const char* fn, const int line,
                         flags.has_tag = 1;
                }
                else if (strncmp(s, "len+=", 5) == 0 ||
-                        strncmp(s, "len-=", 5) == 0) { 
+                        strncmp(s, "len-=", 5) == 0) {
                          /* Length difference, to accomodate
                             braindead NASes & their vendors */
                          flags.len_disp = strtol(s + 5, &c, 0);
@@ -365,7 +365,7 @@ static int process_attribute(const char* fn, const int line,
                          /* Encryption method, defaults to 0 (none).
                             Currently valid is just type 2,
                             Tunnel-Password style, which can only
-                            be applied to strings. */    
+                            be applied to strings. */
                          flags.encrypt = strtol(s + 8, &c, 0);
                          if (*c) {
                                librad_log( "dict_init: %s[%d] invalid option %s",
@@ -377,9 +377,9 @@ static int process_attribute(const char* fn, const int line,
                          /* Must be a vendor 'flag'... */
                          if (strncmp(s, "vendor=", 5) == 0) {
                                /* New format */
-                               s += 5;   
+                               s += 5;
                          }
-        
+
                          vendor = dict_vendorbyname(s);
                          if (!vendor) {
                                librad_log( "dict_init: %s[%d]: unknown vendor %s",
@@ -443,7 +443,7 @@ static int process_value(const char* fn, const int line, const char* data)
                sscanf(valstr, "%i", &value);
 
        if (dict_addvalue(namestr, attrstr, value) < 0) {
-               librad_log("dict_init: %s[%d]: %s", 
+               librad_log("dict_init: %s[%d]: %s",
                           fn, line, librad_errstr);
                return -1;
        }
@@ -689,7 +689,7 @@ static int attrname_cmp(const void *a, const void *b)
  */
 static int attrvalue_cmp(const void *a, const void *b)
 {
-       return (((const DICT_ATTR *)a)->attr - 
+       return (((const DICT_ATTR *)a)->attr -
                ((const DICT_ATTR *)b)->attr);
 }
 
@@ -700,7 +700,7 @@ static int attrvalue_cmp(const void *a, const void *b)
 static int valuename_cmp(const void *a, const void *b)
 {
        int rcode;
-       rcode = (((const DICT_VALUE *)a)->attr - 
+       rcode = (((const DICT_VALUE *)a)->attr -
                 ((const DICT_VALUE *)b)->attr);
        if (rcode != 0) return rcode;
 
@@ -715,11 +715,11 @@ static int valuename_cmp(const void *a, const void *b)
 static int valuevalue_cmp(const void *a, const void *b)
 {
        int rcode;
-       rcode = (((const DICT_VALUE *)a)->attr - 
+       rcode = (((const DICT_VALUE *)a)->attr -
                 ((const DICT_VALUE *)b)->attr);
        if (rcode != 0) return rcode;
 
-       return (((const DICT_VALUE *)a)->value - 
+       return (((const DICT_VALUE *)a)->value -
                 ((const DICT_VALUE *)b)->value);
 }
 
@@ -734,7 +734,7 @@ static int valuefixup_cmp(const void *a, const void *b)
                           (const char *) ((const DICT_VALUE *)b)->attr);
        if (rcode != 0) return rcode;
 
-       return (((const DICT_VALUE *)a)->value - 
+       return (((const DICT_VALUE *)a)->value -
                ((const DICT_VALUE *)b)->value);
 }
 
@@ -852,9 +852,9 @@ DICT_ATTR *dict_attrbyvalue(int val)
 
        } else {
                DICT_ATTR myattr;
-               
+
                myattr.attr = val;
-               return rbtree_finddata(attributes_byvalue, &myattr); 
+               return rbtree_finddata(attributes_byvalue, &myattr);
        }
 
        return NULL;            /* never reached, but useful */
@@ -866,10 +866,10 @@ DICT_ATTR *dict_attrbyvalue(int val)
 DICT_ATTR *dict_attrbyname(const char *name)
 {
        DICT_ATTR myattr;
-       
+
        strNcpy(myattr.name, name, sizeof(myattr.name));
-       
-       return rbtree_finddata(attributes_byname, &myattr); 
+
+       return rbtree_finddata(attributes_byname, &myattr);
 }
 
 /*
index f065e0c..43c4768 100644 (file)
@@ -164,7 +164,7 @@ typedef struct ascend_ipx_filter_t {
  *
  *     value:          A value to compare against the masked bits at
  *                     offset in a users packet.
- *                     
+ *
  *     compNeq:        Defines type of comarison (Equal or Notequal)
  *                     default is Equal.
  *
@@ -363,7 +363,7 @@ static int str2argv(char *str, char **argv, int max_argc)
 
                argv[argc] = str;
                argc++;
-               
+
                while (*str && (*str != ' ')) str++;
        }
 
@@ -536,19 +536,19 @@ static int ascend_parse_ipx_net(int argc, char **argv,
  *
  *     cmd:            One of ">" or "<" or "=" or "!=".
  *
- *     value:          Socket value to be compared against, in hex. 
- *                     
+ *     value:          Socket value to be compared against, in hex.
+ *
  *     dstipxnet:      Keyword for destination IPX address.
- *                     nnnn = IPX Node address. 
- *                     
+ *                     nnnn = IPX Node address.
+ *
  *     dstipxnode:     Keyword for destination IPX Node address.
  *             mmmmm = IPX Node Address, could be FFFFFF.
  *                    A valid ipx node number should accompany ipx net number.
- *                     
+ *
  *     dstipxsoc:      Keyword for destination IPX socket address.
- *                     
+ *
  *     cmd:            One of ">" or "<" or "=" or "!=".
- *                     
+ *
  *     value:          Socket value to be compared against, in hex.
  */
 static int ascend_parse_ipx(int argc, char **argv, ascend_ipx_filter_t *filter)
@@ -580,7 +580,7 @@ static int ascend_parse_ipx(int argc, char **argv, ascend_ipx_filter_t *filter)
                        argv += rcode + 1;
                        flags |= 0x01;
                        break;
-                       
+
                case FILTER_IPX_DST_IPXNET:
                        if (flags & 0x02) return -1;
                        rcode = ascend_parse_ipx_net(argc - 1, argv + 1,
@@ -591,7 +591,7 @@ static int ascend_parse_ipx(int argc, char **argv, ascend_ipx_filter_t *filter)
                        argv += rcode + 1;
                        flags |= 0x02;
                        break;
-                       
+
                default:
                        librad_log("Unknown string \"%s\" in IPX data filter",
                                   argv[0]);
@@ -678,7 +678,7 @@ static int ascend_parse_ipaddr(uint32_t *ipaddr, char *str)
                 *      Do the last one, too.
                 */
                if (ip[count] > 255) return -1;
-               
+
                /*
                 *      24, 16, 8, 0, done.
                 */
@@ -749,19 +749,19 @@ static int ascend_parse_port(uint16_t *port, char *compare, char *str)
  *     reply. The format of the string is:
  *
  *     ip dir action [ dstip n.n.n.n/nn ] [ srcip n.n.n.n/nn ]
- *         [ proto [ dstport cmp value ] [ srcport cmd value ] [ est ] ] 
+ *         [ proto [ dstport cmp value ] [ srcport cmd value ] [ est ] ]
  *
  *     Fields in [...] are optional.
  *
  *     dstip:          Keyword for destination IP address.
- *                     n.n.n.n = IP address. /nn - netmask. 
- *                     
+ *                     n.n.n.n = IP address. /nn - netmask.
+ *
  *     srcip:          Keyword for source IP address.
- *                     n.n.n.n = IP address. /nn - netmask. 
- *                     
+ *                     n.n.n.n = IP address. /nn - netmask.
+ *
  *     proto:          Optional protocol field. Either a name or
  *                     number. Known names are in FilterProtoName[].
- *                     
+ *
  *     dstport:        Keyword for destination port. Only valid with tcp
  *                     or udp. 'cmp' are in FilterPortType[]. 'value' can be
  *                     a name or number.
@@ -769,9 +769,9 @@ static int ascend_parse_port(uint16_t *port, char *compare, char *str)
  *     srcport:        Keyword for source port. Only valid with tcp
  *                     or udp. 'cmp' are in FilterPortType[]. 'value' can be
  *                     a name or number.
- *                     
+ *
  *     est:            Keyword for TCP established. Valid only for tcp.
- *                     
+ *
  */
 static int ascend_parse_ip(int argc, char **argv, ascend_ip_filter_t *filter)
 {
@@ -816,7 +816,7 @@ static int ascend_parse_ip(int argc, char **argv, ascend_ip_filter_t *filter)
                        argv += 2;
                        argc -= 2;
                        break;
-                       
+
                        /*
                         *      Should be protocol, ASCII or otherwise.
                         */
@@ -889,7 +889,7 @@ static int ascend_parse_ip(int argc, char **argv, ascend_ip_filter_t *filter)
                        argc--;
                        flags = 0x07;
                        break;
-                       
+
                        /*
                         *      Unknown thingy.
                         */
@@ -924,16 +924,16 @@ static int ascend_parse_ip(int argc, char **argv, ascend_ip_filter_t *filter)
  *
  *     Fields in [...] are optional.
  *
- *     offset:         A Number. Specifies an offset into a frame 
+ *     offset:         A Number. Specifies an offset into a frame
  *                     to start comparing.
- *                     
+ *
  *     mask:           A hexadecimal mask of bits to compare.
- *                     
+ *
  *     value:          A value to compare with the masked data.
  *
  *     compNeq:        Defines type of comparison. ( "==" or "!=")
  *                     Default is "==".
- *                     
+ *
  *     more:           Optional keyword MORE, to represent the attachment
  *                     to the next entry.
  */
@@ -1006,7 +1006,7 @@ static int ascend_parse_generic(int argc, char **argv,
                        filter->compNeq = FALSE;
                        flags |= 0x01;
                        break;
-                       
+
                case FILTER_MORE:
                        if (flags & 0x02) return -1;
                        filter->more = htons( 1 );
@@ -1035,11 +1035,11 @@ static int ascend_parse_generic(int argc, char **argv,
  *
  *     pair:                   Pointer to value_pair to place return.
  *
- *     valstr:                 The string to parse     
+ *     valstr:                 The string to parse
  *
  *     return:                 -1 for error or 0.
  */
-int 
+int
 ascend_parse_filter(VALUE_PAIR *pair)
 {
        int             token, type;
@@ -1047,9 +1047,9 @@ ascend_parse_filter(VALUE_PAIR *pair)
        int             argc;
        char            *argv[32];
        ascend_filter_t filter;
-       
+
        rcode = -1;
-       
+
        /*
         *      Tokenize the input string in the VP.
         *
@@ -1058,13 +1058,13 @@ ascend_parse_filter(VALUE_PAIR *pair)
         */
        argc = str2argv(pair->strvalue, argv, 32);
        if (argc < 3) return -1;
-       
+
        /*
         *      Decide which filter type it is: ip, ipx, or generic
         */
        type = lrad_str2int(filterType, argv[0], -1);
        memset(&filter, 0, sizeof(filter));
-       
+
        /*
         *      Validate the filter type.
         */
@@ -1074,13 +1074,13 @@ ascend_parse_filter(VALUE_PAIR *pair)
        case RAD_FILTER_IPX:
                filter.type = type;
                break;
-               
+
        default:
                librad_log("Unknown Ascend filter type \"%s\"", argv[0]);
                return -1;
                break;
        }
-       
+
        /*
         *      Parse direction
         */
@@ -1137,7 +1137,7 @@ ascend_parse_filter(VALUE_PAIR *pair)
        default:                /* should never reach here. */
                break;
        }
-       
+
        /*
         *      Touch the VP only if everything was OK.
         */
@@ -1145,21 +1145,21 @@ ascend_parse_filter(VALUE_PAIR *pair)
                pair->length = SIZEOF_RADFILTER;
                memcpy(pair->strvalue, &filter, sizeof(filter));
        }
-       
+
        return rcode;
-       
+
 #if 0
     /*
-     * if 'more' is set then this new entry must exist, be a 
-     * FILTER_GENERIC_TYPE, direction and disposition must match for 
-     * the previous 'more' to be valid. If any should fail then TURN OFF 
+     * if 'more' is set then this new entry must exist, be a
+     * FILTER_GENERIC_TYPE, direction and disposition must match for
+     * the previous 'more' to be valid. If any should fail then TURN OFF
      * previous 'more'
      */
     if( prevRadPair ) {
        filt = ( RadFilter * )prevRadPair->strvalue;
        if(( tok != FILTER_GENERIC_TYPE ) || (rc == -1 ) ||
-          ( prevRadPair->attribute != pair->attribute ) || 
-          ( filt->indirection != radFil.indirection ) || 
+          ( prevRadPair->attribute != pair->attribute ) ||
+          ( filt->indirection != radFil.indirection ) ||
           ( filt->forward != radFil.forward ) ) {
            gen = &filt->u.generic;
            gen->more = FALSE;
@@ -1171,7 +1171,7 @@ ascend_parse_filter(VALUE_PAIR *pair)
     if( rc != -1 && tok == FILTER_GENERIC_TYPE ) {
        if( radFil.u.generic.more ) {
            prevRadPair = pair;
-       } 
+       }
     }
 
     if( rc != -1 ) {
@@ -1195,10 +1195,10 @@ void print_abinary(VALUE_PAIR *vp, u_char *buffer, int len)
   int                  i;
   char                 *p;
   ascend_filter_t      filter;
-  
+
   static const char *action[] = {"drop", "forward"};
   static const char *direction[] = {"out", "in"};
-  
+
   p = (char *)buffer;
 
   /*
@@ -1252,12 +1252,12 @@ void print_abinary(VALUE_PAIR *vp, u_char *buffer, int len)
       p += i;
       len -= i;
     }
-    
-    i =  snprintf(p, len, " %s", 
+
+    i =  snprintf(p, len, " %s",
                  lrad_int2str(filterProtoName, filter.u.ip.proto, "??"));
     p += i;
     len -= i;
-    
+
     if (filter.u.ip.srcPortComp > RAD_NO_COMPARE) {
       i = snprintf(p, len, " srcport %s %d",
                   lrad_int2str(filterCompare, filter.u.ip.srcPortComp, "??"),
@@ -1273,7 +1273,7 @@ void print_abinary(VALUE_PAIR *vp, u_char *buffer, int len)
       p += i;
       len -= i;
     }
-    
+
     if (filter.u.ip.established) {
       i = snprintf(p, len, " est");
       p += i;
@@ -1288,8 +1288,8 @@ void print_abinary(VALUE_PAIR *vp, u_char *buffer, int len)
     if (filter.u.ipx.src.net) {
       i = snprintf(p, len, " srcipxnet 0x%04x srcipxnode 0x%02x%02x%02x%02x%02x%02x",
                  (unsigned int)ntohl(filter.u.ipx.src.net),
-                 filter.u.ipx.src.node[0], filter.u.ipx.src.node[1], 
-                 filter.u.ipx.src.node[2], filter.u.ipx.src.node[3], 
+                 filter.u.ipx.src.node[0], filter.u.ipx.src.node[1],
+                 filter.u.ipx.src.node[2], filter.u.ipx.src.node[3],
                  filter.u.ipx.src.node[4], filter.u.ipx.src.node[5]);
       p += i;
       len -= i;
@@ -1307,8 +1307,8 @@ void print_abinary(VALUE_PAIR *vp, u_char *buffer, int len)
     if (filter.u.ipx.dst.net) {
       i = snprintf(p, len, " dstipxnet 0x%04x dstipxnode 0x%02x%02x%02x%02x%02x%02x",
                  (unsigned int)ntohl(filter.u.ipx.dst.net),
-                 filter.u.ipx.dst.node[0], filter.u.ipx.dst.node[1], 
-                 filter.u.ipx.dst.node[2], filter.u.ipx.dst.node[3], 
+                 filter.u.ipx.dst.node[0], filter.u.ipx.dst.node[1],
+                 filter.u.ipx.dst.node[2], filter.u.ipx.dst.node[3],
                  filter.u.ipx.dst.node[4], filter.u.ipx.dst.node[5]);
       p += i;
       len -= i;
index 611a229..e4f3228 100644 (file)
@@ -158,12 +158,12 @@ int main(int argc, char **argv)
   text_len = strlen(text);
 
   lrad_hmac_md5(text, text_len, key, key_len, digest);
-  
+
   for (i = 0; i < 16; i++) {
     printf("%02x", digest[i]);
   }
   printf("\n");
-  
+
   exit(0);
   return 0;
 }
index fe1ae70..ba45a9d 100644 (file)
@@ -67,7 +67,7 @@ lrad_hmac_sha1(const unsigned char *text, int text_len,
                                j=0;
                        }
                        j++;
-                       
+
                        printf("%02x", key[i]);
                }
                printf("\nDATA: (%d)    ",text_len);
@@ -78,14 +78,14 @@ lrad_hmac_sha1(const unsigned char *text, int text_len,
                    printf("\n            ");
                    k=0;
                    j=0;
-                 } 
+                 }
                  if(j==4) {
                    printf("_");
                    j=0;
                  }
                  k++;
                  j++;
-                 
+
                  printf("%02x", text[i]);
                }
                printf("\n");
@@ -147,7 +147,7 @@ lrad_hmac_sha1(const unsigned char *text, int text_len,
                                j=0;
                        }
                        j++;
-                       
+
                        printf("%02x", digest[i]);
                }
                printf("\n");
@@ -161,7 +161,7 @@ Test Vectors (Trailing '\0' of a character string not included in test):
   key =         "Jefe"
   data =        "what do ya want for nothing?"
   data_len =    28 bytes
-  digest =      
+  digest =
 
   key =         0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 
@@ -206,7 +206,7 @@ int main(int argc, char **argv)
     printf("%02x", digest[i]);
   }
   printf("\n");
-  
+
   exit(0);
   return 0;
 }
index 5f88ce5..e19dc05 100644 (file)
@@ -70,11 +70,11 @@ void lrad_randinit(lrad_randctx *ctx, int flag)
   m=ctx->randmem;
   r=ctx->randrsl;
   a=b=c=d=e=f=g=h=0x9e3779b9;  /* the golden ratio */
-  
+
   for (i=0; i<4; ++i) {        /* scramble it */
     mix(a,b,c,d,e,f,g,h);
   }
-  
+
   if (flag) {
     /* initialize using the contents of r[] as the seed */
     for (i=0; i<RANDSIZ; i+=8) {
@@ -100,7 +100,7 @@ void lrad_randinit(lrad_randctx *ctx, int flag)
       m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
     }
   }
-  
+
   lrad_isaac(ctx);       /* fill in the first set of results */
   ctx->randcnt=RANDSIZ;  /* prepare to use the first set of results */
 }
@@ -116,9 +116,9 @@ int main()
 {
   uint32_t i,j;
   lrad_randctx ctx;
-  
+
   ctx.randa = ctx.randb = ctx.randc = (uint32_t)0;
-  
+
   for (i=0; i<256; ++i) ctx.randrsl[i]=(uint32_t)0;
   lrad_randinit(&ctx, 1);
   for (i=0; i<2; ++i) {
index 4423b5b..3715488 100644 (file)
@@ -131,7 +131,7 @@ uint32_t ip_getaddr(const char *host)
        if (hp == NULL) {
                return htonl(INADDR_NONE);
        }
-       
+
        /*
         *      Paranoia from a Bind vulnerability.  An attacker
         *      can manipulate DNS entries to change the length of the
@@ -185,7 +185,7 @@ char *strNcpy(char *dest, const char *src, int n)
 
        while ((n > 1) && (*src)) {
                *(p++) = *(src++);
-               
+
                n--;
        }
        *p = '\0';
@@ -207,7 +207,7 @@ void rad_lowercase(char *str) {
  * Remove spaces from a string
  */
 void rad_rmspace(char *str) {
-       char *s = str;  
+       char *s = str;
        char *ptr = str;
 
   while(ptr && *ptr!='\0') {
index 6b9542f..59357ee 100644 (file)
@@ -211,4 +211,4 @@ struct tm *gmtime_r(const time_t *l_clock, struct tm *result)
 
   return result;
 }
-#endif 
+#endif
index 0a840bf..e7cd9fe 100644 (file)
@@ -208,7 +208,7 @@ int vp_prints_value(char * out, int outlen, VALUE_PAIR *vp, int delimitst)
                        break;
        }
        strNcpy(out, a?a:"UNKNOWN-TYPE", outlen);
-       
+
        return strlen(out);
 }
 
@@ -272,7 +272,7 @@ int vp_prints(char *out, int outlen, VALUE_PAIR *vp)
 
                snprintf(out, outlen, "%s:%d %s ", vp->name, vp->flags.tag,
                         token);
-               
+
                len = strlen(out);
                vp_prints_value(out + len, outlen - len, vp, 1);
 
@@ -282,7 +282,7 @@ int vp_prints(char *out, int outlen, VALUE_PAIR *vp)
                len = strlen(out);
                vp_prints_value(out + len, outlen - len, vp, 1);
 
-       }         
+       }
 
        return strlen(out);
 }
index 9ebab5f..5472dc6 100644 (file)
@@ -194,7 +194,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                   *    RADIUS packet size, by one attribute.
                   */
                  uint8_t               data[MAX_PACKET_LEN + 256];
-                 
+
                  /*
                   *    Use memory on the stack, until we know how
                   *    large the packet will be.
@@ -230,7 +230,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
 
                  default:
                          break;
-                         
+
                  }
                  memcpy(hdr->vector, packet->vector, sizeof(hdr->vector));
 
@@ -238,9 +238,9 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                        what, packet->id,
                        ip_ntoa((char *)ip_buffer, packet->dst_ipaddr),
                        packet->dst_port);
-                 
+
                  total_length = AUTH_HDR_LEN;
-                 
+
                  /*
                   *    Load up the configuration values for the user
                   */
@@ -328,7 +328,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                          if ((vendorcode == 0) &&
                              ((vendorcode = VENDOR(reply->attribute)) != 0)) {
                                  vendorpec  = dict_vendorpec(vendorcode);
-                                 
+
                                  /*
                                   *    This is a potentially bad error...
                                   *    we can't find the vendor ID!
@@ -381,9 +381,9 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                                  *ptr++ = 2;
                                  total_length += 2;
                          }
-                         
+
                          switch(reply->type) {
-                                 
+
                                  /*
                                   *    Ascend binary attributes are
                                   *    stored internally in binary form.
@@ -454,7 +454,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                                                  *ptr++ = 0x00;
                                          } /* else don't write a tag */
                                  } /* else the attribute doesn't have a tag */
-                                
+
                                  /*
                                   *    Ensure we don't go too far.
                                   *    The 'length' of the attribute
@@ -468,11 +468,11 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                                  } else {
                                          allowed -= *length_ptr;
                                  }
-                                 
+
                                  if (len > allowed) {
                                          len = allowed;
                                  }
-                                 
+
                                  *length_ptr += len;
                                  if (vsa_length_ptr) *vsa_length_ptr += len;
                                  /*
@@ -485,7 +485,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                                  ptr += reply->length;
                                  total_length += len;
                                  break;
-                                 
+
                          case PW_TYPE_INTEGER:
                          case PW_TYPE_IPADDR:
                                  *length_ptr += 4;
@@ -566,11 +566,11 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                   */
                  if (msg_auth_offset) {
                          uint8_t calc_auth_vector[AUTH_VECTOR_LEN];
-                         
+
                          switch (packet->code) {
                          default:
                                  break;
-                                 
+
                          case PW_AUTHENTICATION_ACK:
                          case PW_AUTHENTICATION_REJECT:
                          case PW_ACCESS_CHALLENGE:
@@ -579,7 +579,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                                         AUTH_VECTOR_LEN);
                                  break;
                          }
-                         
+
                          /*
                           *    Set the authentication vector to zero,
                           *    calculate the signature, and put it
@@ -624,7 +624,7 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                                MD5Update(&context, packet->data, packet->data_len);
                                MD5Update(&context, secret, strlen(secret));
                                MD5Final(digest, &context);
-                               
+
                                memcpy(hdr->vector, digest, AUTH_VECTOR_LEN);
                                memcpy(packet->vector, digest, AUTH_VECTOR_LEN);
                                break;
@@ -640,13 +640,13 @@ int rad_send(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
                DEBUG("Re-sending %s of id %d to %s:%d\n", what, packet->id,
                      ip_ntoa((char *)ip_buffer, packet->dst_ipaddr),
                      packet->dst_port);
-               
+
                for (reply = packet->vps; reply; reply = reply->next) {
                        /* FIXME: ignore attributes > 0xff */
                        debug_pair(reply);
                }
        }
-       
+
        /*
         *      And send it on it's way.
         */
@@ -699,7 +699,7 @@ static int calc_acctdigest(RADIUS_PACKET *packet, const char *secret)
         *      as the original MD5 sum (packet->vector).
         */
        memset(packet->data + 4, 0, AUTH_VECTOR_LEN);
-       
+
        /*
         *  MD5(packet + secret);
         */
@@ -778,7 +778,7 @@ RADIUS_PACKET *rad_recv(int fd)
        int                     seen_eap;
        uint8_t                 data[MAX_PACKET_LEN];
        int                     num_attributes;
-       
+
        /*
         *      Allocate the new request data structure
         */
@@ -802,7 +802,7 @@ RADIUS_PACKET *rad_recv(int fd)
                struct sockaddr_in      salocal;
                salen_local = sizeof(salocal);
                memset(&salocal, 0, sizeof(salocal));
-               packet->data_len = recvfromto(fd, data, sizeof(data), 0, 
+               packet->data_len = recvfromto(fd, data, sizeof(data), 0,
                                              (struct sockaddr *)&saremote, &salen,
                                              (struct sockaddr *)&salocal, &salen_local);
                packet->dst_ipaddr = salocal.sin_addr.s_addr;
@@ -979,7 +979,7 @@ RADIUS_PACKET *rad_recv(int fd)
                        free(packet);
                        return NULL;
                }
-               
+
                /*
                 *      Attributes are at LEAST as long as the ID & length
                 *      fields.  Anything shorter is an invalid attribute.
@@ -1013,7 +1013,7 @@ RADIUS_PACKET *rad_recv(int fd)
                        }
                        seen_eap |= PW_MESSAGE_AUTHENTICATOR;
                        break;
-                       
+
                case PW_VENDOR_SPECIFIC:
                        if (attr[1] <= 6) {
                                librad_log("WARNING: Malformed RADIUS packet from host %s: Vendor-Specific has invalid length %d",
@@ -1102,7 +1102,7 @@ RADIUS_PACKET *rad_recv(int fd)
                               packet_codes[hdr->code],
                               ip_ntoa(host_ipaddr, packet->src_ipaddr), packet->src_port);
                } else {
-                       printf("rad_recv: Packet from host %s:%d code=%d",      
+                       printf("rad_recv: Packet from host %s:%d code=%d",
                               ip_ntoa(host_ipaddr, packet->src_ipaddr), packet->src_port,
                               hdr->code);
                }
@@ -1364,7 +1364,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original,
                        } else if ((vendorcode == VENDORPEC_USR) &&
                                   ((ptr[4] == 0) && (ptr[5] == 0))) {
                                DICT_ATTR *da;
-                               
+
                                da = dict_attrbyvalue((vendorcode << 16) |
                                                      (ptr[6] << 8) |
                                                      ptr[7]);
@@ -1400,13 +1400,13 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original,
                        librad_log("out of memory");
                        return -1;
                }
-               
+
                pair->length = attrlen;
                pair->operator = T_OP_EQ;
                pair->next = NULL;
-               
+
                switch (pair->type) {
-                       
+
                        /*
                         *      The attribute may be zero length,
                         *      or it may have a tag, and then no data...
@@ -1500,7 +1500,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original,
                                        return -1;
                                }
                                if (rad_tunnel_pwdecode(pair->strvalue,
-                                                       &pair->length, 
+                                                       &pair->length,
                                                        secret,
                                                        (char *)original->vector) < 0) {
                                        return -1;
@@ -1525,7 +1525,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original,
                                break;
                        } /* switch over encryption flags */
                        break;  /* from octets/string/abinary */
-                       
+
                case PW_TYPE_INTEGER:
                case PW_TYPE_DATE:
                case PW_TYPE_IPADDR:
@@ -1584,7 +1584,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original,
                                }
                        }
                        break;
-                       
+
                        /*
                         *      IPv6 interface ID is 8 octets long.
                         */
@@ -1634,7 +1634,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original,
                        pair = NULL;
                        break;
                }
-               
+
                if (pair) {
                        debug_pair(pair);
                        *tail = pair;
@@ -1713,7 +1713,7 @@ int rad_pwencode(char *passwd, int *pwlen, const char *secret,
         *      Length > AUTH_PASS_LEN, so we need to use the extended
         *      algorithm.
         */
-       for (n = 0; n < 128 && n <= (len - AUTH_PASS_LEN); n += AUTH_PASS_LEN) { 
+       for (n = 0; n < 128 && n <= (len - AUTH_PASS_LEN); n += AUTH_PASS_LEN) {
                memcpy(buffer + secretlen, passwd + n, AUTH_PASS_LEN);
                librad_md5_calc((u_char *)digest, buffer, secretlen + AUTH_PASS_LEN);
                for (i = 0; i < AUTH_PASS_LEN; i++)
@@ -1762,7 +1762,7 @@ int rad_pwdecode(char *passwd, int pwlen, const char *secret,
         */
        rlen = ((pwlen - 1) / AUTH_PASS_LEN) * AUTH_PASS_LEN;
 
-       for (n = rlen; n > 0; n -= AUTH_PASS_LEN ) { 
+       for (n = rlen; n > 0; n -= AUTH_PASS_LEN ) {
                s = (n == AUTH_PASS_LEN) ? r : (passwd + n - AUTH_PASS_LEN);
                memcpy(buffer + secretlen, s, AUTH_PASS_LEN);
                librad_md5_calc((u_char *)digest, buffer, secretlen + AUTH_PASS_LEN);
@@ -1793,7 +1793,7 @@ int rad_tunnel_pwencode(char *passwd, int *pwlen, const char *secret,
        char*   salt;
        int     i, n, secretlen;
        unsigned len, n2;
-       
+
        len = *pwlen;
 
        if (len > 127) len = 127;
@@ -1823,7 +1823,7 @@ int rad_tunnel_pwencode(char *passwd, int *pwlen, const char *secret,
        salt[0] = (0x80 | ( ((salt_offset++) & 0x0f) << 3) |
                   (lrad_rand() & 0x07));
        salt[1] = lrad_rand();
-       
+
        /*
         *      Padd password to multiple of AUTH_PASS_LEN bytes.
         */
@@ -1835,23 +1835,23 @@ int rad_tunnel_pwencode(char *passwd, int *pwlen, const char *secret,
        }
        /* set new password length */
        *pwlen = len + 2;
-       
+
        /*
         *      Use the secret to setup the decryption digest
         */
        secretlen = strlen(secret);
        memcpy(buffer, secret, secretlen);
-       
+
        for (n2 = 0; n2 < len; n2+=AUTH_PASS_LEN) {
                if (!n2) {
                        memcpy(buffer + secretlen, vector, AUTH_VECTOR_LEN);
                        memcpy(buffer + secretlen + AUTH_VECTOR_LEN, salt, 2);
                        librad_md5_calc(digest, buffer, secretlen + AUTH_VECTOR_LEN + 2);
                } else {
-                       memcpy(buffer + secretlen, passwd + n2 - AUTH_PASS_LEN, AUTH_PASS_LEN); 
+                       memcpy(buffer + secretlen, passwd + n2 - AUTH_PASS_LEN, AUTH_PASS_LEN);
                        librad_md5_calc(digest, buffer, secretlen + AUTH_PASS_LEN);
                }
-               
+
                for (i = 0; i < AUTH_PASS_LEN; i++) {
                        passwd[i + n2] ^= digest[i];
                }
@@ -1875,7 +1875,7 @@ int rad_tunnel_pwdecode(uint8_t *passwd, int *pwlen, const char *secret,
        uint8_t         decrypted[MAX_STRING_LEN + 1];
        int             secretlen;
        unsigned        i, n, len;
-       
+
        len = *pwlen;
 
        /*
@@ -1887,7 +1887,7 @@ int rad_tunnel_pwdecode(uint8_t *passwd, int *pwlen, const char *secret,
        }
 
        /*
-        *      There's a salt, but no password.  Or, there's a salt 
+        *      There's a salt, but no password.  Or, there's a salt
         *      and a 'data_len' octet.  It's wrong, but at least we
         *      can figure out what it means: the password is empty.
         *
@@ -2017,7 +2017,7 @@ int rad_chap_encode(RADIUS_PACKET *packet, char *output, int id,
                i += challenge->length;
        } else {
                memcpy(ptr, packet->vector, AUTH_VECTOR_LEN);
-               i += AUTH_VECTOR_LEN; 
+               i += AUTH_VECTOR_LEN;
        }
 
        *output = id;
index deb204a..ef21180 100644 (file)
@@ -116,13 +116,13 @@ static void RotateLeft(rbtree_t *tree, rbnode_t *X)
        /**************************
         *  rotate Node X to left *
         **************************/
-       
+
        rbnode_t *Y = X->Right;
-       
+
        /* establish X->Right link */
        X->Right = Y->Left;
        if (Y->Left != NIL) Y->Left->Parent = X;
-       
+
        /* establish Y->Parent link */
        if (Y != NIL) Y->Parent = X->Parent;
        if (X->Parent) {
@@ -133,7 +133,7 @@ static void RotateLeft(rbtree_t *tree, rbnode_t *X)
        } else {
                tree->Root = Y;
        }
-       
+
        /* link X and Y */
        Y->Left = X;
        if (X != NIL) X->Parent = Y;
@@ -144,13 +144,13 @@ static void RotateRight(rbtree_t *tree, rbnode_t *X)
        /****************************
         *  rotate Node X to right  *
         ****************************/
-       
+
        rbnode_t *Y = X->Left;
-       
+
        /* establish X->Left link */
        X->Left = Y->Right;
        if (Y->Right != NIL) Y->Right->Parent = X;
-       
+
        /* establish Y->Parent link */
        if (Y != NIL) Y->Parent = X->Parent;
        if (X->Parent) {
@@ -161,7 +161,7 @@ static void RotateRight(rbtree_t *tree, rbnode_t *X)
        } else {
                tree->Root = Y;
        }
-       
+
        /* link X and Y */
        Y->Right = X;
        if (X != NIL) X->Parent = Y;
@@ -173,46 +173,46 @@ static void InsertFixup(rbtree_t *tree, rbnode_t *X)
         *  maintain red-black tree balance  *
         *  after inserting node X           *
         *************************************/
-       
+
        /* check red-black properties */
        while (X != tree->Root && X->Parent->Color == Red) {
                /* we have a violation */
                if (X->Parent == X->Parent->Parent->Left) {
                        rbnode_t *Y = X->Parent->Parent->Right;
                        if (Y->Color == Red) {
-                               
+
                                /* uncle is red */
                                X->Parent->Color = Black;
                                Y->Color = Black;
                                X->Parent->Parent->Color = Red;
                                X = X->Parent->Parent;
                        } else {
-                               
+
                                /* uncle is black */
                                if (X == X->Parent->Right) {
                                        /* make X a left child */
                                        X = X->Parent;
                                        RotateLeft(tree, X);
                                }
-                               
+
                                /* recolor and rotate */
                                X->Parent->Color = Black;
                                X->Parent->Parent->Color = Red;
                                RotateRight(tree, X->Parent->Parent);
                        }
                } else {
-                       
+
                        /* mirror image of above code */
                        rbnode_t *Y = X->Parent->Parent->Left;
                        if (Y->Color == Red) {
-                               
+
                                /* uncle is red */
                                X->Parent->Color = Black;
                                Y->Color = Black;
                                X->Parent->Parent->Color = Red;
                                X = X->Parent->Parent;
                        } else {
-                               
+
                                /* uncle is black */
                                if (X == X->Parent->Left) {
                                        X = X->Parent;
@@ -235,11 +235,11 @@ static void InsertFixup(rbtree_t *tree, rbnode_t *X)
 int rbtree_insert(rbtree_t *tree, void *Data)
 {
        rbnode_t *Current, *Parent, *X;
-       
+
        /***********************************************
         *  allocate node for Data and insert in tree  *
         ***********************************************/
-       
+
        /* find where node belongs */
        Current = tree->Root;
        Parent = NULL;
@@ -268,7 +268,7 @@ int rbtree_insert(rbtree_t *tree, void *Data)
                Parent = Current;
                Current = (result < 0) ? Current->Left : Current->Right;
        }
-       
+
        /* setup new node */
        if ((X = malloc (sizeof(*X))) == NULL) {
                exit(1);
@@ -279,7 +279,7 @@ int rbtree_insert(rbtree_t *tree, void *Data)
        X->Left = NIL;
        X->Right = NIL;
        X->Color = Red;
-       
+
        /* insert node in tree */
        if (Parent) {
                if (tree->Compare(Data, Parent->Data) <= 0)
@@ -289,7 +289,7 @@ int rbtree_insert(rbtree_t *tree, void *Data)
        } else {
                tree->Root = X;
        }
-       
+
        InsertFixup(tree, X);
 
        tree->num_elements++;
@@ -304,7 +304,7 @@ static void DeleteFixup(rbtree_t *tree, rbnode_t *X)
         *  maintain red-black tree balance  *
         *  after deleting node X            *
         *************************************/
-       
+
        while (X != tree->Root && X->Color == Black) {
                if (X == X->Parent->Left) {
                        rbnode_t *W = X->Parent->Right;
@@ -365,13 +365,13 @@ static void DeleteFixup(rbtree_t *tree, rbnode_t *X)
 void rbtree_delete(rbtree_t *tree, rbnode_t *Z)
 {
        rbnode_t *X, *Y;
-       
+
        /*****************************
         *  delete node Z from tree  *
         *****************************/
-       
+
        if (!Z || Z == NIL) return;
-       
+
        if (Z->Left == NIL || Z->Right == NIL) {
                /* Y has a NIL node as a child */
                Y = Z;
@@ -380,13 +380,13 @@ void rbtree_delete(rbtree_t *tree, rbnode_t *Z)
                Y = Z->Right;
                while (Y->Left != NIL) Y = Y->Left;
        }
-       
+
        /* X is Y's only child */
        if (Y->Left != NIL)
                X = Y->Left;
        else
                X = Y->Right;
-       
+
        /* remove Y from the parent chain */
        X->Parent = Y->Parent;
        if (Y->Parent)
@@ -396,7 +396,7 @@ void rbtree_delete(rbtree_t *tree, rbnode_t *Z)
                        Y->Parent->Right = X;
        else
                tree->Root = X;
-       
+
        if (Y != Z) {
                /*
                 *      Move the child's data to here, and then
@@ -424,7 +424,7 @@ rbnode_t *rbtree_find(rbtree_t *tree, void *Data)
        /*******************************
         *  find node containing Data  *
         *******************************/
-       
+
        rbnode_t *Current = tree->Root;
 
        while (Current != NIL) {
@@ -536,11 +536,11 @@ static int WalkNodePostOrder(rbnode_t *X, int (*callback)(void *))
 int rbtree_walk(rbtree_t *tree, int (*callback)(void *), RBTREE_ORDER order)
 {
        switch (order) {
-       case PreOrder:          
+       case PreOrder:
                return WalkNodePreOrder(tree->Root, callback);
-       case InOrder:           
+       case InOrder:
                return WalkNodeInOrder(tree->Root, callback);
-       case PostOrder:         
+       case PostOrder:
                return WalkNodePostOrder(tree->Root, callback);
 
        default:
index fa1b3cc..dacddc1 100644 (file)
@@ -5,7 +5,7 @@
  *
  *  Version:   $Id$
  */
+
 #include "autoconf.h"
 
 #include <string.h>
index 175e5f8..98c60ff 100644 (file)
@@ -1,31 +1,31 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
-   a partial implementation of DES designed for use in the 
+   a partial implementation of DES designed for use in the
    SMB authentication protocol
 
    Copyright (C) Andrew Tridgell 1998
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 
-/* NOTES: 
+/* NOTES:
 
    This code makes no attempt to be fast! In fact, it is a very
-   slow implementation 
+   slow implementation
 
    This code is NOT a complete DES implementation. It implements only
    the minimum necessary for SMB authentication, as used by all SMB
@@ -204,8 +204,8 @@ static void dohash(char *out, char *in, char *key)
                lshift(c, sc[i], 28);
                lshift(d, sc[i], 28);
 
-               concat(cd, c, d, 28, 28); 
-               permute(ki[i], cd, perm2, 48); 
+               concat(cd, c, d, 28, 28);
+               permute(ki[i], cd, perm2, 48);
        }
 
        permute(pd1, in, perm3, 64);
@@ -235,10 +235,10 @@ static void dohash(char *out, char *in, char *key)
                        int m, n;
                        m = (b[j][0]<<1) | b[j][5];
 
-                       n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4]; 
+                       n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4];
 
-                       for (k=0;k<4;k++) 
-                               b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0; 
+                       for (k=0;k<4;k++)
+                               b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0;
                }
 
                for (j=0;j<8;j++)
index f2a2a68..9c9ace8 100644 (file)
@@ -28,9 +28,9 @@
  *    original.  Also, there is now a builtin-test, just compile with:
  *           gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
  *    and run snprintf for results.
- * 
+ *
  *  Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
- *    The PGP code was using unsigned hexadecimal formats. 
+ *    The PGP code was using unsigned hexadecimal formats.
  *    Unfortunately, unsigned formats simply didn't work.
  *
  *  Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
@@ -64,7 +64,7 @@
 #define VA_SHIFT(v,t)  ;   /* no-op for ANSI */
 #define VA_END          va_end(ap)
 
-static void dopr (char *buffer, size_t maxlen, const char *format, 
+static void dopr (char *buffer, size_t maxlen, const char *format,
                   va_list args);
 static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
                    char *value, int flags, int min, int max);
@@ -117,7 +117,7 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
   int flags;
   int cflags;
   size_t currlen;
-  
+
   state = DP_S_DEFAULT;
   currlen = flags = cflags = min = 0;
   max = -1;
@@ -125,20 +125,20 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
 
   while (state != DP_S_DONE)
   {
-    if ((ch == '\0') || (currlen >= maxlen)) 
+    if ((ch == '\0') || (currlen >= maxlen))
       state = DP_S_DONE;
 
-    switch(state) 
+    switch(state)
     {
     case DP_S_DEFAULT:
-      if (ch == '%') 
+      if (ch == '%')
        state = DP_S_FLAGS;
-      else 
+      else
        dopr_outch (buffer, &currlen, maxlen, ch);
       ch = *format++;
       break;
     case DP_S_FLAGS:
-      switch (ch) 
+      switch (ch)
       {
       case '-':
        flags |= DP_F_MINUS;
@@ -166,49 +166,49 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
       }
       break;
     case DP_S_MIN:
-      if (isdigit((int)ch)) 
+      if (isdigit((int)ch))
       {
        min = 10*min + char_to_int (ch);
        ch = *format++;
-      } 
-      else if (ch == '*') 
+      }
+      else if (ch == '*')
       {
        min = va_arg (args, int);
        ch = *format++;
        state = DP_S_DOT;
-      } 
-      else 
+      }
+      else
        state = DP_S_DOT;
       break;
     case DP_S_DOT:
-      if (ch == '.') 
+      if (ch == '.')
       {
        state = DP_S_MAX;
        ch = *format++;
-      } 
-      else 
+      }
+      else
        state = DP_S_MOD;
       break;
     case DP_S_MAX:
-      if (isdigit((int)ch)) 
+      if (isdigit((int)ch))
       {
        if (max < 0)
          max = 0;
        max = 10*max + char_to_int (ch);
        ch = *format++;
-      } 
-      else if (ch == '*') 
+      }
+      else if (ch == '*')
       {
        max = va_arg (args, int);
        ch = *format++;
        state = DP_S_MOD;
-      } 
-      else 
+      }
+      else
        state = DP_S_MOD;
       break;
     case DP_S_MOD:
       /* Currently, we don't support Long Long, bummer */
-      switch (ch) 
+      switch (ch)
       {
       case 'h':
        cflags = DP_C_SHORT;
@@ -228,11 +228,11 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
       state = DP_S_CONV;
       break;
     case DP_S_CONV:
-      switch (ch) 
+      switch (ch)
       {
       case 'd':
       case 'i':
-       if (cflags == DP_C_SHORT) 
+       if (cflags == DP_C_SHORT)
          value = va_arg (args, short int);
        else if (cflags == DP_C_LONG)
          value = va_arg (args, long int);
@@ -301,7 +301,7 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
        break;
       case 's':
        strvalue = va_arg (args, char *);
-       if (max < 0) 
+       if (max < 0)
          max = maxlen; /* ie, no max */
        fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
        break;
@@ -310,19 +310,19 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
        fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
        break;
       case 'n':
-       if (cflags == DP_C_SHORT) 
+       if (cflags == DP_C_SHORT)
        {
          short int *num;
          num = va_arg (args, short int *);
          *num = currlen;
-        } 
-       else if (cflags == DP_C_LONG) 
+        }
+       else if (cflags == DP_C_LONG)
        {
          long int *num;
          num = va_arg (args, long int *);
          *num = currlen;
-        } 
-       else 
+        }
+       else
        {
          int *num;
          num = va_arg (args, int *);
@@ -352,9 +352,9 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
       break; /* some picky compilers need this */
     }
   }
-  if (currlen < maxlen - 1) 
+  if (currlen < maxlen - 1)
     buffer[currlen] = '\0';
-  else 
+  else
     buffer[maxlen - 1] = '\0';
 }
 
@@ -363,7 +363,7 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
 {
   int padlen, strln;     /* amount to pad */
   int cnt = 0;
-  
+
   if (value == 0)
   {
     value = "<NULL>";
@@ -371,23 +371,23 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
 
   for (strln = 0; value[strln]; ++strln); /* strlen */
   padlen = min - strln;
-  if (padlen < 0) 
+  if (padlen < 0)
     padlen = 0;
-  if (flags & DP_F_MINUS) 
+  if (flags & DP_F_MINUS)
     padlen = -padlen; /* Left Justify */
 
-  while ((padlen > 0) && (cnt < max)) 
+  while ((padlen > 0) && (cnt < max))
   {
     dopr_outch (buffer, currlen, maxlen, ' ');
     --padlen;
     ++cnt;
   }
-  while (*value && (cnt < max)) 
+  while (*value && (cnt < max))
   {
     dopr_outch (buffer, currlen, maxlen, *value++);
     ++cnt;
   }
-  while ((padlen < 0) && (cnt < max)) 
+  while ((padlen < 0) && (cnt < max))
   {
     dopr_outch (buffer, currlen, maxlen, ' ');
     ++padlen;
@@ -407,7 +407,7 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
   int spadlen = 0; /* amount to space pad */
   int zpadlen = 0; /* amount to zero pad */
   int caps = 0;
-  
+
   if (max < 0)
     max = 0;
 
@@ -426,7 +426,7 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
       if (flags & DP_F_SPACE)
        signvalue = ' ';
   }
-  
+
   if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
 
   do {
@@ -447,7 +447,7 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
     zpadlen = THEMAX(zpadlen, spadlen);
     spadlen = 0;
   }
-  if (flags & DP_F_MINUS) 
+  if (flags & DP_F_MINUS)
     spadlen = -spadlen; /* Left Justifty */
 
 #ifdef DEBUG_SNPRINTF
@@ -456,18 +456,18 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
 #endif
 
   /* Spaces */
-  while (spadlen > 0) 
+  while (spadlen > 0)
   {
     dopr_outch (buffer, currlen, maxlen, ' ');
     --spadlen;
   }
 
   /* Sign */
-  if (signvalue) 
+  if (signvalue)
     dopr_outch (buffer, currlen, maxlen, signvalue);
 
   /* Zeros */
-  if (zpadlen > 0) 
+  if (zpadlen > 0)
   {
     while (zpadlen > 0)
     {
@@ -477,9 +477,9 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
   }
 
   /* Digits */
-  while (place > 0) 
+  while (place > 0)
     dopr_outch (buffer, currlen, maxlen, convert[--place]);
-  
+
   /* Left Justified spaces */
   while (spadlen < 0) {
     dopr_outch (buffer, currlen, maxlen, ' ');
@@ -506,7 +506,7 @@ static long double pow10 (int exp)
     result *= 10;
     exp--;
   }
-  
+
   return result;
 }
 
@@ -532,12 +532,12 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
   int iplace = 0;
   int fplace = 0;
   int padlen = 0; /* amount to pad */
-  int zpadlen = 0; 
+  int zpadlen = 0;
   int caps = 0;
   long intpart;
   long fracpart;
-  
-  /* 
+
+  /*
    * AIX manpage says the default is 0, but Solaris says the default
    * is 6, and sprintf on AIX defaults to 6
    */
@@ -561,8 +561,8 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
 
   intpart = ufvalue;
 
-  /* 
-   * Sorry, we only support 9 digits past the decimal because of our 
+  /*
+   * Sorry, we only support 9 digits past the decimal because of our
    * conversion method
    */
   if (max > 9)
@@ -602,18 +602,18 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
   fconvert[fplace] = 0;
 
   /* -1 for decimal point, another -1 if we are printing a sign */
-  padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); 
+  padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
   zpadlen = max - fplace;
   if (zpadlen < 0)
     zpadlen = 0;
-  if (padlen < 0) 
+  if (padlen < 0)
     padlen = 0;
-  if (flags & DP_F_MINUS) 
+  if (flags & DP_F_MINUS)
     padlen = -padlen; /* Left Justifty */
 
-  if ((flags & DP_F_ZERO) && (padlen > 0)) 
+  if ((flags & DP_F_ZERO) && (padlen > 0))
   {
-    if (signvalue) 
+    if (signvalue)
     {
       dopr_outch (buffer, currlen, maxlen, signvalue);
       --padlen;
@@ -630,10 +630,10 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
     dopr_outch (buffer, currlen, maxlen, ' ');
     --padlen;
   }
-  if (signvalue) 
+  if (signvalue)
     dopr_outch (buffer, currlen, maxlen, signvalue);
 
-  while (iplace > 0) 
+  while (iplace > 0)
     dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
 
   /*
@@ -642,7 +642,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
    */
   dopr_outch (buffer, currlen, maxlen, '.');
 
-  while (fplace > 0) 
+  while (fplace > 0)
     dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
 
   while (zpadlen > 0)
@@ -651,7 +651,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
     --zpadlen;
   }
 
-  while (padlen < 0) 
+  while (padlen < 0)
   {
     dopr_outch (buffer, currlen, maxlen, ' ');
     ++padlen;
@@ -674,7 +674,7 @@ int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
 int snprintf (char *str,size_t count,const char *fmt,...)
 {
   VA_LOCAL_DECL;
-    
+
   VA_START (fmt);
   VA_SHIFT (str, char *);
   VA_SHIFT (count, size_t );
@@ -706,7 +706,7 @@ int main (void)
     "%3.2f",
     NULL
   };
-  double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 
+  double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
     0.9996, 1.996, 4.136, 0};
   char *int_fmt[] = {
     "%-1.5d",
@@ -734,7 +734,7 @@ int main (void)
       sprintf (buf2, fp_fmt[x], fp_nums[y]);
       if (strcmp (buf1, buf2))
       {
-       printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n", 
+       printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n",
            fp_fmt[x], buf1, buf2);
        fail++;
       }
@@ -748,7 +748,7 @@ int main (void)
       sprintf (buf2, int_fmt[x], int_nums[y]);
       if (strcmp (buf1, buf2))
       {
-       printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n", 
+       printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n",
            int_fmt[x], buf1, buf2);
        fail++;
       }
index 00df222..8dac01f 100644 (file)
@@ -13,7 +13,7 @@
  *   License along with this library; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  *
- *  Helper functions to get/set addresses of UDP packets 
+ *  Helper functions to get/set addresses of UDP packets
  *  based on recvfromto by Miquel van Smoorenburg
  *
  * recvfromto  Like recvfrom, but also stores the destination
@@ -29,8 +29,8 @@
  *             version 2 of the License, or (at your option) any later version.
  *
  * sendfromto  added 18/08/2003, Jan Berkel <jan@sitadelle.com>
- *             Works on Linux and FreeBSD (5.x)                        
- * 
+ *             Works on Linux and FreeBSD (5.x)
+ *
  * Version: $Id$
  */
 
@@ -64,14 +64,14 @@ int udpfromto_init(int s)
 
 #ifdef HAVE_IP_RECVDSTADDR
        /*
-        * Set the IP_RECVDSTADDR option (BSD). 
-        * Note: IP_RECVDSTADDR == IP_SENDSRCADDR 
+        * Set the IP_RECVDSTADDR option (BSD).
+        * Note: IP_RECVDSTADDR == IP_SENDSRCADDR
         */
        err = setsockopt(s, IPPROTO_IP, IP_RECVDSTADDR, &opt, sizeof(opt));
 #endif
        return err;
 }
-       
+
 int recvfromto(int s, void *buf, size_t len, int flags,
        struct sockaddr *from, socklen_t *fromlen,
        struct sockaddr *to, socklen_t *tolen)
@@ -106,7 +106,7 @@ int recvfromto(int s, void *buf, size_t len, int flags,
                l = sizeof(si);
                if (getsockname(s, (struct sockaddr *)&si, &l) == 0) {
                        ((struct sockaddr_in *)to)->sin_port = si.sin_port;
-                       ((struct sockaddr_in *)to)->sin_addr = si.sin_addr; 
+                       ((struct sockaddr_in *)to)->sin_addr = si.sin_addr;
                }
                if (tolen) *tolen = sizeof(struct sockaddr_in);
        }
@@ -161,7 +161,7 @@ int recvfromto(int s, void *buf, size_t len, int flags,
 # endif
        }
        return err;
-#else 
+#else
        /* fallback: call recvfrom */
        return recvfrom(s, buf, len, flags, from, fromlen);
 #endif /* defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR) */
@@ -195,7 +195,7 @@ int sendfromto(int s, void *buf, size_t len, int flags,
        msgh.msg_controllen = sizeof(cmsgbuf);
        msgh.msg_name = to;
        msgh.msg_namelen = tolen;
-       
+
        cmsg = CMSG_FIRSTHDR(&msgh);
 
 # ifdef HAVE_IP_PKTINFO
@@ -210,7 +210,7 @@ int sendfromto(int s, void *buf, size_t len, int flags,
        cmsg->cmsg_level = IPPROTO_IP;
        cmsg->cmsg_type = IP_SENDSRCADDR;
        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
-       memcpy((struct in_addr *)CMSG_DATA(cmsg), 
+       memcpy((struct in_addr *)CMSG_DATA(cmsg),
               &((struct sockaddr_in *)from)->sin_addr, sizeof(struct in_addr));
 # endif
 
@@ -226,7 +226,7 @@ int sendfromto(int s, void *buf, size_t len, int flags,
 /*
  *     Small test program to test recvfromto/sendfromto
  *
- *     use a virtual IP address as first argument to test 
+ *     use a virtual IP address as first argument to test
  *
  *     reply packet should originate from virtual IP and not
  *     from the default interface the alias is bound to
@@ -267,7 +267,7 @@ int main(int argc, char **argv)
                        return 0;
                case 0:
                        /* child */
-                       usleep(100000); 
+                       usleep(100000);
                        goto client;
        }
 
@@ -301,7 +301,7 @@ int main(int argc, char **argv)
                inet_ntoa(to.sin_addr), ntohs(to.sin_port));
 
        printf("server: replying from address packet was received on to source address\n");
-               
+
        if ((n = sendfromto(server_socket, buf, n, 0,
                (struct sockaddr *)&to, tl,
                (struct sockaddr *)&from, fl)) < 0) {
@@ -329,12 +329,12 @@ client:
        in.sin_addr.s_addr = inet_addr(destip);
 
        printf("client: sending packet to %s:%d\n", destip, port);
-       if (sendto(client_socket, TESTSTRING, TESTLEN, 0, 
+       if (sendto(client_socket, TESTSTRING, TESTLEN, 0,
                        (struct sockaddr *)&in, sizeof(in)) < 0) {
                perror("client: sendto");
                _exit(0);
        }
-                       
+
        printf("client: waiting for reply from server on INADDR_ANY:%d\n", port+1);
 
        if ((n = recvfromto(client_socket, buf, sizeof(buf), 0,
index d3f6e6a..0034be5 100644 (file)
@@ -318,7 +318,7 @@ void pairmove(VALUE_PAIR **to, VALUE_PAIR **from)
                 */
                if (i->attribute == PW_FALL_THROUGH ||
                    (i->attribute != PW_HINT && i->attribute != PW_FRAMED_ROUTE)) {
-                 
+
                        found = pairfind(*to, i->attribute);
                        switch (i->operator) {
 
@@ -332,7 +332,7 @@ void pairmove(VALUE_PAIR **to, VALUE_PAIR **from)
                                            (strcmp((char *)found->strvalue,
                                                    (char *)i->strvalue) == 0)){
                                                pairdelete(to, found->attribute);
-                                               
+
                                                /*
                                                 *      'tailto' may have been
                                                 *      deleted...
@@ -346,9 +346,9 @@ void pairmove(VALUE_PAIR **to, VALUE_PAIR **from)
                                tailfrom = i;
                                continue;
                                break;
-                               
+
 /* really HAVE_REGEX_H */
-#if 0 
+#if 0
                                /*
                                 *  Attr-Name =~ "s/find/replace/"
                                 *
@@ -375,7 +375,7 @@ void pairmove(VALUE_PAIR **to, VALUE_PAIR **from)
                            q = strchr(str, *p);
                            *(q++) = '\0';
                            q[strlen(q) - 1] = '\0';
-                           
+
                            regcomp(&reg, str, 0);
                            if (regexec(&reg, found->strvalue,
                                        1, match, 0) == 0) {
@@ -435,7 +435,7 @@ void pairmove(VALUE_PAIR **to, VALUE_PAIR **from)
                        tailfrom->next = next;
                else
                        *from = next;
-               
+
                /*
                 *      If ALL of the 'to' attributes have been deleted,
                 *      then ensure that the 'tail' is updated to point
@@ -576,7 +576,7 @@ static int gettime(const char *valstr, time_t *lvalue)
         */
        tm->tm_mon = 12;
        for (i = 0; i < 3; i++) {
-               if (isalpha( (int) *f[i])) {    
+               if (isalpha( (int) *f[i])) {
                        /*
                         *  Bubble the month to the front of the list
                         */
@@ -760,7 +760,7 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value)
 
                                while (*cp && vp->length < MAX_STRING_LEN) {
                                        unsigned int tmp;
-                                       
+
                                        if (sscanf(cp, "%02x", &tmp) != 1) {
                                                librad_log("Non-hex characters at %c%c", cp[0], cp[1]);
                                                return NULL;
@@ -949,16 +949,16 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value,
                case PW_TYPE_IFID:
                        if (vp->length != 8) goto length_error;
                        break;
-                       
+
                case PW_TYPE_IPV6ADDR:
                        if (vp->length != 16) goto length_error;
                        break;
-                       
+
 #ifdef ASCEND_BINARY
                case PW_TYPE_ABINARY:
                        if (vp->length != 32) goto length_error;
                        break;
-#endif           
+#endif
                default:        /* string, octets, etc. */
                        break;
                }
@@ -1069,8 +1069,8 @@ VALUE_PAIR *pairmake(const char *attribute, const char *value, int operator)
                       else tag = 0;
                }
                found_tag = 1;
-       }       
-       
+       }
+
        if (found_tag) {
          vp->flags.tag = tag;
        }
@@ -1114,7 +1114,7 @@ VALUE_PAIR *pairmake(const char *attribute, const char *value, int operator)
                if (res != 0) {
                        char    msg[128];
 
-                       regerror(res, &cre, msg, sizeof(msg));               
+                       regerror(res, &cre, msg, sizeof(msg));
                        librad_log("Illegal regular expression in attribute: %s: %s",
                                vp->name, msg);
                        pairbasicfree(vp);
@@ -1212,13 +1212,13 @@ VALUE_PAIR *pairread(char **ptr, LRAD_TOKEN *eol)
        case T_BACK_QUOTED_STRING:
                vp = pairmake(attr, NULL, token);
                if (!vp) return vp;
-               
+
                vp->flags.do_xlat = 1;
                strNcpy(vp->strvalue, value, sizeof(vp->strvalue));
                vp->length = 0;
                break;
        }
-       
+
        return vp;
 }
 
@@ -1306,7 +1306,7 @@ VALUE_PAIR *readvp2(FILE *fp, int *pfiledone, const char *errprefix)
                        }
                        break;
                }
-               
+
                pairadd(&list, vp);
                buf[0] = '\0';
        }
index 2a339fd..1c6efa1 100644 (file)
@@ -57,7 +57,7 @@ int rad_accounting(REQUEST *request)
                    reply != RLM_MODULE_OK &&
                    reply != RLM_MODULE_UPDATED)
                        return reply;
-               
+
                /*
                 *      Do accounting, ONLY the first time through.
                 *      This is to ensure that we log the packet
@@ -67,7 +67,7 @@ int rad_accounting(REQUEST *request)
                if (vp)
                        acct_type = vp->lvalue;
                reply = module_accounting(acct_type,request);
-               
+
                /*
                 *      See if we need to execute a program.
                 *      FIXME: somehow cache this info, and only execute the
@@ -87,7 +87,7 @@ int rad_accounting(REQUEST *request)
                        exec_program = strdup((char *)vp->strvalue);
                        pairdelete(&request->reply->vps, PW_EXEC_PROGRAM_WAIT);
                }
-               
+
                /*
                 *      If we want to exec a program, but wait for it,
                 *      do it first before sending the reply, or
@@ -115,7 +115,7 @@ int rad_accounting(REQUEST *request)
                         */
                        pairmove(&request->reply->vps, &vp);
                        pairfree(&vp);
-                               
+
                        if (exec_wait) {
                                if (rcode != 0) {
                                        return reply;
index 0ceb4fc..b207a11 100644 (file)
@@ -124,7 +124,7 @@ static int rad_authlog(const char *msg, REQUEST *request, int goodpass) {
                username = request->username;
        }
 
-       /* 
+       /*
         *      Clean up the username
         */
        if (username == NULL) {
@@ -135,7 +135,7 @@ static int rad_authlog(const char *msg, REQUEST *request, int goodpass) {
                                clean_username, sizeof(clean_username));
        }
 
-       /* 
+       /*
         *      Clean up the password
         */
        if (mainconfig.log_auth_badpass || mainconfig.log_auth_goodpass) {
@@ -152,20 +152,20 @@ static int rad_authlog(const char *msg, REQUEST *request, int goodpass) {
 
        if (goodpass) {
                radlog(L_AUTH, "%s: [%s%s%s] (%s)",
-                               msg,    
+                               msg,
                                clean_username,
                                mainconfig.log_auth_goodpass ? "/" : "",
                                mainconfig.log_auth_goodpass ? clean_password : "",
                                auth_name(buf, sizeof(buf), request, 1));
        } else {
                radlog(L_AUTH, "%s: [%s%s%s] (%s)",
-                               msg,    
+                               msg,
                                clean_username,
                                mainconfig.log_auth_badpass ? "/" : "",
                                mainconfig.log_auth_badpass ? clean_password : "",
                                auth_name(buf, sizeof(buf), request, 1));
        }
-       
+
        return 0;
 }
 
@@ -212,14 +212,14 @@ int rad_check_password(REQUEST *request)
        }
 
        if (( auth_type_count > 1) && (debug_flag)) {
-               radlog(L_ERR, "Warning:  Found %d auth-types on request for user '%s'", 
+               radlog(L_ERR, "Warning:  Found %d auth-types on request for user '%s'",
                        auth_type_count, request->username->strvalue);
        }
 
        /*
-        *      This means we have a proxy reply or an accept  
-        *  and it wasn't rejected in the above loop.  So 
-        *  that means it is accepted and we do no further 
+        *      This means we have a proxy reply or an accept
+        *  and it wasn't rejected in the above loop.  So
+        *  that means it is accepted and we do no further
         *  authentication
         */
        if ((auth_type == PW_AUTHTYPE_ACCEPT) || (request->proxy)) {
@@ -275,7 +275,7 @@ int rad_check_password(REQUEST *request)
                                        "(No Crypt-Password configured for the user)", request, 0);
                                return -1;
                        }
-                                       
+
                        switch (lrad_crypt_check((char *)auth_item->strvalue,
                                                                         (char *)password_pair->strvalue)) {
                        case -1:
@@ -401,7 +401,7 @@ static int rad_postauth(REQUEST *request)
        switch (result) {
        default:
          break;
-         
+
          /*
           *    The module failed, or said to reject the user: Do so.
           */
@@ -517,7 +517,7 @@ int rad_authenticate(REQUEST *request)
                request->password = pairfind(request->packet->vps,
                                             PW_PASSWORD);
        }
-         
+
        /*
         *      Discover which password we want to use.
         */
@@ -529,10 +529,10 @@ int rad_authenticate(REQUEST *request)
                /*
                 *      Maybe there's a CHAP-Password?
                 */
-               if ((auth_item = pairfind(request->packet->vps, 
+               if ((auth_item = pairfind(request->packet->vps,
                                PW_CHAP_PASSWORD)) != NULL) {
                        password = "<CHAP-PASSWORD>";
-               
+
                } else {
                        /*
                         *      No password we recognize.
@@ -541,7 +541,7 @@ int rad_authenticate(REQUEST *request)
                }
        }
        request->password = auth_item;
-       
+
        /*
         *      Get the user's authorization information from the database
         */
@@ -618,7 +618,7 @@ autz_redo:
                        return RLM_MODULE_HANDLED;
                }
        } while(0);
-       
+
        /*
         *      Failed to validate the user.
         *
@@ -685,7 +685,7 @@ autz_redo:
                        }
                        if (!mpp_ok){
                                if (check_item->lvalue > 1) {
-                               snprintf(umsg, sizeof(umsg), 
+                               snprintf(umsg, sizeof(umsg),
                                                        "\r\nYou are already logged in %d times  - access denied\r\n\n",
                                                        (int)check_item->lvalue);
                                        user_msg = umsg;
@@ -746,7 +746,7 @@ autz_redo:
                        tmp = pairmake("Reply-Message", user_msg, T_OP_SET);
                        request->reply->vps = tmp;
 
-                       snprintf(logstr, sizeof(logstr), "Outside allowed timespan (time allowed %s)", 
+                       snprintf(logstr, sizeof(logstr), "Outside allowed timespan (time allowed %s)",
                                 check_item->strvalue);
                        rad_authlog(logstr, request, 1);
 
@@ -805,11 +805,11 @@ autz_redo:
         *      Add the port number to the Framed-IP-Address if
         *      vp->addport is set.
         */
-       if (((tmp = pairfind(request->reply->vps, 
+       if (((tmp = pairfind(request->reply->vps,
                             PW_FRAMED_IP_ADDRESS)) != NULL) &&
            (tmp->flags.addport != 0)) {
                VALUE_PAIR *vpPortId;
-               
+
                /*
                 *  Find the NAS port ID.
                 */
@@ -893,7 +893,7 @@ autz_redo:
                        tmp = pairmake("Reply-Message", user_msg, T_OP_SET);
 
                        pairadd(&request->reply->vps, tmp);
-                       rad_authlog("Login incorrect (external check failed)", 
+                       rad_authlog("Login incorrect (external check failed)",
                                        request, 0);
 
                        return RLM_MODULE_REJECT;
@@ -964,7 +964,7 @@ autz_redo:
                                    NULL, 0, request->packet->vps, NULL);
        }
 
-       if (exec_program) 
+       if (exec_program)
                free(exec_program);
 
        result = rad_postauth(request);
index c8a7d6a..c1b3123 100644 (file)
@@ -96,7 +96,7 @@ int read_clients_file(const char *file)
                 */
                p = buffer;
                while (*p &&
-                               ((*p == ' ') || (*p == '\t'))) 
+                               ((*p == ' ') || (*p == '\t')))
                        p++;
 
                /*
@@ -163,7 +163,7 @@ int read_clients_file(const char *file)
                               (int) sizeof(c->shortname) - 1);
                        return -1;
                }
-               
+
                /*
                 *      It should be OK now, let's create the buffer.
                 */
@@ -247,7 +247,7 @@ RADCLIENT *client_find(uint32_t ipaddr)
  *     Walk the RADCLIENT list displaying the clients.  This function
  *     is for debugging purposes.
  */
-void client_walk(void) 
+void client_walk(void)
 {
        RADCLIENT *cl;
        char host_ipaddr[16];
@@ -272,10 +272,10 @@ const char *client_name(uint32_t ipaddr)
                else
                        return cl->longname;
        }
-       
-       /* 
-        * this isn't normally reachable, but if a loggable event happens just 
-        * after a client list change and a HUP, then we may not know this 
+
+       /*
+        * this isn't normally reachable, but if a loggable event happens just
+        * after a client list change and a HUP, then we may not know this
         * information any more.
         *
         * If you see lots of these, then there's something wrong.
index d1ddbce..4fc5458 100644 (file)
@@ -148,7 +148,7 @@ static CONF_SECTION *cf_section_alloc(const char *name1, const char *name2,
 {
        CONF_SECTION    *cs;
 
-       if (name1 == NULL || !name1[0]) 
+       if (name1 == NULL || !name1[0])
                name1 = "main";
 
        cs = (CONF_SECTION *)rad_malloc(sizeof(CONF_SECTION));
@@ -181,9 +181,9 @@ void cf_section_free(CONF_SECTION **cs)
                }
        }
 
-       if ((*cs)->name1) 
+       if ((*cs)->name1)
                free((*cs)->name1);
-       if ((*cs)->name2) 
+       if ((*cs)->name2)
                free((*cs)->name2);
 
        /*
@@ -203,7 +203,7 @@ void cf_section_free(CONF_SECTION **cs)
 static void cf_item_add(CONF_SECTION *cs, CONF_ITEM *ci_new)
 {
        CONF_ITEM *ci;
-       
+
        for (ci = cs->children; ci && ci->next; ci = ci->next)
                ;
 
@@ -224,7 +224,7 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
        const char *end, *ptr;
        char name[8192];
        CONF_SECTION *parentcs;
-       
+
        /*
         *      Find the master parent conf section.
         *      We can't use mainconfig.config, because we're in the
@@ -259,9 +259,9 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                                       cf, *lineno);
                                return NULL;
                        }
-                       
+
                        ptr += 2;
-                       
+
                        cp = NULL;
                        up = 0;
 
@@ -272,7 +272,7 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                                up = 1;
                                cs = outercs;
                                ptr++;
-                               
+
                                /*
                                 *      ${..foo} means "foo from the section
                                 *      enclosing this section" (etc.)
@@ -324,9 +324,9 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                                 */
                                if (*ptr == '.') {
                                        CONF_SECTION *next;
-                                       
+
                                        ptr++;  /* skip the period */
-                                       
+
                                        /*
                                         *      Find the sub-section.
                                         */
@@ -336,7 +336,7 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                                                return NULL;
                                        }
                                        cs = next;
-                                       
+
                                } else { /* no period, must be a conf-part */
                                        /*
                                         *      Find in the current referenced
@@ -357,7 +357,7 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                                        }
                                }
                        } /* until cp is non-NULL */
-                       
+
                        /*
                         *  Substitute the value of the variable.
                         */
@@ -382,10 +382,10 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                                       cf, *lineno);
                                return NULL;
                        }
-                       
+
                        memcpy(name, ptr, end - ptr);
                        name[end - ptr] = '\0';
-                       
+
                        /*
                         *      Get the environment variable.
                         *      If none exists, then make it an empty string.
@@ -407,7 +407,7 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
                        *(p++) = *(ptr++);
                }
        } /* loop over all of the input string. */
-               
+
        *p = '\0';
 
        return output;
@@ -444,7 +444,7 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
                if (cp) {
                        value = cp->value;
                }
-               
+
                switch (variables[i].type)
                {
                case PW_TYPE_SUBSECTION:
@@ -496,7 +496,7 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
                                        variables[i].name,
                                        *(int *)data);
                        break;
-                       
+
                case PW_TYPE_STRING_PTR:
                        q = (char **) data;
                        if (*q != NULL) {
@@ -543,14 +543,14 @@ int cf_section_parse(CONF_SECTION *cs, void *base,
                                        value, ip_ntoa(buffer, ipaddr));
                        *(uint32_t *) data = ipaddr;
                        break;
-                       
+
                default:
                        radlog(L_ERR, "type %d not supported yet", variables[i].type);
                        return -1;
                        break;
                } /* switch over variable type */
        } /* for all variables in the configuration section */
-       
+
        return 0;
 }
 
@@ -572,7 +572,7 @@ static CONF_SECTION *cf_section_read(const char *cf, int *lineno, FILE *fp,
        int t1, t2, t3;
        char *cbuf = buf;
        int len;
-       
+
        /*
         *      Ensure that the user can't add CONF_SECTIONs
         *      with 'internal' names;
@@ -650,7 +650,7 @@ static CONF_SECTION *cf_section_read(const char *cf, int *lineno, FILE *fp,
                /*
                 *      Allow for $INCLUDE files
                 *
-                *      This *SHOULD* work for any level include.  
+                *      This *SHOULD* work for any level include.
                 *      I really really really hate this file.  -cparker
                 */
                if (strcasecmp(buf1, "$INCLUDE") == 0) {
@@ -678,7 +678,7 @@ static CONF_SECTION *cf_section_read(const char *cf, int *lineno, FILE *fp,
                        if (is != NULL) {
                                if (is->children != NULL) {
                                        CONF_ITEM *ci;
-                       
+
                                        /*
                                         *      Re-write the parent of the
                                         *      moved children to be the
@@ -749,7 +749,7 @@ static CONF_SECTION *cf_section_read(const char *cf, int *lineno, FILE *fp,
                /*
                 *      Ignore semi-colons.
                 */
-               if (*buf2 == ';') 
+               if (*buf2 == ';')
                        *buf2 = '\0';
 
                /*
@@ -757,7 +757,7 @@ static CONF_SECTION *cf_section_read(const char *cf, int *lineno, FILE *fp,
                 */
                if (buf1[0] != 0 && buf2[0] == 0 && buf3[0] == 0) {
                        t2 = T_OP_EQ;
-               } else if (buf1[0] == 0 || buf2[0] == 0 || 
+               } else if (buf1[0] == 0 || buf2[0] == 0 ||
                           (t2 < T_EQSTART || t2 > T_EQEND)) {
                        radlog(L_ERR, "%s[%d]: Line is not in 'attribute = value' format",
                                        cf, *lineno);
@@ -809,13 +809,13 @@ static CONF_SECTION *cf_section_read(const char *cf, int *lineno, FILE *fp,
 /*
  *     Read the config file.
  */
-CONF_SECTION *conf_read(const char *fromfile, int fromline, 
+CONF_SECTION *conf_read(const char *fromfile, int fromline,
                        const char *conffile, CONF_SECTION *parent)
 {
        FILE            *fp;
        int             lineno = 0;
        CONF_SECTION    *cs;
-       
+
        if ((fp = fopen(conffile, "r")) == NULL) {
                if (fromfile) {
                        radlog(L_ERR|L_CONS, "%s[%d]: Unable to open file \"%s\": %s",
@@ -839,7 +839,7 @@ CONF_SECTION *conf_read(const char *fromfile, int fromline,
 }
 
 
-/* 
+/*
  * Return a CONF_PAIR within a CONF_SECTION.
  */
 CONF_PAIR *cf_pair_find(CONF_SECTION *section, const char *name)
@@ -896,7 +896,7 @@ char *cf_section_name2(CONF_SECTION *section)
        return (section ? section->name2 : NULL);
 }
 
-/* 
+/*
  * Find a value in a CONF_SECTION
  */
 char *cf_section_value_find(CONF_SECTION *section, const char *attr)
@@ -996,7 +996,7 @@ CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
        for (; ci; ci = ci->next) {
                if (ci->type != CONF_ITEM_SECTION)
                        continue;
-               if ((name1 == NULL) || 
+               if ((name1 == NULL) ||
                                (strcmp(cf_itemtosection(ci)->name1, name1) == 0))
                        break;
        }
@@ -1039,9 +1039,9 @@ int cf_item_is_section(CONF_ITEM *item)
 
 
 #if 0
-/* 
+/*
  * JMG dump_config tries to dump the config structure in a readable format
- * 
+ *
 */
 
 static int dump_config_section(CONF_SECTION *cs, int indent)
index a75f40f..865e6e4 100644 (file)
@@ -97,12 +97,12 @@ int radius_exec_program(const char *cmd, REQUEST *request,
         */
        radius_xlat(answer, sizeof(answer), cmd, request, NULL);
        buf = answer;
-       
+
        /*
         *      Log the command if we are debugging something
         */
        DEBUG("Exec-Program: %s", buf);
-       
+
        /*
         *      Build vector list of arguments and execute.
         *
@@ -133,7 +133,7 @@ int radius_exec_program(const char *cmd, REQUEST *request,
                int envlen;
                char buffer[1024];
 
-               /*      
+               /*
                 *      Child process.
                 *
                 *      We try to be fail-safe here.  So if ANYTHING
@@ -165,7 +165,7 @@ int radius_exec_program(const char *cmd, REQUEST *request,
                                       strerror(errno));
                                exit(1);
                        }
-                       
+
                        /*
                         *      pd[1] is the FD that the child will write to,
                         *      so we make it STDOUT.
index b86b947..8e9662b 100644 (file)
@@ -89,7 +89,7 @@ int pairlist_read(const char *file, PAIR_LIST **list, int complain)
         *      more useful...
         */
        if ((fp = fopen(file, "r")) == NULL) {
-               if (!complain) 
+               if (!complain)
                        return -1;
                radlog(L_CONS|L_ERR, "Couldn't open %s for reading: %s",
                                file, strerror(errno));
@@ -186,7 +186,7 @@ parse_again:
                                 *      of entries.  Go to the end of the
                                 *      list.
                                 */
-                               while (*last) 
+                               while (*last)
                                        last = &((*last)->next);
                                continue;
                        }
@@ -513,7 +513,7 @@ REALM *realm_find(const char *realm, int accounting)
        if (realm == NULL) {
                realm = "NULL";
        }
-       
+
        for (cl = mainconfig.realms; cl; cl = cl->next) {
                /*
                 *      Wake up any sleeping realm.
@@ -595,7 +595,7 @@ REALM *realm_find(const char *realm, int accounting)
                }
        }
 
-       /*      If we didn't find the realm 'NULL' don't return the 
+       /*      If we didn't find the realm 'NULL' don't return the
         *      DEFAULT entry.
         */
        if ((strcmp(realm, "NULL")) == 0) {
@@ -620,7 +620,7 @@ REALM *realm_find(const char *realm, int accounting)
 REALM *realm_findbyaddr(uint32_t ipaddr, int port)
 {
        REALM *cl;
-       
+
        /*
         *      Note that we do NOT check for inactive realms!
         *
index 6937ec2..eb50a2e 100644 (file)
@@ -81,7 +81,7 @@ int vradlog(int lvl, const char *fmt, va_list ap)
                return 0;
        }
 
-       if (debug_flag 
+       if (debug_flag
            || (radlog_dest == RADLOG_STDOUT)
            || (radlog_dir == NULL)) {
                msgfd = stdout;
@@ -102,7 +102,7 @@ int vradlog(int lvl, const char *fmt, va_list ap)
                } else if ((msgfd = fopen(mainconfig.log_file, "a")) == NULL) {
                         fprintf(stderr, "%s: Couldn't open %s for logging: %s\n",
                                 progname, mainconfig.log_file, strerror(errno));
-                               
+
                         fprintf(stderr, "  (");
                         vfprintf(stderr, fmt, ap);  /* the message that caused the log */
                         fprintf(stderr, ")\n");
@@ -148,7 +148,7 @@ int vradlog(int lvl, const char *fmt, va_list ap)
                        *p = '?';
        }
        strcat(buffer, "\n");
-       
+
        /*
         *   If we're debugging, for small values of debug, then
         *   we don't do timestamps.
@@ -230,16 +230,16 @@ int radlog(int lvl, const char *msg, ...)
 
 /*
  *      Dump a whole list of attributes to DEBUG2
- */                     
+ */
 void vp_listdebug(VALUE_PAIR *vp)
-{       
-        char tmpPair[70];  
+{
+        char tmpPair[70];
         for (; vp; vp = vp->next) {
                 vp_prints(tmpPair, sizeof(tmpPair), vp);
                 DEBUG2("     %s", tmpPair);
-        }               
+        }
 }
-   
 
-        
+
+
+
index 6800264..4dfa7b4 100644 (file)
@@ -94,7 +94,7 @@ static CONF_PARSER server_config[] = {
         *      files.
         */
        { "prefix",             PW_TYPE_STRING_PTR, 0, &prefix,            "/usr/local"},
-       { "localstatedir",      PW_TYPE_STRING_PTR, 0, &localstatedir,     "${prefix}/var"}, 
+       { "localstatedir",      PW_TYPE_STRING_PTR, 0, &localstatedir,     "${prefix}/var"},
        { "logdir",             PW_TYPE_STRING_PTR, 0, &radlog_dir,        "${localstatedir}/log"},
        { "libdir",             PW_TYPE_STRING_PTR, 0, &radlib_dir,        "${prefix}/lib"},
        { "radacctdir",         PW_TYPE_STRING_PTR, 0, &radacct_dir,       "${logdir}/radacct" },
@@ -200,7 +200,7 @@ static int xlat_config(void *instance, REQUEST *request,
                        outlen = strlen(value) + 1;
                }
        }
-       
+
        return func(out, outlen, value);
 }
 
@@ -234,7 +234,7 @@ static int r_mkdir(const char *part) {
 
        return(0);
 }
-               
+
 /*
  *     Checks if the log directory is writeable by a particular user.
  */
@@ -251,11 +251,11 @@ static int radlogdir_iswritable(const char *effectiveuser) {
        if (strstr(radlog_dir, "radius") == NULL)
                return(0);
 
-       /* we have a logdir that mentions 'radius', so it's probably 
-        * safe to chown the immediate directory to be owned by the normal 
+       /* we have a logdir that mentions 'radius', so it's probably
+        * safe to chown the immediate directory to be owned by the normal
         * process owner. we gotta do it before we give up root.  -chad
         */
-       
+
        if (!effectiveuser) {
                return 1;
        }
@@ -273,7 +273,7 @@ static int radlogdir_iswritable(const char *effectiveuser) {
 
 
 static int switch_users(void) {
-       
+
        /*
         *  Switch UID and GID to what is specified in the config file
         */
@@ -322,7 +322,7 @@ static int switch_users(void) {
 }
 
 
-/* 
+/*
  * Create the linked list of realms from the new configuration type
  * This way we don't have to change to much in the other source-files
  */
@@ -382,7 +382,7 @@ static int generate_realms(const char *filename)
                                }
                        }
 
-                       /* 
+                       /*
                         * Double check length, just to be sure!
                         */
                        if (strlen(authhost) >= sizeof(c->server)) {
@@ -403,7 +403,7 @@ static int generate_realms(const char *filename)
                } else {
                        if ((s = strchr(accthost, ':')) != NULL) {
                                *s++ = 0;
-                               c->acct_port = atoi(s); 
+                               c->acct_port = atoi(s);
                        } else {
                                c->acct_port = acct_port;
                        }
@@ -422,7 +422,7 @@ static int generate_realms(const char *filename)
                                               accthost);
                                        return -1;
                                }
-                       }                                   
+                       }
 
                        if (strlen(accthost) >= sizeof(c->acct_server)) {
                                radlog(L_ERR, "%s[%d]: Server name of length %d is greater than allowed: %d",
@@ -440,10 +440,10 @@ static int generate_realms(const char *filename)
                               (int) sizeof(c->server) - 1);
                        return -1;
                }
-               
+
                strcpy(c->realm, name2);
                 if (authhost) strcpy(c->server, authhost);
-               if (accthost) strcpy(c->acct_server, accthost); 
+               if (accthost) strcpy(c->acct_server, accthost);
 
                /*
                 *      If one or the other of authentication/accounting
@@ -457,7 +457,7 @@ static int generate_realms(const char *filename)
                                       filename, cf_section_lineno(cs), name2);
                                return -1;
                        }
-                       
+
                        if (strlen(s) >= sizeof(c->secret)) {
                                radlog(L_ERR, "%s[%d]: Secret of length %d is greater than the allowed maximum of %d.",
                                       filename, cf_section_lineno(cs),
@@ -468,7 +468,7 @@ static int generate_realms(const char *filename)
                }
 
                c->striprealm = 1;
-               
+
                if ((cf_section_value_find(cs, "nostrip")) != NULL)
                        c->striprealm = 0;
                if ((cf_section_value_find(cs, "noacct")) != NULL)
@@ -572,7 +572,7 @@ static int generate_clients(const char *filename)
        char            *name2;
 
        for (cs = cf_subsection_find_next(mainconfig.config, NULL, "client");
-            cs != NULL; 
+            cs != NULL;
             cs = cf_subsection_find_next(mainconfig.config, cs, "client")) {
 
                name2 = cf_section_name2(cs);
@@ -614,27 +614,27 @@ static int generate_clients(const char *filename)
                }
 
                if((nastype = cf_section_value_find(cs, "nastype")) != NULL) {
-                       if(strlen(nastype) >= sizeof(c->nastype)) { 
+                       if(strlen(nastype) >= sizeof(c->nastype)) {
                               radlog(L_ERR, "%s[%d]: nastype of length %d longer than the allowed maximum of %d",
-                                     filename, cf_section_lineno(cs), 
+                                     filename, cf_section_lineno(cs),
                                      strlen(nastype), sizeof(c->nastype) - 1);
                               return -1;
                        }
                }
 
                if((login = cf_section_value_find(cs, "login")) != NULL) {
-                       if(strlen(login) >= sizeof(c->login)) { 
+                       if(strlen(login) >= sizeof(c->login)) {
                               radlog(L_ERR, "%s[%d]: login of length %d longer than the allowed maximum of %d",
-                                     filename, cf_section_lineno(cs), 
+                                     filename, cf_section_lineno(cs),
                                      strlen(login), sizeof(c->login) - 1);
                               return -1;
                        }
                }
 
                if((password = cf_section_value_find(cs, "password")) != NULL) {
-                       if(strlen(password) >= sizeof(c->password)) { 
+                       if(strlen(password) >= sizeof(c->password)) {
                               radlog(L_ERR, "%s[%d]: password of length %d longer than the allowed maximum of %d",
-                                     filename, cf_section_lineno(cs), 
+                                     filename, cf_section_lineno(cs),
                                      strlen(password), sizeof(c->password) - 1);
                               return -1;
                        }
@@ -659,7 +659,7 @@ static int generate_clients(const char *filename)
                                                filename, cf_section_lineno(cs), netmask + 1);
                                return -1;
                        }
-                       
+
                        c->netmask = (1 << 31);
                        for (i = 1; i < mask_length; i++) {
                                c->netmask |= (c->netmask >> 1);
@@ -838,7 +838,7 @@ int read_mainconfig(int reload)
        }
        librad_debug = debug_flag;
        old_debug_level = mainconfig.debug_level;
-       
+
        /*
         *  Go update our behaviour, based on the configuration
         *  changes.
@@ -873,7 +873,7 @@ int read_mainconfig(int reload)
 
                limits.rlim_cur = 0;
                limits.rlim_max = core_limits.rlim_max;
-               
+
                if (setrlimit(RLIMIT_CORE, &limits) < 0) {
                        radlog(L_ERR|L_CONS, "Cannot disable core dumps: %s",
                                        strerror(errno));
@@ -890,7 +890,7 @@ int read_mainconfig(int reload)
                 *      We need root to do mkdir() and chown(), so we
                 *      do this before giving up root.
                 */
-               radlogdir_iswritable(mainconfig.uid_name); 
+               radlogdir_iswritable(mainconfig.uid_name);
        }
        switch_users();
 
index 376e077..8ab071d 100644 (file)
@@ -180,7 +180,7 @@ static const char *comp2str[] = {
  */
 static void safe_lock(module_instance_t *instance)
 {
-       if (instance->mutex) 
+       if (instance->mutex)
                pthread_mutex_lock(instance->mutex);
 }
 
@@ -189,7 +189,7 @@ static void safe_lock(module_instance_t *instance)
  */
 static void safe_unlock(module_instance_t *instance)
 {
-       if (instance->mutex) 
+       if (instance->mutex)
                pthread_mutex_unlock(instance->mutex);
 }
 #else
@@ -206,14 +206,14 @@ static int call_modsingle(int component, modsingle *sp, REQUEST *request,
        int myresult = default_result;
 
        DEBUG3("  modsingle[%s]: calling %s (%s) for request %d",
-              comp2str[component], sp->modinst->name, 
+              comp2str[component], sp->modinst->name,
               sp->modinst->entry->name, request->number);
        safe_lock(sp->modinst);
        myresult = sp->modinst->entry->module->methods[component](
                        sp->modinst->insthandle, request);
        safe_unlock(sp->modinst);
        DEBUG3("  modsingle[%s]: returned from %s (%s) for request %d",
-              comp2str[component], sp->modinst->name, 
+              comp2str[component], sp->modinst->name,
               sp->modinst->entry->name, request->number);
 
        return myresult;
index 1cb4cfe..ce7ff94 100644 (file)
@@ -218,7 +218,7 @@ static module_list_t *linkto_module(const char *module_name,
        node->next = NULL;
        node->handle = handle;
        strNcpy(node->name, module_name, sizeof(node->name));
-       
+
        /*
         *      Link to the module's rlm_FOO{} module structure.
         */
@@ -237,7 +237,7 @@ static module_list_t *linkto_module(const char *module_name,
                free(node);
                return NULL;
        }
-       
+
        /* call the modules initialization */
        if (node->module->init && (node->module->init)() < 0) {
                radlog(L_ERR|L_CONS, "%s[%d] Module initialization failed.\n",
@@ -304,7 +304,7 @@ module_instance_t *find_module_instance(const char *instname)
         *      no name2.
         */
        name1 = name2 = NULL;
-       for(inst_cs=cf_subsection_find_next(cs, NULL, NULL); 
+       for(inst_cs=cf_subsection_find_next(cs, NULL, NULL);
                        inst_cs != NULL;
                        inst_cs=cf_subsection_find_next(cs, inst_cs, NULL)) {
                name1 = cf_section_name1(inst_cs);
@@ -324,7 +324,7 @@ module_instance_t *find_module_instance(const char *instname)
        node = rad_malloc(sizeof(*node));
        node->next = NULL;
        node->insthandle = NULL;
-       
+
        /*
         *      Link to the module by name: rlm_FOO-major.minor
         */
@@ -351,7 +351,7 @@ module_instance_t *find_module_instance(const char *instname)
                /* linkto_module logs any errors */
                return NULL;
        }
-       
+
        /*
         *      Call the module's instantiation routine.
         */
@@ -390,11 +390,11 @@ module_instance_t *find_module_instance(const char *instname)
                node->mutex = NULL;
        }
 
-#endif 
+#endif
        *last = node;
 
        DEBUG("Module: Instantiated %s (%s) ", name1, node->name);
-       
+
        return node;
 }
 
@@ -419,7 +419,7 @@ static indexed_modcallable *new_sublist(int comp, int idx)
                /* It is an error to try to create a sublist that already
                 * exists. It would almost certainly be caused by accidental
                 * duplication in the config file.
-                * 
+                *
                 * index 0 is the exception, because it is used when we want
                 * to collect _all_ listed modules under a single index by
                 * default, which is currently the case in all components
@@ -526,7 +526,7 @@ static int load_component_section(CONF_SECTION *cs, int comp,
        const char *modname;
        char *visiblename;
 
-       for (modref=cf_item_find_next(cs, NULL); 
+       for (modref=cf_item_find_next(cs, NULL);
                        modref != NULL;
                        modref=cf_item_find_next(cs, modref)) {
 
@@ -666,7 +666,7 @@ int setup_modules(void)
                /*
                 *      Set the default list of preloaded symbols.
                 *      This is used to initialize libltdl's list of
-                *      preloaded modules. 
+                *      preloaded modules.
                 *
                 *      i.e. Static modules.
                 */
@@ -676,7 +676,7 @@ int setup_modules(void)
                        radlog(L_ERR|L_CONS, "Failed to initialize libraries: %s\n",
                                        lt_dlerror());
                        exit(1); /* FIXME */
-                       
+
                }
 
                /*
@@ -685,7 +685,7 @@ int setup_modules(void)
                 *      any location on the disk.
                 */
                lt_dlsetsearchpath(radlib_dir);
-               
+
                DEBUG2("Module: Library search path is %s",
                                lt_dlgetsearchpath());
 
@@ -736,7 +736,7 @@ int setup_modules(void)
                         *      Allow some old names, too.
                         */
                        if (!next && (comp <= 4)) {
-                               
+
                                next = cf_subsection_find_next(cs, sub,
                                                               old_section_type_value[comp].typename);
                        }
@@ -834,11 +834,11 @@ int setup_modules(void)
                        if (cf_item_is_section(ci)) {
                                radlog(L_ERR|L_CONS,
                                       "%s[%d] Subsection for module instantiate is not allowed\n", filename,
-                                      
+
                                       cf_section_lineno(cf_itemtosection(ci)));
                                exit(1);
                        }
-       
+
                        cp = cf_itemtopair(ci);
                        name = cf_pair_attr(cp);
                        module = find_module_instance(name);
@@ -854,9 +854,9 @@ int setup_modules(void)
         */
        for (comp = 0; comp < RLM_COMPONENT_COUNT; ++comp) {
                cs = cf_section_find(component_names[comp]);
-               if (cs == NULL) 
+               if (cs == NULL)
                        continue;
-               
+
                if (load_component_section(cs, comp, filename) < 0) {
                        exit(1);
                }
index 6499c06..024df2f 100644 (file)
@@ -119,7 +119,7 @@ int read_naslist_file(char *file)
                               (int) sizeof(nas->nastype) - 1);
                        return -1;
                }
-               
+
                /*
                 *      It should be OK now, let's create the buffer.
                 */
@@ -227,7 +227,7 @@ const char *nas_name2(RADIUS_PACKET *packet)
 }
 
 /*
- *     Find the name of a nas (prefer short name) based on ipaddr, 
+ *     Find the name of a nas (prefer short name) based on ipaddr,
  *     store in passed buffer.  If NAS is unknown, return dotted quad.
  */
 char * nas_name3(char *buf, size_t buflen, uint32_t ipaddr)
index 80b74d7..f523ba6 100644 (file)
@@ -121,7 +121,7 @@ static REALM *proxy_realm_ldb(REQUEST *request, const char *realm_name,
 {
        REALM           *cl, *lb;
        uint32_t        count;
-       
+
        lb = NULL;
        count = 0;
        for (cl = mainconfig.realms; cl; cl = cl->next) {
@@ -279,20 +279,20 @@ int proxy_send(REQUEST *request)
         */
        pairadd(&request->packet->vps,
                pairmake("Realm", realm->realm, T_OP_EQ));
-       
+
        /*
         *      Access-Request: look for LOCAL realm.
         *      Accounting-Request: look for LOCAL realm.
         */
        if (((request->packet->code == PW_AUTHENTICATION_REQUEST) &&
             (realm->ipaddr == htonl(INADDR_NONE))) ||
-           ((request->packet->code == PW_ACCOUNTING_REQUEST) &&            
+           ((request->packet->code == PW_ACCOUNTING_REQUEST) &&
             (realm->acct_ipaddr == htonl(INADDR_NONE)))) {
                DEBUG2(" WARNING: Cancelling proxy to Realm %s, as the realm is local.",
                       realm->realm);
                return RLM_MODULE_NOOP;
        }
-       
+
        /*
         *      Allocate the proxy packet, only if it wasn't already
         *      allocated by a module.  This check is mainly to support
@@ -345,7 +345,7 @@ int proxy_send(REQUEST *request)
                vps = paircopy(request->packet->vps);
                namepair = pairfind(vps, PW_USER_NAME);
                strippednamepair = pairfind(vps, PW_STRIPPED_USER_NAME);
-               
+
                /*
                 *      If there's a Stripped-User-Name attribute in
                 *      the request, then use THAT as the User-Name
@@ -404,7 +404,7 @@ int proxy_send(REQUEST *request)
         *      Proxied requests get sent out the proxy FD ONLY.
         */
        request->proxy->sockfd = proxyfd;
-       
+
        request->proxy->code = request->packet->code;
        if (request->packet->code == PW_AUTHENTICATION_REQUEST) {
                request->proxy->dst_port = realm->auth_port;
index 63d1b15..cc58f82 100644 (file)
@@ -101,7 +101,7 @@ static radclient_t *radclient_tail = NULL;
 static void usage(void)
 {
        fprintf(stderr, "Usage: radclient [options] server[:port] <command> [<secret>]\n");
-       
+
        fprintf(stderr, "  <command>    One of auth, acct, status, or disconnect.\n");
        fprintf(stderr, "  -c count    Send each packet 'count' times.\n");
        fprintf(stderr, "  -d raddb    Set dictionary directory.\n");
@@ -138,7 +138,7 @@ static void radclient_free(radclient_t *radclient)
                assert(radclient_head == radclient);
                radclient_head = next;
        }
-       
+
        if (next) {
                assert(radclient_tail != radclient);
                next->prev = prev;
@@ -190,18 +190,18 @@ static radclient_t *radclient_init(const char *filename)
                        return NULL; /* memory leak "start" */
                }
                memset(radclient, 0, sizeof(*radclient));
-               
+
                radclient->request = rad_alloc(1);
                if (!radclient->request) {
                        librad_perror("radclient: ");
                        radclient_free(radclient);
                        return NULL; /* memory leak "start" */
                }
-               
+
                radclient->filename = filename;
                radclient->request->id = -1; /* allocate when sending */
                radclient->packet_number = packet_number++;
-               
+
                /*
                 *      Read the VP's.
                 */
@@ -210,7 +210,7 @@ static radclient_t *radclient_init(const char *filename)
                        radclient_free(radclient);
                        return NULL; /* memory leak "start" */
                }
-               
+
                /*
                 *      Keep a copy of the the User-Password attribute.
                 */
@@ -224,7 +224,7 @@ static radclient_t *radclient_init(const char *filename)
                } else {
                        radclient->password[0] = '\0';
                }
-               
+
                /*
                 *  Fix up Digest-Attributes issues
                 */
@@ -232,7 +232,7 @@ static radclient_t *radclient_init(const char *filename)
                        switch (vp->attribute) {
                        default:
                                break;
-                               
+
                                /*
                                 *      Allow it to set the packet type in
                                 *      the attributes read from the file.
@@ -240,11 +240,11 @@ static radclient_t *radclient_init(const char *filename)
                        case PW_PACKET_TYPE:
                                radclient->request->code = vp->lvalue;
                                break;
-                               
+
                        case PW_PACKET_DST_PORT:
                                radclient->request->dst_port = (vp->lvalue & 0xffff);
                                break;
-                               
+
                        case PW_DIGEST_REALM:
                        case PW_DIGEST_NONCE:
                        case PW_DIGEST_METHOD:
@@ -274,9 +274,9 @@ static radclient_t *radclient_init(const char *filename)
                        prev = radclient;
                }
        } while (!filedone); /* loop until the file is done. */
-       
+
        if (fp != stdin) fclose(fp);
-       
+
        /*
         *      And we're done.
         */
@@ -330,7 +330,7 @@ static int filename_walk(void *data)
        if (!radclient) {
                exit(1);
        }
-       
+
        if (!radclient_head) {
                assert(radclient_tail == NULL);
                radclient_head = radclient;
@@ -470,10 +470,10 @@ static int send_one_packet(radclient_t *radclient)
 
                assert(radclient->request->id != -1);
                assert(radclient->request->data == NULL);
-               
+
                librad_md5_calc(radclient->request->vector, radclient->request->vector,
                                sizeof(radclient->request->vector));
-               
+
                /*
                 *      Update the password, so it can be encrypted with the
                 *      new authentication vector.
@@ -484,11 +484,11 @@ static int send_one_packet(radclient_t *radclient)
                        if ((vp = pairfind(radclient->request->vps, PW_PASSWORD)) != NULL) {
                                strNcpy((char *)vp->strvalue, radclient->password, strlen(radclient->password) + 1);
                                vp->length = strlen(radclient->password);
-                               
+
                        } else if ((vp = pairfind(radclient->request->vps, PW_CHAP_PASSWORD)) != NULL) {
                                strNcpy((char *)vp->strvalue, radclient->password, strlen(radclient->password) + 1);
                                vp->length = strlen(radclient->password);
-                               
+
                                rad_chap_encode(radclient->request, (char *) vp->strvalue, radclient->request->id, vp);
                                vp->length = 17;
                        }
@@ -575,25 +575,25 @@ static int recv_one_packet(int wait_time)
        RADIUS_PACKET   myrequest, *reply;
        rbnode_t        *node;
 
-       
+
        /* And wait for reply, timing out as necessary */
        FD_ZERO(&set);
        FD_SET(sockfd, &set);
-       
+
        if (wait_time <= 0) {
                tv.tv_sec = 0;
        } else {
                tv.tv_sec = wait_time;
        }
        tv.tv_usec = 0;
-       
+
        /*
         *      No packet was received.
         */
        if (select(sockfd + 1, &set, NULL, NULL, &tv) != 1) {
                return 0;
        }
-       
+
        /*
         *      Look for the packet.
         */
@@ -716,7 +716,7 @@ int main(int argc, char **argv)
 
        while ((c = getopt(argc, argv, "c:d:f:hi:qst:r:S:xv")) != EOF) switch(c) {
                case 'c':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        resend_count = atoi(optarg);
                        break;
@@ -733,12 +733,12 @@ int main(int argc, char **argv)
                        librad_debug++;
                        break;
                case 'r':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        retries = atoi(optarg);
                        break;
                case 'i':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        id = atoi(optarg);
                        if ((id < 0) || (id > 255)) {
@@ -749,7 +749,7 @@ int main(int argc, char **argv)
                        do_summary = 1;
                        break;
                case 't':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        timeout = atof(optarg);
                        break;
@@ -914,7 +914,7 @@ int main(int argc, char **argv)
                /*
                 *      Walk over the packets, sending them.
                 */
-               
+
                for (this = radclient_head; this != NULL; this = next) {
                        next = this->next;
 
index c0916c3..06d9736 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * radius_snmp.c       Radius SNMP support
  *
  * Version:    $Id$
@@ -141,7 +141,7 @@ static const unsigned char *radAuthEntry(struct variable *vp,
        size_t  *var_len,
        WriteMethod **write_method);
 
-static struct variable radiusacc_variables[] = 
+static struct variable radiusacc_variables[] =
 {
        {RADIUSACCSERVIDENT, STRING, RONLY, radAccServ, 1, {1}},
        {RADIUSACCSERVUPTIME, TIMETICKS, RONLY, radAccServ, 1, {2}},
@@ -246,7 +246,7 @@ get_client(struct variable *v, oid objid[], size_t *objid_len, int exact) {
 }
 
 static int
-radServReset (int action, u_char *var_val, u_char var_val_type, 
+radServReset (int action, u_char *var_val, u_char var_val_type,
                size_t var_val_len, const unsigned char *statP, oid *name,
                size_t name_len) {
 
@@ -255,13 +255,13 @@ radServReset (int action, u_char *var_val, u_char var_val_type,
 
        switch (action) {
                case RESERVE1:
-                       if (var_val_type != INTEGER) 
+                       if (var_val_type != INTEGER)
                                return SNMP_ERR_WRONGTYPE;
-                       if (var_val_len != sizeof (long)) 
+                       if (var_val_len != sizeof (long))
                                return SNMP_ERR_WRONGLENGTH;
                        if (! asn_parse_int(var_val, &big, &var_val_type, &i, sizeof(long)))
                                return SNMP_ERR_WRONGENCODING;
-                       if (i != 2) 
+                       if (i != 2)
                                return SNMP_ERR_WRONGVALUE;
                        break;
                case COMMIT:
@@ -276,7 +276,7 @@ radServReset (int action, u_char *var_val, u_char var_val_type,
 }
 
 static const unsigned char *
-radAccServ(struct variable *vp, oid *name, size_t *length, int exact, 
+radAccServ(struct variable *vp, oid *name, size_t *length, int exact,
                size_t *var_len, WriteMethod **write_method) {
 
        static int result;
@@ -350,7 +350,7 @@ radAccServ(struct variable *vp, oid *name, size_t *length, int exact,
 }
 
 static const unsigned char *
-radAccEntry(struct variable *vp, oid *name, size_t *length, int exact, 
+radAccEntry(struct variable *vp, oid *name, size_t *length, int exact,
                size_t *var_len, WriteMethod **write_method) {
 
        RADCLIENT *c;
@@ -404,7 +404,7 @@ radAccEntry(struct variable *vp, oid *name, size_t *length, int exact,
 }
 
 static const unsigned char *
-radAuthServ(struct variable *vp, oid *name, size_t *length, int exact, 
+radAuthServ(struct variable *vp, oid *name, size_t *length, int exact,
                size_t *var_len, WriteMethod **write_method) {
 
        static int result;
@@ -484,7 +484,7 @@ radAuthServ(struct variable *vp, oid *name, size_t *length, int exact,
 }
 
 static const unsigned char *
-radAuthEntry(struct variable *vp, oid   *name, size_t *length, int exact, 
+radAuthEntry(struct variable *vp, oid   *name, size_t *length, int exact,
                size_t *var_len, WriteMethod **write_method) {
 
        RADCLIENT *c;
@@ -582,7 +582,7 @@ radius_snmp_init (void) {
         *  Parse the SNMP configuration information.
         */
        cs = cf_section_find(NULL);
-       if (cs != NULL) 
+       if (cs != NULL)
                cf_section_parse(cs, NULL, snmp_config);
 
        /*
index bca0220..6e5c47f 100644 (file)
@@ -239,7 +239,7 @@ static int str2fac(const char *s)
                        progname, s);
                exit(1);
        }
-       
+
        /* this should never be reached */
        return LOG_DAEMON;
 }
@@ -354,14 +354,14 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                        RAD_SNMP_INC(rad_snmp.auth.total_unknown_types);
 
                        radlog(L_ERR, "Unknown packet code %d from client %s:%d "
-                              "- ID %d : IGNORED", packet->code, 
+                              "- ID %d : IGNORED", packet->code,
                               client_name(packet->src_ipaddr),
-                              packet->src_port, packet->id); 
+                              packet->src_port, packet->id);
                        return NULL;
                        break;
 
        } /* switch over packet types */
-       
+
        /*
         *      Don't handle proxy replies here.  They need to
         *      return the *old* request, so we can re-process it.
@@ -382,7 +382,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                 */
                if (mainconfig.max_requests) {
                        int request_count = rl_num_requests();
-                       
+
                        /*
                         *      This is a new request.  Let's see if
                         *      it makes us go over our configured
@@ -390,7 +390,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                         */
                        if (request_count > mainconfig.max_requests) {
                                radlog(L_ERR, "Dropping request (%d is too many): "
-                                      "from client %s:%d - ID: %d", request_count, 
+                                      "from client %s:%d - ID: %d", request_count,
                                       client_name(packet->src_ipaddr),
                                       packet->src_port, packet->id);
                                radlog(L_INFO, "WARNING: Please check the radiusd.conf file.\n"
@@ -411,7 +411,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
 
                return fun;
        }
-       
+
        /*
         *      The current request isn't finished, which
         *      means that the NAS sent us a new packet, while
@@ -443,7 +443,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                                 */
                                if (!mainconfig.proxy_synchronous) {
                                        RAD_SNMP_FD_INC(packet->sockfd, total_packets_dropped);
-                                       
+
                                        DEBUG2("Ignoring duplicate packet from client "
                                               "%s:%d - ID: %d, due to outstanding proxied request %d.",
                                               client_name(packet->src_ipaddr),
@@ -463,11 +463,11 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                                         */
                                } else {
                                        char buffer[64];
-                                       
+
                                        DEBUG2("Sending duplicate proxied request to home server %s:%d - ID: %d",
                                               ip_ntoa(buffer, curreq->proxy->dst_ipaddr),
                                               curreq->proxy->dst_port,
-                                              
+
                                               curreq->proxy->id);
                                }
                                curreq->proxy_next_try = time_now + mainconfig.proxy_retry_delay;
@@ -536,7 +536,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                        rad_send(curreq->reply, curreq->packet, curreq->secret);
                        return NULL;
                }
-               
+
                /*
                 *      Maybe we've saved a reply packet.  If so,
                 *      re-send it.  Otherwise, just complain.
@@ -561,7 +561,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
                       packet->src_port, packet->id);
                return NULL;
        } /* else the vectors were different, so we discard the old request. */
-       
+
        /*
         *      'packet' has the same source IP, source port, code,
         *      and Id as 'curreq', but a different authentication
@@ -570,7 +570,7 @@ static RAD_REQUEST_FUNP packet_ok(RADIUS_PACKET *packet)
         *      if the first reply got lost in the network.
         */
        rl_delete(curreq);
-       
+
        /*
         *      The request is OK.  We can process it...
         *
@@ -590,7 +590,7 @@ static REQUEST *proxy_ok(RADIUS_PACKET *packet)
        REALM *cl;
        REQUEST *oldreq;
        char buffer[32];
-       
+
        /*
         *      Find the original request in the request list
         */
@@ -623,7 +623,7 @@ static REQUEST *proxy_ok(RADIUS_PACKET *packet)
                       oldreq->number);
                return NULL;
        }
-       
+
        /*
         *      If there is already a reply, maybe this one is a
         *      duplicate?
@@ -644,7 +644,7 @@ static REQUEST *proxy_ok(RADIUS_PACKET *packet)
                         !  */
                        DEBUG2("Ignoring conflicting proxy reply");
                }
-               
+
                /*
                 *      We've already received a reply, so
                 *      we discard this one, as we don't want
@@ -727,7 +727,7 @@ static REQUEST *request_ok(RADIUS_PACKET *packet, uint8_t *secret)
                 *      reply packet to it.
                 */
                rad_assert(request->reply != NULL);
-               
+
        } else {                /* remember the new request */
                /*
                 *      A unique per-request counter.
@@ -841,7 +841,7 @@ int main(int argc, char *argv[])
                                if (radacct_dir) xfree(radacct_dir);
                                radacct_dir = strdup(optarg);
                                break;
-                       
+
                        case 'c':
                                /* ignore for backwards compatibility with Cistron */
                                break;
@@ -850,7 +850,7 @@ int main(int argc, char *argv[])
                                if (radius_dir) xfree(radius_dir);
                                radius_dir = strdup(optarg);
                                break;
-                       
+
                        case 'f':
                                dont_fork = TRUE;
                                break;
@@ -866,11 +866,11 @@ int main(int argc, char *argv[])
                                        exit(1);
                                }
                                break;
-                       
+
                        case 'l':
                                radlog_dir = strdup(optarg);
                                break;
-                       
+
                                /*
                                 *  We should also have this as a configuration
                                 *  file directive.
@@ -912,7 +912,7 @@ int main(int argc, char *argv[])
                        case 'x':
                                debug_flag++;
                                break;
-                       
+
                        case 'y':
                                mainconfig.log_auth = TRUE;
                                mainconfig.log_auth_badpass = TRUE;
@@ -994,7 +994,7 @@ int main(int argc, char *argv[])
        if (radius_port != 0) {
                auth_port = radius_port;
        } /* else auth_port is set from the config file */
-       
+
        /*
         *  Maybe auth_port *wasn't* set from the config file,
         *  or the config file set it to zero.
@@ -1011,7 +1011,7 @@ int main(int argc, char *argv[])
                         *  there, too.
                         */
                        svp = getservbyname ("radacct", "udp");
-                       if (svp != NULL) 
+                       if (svp != NULL)
                                acct_port = ntohs(svp->s_port);
                } else {
                        auth_port = PW_AUTH_UDP_PORT;
@@ -1047,9 +1047,9 @@ int main(int argc, char *argv[])
         *  If we haven't already gotten acct_port from /etc/services,
         *  then make it auth_port + 1.
         */
-       if (acct_port == 0) 
+       if (acct_port == 0)
                acct_port = auth_port + 1;
-       
+
        acctfd = socket (AF_INET, SOCK_DGRAM, 0);
        if (acctfd < 0) {
                perror ("acct socket");
@@ -1082,12 +1082,12 @@ int main(int argc, char *argv[])
                        perror ("proxy socket");
                        exit(1);
                }
-               
+
                sa = (struct sockaddr_in *) &salocal;
                memset((char *) sa, '\0', sizeof(salocal));
                sa->sin_family = AF_INET;
                sa->sin_addr.s_addr = mainconfig.myip;
-               
+
                /*
                 *  Set the proxy port to be one more than the
                 *  accounting port.
@@ -1099,7 +1099,7 @@ int main(int argc, char *argv[])
                                break;
                        }
                }
-               
+
                /*
                 *  Couldn't find a port to which we could bind.
                 */
@@ -1183,7 +1183,7 @@ int main(int argc, char *argv[])
         */
        if (debug_flag == FALSE) {
                int devnull;
-               
+
                devnull = open("/dev/null", O_RDWR);
                if (devnull < 0) {
                        radlog(L_ERR|L_CONS, "Failed opening /dev/null: %s\n",
@@ -1216,7 +1216,7 @@ int main(int argc, char *argv[])
         *  Use linebuffered or unbuffered stdout if
         *  the debug flag is on.
         */
-       if (debug_flag == TRUE) 
+       if (debug_flag == TRUE)
                setlinebuf(stdout);
 
        if (mainconfig.myip == INADDR_ANY) {
@@ -1238,7 +1238,7 @@ int main(int argc, char *argv[])
         *      handlers.  Before this, if we get any signal, we don't know
         *      what to do, so we might as well do the default, and die.
         */
-       signal(SIGPIPE, SIG_IGN);       
+       signal(SIGPIPE, SIG_IGN);
 #ifdef HAVE_SIGACTION
        act.sa_handler = sig_hup;
        sigaction(SIGHUP, &act, NULL);
@@ -1323,7 +1323,7 @@ int main(int argc, char *argv[])
                         *      Detach any modules.
                         */
                        detach_modules();
-                       
+
                        /*
                         *      FIXME: clean up any active REQUEST
                         *      handles.
@@ -1569,7 +1569,7 @@ int main(int argc, char *argv[])
                            (rad_snmp.smux_event == SMUX_READ)) {
                                smux_read();
                        }
-                       
+
                        /*
                         *  If we've got to re-connect, then do so now,
                         *  before calling select again.
@@ -1595,13 +1595,13 @@ int main(int argc, char *argv[])
                  thread_pool_clean(time_now);
                }
 #endif
-       
+
 
        } /* loop forever */
 }
 
 
-/* 
+/*
  * FIXME:  The next two functions should all
  * be in a module.  But not until we have
  * more control over module execution.
@@ -1628,11 +1628,11 @@ static int rad_rmspace_pair(REQUEST *request UNUSED, VALUE_PAIR *vp) {
        if (vp == NULL) {
                return -1;
        }
-       
+
        rad_rmspace((char *)vp->strvalue);
        vp->length = strlen((char *)vp->strvalue);
        DEBUG2("rad_rmspace_pair:  %s now '%s'", vp->name, vp->strvalue);
-       
+
        return 0;
 }
 
@@ -1649,7 +1649,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
        const char *secret;
        int finished = FALSE;
        int reprocess = 0;
-       
+
        /*
         *  Put the decoded packet into it's proper place.
         */
@@ -1664,7 +1664,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
        }
 
        rad_assert(request->magic == REQUEST_MAGIC);
-       
+
        /*
         *  Decode the packet, verifying it's signature,
         *  and parsing the attributes into structures.
@@ -1682,7 +1682,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
                request_reject(request);
                goto finished_request;
        }
-       
+
        /*
         *  For proxy replies, remove non-allowed
         *  attributes from the list of VP's.
@@ -1728,7 +1728,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
                        request->options |= RAD_REQUEST_OPTION_DONT_CACHE;
                }
        }
-       
+
        /*
         *  We should have a User-Name attribute now.
         */
@@ -1743,7 +1743,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
         */
        rad_assert(request->magic == REQUEST_MAGIC);
 
-       /* 
+       /*
         *  FIXME:  All this lowercase/nospace junk will be moved
         *  into a module after module failover is fully in place
         *
@@ -1797,7 +1797,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
 
                  reprocess = 1;
          }
-         
+
          /*
           *    If we're re-processing the request, re-set it.
           */
@@ -1808,7 +1808,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
                  (*fun)(request);
          }
        }
-       
+
        /*
         *  Status-Server requests NEVER get proxied.
         */
@@ -1825,7 +1825,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
                        switch (rcode) {
                        default:
                                break;
-                               
+
                        /*
                         *  There was an error trying to proxy the request.
                         *  Drop it on the floor.
@@ -1845,7 +1845,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
                                request_reject(request);
                                goto finished_request;
                                break;
-                               
+
                        /*
                         *  If the proxy code has handled the request,
                         *  then postpone more processing, until we get
@@ -1899,7 +1899,7 @@ int rad_respond(REQUEST *request, RAD_REQUEST_FUNP fun)
                 *  Need to copy Proxy-State from request->packet->vps
                 */
                vp = paircopy2(request->packet->vps, PW_PROXY_STATE);
-               if (vp != NULL) 
+               if (vp != NULL)
                        pairadd(&(request->reply->vps), vp);
 
                /*
@@ -2007,7 +2007,7 @@ static void sig_cleanup(int sig)
        pid_t pid;
 
        sig = sig; /* -Wunused */
+
        got_child = FALSE;
 
        needs_child_cleanup = 0;  /* reset the queued cleanup number */
@@ -2016,7 +2016,7 @@ static void sig_cleanup(int sig)
         *  Reset the signal handler, if required.
         */
        reset_signal(SIGCHLD, sig_cleanup);
-       
+
        /*
         *      Wait for the child, without hanging.
         */
index bd084ec..37d462a 100644 (file)
@@ -20,7 +20,7 @@
  *   You should have received a copy of the GNU General Public License
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- * 
+ *
  * Copyright 2001 Cistron Internet Services B.V.
  * Copyright 2002 Simon Ekstrand <simon@routemeister.net>
  *
@@ -463,7 +463,7 @@ int do_send(struct relay_request *r, char *secret)
         * Acct-Delay-Time value).
         * Otherwise the radius server may consider the
         * packet a duplicate and we 'll get caught in a
-        * loop. 
+        * loop.
         */
        if (r->retrans > 0){
                id_map[r->req->id] = 0;
index f6d819c..e43d497 100644 (file)
@@ -53,14 +53,14 @@ static const char rcsid[] =
 /*
  *     Header above output and format.
  */
-static const char *hdr1 = 
+static const char *hdr1 =
 "Login      Name              What  TTY  When      From      Location";
 static const char *ufmt1 = "%-10.10s %-17.17s %-5.5s %-4.4s %-9.9s %-9.9s %-.16s%s";
 static const char *ufmt1r = "%s,%s,%s,%s,%s,%s,%s%s";
 static const char *rfmt1 = "%-10.10s %-17.17s %-5.5s %s%-3d %-9.9s %-9.9s %-.19s%s";
 static const char *rfmt1r = "%s,%s,%s,%s%d,%s,%s,%s%s";
 
-static const char *hdr2 = 
+static const char *hdr2 =
 "Login      Port    What      When          From       Location";
 static const char *ufmt2 = "%-10.10s %-6.6d %-7.7s %-13.13s %-10.10s %-.16s%s";
 static const char *ufmt2r = "%s,%d,%s,%s,%s,%s%s";
@@ -135,7 +135,7 @@ static int ffile(const char *arg)
                fp = safe_popen(fn, "r");
        } else fp = fopen(fn, "r");
 
-       if (fp == NULL) 
+       if (fp == NULL)
                return -1;
 
        while(fgets(fn, 1024, fp)) {
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
 
        if (showlocal && (fp = fopen(radutmp_file, "r"))) {
                if (rawoutput == 0)
-               {       
+               {
                        fputs(showname ? hdr1 : hdr2, stdout);
                        fputs(eol, stdout);
                }
@@ -549,7 +549,7 @@ int main(int argc, char **argv)
                                                proto(rt.proto, rt.porttype),
                                                dotime(rt.time),
                                                nas_name3(nasname, sizeof(nasname), rt.nas_address),
-                                               hostname(othername, sizeof(othername), rt.framed_address),      
+                                               hostname(othername, sizeof(othername), rt.framed_address),
                                                eol);
                }
        }
index fddef04..38d6707 100644 (file)
@@ -117,7 +117,7 @@ static void usage(void)
         fprintf(stderr, "  [port]          Terminal Server port to match\n");
         fprintf(stderr, "  [user]          Login account to match\n");
         exit(1);
-}                
+}
 
 
 /*
@@ -141,9 +141,9 @@ int main(int argc, char **argv)
 
         /*  Process the options.  */
         while ((argval = getopt(argc, argv, "d:p:r:")) != EOF) {
-                                
+
                 switch(argval) {
-                        
+
                        case 'd':
                                if (radius_dir) free(radius_dir);
                                radius_dir = strdup(optarg);
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
                         case 'p':
                                acct_port = atoi(optarg);
                                 break;
-                                 
+
                         case 'r':
                                 if ((radiusip = ip_getaddr(optarg)) == INADDR_NONE) {
                                         fprintf(stderr, "%s: %s: radius server unknown\n",
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
                                         exit(1);
                                }
                                 break;
-                               
+
                         default:
                                 usage();
                                 exit(1);
@@ -191,7 +191,7 @@ int main(int argc, char **argv)
                        exit(1);
                }
        }
-       if (nas != NULL) 
+       if (nas != NULL)
                ip = nas->ipaddr;
 
        /*
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
 
        printf("%s: zapping termserver %s, port %u",
                progname, ip_hostname(buf, sizeof(buf), ip), nas_port);
-       if (user != NULL) 
+       if (user != NULL)
                printf(", user %s", user);
        printf("\n");
 
@@ -298,9 +298,9 @@ static int do_packet(int allports, uint32_t nasaddr, const struct radutmp *u)
        req->id = getpid() & 0xFF;
        req->code = PW_ACCOUNTING_REQUEST;
        req->dst_port = acct_port;
-       if(req->dst_port == 0) 
+       if(req->dst_port == 0)
                req->dst_port = getport("radacct");
-       if(req->dst_port == 0) 
+       if(req->dst_port == 0)
                req->dst_port = PW_ACCT_UDP_PORT;
        if (radiusip == INADDR_NONE) {
                req->dst_ipaddr = ip_getaddr("localhost");
@@ -308,7 +308,7 @@ static int do_packet(int allports, uint32_t nasaddr, const struct radutmp *u)
        else {
                req->dst_ipaddr = radiusip;
        }
-       if(!req->dst_ipaddr) 
+       if(!req->dst_ipaddr)
                req->dst_ipaddr = 0x7f000001;
        req->vps = NULL;
        secret = getsecret(req->dst_ipaddr);
index a0561ee..6df6267 100644 (file)
@@ -44,8 +44,8 @@ static const char rcsid[] = "$Id$";
 /*
  *  We keep the incoming requests in an array, indexed by ID.
  *
- *  Each array element contains a linked list of containers of 
- *  active requests, a count of the number of requests, and a time 
+ *  Each array element contains a linked list of containers of
+ *  active requests, a count of the number of requests, and a time
  *  at which the first request in the list must be serviced.
  */
 
@@ -197,7 +197,7 @@ int rl_init(void)
                request_list[i].request_count = 0;
                request_list[i].last_cleaned_list = 0;
        }
-       
+
 #ifdef WITH_RBTREE
        request_tree = rbtree_create(request_cmp, NULL, 0);
        if (!request_tree) {
@@ -236,7 +236,7 @@ void rl_delete(REQUEST *request)
 
        prev = ((REQNODE *) request->container)->prev;
        next = ((REQNODE *) request->container)->next;
-       
+
        id = request->packet->id;
 
        /*
@@ -250,7 +250,7 @@ void rl_delete(REQUEST *request)
        if (last_request == request) {
                last_request = rl_next(last_request);
        }
-       
+
 
        if (prev == NULL) {
                request_list[id].first_request = next;
@@ -263,7 +263,7 @@ void rl_delete(REQUEST *request)
        } else {
                next->prev = prev;
        }
-       
+
        free(request->container);
 
 #ifdef WITH_SNMP
@@ -386,7 +386,7 @@ void rl_add(REQUEST *request)
 /*
  *     Look up a particular request, using:
  *
- *     Request ID, request code, source IP, source port, 
+ *     Request ID, request code, source IP, source port,
  *
  *     Note that we do NOT use the request vector to look up requests.
  *
@@ -397,9 +397,9 @@ REQUEST *rl_find(RADIUS_PACKET *packet)
 {
 #ifdef WITH_RBTREE
        REQUEST myrequest;
-       
+
        myrequest.packet = packet;
-       
+
        return rbtree_finddata(request_tree, &myrequest);
 #else
        REQNODE *curreq;
@@ -471,17 +471,17 @@ REQUEST *rl_find_proxy(RADIUS_PACKET *packet)
        REQUEST myrequest, *maybe = NULL;
        RADIUS_PACKET myproxy;
        rbnode_t *node;
-       
+
        myrequest.proxy = &myproxy;
-       
+
        myproxy.id = packet->id;
-       
+
        /*
         *      FIXME: Look for BOTH src/dst stuff.
         */
        myproxy.dst_ipaddr = packet->src_ipaddr;
        myproxy.dst_port = packet->src_port;
-       
+
        pthread_mutex_lock(&proxy_mutex);
        node = rbtree_find(proxy_tree, &myrequest);
        if (node) {
@@ -493,7 +493,7 @@ REQUEST *rl_find_proxy(RADIUS_PACKET *packet)
 #else
        REQNODE *curreq = NULL;
        int id;
-       
+
        /*
         *      The Proxy RADIUS Id is completely independent
         *      of the original request Id.  We've got to root through
@@ -624,7 +624,7 @@ int rl_num_requests(void)
        for (id = 0; id < 256; id++) {
                request_count += request_list[id].request_count;
        }
-       
+
        return request_count;
 }
 
@@ -727,7 +727,7 @@ static int refresh_request(REQUEST *request, void *data)
                 */
                if (request->proxy && !request->proxy_reply) {
                        rad_assert(request->child_pid == NO_SUCH_CHILD_PID);
-                       
+
                        radlog(L_ERR, "Rejecting request %d due to lack of any response from home server %s:%d",
                               request->number,
                               client_name(request->packet->src_ipaddr),
@@ -749,7 +749,7 @@ static int refresh_request(REQUEST *request, void *data)
                                pthread_cancel(child_pid);
 #endif
                        } /* else no proxy reply, quietly fail */
-               
+
                        /*
                         *      Maybe we haven't killed it.  In that
                         *      case, print a warning.
@@ -824,7 +824,7 @@ static int refresh_request(REQUEST *request, void *data)
         *  It's not yet time to re-send this proxied request.
         */
        if (request->proxy_next_try > info->now) goto setup_timeout;
-       
+
        /*
         *  If the proxy retry count is zero, then
         *  we've sent the last try, and have NOT received
@@ -846,12 +846,12 @@ static int refresh_request(REQUEST *request, void *data)
         */
        request->proxy_try_count--;
        request->proxy_next_try = info->now + mainconfig.proxy_retry_delay;
-               
+
        /* Fix up Acct-Delay-Time */
        if (request->proxy->code == PW_ACCOUNTING_REQUEST) {
                VALUE_PAIR *delaypair;
                delaypair = pairfind(request->proxy->vps, PW_ACCT_DELAY_TIME);
-               
+
                if (!delaypair) {
                        delaypair = paircreate(PW_ACCT_DELAY_TIME, PW_TYPE_INTEGER);
                        if (!delaypair) {
@@ -861,7 +861,7 @@ static int refresh_request(REQUEST *request, void *data)
                        pairadd(&request->proxy->vps, delaypair);
                }
                delaypair->lvalue = info->now - request->proxy->timestamp;
-                       
+
                /* Must recompile the valuepairs to wire format */
                free(request->proxy->data);
                request->proxy->data = NULL;
@@ -1001,7 +1001,7 @@ struct timeval *rl_clean_list(time_t now)
         */
        if ((last_tv_ptr != NULL) &&
            (last_cleaned_list == now) &&
-           (tv.tv_sec != 0)) {         
+           (tv.tv_sec != 0)) {
                int i;
 
                /*
@@ -1011,7 +1011,7 @@ struct timeval *rl_clean_list(time_t now)
                 *
                 *  If there is NO previous request, go look for one.
                 */
-               if (!last_request) 
+               if (!last_request)
                        last_request = rl_next(last_request);
 
                /*
@@ -1022,10 +1022,10 @@ struct timeval *rl_clean_list(time_t now)
                 *  And only do this servicing, if we have a request
                 *  to service.
                 */
-               if (last_request) 
+               if (last_request)
                        for (i = 0; i < mainconfig.cleanup_delay; i++) {
                                REQUEST *next;
-                       
+
                                /*
                                 *  This function call MAY delete the
                                 *  request pointed to by 'last_request'.
@@ -1037,7 +1037,7 @@ struct timeval *rl_clean_list(time_t now)
                                /*
                                 *  Nothing to do any more, exit.
                                 */
-                               if (!last_request) 
+                               if (!last_request)
                                        break;
                        }
 
@@ -1072,7 +1072,7 @@ struct timeval *rl_clean_list(time_t now)
                 *  If we ARE proxying, then we can safely sleep
                 *  forever if we're told to NEVER send proxy retries
                 *  ourselves, until the NAS kicks us again.
-                * 
+                *
                 *  Otherwise, there are no outstanding requests, then
                 *  we can sleep forever.  This happens when we get
                 *  woken up with a bad packet.  It's discarded, so if
index 29510a3..78c4c1f 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * smux.c      SNMP support
  *
  * Version:    $Id$
@@ -150,7 +150,7 @@ smux_oid_dump(const char *prefix, oid *my_oid, size_t oid_len)
                        sprintf (buf + strlen (buf), "%s%d", first ? "" : ".", (int) my_oid[i]);
                        first = 0;
        }
-       DEBUG2 ("%s: %s", prefix, buf); 
+       DEBUG2 ("%s: %s", prefix, buf);
 }
 
 static int
@@ -214,7 +214,7 @@ smux_sock (void)
 #endif /* HAVE_SIN_LEN */
 
        sp = getservbyname ("smux", "tcp");
-       if (sp != NULL) 
+       if (sp != NULL)
                serv.sin_port = sp->s_port;
        else
                serv.sin_port = htons (SMUX_PORT_DEFAULT);
@@ -256,7 +256,7 @@ smux_getresp_send (oid objid[], size_t objid_len, long reqid, long errstat,
        /* Place holder h1 for complete sequence */
        ptr = asn_build_sequence (ptr, &len, (u_char) SMUX_GETRSP, 0);
        h1e = ptr;
+
        ptr = asn_build_int (ptr, &len,
                        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
                        &reqid, sizeof (reqid));
@@ -274,12 +274,12 @@ smux_getresp_send (oid objid[], size_t objid_len, long reqid, long errstat,
 
        h2 = ptr;
        /* Place holder h2 for one variable */
-       ptr = asn_build_sequence (ptr, &len, 
+       ptr = asn_build_sequence (ptr, &len,
                        (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
                        0);
        h2e = ptr;
 
-       ptr = snmp_build_var_op (ptr, objid, &objid_len, 
+       ptr = snmp_build_var_op (ptr, objid, &objid_len,
                        val_type, arg_len, arg, &len);
 
        /* Now variable size is known, fill in size */
@@ -289,7 +289,7 @@ smux_getresp_send (oid objid[], size_t objid_len, long reqid, long errstat,
        asn_build_sequence(h1,&length,(u_char)SMUX_GETRSP,ptr-h1e);
 
        DEBUG2("SMUX getresp send: %d", ptr - buf);
-       
+
        ret = send (rad_snmp.smux_fd, buf, (ptr - buf), 0);
 }
 
@@ -308,13 +308,13 @@ smux_var (char *ptr, int len, oid objid[], size_t *objid_len,
 
        /* Parse header. */
        ptr = asn_parse_header (ptr, &len, &type);
-       
+
        DEBUG2("SMUX var parse: type %d len %d", type, len);
        DEBUG2("SMUX var parse: type must be %d", (ASN_SEQUENCE | ASN_CONSTRUCTOR));
 
        /* Parse var option. */
        *objid_len = MAX_OID_LEN;
-       ptr = snmp_parse_var_op(ptr, objid, objid_len, &val_type, 
+       ptr = snmp_parse_var_op(ptr, objid, objid_len, &val_type,
                                &val_len, &val, &len);
 
        if (var_val_len)
@@ -466,7 +466,7 @@ smux_get (oid *reqid, size_t *reqid_len, int exact,
        /* Check */
        for (l = treelist; l; l=l->next) {
                subtree = l->data;
-               subresult = oid_compare_part (reqid, *reqid_len, 
+               subresult = oid_compare_part (reqid, *reqid_len,
                                subtree->name, subtree->name_len);
 
                /* Subtree matched. */
@@ -512,7 +512,7 @@ smux_get (oid *reqid, size_t *reqid_len, int exact,
 }
 
 static int
-smux_getnext (oid *reqid, size_t *reqid_len, int exact, 
+smux_getnext (oid *reqid, size_t *reqid_len, int exact,
                u_char *val_type, const void **val, size_t *val_len)
 {
        int j;
@@ -536,7 +536,7 @@ smux_getnext (oid *reqid, size_t *reqid_len, int exact,
        for (l = treelist; l; l=l->next) {
                subtree = l->data;
 
-               subresult = oid_compare_part (reqid, *reqid_len, 
+               subresult = oid_compare_part (reqid, *reqid_len,
                                subtree->name, subtree->name_len);
 
                 /* If request is in the tree. The agent has to make sure we
@@ -657,10 +657,10 @@ smux_parse_get (char *ptr, size_t len, int exact)
        int ret;
 
        DEBUG2 ("SMUX GET message parse: len %d", len);
-       
+
        /* Parse GET message header. */
        ptr = smux_parse_get_header (ptr, &len, &reqid);
-       
+
        /* Parse GET message object ID. We needn't the value come */
        ptr = smux_var (ptr, len, my_oid, &oid_len, NULL, NULL, NULL);
 
@@ -696,7 +696,7 @@ smux_parse_rrsp (char *ptr, int len)
 {
        char val;
        long errstat;
-       
+
        ptr = asn_parse_int (ptr, &len, &val, &errstat, sizeof (errstat));
 
        DEBUG2 ("SMUX_RRSP value: %d errstat: %ld", val, errstat);
@@ -706,7 +706,7 @@ smux_parse_rrsp (char *ptr, int len)
 static int
 smux_parse (char *ptr, int len)
 {
-       /* this buffer we'll use for SOUT message. We could allocate it with malloc and 
+       /* this buffer we'll use for SOUT message. We could allocate it with malloc and
                 save only static pointer/lenght, but IMHO static buffer is a faster solusion */
        static u_char sout_save_buff[SMUXMAXPKTSIZE];
        static int sout_save_len = 0;
@@ -870,24 +870,24 @@ smux_open(void)
 
        /* SMUX Open. */
        smux_proto_version = 0;
-       ptr = asn_build_int (ptr, &len, 
+       ptr = asn_build_int (ptr, &len,
                        (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
                        &smux_proto_version, sizeof (u_long));
 
        /* SMUX connection oid. */
        ptr = asn_build_objid (ptr, &len,
-                       (u_char) 
+                       (u_char)
                        (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
                        smux_oid, smux_oid_len);
 
        /* SMUX connection description. */
-       ptr = asn_build_string (ptr, &len, 
+       ptr = asn_build_string (ptr, &len,
                        (u_char)
                        (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
                        rad_progname, strlen (rad_progname));
 
        /* SMUX connection password. */
-       ptr = asn_build_string (ptr, &len, 
+       ptr = asn_build_string (ptr, &len,
                        (u_char)
                        (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
                        rad_snmp.smux_password, strlen(rad_snmp.smux_password));
@@ -929,13 +929,13 @@ smux_register(void)
 
                /* Priority. */
                priority = -1;
-               ptr = asn_build_int (ptr, &len, 
+               ptr = asn_build_int (ptr, &len,
                                (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
                                &priority, sizeof (u_long));
 
                /* Operation. */
                operation = rad_snmp.snmp_write_access ? 2 : 1; /* Register R/O or R/W */
-               ptr = asn_build_int (ptr, &len, 
+               ptr = asn_build_int (ptr, &len,
                                (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
                                &operation, sizeof (u_long));
 
index 39775a5..154aaab 100644 (file)
@@ -153,12 +153,12 @@ static pthread_mutex_t fork_mutex;
  *     A mapping of configuration file names to internal integers
  */
 static const CONF_PARSER thread_config[] = {
-       { "start_servers",           PW_TYPE_INTEGER, 0, &thread_pool.start_threads,           "5" }, 
-       { "max_servers",             PW_TYPE_INTEGER, 0, &thread_pool.max_threads,             "32" }, 
-       { "min_spare_servers",       PW_TYPE_INTEGER, 0, &thread_pool.min_spare_threads,       "3" }, 
-       { "max_spare_servers",       PW_TYPE_INTEGER, 0, &thread_pool.max_spare_threads,       "10" }, 
-       { "max_requests_per_server", PW_TYPE_INTEGER, 0, &thread_pool.max_requests_per_thread, "0" }, 
-       { "cleanup_delay",           PW_TYPE_INTEGER, 0, &thread_pool.cleanup_delay,           "5" }, 
+       { "start_servers",           PW_TYPE_INTEGER, 0, &thread_pool.start_threads,           "5" },
+       { "max_servers",             PW_TYPE_INTEGER, 0, &thread_pool.max_threads,             "32" },
+       { "min_spare_servers",       PW_TYPE_INTEGER, 0, &thread_pool.min_spare_threads,       "3" },
+       { "max_spare_servers",       PW_TYPE_INTEGER, 0, &thread_pool.max_spare_threads,       "10" },
+       { "max_requests_per_server", PW_TYPE_INTEGER, 0, &thread_pool.max_requests_per_thread, "0" },
+       { "cleanup_delay",           PW_TYPE_INTEGER, 0, &thread_pool.cleanup_delay,           "5" },
        { NULL, -1, 0, NULL, NULL }
 };
 
@@ -314,7 +314,7 @@ static void request_dequeue(REQUEST **request, RAD_REQUEST_FUNP *fun)
                struct timeval tv;
 #ifdef HAVE_PTHREAD_SIGMASK
                sigset_t set, old_set;
-               
+
                /*
                 *      Block a large number of signals which could
                 *      cause the select to return EINTR
@@ -340,7 +340,7 @@ static void request_dequeue(REQUEST **request, RAD_REQUEST_FUNP *fun)
                for (count = 0; count < 10; count++) {
                        tv.tv_sec = 0;
                        tv.tv_usec = 10000; /* sleep for 10 milliseconds */
-                       
+
                        /*
                         *      Portable sleep that's thread-safe.
                         *
@@ -352,7 +352,7 @@ static void request_dequeue(REQUEST **request, RAD_REQUEST_FUNP *fun)
                                ok = TRUE;
                                break;
                        }
-               }                       
+               }
 
 #ifdef HAVE_PTHREAD_SIGMASK
                /*
@@ -400,7 +400,7 @@ static void *request_handler_thread(void *arg)
        sigaddset(&set, SIGTERM);
        pthread_sigmask(SIG_BLOCK, &set, NULL);
 #endif
-       
+
        /*
         *      Loop forever, until told to exit.
         */
@@ -453,7 +453,7 @@ static void *request_handler_thread(void *arg)
                DEBUG2("Thread %d handling request %d, (%d handled so far)",
                       self->thread_num, self->request->number,
                       self->request_count);
-               
+
                /*
                 *      Respond, and reset request->child_pid
                 */
@@ -505,7 +505,7 @@ static void delete_thread(THREAD_HANDLE *handle)
        } else {
                prev->next = next;
        }
-  
+
        if (next == NULL) {
                rad_assert(thread_pool.tail == handle);
                thread_pool.tail = prev;
@@ -570,7 +570,7 @@ static THREAD_HANDLE *spawn_thread(time_t now)
         */
        pthread_attr_init(&attr);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-       
+
        /*
         *      Create the thread detached, so that it cleans up it's
         *      own memory when it exits.
@@ -622,11 +622,11 @@ static THREAD_HANDLE *spawn_thread(time_t now)
  *      until all threads are finished handling requests.  This returns
  *      the number of active threads to 'radiusd.c'.
  */
-int total_active_threads(void) 
+int total_active_threads(void)
 {
         int rcode = 0;
        THREAD_HANDLE *handle;
-       
+
        for (handle = thread_pool.head; handle != NULL; handle = handle->next){
                if (handle->request != NULL) {
                        rcode ++;
@@ -749,8 +749,8 @@ int thread_pool_addrequest(REQUEST *request, RAD_REQUEST_FUNP fun)
         */
        if (thread_pool.active_threads == thread_pool.total_threads) {
                if (spawn_thread(request->timestamp) == NULL) {
-                       radlog(L_INFO, 
-                              "The maximum number of threads (%d) are active, cannot spawn new thread to handle request", 
+                       radlog(L_INFO,
+                              "The maximum number of threads (%d) are active, cannot spawn new thread to handle request",
                               thread_pool.max_threads);
                        return 0;
                }
@@ -904,7 +904,7 @@ int thread_pool_clean(time_t now)
                        }
                }
        }
-  
+
        /*
         *      Otherwise everything's kosher.  There are not too few,
         *      or too many spare threads.  Exit happily.
@@ -920,12 +920,12 @@ static int exec_initialized = FALSE;
 void rad_exec_init(void)
 {
        int i;
-       
+
        /*
         *      Initialize the mutex used to remember calls to fork.
         */
        pthread_mutex_init(&fork_mutex, NULL);
-       
+
        /*
         *      Initialize the data structure where we remember the
         *      mappings of thread ID && child PID to exit status.
@@ -952,7 +952,7 @@ void rad_exec_init(void)
 pid_t rad_fork(int exec_wait)
 {
        sigset_t set;
-       pid_t child_pid;        
+       pid_t child_pid;
 
        /*
         *      The thread is NOT interested in waiting for the exit
@@ -998,7 +998,7 @@ pid_t rad_fork(int exec_wait)
                 */
                i = PID_2_ARRAY(child_pid);
                found = -1;
-               
+
                /*
                 *      We may have multiple threads trying to find an
                 *      empty position, so we lock the array until
@@ -1195,7 +1195,7 @@ int rad_savepid(pid_t pid, int status)
                         *      That is, we've forked, and the forker
                         *      is waiting nearly forever
                         */
-                       return 0;               
+                       return 0;
                }
 
                i++;
index 368b8fe..a1da599 100644 (file)
@@ -138,7 +138,7 @@ static int day_fill(char *bitmap, const char *tm)
        for (hr = tm; *hr; hr++)
                if (isdigit((int) *hr))
                        break;
-       if (hr == tm) 
+       if (hr == tm)
                tm = "Al";
 
        timestr_debug("dayfill: hr %s    tm %s\n", hr, tm);
@@ -249,7 +249,7 @@ int timestr_match(char *tmstr, time_t t)
                        break;
        }
 
-       if (tot == 0) 
+       if (tot == 0)
                return -1;
 
        return (i == now) ? 0 : tot;
index e3378ed..0ef2cb1 100644 (file)
@@ -71,7 +71,7 @@ void (*reset_signal(int signo, void (*func)(int)))(int)
                return SIG_ERR;
        return oact.sa_handler;
 #else
-       
+
        /*
         *      re-set by calling the 'signal' function, which
         *      may cause infinite recursion and core dumps due to
@@ -89,7 +89,7 @@ void (*reset_signal(int signo, void (*func)(int)))(int)
  */
 struct request_data_t {
        request_data_t  *next;
-       
+
        void            *unique_ptr;
        int             unique_int;
        void            *opaque;
@@ -188,20 +188,20 @@ void request_free(REQUEST **request_ptr)
         *      blow up!
         */
        rad_assert(request->child_pid == NO_SUCH_CHILD_PID);
-       
-       if (request->packet) 
+
+       if (request->packet)
                rad_free(&request->packet);
 
-       if (request->proxy) 
+       if (request->proxy)
                rad_free(&request->proxy);
 
-       if (request->reply) 
+       if (request->reply)
                rad_free(&request->reply);
 
-       if (request->proxy_reply) 
+       if (request->proxy_reply)
                rad_free(&request->proxy_reply);
 
-       if (request->config_items) 
+       if (request->config_items)
                pairfree(&request->config_items);
 
        request->username = NULL;
@@ -306,7 +306,7 @@ int rad_mkdir(char *directory, int mode)
 void *rad_malloc(size_t size)
 {
        void *ptr = malloc(size);
-       
+
        if (ptr == NULL) {
                radlog(L_ERR|L_CONS, "no memory");
                exit(1);
@@ -428,7 +428,7 @@ void rfc_clean(RADIUS_PACKET *packet)
                vps = packet->vps;
                packet->vps = NULL;
                break;
-               
+
                /*
                 *      Accounting responses can only contain
                 *      Proxy-State and VSA's.  Note that we do NOT
@@ -485,7 +485,7 @@ void rfc_clean(RADIUS_PACKET *packet)
        if (request->options & RAD_REQUEST_OPTION_REJECTED) {
                return;
        }
-       
+
        DEBUG2("Server rejecting request %d.", request->number);
        switch (request->packet->code) {
                /*
@@ -502,7 +502,7 @@ void rfc_clean(RADIUS_PACKET *packet)
                 *  reject message sent.
                 */
                case PW_AUTHENTICATION_REQUEST:
-                       request->reply->code = PW_AUTHENTICATION_REJECT; 
+                       request->reply->code = PW_AUTHENTICATION_REJECT;
 
                        /*
                         *  Perform RFC limitations on outgoing replies.
@@ -517,7 +517,7 @@ void rfc_clean(RADIUS_PACKET *packet)
                                pairadd(&(request->reply->vps), vps);
                        break;
        }
-       
+
        /*
         *  If a reply exists, send it.
         */
index 1abfefd..3d1265d 100644 (file)
@@ -168,7 +168,7 @@ int paircompare_register(int attr, int compare_attr, RAD_COMPARE_FUNC fun, void
 
        c = rad_malloc(sizeof(struct cmp));
 
-       if (compare_attr < 0) 
+       if (compare_attr < 0)
                compare_attr = attr;
        c->compare = fun;
        c->attribute = attr;
@@ -309,7 +309,7 @@ int paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR **r
                        rcode = radius_xlat(buffer, sizeof(buffer),
                                            check_item->strvalue,
                                            req, NULL);
-                       
+
                        /*
                         *      Parse the string into a new value.
                         */
@@ -344,7 +344,7 @@ int paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR **r
                        case T_OP_GT:
                                if (compare <= 0) result = -1;
                                break;
-                   
+
                        case T_OP_LE:
                                if (compare > 0) result = -1;
                                break;
@@ -455,7 +455,7 @@ static int portcmp(void *instance,
                        return 0;
                }
                s = strtok(NULL, ",");
-       } 
+       }
 
        return -1;
 }
@@ -463,7 +463,7 @@ static int portcmp(void *instance,
 /*
  *     Compare prefix/suffix.
  *
- *     If they compare: 
+ *     If they compare:
  *     - if PW_STRIP_USER_NAME is present in check_pairs,
  *       strip the username of prefix/suffix.
  *     - if PW_STRIP_USER_NAME is not present in check_pairs,
@@ -479,7 +479,7 @@ static int presufcmp(void *instance,
        char rest[MAX_STRING_LEN];
        int len, namelen;
        int ret = -1;
-       
+
        instance = instance;
        reply_pairs = reply_pairs; /* shut the compiler up */
 
@@ -541,7 +541,7 @@ static int presufcmp(void *instance,
  *     and have one less system call to do.
  */
 static int timecmp(void *instance,
-                  REQUEST *req UNUSED, 
+                  REQUEST *req UNUSED,
                   VALUE_PAIR *request, VALUE_PAIR *check,
        VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
 {
@@ -721,7 +721,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                        rcode = radius_xlat(buffer, sizeof(buffer),
                                            i->strvalue,
                                            req, NULL);
-                       
+
                        /*
                         *      Parse the string into a new value.
                         */
@@ -730,7 +730,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
 
                found = pairfind(*to, i->attribute);
                switch (i->operator) {
-                       
+
                        /*
                         *  If a similar attribute is found,
                         *  delete it.
@@ -741,7 +741,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                                    (strcmp((char *)found->strvalue,
                                            (char *)i->strvalue) == 0)){
                                        pairdelete(to, found->attribute);
-                                       
+
                                        /*
                                         *      'tailto' may have been
                                         *      deleted...
@@ -755,7 +755,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                        tailfrom = i;
                        continue;
                        break;
-                       
+
                        /*
                         *  Add it, if it's not already there.
                         */
@@ -765,7 +765,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                                continue; /* with the loop */
                        }
                        break;
-                       
+
                        /*
                         *  If a similar attribute is found,
                         *  replace it with the new one.  Otherwise,
@@ -781,14 +781,14 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                                continue;
                        }
                        break;
-                       
+
                        /*
                         *  FIXME: Add support for <=, >=, <, >
                         *
                         *  which will mean (for integers)
                         *  'make the attribute the smaller, etc'
                         */
-                       
+
                        /*
                         *  Add the new element to the list, even
                         *  if similar ones already exist.
@@ -797,12 +797,12 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                case T_OP_ADD:          /* += */
                        break;
                }
-               
+
                if (tailfrom)
                        tailfrom->next = next;
                else
                        *from = next;
-               
+
                /*
                 *      If ALL of the 'to' attributes have been deleted,
                 *      then ensure that the 'tail' is updated to point
index 4e9fa93..745a3f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * xlat.c      Translate strings.  This is the first version of xlat 
+ * xlat.c      Translate strings.  This is the first version of xlat
  *             incorporated to RADIUS
  *
  * Version:    $Id$
@@ -22,7 +22,7 @@
  * Copyright 2000  Alan DeKok <aland@ox.org>
  */
 
-static const char rcsid[] = 
+static const char rcsid[] =
 "$Id$";
 
 #include       "autoconf.h"
@@ -154,7 +154,7 @@ static int decode_attr_packet(const char *from, char **to, int freespace,
 {
        DICT_ATTR *tmpda;
        VALUE_PAIR *vp;
-       
+
        tmpda = dict_attrbyname(from);
        if (!tmpda) return 0;
 
@@ -205,7 +205,7 @@ static int decode_attr_vps(const char *from, char **to, int freespace,
 {
        DICT_ATTR *tmpda;
        VALUE_PAIR *vp;
-       
+
        tmpda = dict_attrbyname(from);
        if (!tmpda) return 0;
 
@@ -242,10 +242,10 @@ static void decode_attribute(const char **from, char **to, int freespace,
 
        *q = '\0';
 
-       /* 
-        * Skip the '{' at the front of 'p' 
-        * Increment open braces 
-        */ 
+       /*
+        * Skip the '{' at the front of 'p'
+        * Increment open braces
+        */
        p++;
        openbraces++;
 
@@ -266,7 +266,7 @@ static void decode_attribute(const char **from, char **to, int freespace,
                                openbraces++;
                                *pa++ = *p++;
                                break;
-                               
+
                        case '}':
                                openbraces--;
                                if (openbraces == *open) {
@@ -465,7 +465,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                        /*
                         * We check if we're inside an open brace.  If we are
                         * then we assume this brace is NOT literal, but is
-                        * a closing brace and apply it 
+                        * a closing brace and apply it
                         */
                        if ((c == '}') && openbraces) {
                                openbraces--;
index 069ff98..46e1375 100644 (file)
@@ -42,7 +42,7 @@ typedef struct rlm_acct_unique_list_t {
 
 typedef struct rlm_acct_unique_t {
        char                    *key;
-       rlm_acct_unique_list_t *head;           
+       rlm_acct_unique_list_t *head;
 } rlm_acct_unique_t;
 
 static CONF_PARSER module_config[] = {
@@ -55,8 +55,8 @@ static CONF_PARSER module_config[] = {
  */
 static void unique_add_attr(rlm_acct_unique_t *inst, DICT_ATTR *dattr)
 {
-       rlm_acct_unique_list_t  *new;           
-       
+       rlm_acct_unique_list_t  *new;
+
        new = rad_malloc(sizeof(*new));
        memset(new, 0, sizeof(*new));
 
@@ -74,14 +74,14 @@ static int unique_parse_key(rlm_acct_unique_t *inst, char *key)
 {
        char *ptr, *prev, *keyptr;
        DICT_ATTR *a;
-       
+
        keyptr = key;
        ptr = key;
        prev = key;
-       
+
        /* Let's remove spaces in the string */
        rad_rmspace(key);
-       
+
        ptr = key;
        while(ptr) {
                switch(*ptr) {
@@ -107,9 +107,9 @@ static int unique_parse_key(rlm_acct_unique_t *inst, char *key)
                        continue;
                        break;
                }
-               ptr++;  
-       }       
-       
+               ptr++;
+       }
+
        return 0;
 }
 
@@ -140,24 +140,24 @@ static int unique_instantiate(CONF_SECTION *conf, void **instance)
         */
        inst = rad_malloc(sizeof(*inst));
        memset(inst, 0, sizeof(*inst));
-       
+
        if (cf_section_parse(conf, inst, module_config) < 0) {
                free(inst);
                return -1;
        }
 
-       /* 
-        *      Check to see if 'key' has something in it 
-        */     
+       /*
+        *      Check to see if 'key' has something in it
+        */
        if (!inst->key) {
                radlog(L_ERR,"rlm_acct_unique: Cannot find value for 'key' in configuration.");
                free(inst);
                return -1;
        }
 
-       /* 
+       /*
         * Go thru the list of keys and build attr_list;
-        */     
+        */
        if (unique_parse_key(inst, inst->key) < 0) {
                unique_detach(inst); /* clean up memory */
                return -1;
@@ -182,13 +182,13 @@ static int add_unique_id(void *instance, REQUEST *request)
        int length, left;
        rlm_acct_unique_t *inst = instance;
        rlm_acct_unique_list_t *cur;
-  
+
        /* initialize variables */
        p = buffer;
        left = BUFFERLEN;
        length = 0;
        cur = inst->head;
-       
+
        /*
         *  A unique ID already exists: don't do anything.
         */
@@ -196,7 +196,7 @@ static int add_unique_id(void *instance, REQUEST *request)
        if (vp) {
                return RLM_MODULE_NOOP;
        }
-       
+
        /* loop over items to create unique identifiers */
        while (cur) {
                vp = pairfind(request->packet->vps, cur->dattr->attr);
@@ -210,25 +210,25 @@ static int add_unique_id(void *instance, REQUEST *request)
                cur = cur->next;
        }
        buffer[BUFFERLEN-left-1] = '\0';
-       
+
        DEBUG2("rlm_acct_unique: Hashing '%s'", buffer);
        /* calculate a 'unique' string based on the above information */
        librad_md5_calc(md5_buf, (u_char *)buffer, (p - buffer));
        sprintf(buffer, "%02x%02x%02x%02x%02x%02x%02x%02x",
                md5_buf[0], md5_buf[1], md5_buf[2], md5_buf[3],
                md5_buf[4], md5_buf[5], md5_buf[6], md5_buf[7]);
-       
+
        DEBUG2("rlm_acct_unique: Acct-Unique-Session-ID = \"%s\".", buffer);
-       
+
        vp = pairmake("Acct-Unique-Session-Id", buffer, 0);
        if (!vp) {
                radlog(L_ERR, "%s", librad_errstr);
                return RLM_MODULE_FAIL;
        }
-       
+
        /* add the (hopefully) unique session ID to the packet */
        pairadd(&request->packet->vps, vp);
-       
+
        return RLM_MODULE_OK;
 }
 
index 6b8ee8f..ddc6648 100644 (file)
@@ -92,7 +92,7 @@ static int str2rcode(const char *s)
 static int always_instantiate(CONF_SECTION *conf, void **instance)
 {
        rlm_always_t *data;
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -110,7 +110,7 @@ static int always_instantiate(CONF_SECTION *conf, void **instance)
                free(data);
                return -1;
        }
-       
+
        /*
         *      Convert the rcode string to an int, and get rid of it
         */
@@ -161,7 +161,7 @@ static int always_detach(void *instance)
 }
 
 module_t rlm_always = {
-       "always",       
+       "always",
        RLM_TYPE_THREAD_SAFE,           /* type */
        NULL,                           /* initialization */
        always_instantiate,             /* instantiation */
index bae2bf0..b8d9e82 100644 (file)
@@ -8,12 +8,12 @@
  *   This program is is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License, version 2 if the
  *   License as published by the Free Software Foundation.
- * 
+ *
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *   GNU General Public License for more details.
- *  
+ *
  *   You should have received a copy of the GNU General Public License
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -62,7 +62,7 @@ static int check_pair(VALUE_PAIR *check_item, VALUE_PAIR *reply_item,
                     default:
                        radlog(L_ERR, "Invalid operator for item %s: "
                        "reverting to '=='", check_item->name);
-                       
+
                case T_OP_CMP_TRUE:       /* comp always == 0 */
                case T_OP_CMP_FALSE:      /* comp always == 1 */
                case T_OP_CMP_EQ:
@@ -96,7 +96,7 @@ static int check_pair(VALUE_PAIR *check_item, VALUE_PAIR *reply_item,
                        ++*(fa);
                    }
                    break;
-                               
+
                case T_OP_LE:
                    if (comp <= 0) {
                        ++*(pa);
@@ -195,17 +195,17 @@ static int getattrsfile(const char *filename, PAIR_LIST **pair_list)
        if (rcode < 0) {
                return -1;
        }
-       
+
        /*
         * Walk through the 'attrs' file list.
         */
-       
+
        entry = attrs;
        while (entry) {
-               
+
                entry->check = entry->reply;
                entry->reply = NULL;
-       
+
                for (vp = entry->check; vp != NULL; vp = vp->next) {
 
                    /*
@@ -223,7 +223,7 @@ static int getattrsfile(const char *filename, PAIR_LIST **pair_list)
                                  entry->name);
                    }
                }
-           
+
                entry = entry->next;
        }
 
@@ -297,7 +297,7 @@ static int attr_filter_authorize(void *instance, REQUEST *request)
         */
        realmpair = pairfind(request_pairs, PW_REALM);
        if(!realmpair) {
-               /*    Can't find a realm, so no filtering of attributes 
+               /*    Can't find a realm, so no filtering of attributes
                 *    or should we use a DEFAULT entry?
                 *    For now, just return NOTFOUND. (maybe NOOP?)
                 */
@@ -343,12 +343,12 @@ static int attr_filter_authorize(void *instance, REQUEST *request)
 
                }
 
-                /* 
+                /*
                  * Iterate through the reply items, comparing each reply item
-                * to every rule, then moving it to the reply_tmp list 
+                * to every rule, then moving it to the reply_tmp list
                 * only if it matches all rules for that attribute.
                 * IE, Idle-Timeout is moved only if it matches all rules that
-                 * describe an Idle-Timeout.  
+                 * describe an Idle-Timeout.
                  */
 
                for(reply_item = *reply_items;
@@ -367,7 +367,7 @@ static int attr_filter_authorize(void *instance, REQUEST *request)
 
                            compare = simplepaircmp(request, reply_item,
                                                    check_item);
-                           check_pair(check_item, reply_item, compare, 
+                           check_pair(check_item, reply_item, compare,
                                       &pass, &fail);
                        }
 
@@ -487,7 +487,7 @@ static int attr_filter_accounting(void *instance, REQUEST *request)
 
                    /* reset the pass/fail vars for each packet->vp. */
                    pass = fail = 0;
-               
+
                    /* reset the check_item pointer to beginning of the list */
                    check_item = pl->check;
 
@@ -512,7 +512,7 @@ static int attr_filter_accounting(void *instance, REQUEST *request)
        }
        pairfree (&request->packet->vps);
        request->packet->vps = send_tmp;
-       
+
        /*
         * See if we succeeded. If we didn't find the realm,
         * then exit from the module.
@@ -737,7 +737,7 @@ static int attr_filter_postproxy(void *instance, REQUEST *request)
 
                            compare = simplepaircmp(request, reply_item,
                                                    check_item);
-                           check_pair(check_item, reply_item, compare, 
+                           check_pair(check_item, reply_item, compare,
                                       &pass, &fail);
                        }
 
@@ -774,7 +774,7 @@ static int attr_filter_postproxy(void *instance, REQUEST *request)
 
        return RLM_MODULE_UPDATED;
 }
-               
+
 /*
  *     Clean up.
  */
index 6c22e1d..9a5c769 100644 (file)
@@ -54,7 +54,7 @@ typedef struct rlm_attr_rewrite_t {
        char searchin;          /* The same as above just coded as a number for speed */
        char *replace;          /* The replacement */
        int replace_len;        /* The length of the replacement string */
-       int  append;            /* Switch to control append mode (1,0) */ 
+       int  append;            /* Switch to control append mode (1,0) */
        int  nocase;            /* Ignore case */
        int  new_attr;          /* Boolean. Do we create a new attribute or not? */
        int  num_matches;       /* Maximum number of matches */
@@ -80,7 +80,7 @@ static int attr_rewrite_instantiate(CONF_SECTION *conf, void **instance)
        rlm_attr_rewrite_t *data;
        DICT_ATTR *dattr;
        char *instance_name = NULL;
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -100,7 +100,7 @@ static int attr_rewrite_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        /*
-        *      Discover the attribute number of the key. 
+        *      Discover the attribute number of the key.
         */
        if (data->attribute == NULL) {
                radlog(L_ERR, "rlm_attr_rewrite: 'attribute' must be set.");
@@ -155,10 +155,10 @@ static int attr_rewrite_instantiate(CONF_SECTION *conf, void **instance)
        instance_name = cf_section_name2(conf);
        if (instance_name != NULL)
                data->name = strdup(instance_name);
-       
-       
+
+
        *instance = data;
-       
+
        return 0;
 }
 
@@ -276,12 +276,12 @@ do_again:
                        len = pmatch.rm_so;
                        if (data->append) {
                                len = len + (pmatch.rm_eo - pmatch.rm_so);
-                       } 
+                       }
                        counter += len;
                        if (counter >= MAX_STRING_LEN) {
                                regfree(&preg);
                                DEBUG2("rlm_attr_rewrite: Replacement out of limits for attribute %s with value '%s'",
-                                               data->attribute, attr_vp->strvalue);    
+                                               data->attribute, attr_vp->strvalue);
                                return ret;
                        }
 
@@ -303,12 +303,12 @@ do_again:
                        if (counter >= MAX_STRING_LEN) {
                                regfree(&preg);
                                DEBUG2("rlm_attr_rewrite: Replacement out of limits for attribute %s with value '%s'",
-                                               data->attribute, attr_vp->strvalue);    
+                                               data->attribute, attr_vp->strvalue);
                                return ret;
                        }
                        if (replace_len){
                                strncpy(ptr, replace_STR, replace_len);
-                               ptr += replace_len;     
+                               ptr += replace_len;
                        }
                }
                regfree(&preg);
@@ -316,7 +316,7 @@ do_again:
                counter += len;
                if (counter >= MAX_STRING_LEN){
                        DEBUG2("rlm_attr_rewrite: Replacement out of limits for attribute %s with value '%s'",
-                                       data->attribute, attr_vp->strvalue);    
+                                       data->attribute, attr_vp->strvalue);
                        return ret;
                }
                strncpy(ptr, ptr2, len);
@@ -361,7 +361,7 @@ to_do_again:
                DEBUG2("rlm_attr_rewrite: Added attribute %s with value '%s'",data->attribute,replace_STR);
                ret = RLM_MODULE_OK;
        }
-                               
+
 
        return ret;
 }
@@ -412,7 +412,7 @@ static int attr_rewrite_detach(void *instance)
                free(data->attribute);
        if (data->search)
                free(data->search);
-       if (data->replace)      
+       if (data->replace)
                free(data->replace);
        if (data->name)
                free(data->name);
@@ -431,7 +431,7 @@ static int attr_rewrite_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_attr_rewrite = {
-       "attr_rewrite", 
+       "attr_rewrite",
        RLM_TYPE_THREAD_UNSAFE,         /* type */
        NULL,                           /* initialization */
        attr_rewrite_instantiate,               /* instantiation */
index cdeb4da..6d93b14 100644 (file)
@@ -40,7 +40,7 @@ static const char rcsid[] = "$Id$";
 
 static int chap_authorize(void *instance, REQUEST *request)
 {
-       
+
        /* quiet the compiler */
        instance = instance;
        request = request;
@@ -54,13 +54,13 @@ static int chap_authorize(void *instance, REQUEST *request)
                DEBUG2("  rlm_chap: WARNING: Auth-Type already set.  Not setting to CHAP");
                return RLM_MODULE_NOOP;
        }
-       
+
        DEBUG("  rlm_chap: Setting 'Auth-Type := CHAP'");
        pairadd(&request->config_items,
                pairmake("Auth-Type", "CHAP", T_OP_EQ));
        return RLM_MODULE_OK;
 }
-       
+
 
 /*
  *     Find the named user in this modules database.  Create the set
@@ -102,7 +102,7 @@ static int chap_authenticate(void *instance, REQUEST *request)
        /*
         *      Don't print out the CHAP password here.  It's binary crap.
         */
-       DEBUG("  rlm_chap: login attempt by \"%s\" with CHAP password", 
+       DEBUG("  rlm_chap: login attempt by \"%s\" with CHAP password",
                request->username->strvalue);
 
        if ((passwd_item = pairfind(request->config_items, PW_PASSWORD)) == NULL){
@@ -115,9 +115,9 @@ static int chap_authenticate(void *instance, REQUEST *request)
 
        DEBUG("  rlm_chap: Using clear text password %s for user %s authentication.",
              passwd_item->strvalue, request->username->strvalue);
-       
+
        rad_chap_encode(request->packet,pass_str,request->password->strvalue[0],passwd_item);
-       
+
        if (memcmp(pass_str+1,request->password->strvalue+1,CHAP_VALUE_LENGTH) != 0){
                DEBUG("  rlm_chap: Pasword check failed");
                snprintf(module_fmsg,sizeof(module_fmsg),"rlm_chap: Wrong user password");
@@ -141,7 +141,7 @@ static int chap_authenticate(void *instance, REQUEST *request)
  *     is single-threaded.
  */
 module_t rlm_chap = {
-       "CHAP", 
+       "CHAP",
        0,                              /* type */
        NULL,                           /* initialization */
        NULL,                           /* instantiation */
index f437e9d..1569181 100644 (file)
 #ifdef HAVE_REGEX_H
 #      include <regex.h>
 #endif
-#ifndef REG_EXTENDED 
+#ifndef REG_EXTENDED
 #define REG_EXTENDED (0)
 #endif
 
-#ifndef REG_NOSUB 
+#ifndef REG_NOSUB
 #define REG_NOSUB (0)
 #endif
 /*
@@ -117,7 +117,7 @@ static int checkval_instantiate(CONF_SECTION *conf, void **instance)
                { "binary", PW_TYPE_OCTETS },
                { NULL, 0 }
        };
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -166,7 +166,7 @@ static int checkval_instantiate(CONF_SECTION *conf, void **instance)
                return -1;
        }
        data->item_attr = dattr->attr;
-       
+
        /*
         *      Add the check attribute name to the dictionary
         *      if it does not already exists. dict_addattr() handles that
@@ -198,7 +198,7 @@ static int checkval_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        *instance = data;
-       
+
        return 0;
 }
 
@@ -218,7 +218,7 @@ static int do_checkval(void *instance, REQUEST *request)
        /*
        *      Look for the check item
        */
-       
+
        if (!(item_vp = pairfind(request->packet->vps, data->item_attr))){
                DEBUG2("rlm_checkval: Could not find item named %s in request", data->item_name);
                if (data->notfound_reject)
@@ -259,7 +259,7 @@ static int do_checkval(void *instance, REQUEST *request)
                        }
                }
                else{   /* Integer or Date */
-       
+
                        if (item_vp->lvalue == chk_vp->lvalue)
                                ret = RLM_MODULE_OK;
                        else
@@ -278,7 +278,7 @@ static int do_checkval(void *instance, REQUEST *request)
                                regerror(err, &reg,err_msg, MAX_STRING_LEN);
                                DEBUG("rlm_checkval: regcomp() returned error: %s", err_msg);
                                return RLM_MODULE_FAIL;
-                       } 
+                       }
                        if (regexec(&reg, (char *)item_vp->strvalue,0, NULL, 0) == 0)
                                ret = RLM_MODULE_OK;
                        else
@@ -294,7 +294,7 @@ static int do_checkval(void *instance, REQUEST *request)
                        char module_fmsg[MAX_STRING_LEN];
                        VALUE_PAIR *module_fmsg_vp;
 
-                       snprintf(module_fmsg,sizeof(module_fmsg), 
+                       snprintf(module_fmsg,sizeof(module_fmsg),
                                "rlm_checkval: Could not find item named %s in request", data->item_name);
                        module_fmsg_vp = pairmake("Module-Failure-Message", module_fmsg, T_OP_EQ);
                        pairadd(&request->packet->vps, module_fmsg_vp);
@@ -336,7 +336,7 @@ static int checkval_accounting(void *instance, REQUEST *request)
  *     is single-threaded.
  */
 module_t rlm_checkval = {
-       "checkval",     
+       "checkval",
        0,              /* type */
        NULL,                           /* initialization */
        checkval_instantiate,           /* instantiation */
index 1218d8d..7480475 100644 (file)
@@ -130,8 +130,8 @@ static int counter_detach(void *instance);
 /*
  *     See if the counter matches.
  */
-static int counter_cmp(void *instance, 
-                      REQUEST *req UNUSED, 
+static int counter_cmp(void *instance,
+                      REQUEST *req UNUSED,
                       VALUE_PAIR *request, VALUE_PAIR *check,
                       VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
 {
@@ -174,7 +174,7 @@ static int add_defaults(rlm_counter_t *data)
        datum time_datum;
        const char *default1 = "DEFAULT1";
        const char *default2 = "DEFAULT2";
-       
+
        DEBUG2("rlm_counter: add_defaults: Start");
 
        key_datum.dptr = (char *) default1;
@@ -232,7 +232,7 @@ static int reset_db(rlm_counter_t *data)
         */
        ret = add_defaults(data);
        if (ret != RLM_MODULE_OK)
-               return ret;     
+               return ret;
 
        DEBUG2("rlm_counter: reset_db ended");
 
@@ -298,7 +298,7 @@ static int find_next_reset(rlm_counter_t *data, time_t timeval)
                return -1;
        }
        strftime(sNextTime, sizeof(sNextTime),"%Y-%m-%d %H:%M:%S",tm);
-       DEBUG2("rlm_counter: Current Time: %d [%s], Next reset %d [%s]", 
+       DEBUG2("rlm_counter: Current Time: %d [%s], Next reset %d [%s]",
                (int)timeval,sCurrentTime,(int)data->reset_time,sNextTime);
 
        return ret;
@@ -328,7 +328,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
        datum time_datum;
        const char *default1 = "DEFAULT1";
        const char *default2 = "DEFAULT2";
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -350,7 +350,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
        cache_size = data->cache_size;
 
        /*
-        *      Discover the attribute number of the key. 
+        *      Discover the attribute number of the key.
         */
        if (data->key_name == NULL) {
                radlog(L_ERR, "rlm_counter: 'key' must be set.");
@@ -365,9 +365,9 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
                return -1;
        }
        data->key_attr = dattr->attr;
-       
+
        /*
-        *      Discover the attribute number of the counter. 
+        *      Discover the attribute number of the counter.
         */
        if (data->count_attribute == NULL) {
                radlog(L_ERR, "rlm_counter: 'count-attribute' must be set.");
@@ -434,7 +434,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
                        return -1;
                }
                data->service_val = dval->value;
-       }       
+       }
 
        /*
         * Find when to reset the database.
@@ -507,7 +507,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
                key_datum.dptr = (char *)default2;
                key_datum.dsize = strlen(default2);
 
-               time_datum = gdbm_fetch(data->gdbm, key_datum); 
+               time_datum = gdbm_fetch(data->gdbm, key_datum);
                if (time_datum.dptr != NULL){
                        memcpy(&data->last_reset, time_datum.dptr, sizeof(time_t));
                        free(time_datum.dptr);
@@ -534,7 +534,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
        pthread_mutex_init(&data->mutex, NULL);
 
        *instance = data;
-       
+
        return 0;
 }
 
@@ -608,7 +608,7 @@ static int counter_accounting(void *instance, REQUEST *request)
                }
        }
 
-       
+
 
        /*
         *      Look for the key.  User-Name is special.  It means
@@ -650,8 +650,8 @@ static int counter_accounting(void *instance, REQUEST *request)
                free(count_datum.dptr);
                if (counter.uniqueid)
                        DEBUG("rlm_counter: Counter Unique ID = '%s'",counter.uniqueid);
-               if (uniqueid_vp != NULL){ 
-                       if (counter.uniqueid != NULL && 
+               if (uniqueid_vp != NULL){
+                       if (counter.uniqueid != NULL &&
                                strncmp(uniqueid_vp->strvalue,counter.uniqueid, UNIQUEID_MAX_LEN - 1) == 0){
                                DEBUG("rlm_counter: Unique IDs for user match. Droping the request.");
                                return RLM_MODULE_NOOP;
@@ -775,7 +775,7 @@ static int counter_authorize(void *instance, REQUEST *request)
         */
 
        counter.user_counter = 0;
-       
+
        DEBUG("rlm_counter: Searching the database for key '%s'",key_vp->strvalue);
        pthread_mutex_lock(&data->mutex);
        count_datum = gdbm_fetch(data->gdbm, key_datum);
@@ -797,7 +797,7 @@ static int counter_authorize(void *instance, REQUEST *request)
                DEBUG("rlm_counter: res is greater than zero");
                if (data->count_attr == PW_ACCT_SESSION_TIME) {
                        /*
-                        * Do the following only if the count attribute is 
+                        * Do the following only if the count attribute is
                         * AcctSessionTime
                         */
 
@@ -857,7 +857,7 @@ static int counter_authorize(void *instance, REQUEST *request)
 
                snprintf(module_fmsg,sizeof(module_fmsg), "rlm_counter: Maximum %s usage time reached", data->reset);
                module_fmsg_vp = pairmake("Module-Failure-Message", module_fmsg, T_OP_EQ);
-               pairadd(&request->packet->vps, module_fmsg_vp); 
+               pairadd(&request->packet->vps, module_fmsg_vp);
 
                ret=RLM_MODULE_REJECT;
 
@@ -898,7 +898,7 @@ static int counter_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_counter = {
-       "Counter",      
+       "Counter",
        RLM_TYPE_THREAD_SAFE,           /* type */
        NULL,                           /* initialization */
        counter_instantiate,            /* instantiation */
index 6f38162..f36d8ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_cram.c  
+ * rlm_cram.c
  *
  * Version:    $Id$
  *
@@ -19,7 +19,7 @@
  *
  * Copyright 2002  The FreeRADIUS server project
  */
+
 /*
  *   CRAM mail authentication (APOP, CRAM-MD5)
  *   by 3APA3A
@@ -39,7 +39,7 @@
  *     for APOP/CRAM-MD5/CRAM-MD4, 20 octets for CRAM-SHA1
  *
  *   (c) 2002 by SANDY (http://www.sandy.ru/) under GPL
- */ 
+ */
 
 #include       "autoconf.h"
 #include       "libradius.h"
index 00e97ab..9ee2859 100644 (file)
@@ -61,7 +61,7 @@ typedef struct rlm_dbm_t {
 #ifdef SANDY_MOD
        char    *dms_servers;
        char    *ducpd_servers;
-#endif 
+#endif
        char    *userfile;
        int     findmod;
 } rlm_dbm_t;
@@ -73,24 +73,24 @@ typedef struct user_entry {
 
 
 static CONF_PARSER module_config[] = {
-        { "usersfile",     PW_TYPE_STRING_PTR,offsetof(struct rlm_dbm_t,userfile), 
+        { "usersfile",     PW_TYPE_STRING_PTR,offsetof(struct rlm_dbm_t,userfile),
                NULL, "/etc/uf" },
         { NULL, -1, 0, NULL, NULL }
 };
 
 static void sm_user_list_wipe (SM_USER_ENTRY **ue) {
-       
+
        SM_USER_ENTRY * pue, *nue;
-       
+
        if ( ! *ue ) return ;
        pue = *ue;
-       
+
        while ( pue != NULL ) {
                nue = pue -> next;
                DEBUG2("Remove %s from user list", pue -> username);
                free(pue -> username);
                free(pue);
-               pue = nue; 
+               pue = nue;
        }
        *ue = NULL;
 }
@@ -103,9 +103,9 @@ static void sm_user_list_wipe (SM_USER_ENTRY **ue) {
  */
 
 static int sm_user_list_add(SM_USER_ENTRY **ue, const char *un) {
-       
+
        while( *ue ) {
-               if ( strcmp( (*ue) -> username, un) == 0 ) return 1; 
+               if ( strcmp( (*ue) -> username, un) == 0 ) return 1;
                ue = & ((*ue) -> next);
        }
        *ue = malloc(sizeof(SM_USER_ENTRY));
@@ -143,12 +143,12 @@ static int isfallthrough(VALUE_PAIR *vp) {
  *  pdb        - ndbm handler
  *  username - user name from request
  *  request - pair originated from the nas
- *  mode - search mode SM_SM_ACCUM - accumulative search mode 
+ *  mode - search mode SM_SM_ACCUM - accumulative search mode
  *  out-parameters:
  *  in-out:
  *  parsed_users - list of parsed user names for loop removal
  */
+
 static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* request, VALUE_PAIR **config,
                VALUE_PAIR **reply, SM_USER_ENTRY **ulist)
 {
@@ -157,53 +157,53 @@ static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* requ
        VALUE_PAIR *vp = NULL,* tmp_config = NULL, *tmp_reply = NULL, *nu_reply = NULL;
        VALUE_PAIR *join_attr;
        char    *ch,*beg;
-       
-       int     parse_state = SMP_PATTERN; 
+
+       int     parse_state = SMP_PATTERN;
        int     continue_search = 1;
-       
+
        /* check for loop */
-       
+
        DEBUG2("sm_parse_user.c: check for loops");
 
        if ( (retcod = sm_user_list_add(ulist,username) ) ) {
                if ( retcod < 0 ) radlog(L_ERR,"rlm_dbm: Couldn't allocate memory");
                        else radlog(L_ERR,"rlm_dbm: Invalid configuration: loop detected");
-               return RLM_MODULE_FAIL;  
+               return RLM_MODULE_FAIL;
        }
 
        /* retrieve user content */
-       
+
        k.dptr  = username;
        k.dsize = strlen(username) + 1 ; /* username stored with '\0' */
-       
+
        d = dbm_fetch(pdb, k);
        if ( d.dptr == NULL ) {
                 DEBUG2("rlm_dbm: User <%s> not foud in database\n",username);
                 return RLM_MODULE_NOTFOUND;
        }
-       
+
        ch = d.dptr;
        ch [ d.dsize - 1 ] = '\0'; /* should be closed by 0 */
-       
+
        DEBUG2("sm_parse_user: start parsing: user: %s", username);
-       
+
        /*  start parse content */
        while ( parse_state != SMP_ERROR && *ch && continue_search ) {
 
                beg = ch;
 
                while( *ch && *ch != '\n') ch++ ;
-               
+
                if ( *ch == '\n' ) { *ch = 0; ch++; }
 
-               DEBUG2("parse buffer: <<%s>>\n",beg); 
-               
+               DEBUG2("parse buffer: <<%s>>\n",beg);
+
                retcod = userparse(beg,&vp);
                if ( retcod == T_INVALID ) librad_perror("parse error ");
-               
+
                switch ( retcod ) {
                        case T_COMMA: break; /* continue parse the current list */
-                       case T_EOL:     DEBUG2("rlm_dbm: recod parsed\n"); /* vp contains full pair list */ 
+                       case T_EOL:     DEBUG2("rlm_dbm: recod parsed\n"); /* vp contains full pair list */
                                        if ( parse_state == SMP_PATTERN ) { /* pattern line found */
                                                DEBUG2("process pattern");
                                                /* check pattern against request */
@@ -214,7 +214,7 @@ static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* requ
                                                        parse_state = SMP_REPLY; /* look for reply */
                                                } else  {
                                                          /* skip reply */
-                                                       DEBUG2("rlm_dbm: patern not matched, reply skiped");  
+                                                       DEBUG2("rlm_dbm: patern not matched, reply skiped");
                                                        pairfree(&vp);
                                                        while ( *ch && *ch !='\n' ) ch++;
                                                        if ( *ch == '\n' ) ch++;
@@ -223,11 +223,11 @@ static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* requ
                                                /* look for join-attribute */
                                                DEBUG2("rlm_dbm: Reply found");
                                                join_attr = vp;
-                                               while( (join_attr = pairfind(join_attr,SM_JOIN_ATTR) ) != NULL ) { 
+                                               while( (join_attr = pairfind(join_attr,SM_JOIN_ATTR) ) != NULL ) {
                                                        DEBUG2("rlm_dbm: Proccess nested record: username %s",
                                                                (char *)join_attr->strvalue);
                                                        /* res =  RLM_MODULE_NOTFOUND; */
-                                                       res =  sm_parse_user(pdb, (char *)join_attr->strvalue, request, &tmp_config, 
+                                                       res =  sm_parse_user(pdb, (char *)join_attr->strvalue, request, &tmp_config,
                                                                        &nu_reply, ulist);
                                                        DEBUG("rlm_dbm: recived: %d\n",res);
                                                        switch ( res ) {
@@ -257,15 +257,15 @@ static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* requ
                                                pairfree(&vp);
                                                pairfree(&nu_reply);                                    }
                                        break;
-                       default:        /* we do not wait that !!!! */ 
+                       default:        /* we do not wait that !!!! */
                                        parse_state = SMP_ERROR;
                                        DEBUG2("rlm_dbm: Unknown token: %d\n",retcod);
                                        break;
                }
-               
+
        }
        if ( parse_state == SMP_PATTERN  ) {
-               pairmove(config,&tmp_config); 
+               pairmove(config,&tmp_config);
                pairfree(&tmp_config);
                pairmove(reply,&tmp_reply);
                pairfree(&tmp_reply);
@@ -282,11 +282,11 @@ static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* requ
 
 static int sm_postprocessor(VALUE_PAIR **reply UNUSED) {
        return 0;
-} 
+}
 
 static int rlm_dbm_instantiate(CONF_SECTION *conf, void **instance) {
        struct rlm_dbm_t *inst;
-       
+
        inst = rad_malloc(sizeof(rlm_dbm_t));
        if (!inst) {
                return -1;
@@ -294,7 +294,7 @@ static int rlm_dbm_instantiate(CONF_SECTION *conf, void **instance) {
        memset(inst, 0, sizeof(*inst));
 
         if (cf_section_parse(conf, inst, module_config) < 0) {
-                free(inst);      
+                free(inst);
                 return -1;
         }
        *instance = inst;
@@ -310,22 +310,22 @@ static int rlm_dbm_authorize(void *instance, REQUEST *request)
         int             found = 0;
         const char      *name;
        SM_USER_ENTRY   *ulist = NULL;
-       DBM             *pdb; 
+       DBM             *pdb;
 
         struct rlm_dbm_t *inst = instance;
 
         VALUE_PAIR **check_pairs, **reply_pairs;
-                                
+
         request_pairs = request->packet->vps;
         check_pairs = &request->config_items;
         reply_pairs = &request->reply->vps;
-       
+
         /*
          *      Grab the canonical user name.
          */
         namepair = request->username;
         name = namepair ? (char *) namepair->strvalue : "NONE";
-       
+
        DEBUG2("rlm_dbm: try open database file: %s\n",inst -> userfile);
 
        /* open database */
@@ -335,9 +335,9 @@ static int rlm_dbm_authorize(void *instance, REQUEST *request)
                if ( found == RLM_MODULE_NOTFOUND ) {
                  sm_user_list_wipe(&ulist);
                  found = sm_parse_user(pdb, "DEFAULT", request_pairs, &check_tmp, &reply_tmp, &ulist);
-               }       
+               }
                dbm_close(pdb);
-       } else { 
+       } else {
                found = RLM_MODULE_FAIL;
                DEBUG2("rlm_dbm: Cannot open database file: %s\n",
                       strerror(errno));
@@ -353,7 +353,7 @@ static int rlm_dbm_authorize(void *instance, REQUEST *request)
        sm_user_list_wipe(&ulist);
        pairfree(&reply_tmp);
        pairfree(&check_tmp);
-       
+
        return found;
 }
 
@@ -367,7 +367,7 @@ static int rlm_dbm_detach(void *instance)
 
 
 /* globally exported name */
-module_t rlm_dbm = {   
+module_t rlm_dbm = {
         "dbm",
         0,                              /* type: reserved */
         NULL,                           /* initialization */
index 5860acb..ca02ee1 100644 (file)
@@ -53,10 +53,10 @@ static void dump_record(datum key,datum data)
        int i,j;
        char *p;
        for(i = 0, p = key.dptr; i < key.dsize; i++, p++)
-         putchar(*p); 
+         putchar(*p);
        if ( i < lotstup ) while( i++ <= lotstup) putchar(' ');
                else putchar(' ');
-       
+
        for(j = 0, p = data.dptr ; j < data.dsize && *p ; i++, p++ ) {
                putchar(*p);
                if ( needwrap && *p == ',' && i > wraplen ) putchar('\n');
@@ -65,14 +65,14 @@ static void dump_record(datum key,datum data)
                        i = 0;
                }
        }
-          
+
        putchar('\n');
 }
 
 static void usage(void)
 {
        fprintf(stderr, "Usage: %s: [-f file] [-w] [-i number] [-l number] [-v]\n\n",progname);
-       
+
        exit(1);
 }
 
@@ -83,11 +83,11 @@ int main(int n, char **argv) {
        datum   k,d;
        int     ch;
        int     i;
-       
+
        progname = argv[0];
-       
-       
-       
+
+
+
        while ((ch = getopt(n, argv, "i:l:wf:v")) != -1)
                switch (ch) {
                        case 'i':       if (!isdigit((int) *optarg)) usage();
@@ -96,7 +96,7 @@ int main(int n, char **argv) {
                        case 'l':       if (!isdigit((int) *optarg)) usage();
                                        wraplen = atoi(optarg);
                                        break;
-                       case 'w':       needwrap = 1; 
+                       case 'w':       needwrap = 1;
                                        break;
                        case 'f':       fname = optarg;
                                        break;
@@ -104,11 +104,11 @@ int main(int n, char **argv) {
                                        exit(0);
                                        break;
                        default : usage(); exit(1); break;
-                       
+
                }
        n -= (optind - 1);
        argv += (optind -1);
-       
+
        if ( fname == NULL) fname = "sandy_db";
 
        if ( ( pdb = dbm_open(fname, O_RDONLY, 0777) ) == NULL ) {
@@ -119,21 +119,21 @@ int main(int n, char **argv) {
                for ( i = 1 ; i < n ; i++ ) {
                        printf(" Check: %s\n",argv[i]);
                        k.dptr  = argv[i];
-                       k.dsize = strlen(argv[i]) + 1; 
+                       k.dsize = strlen(argv[i]) + 1;
                        if ( (d = dbm_fetch(pdb,k)).dptr == NULL ) {
                                printf("Not found\n");
                        } else dump_record(k, d);
                }
        } else {
-               for ( k = dbm_firstkey(pdb) ; k.dptr != NULL ; k = dbm_nextkey(pdb) ) 
+               for ( k = dbm_firstkey(pdb) ; k.dptr != NULL ; k = dbm_nextkey(pdb) )
                        if ( (d = dbm_fetch(pdb,k)).dptr == NULL ) {
                                perror("Couldn't fetch user record");
                                exit(1);
                        } else dump_record(k, d);
        }
        dbm_close(pdb);
-       fflush(stdout);                 
-       
+       fflush(stdout);
+
        return 0;
-       
+
 }
index ddf7f0d..15bc928 100644 (file)
@@ -82,12 +82,12 @@ unsigned long       st_errors = 0,
 int dumplist(VALUE_PAIR *vp) {
 
        while (vp != NULL) {
-       
+
                printf("VP: name: %s\nattribute: %d\ntype: %d\nlvalue: %lu"
                        "\noperator %d\naddport: %d\nValue: %s\n",
                        vp -> name, vp -> attribute, vp -> type, vp -> lvalue,
                        vp -> operator, vp -> addport, (char*)vp -> strvalue);
-               vp = vp -> next;        
+               vp = vp -> next;
        }
        return 0;
 }
@@ -107,18 +107,18 @@ static int open_storage(const char * fname) {
        perror("Couldn't open database");
        return 1;
   }
-  return 0; 
+  return 0;
 }
 
 static void  close_storage(void){
-  dbm_close(pdb); 
+  dbm_close(pdb);
 }
 
 static int  addlinetocontent(VALUE_PAIR *vp) {
-       
+
        int outlen = sizeof(content) - concntr - 1;
        int lendiv;
-       
+
        if ( outlen < 4 ) return -1;
        if ( vp == NULL ) { /* add empty line */
                content[concntr++] = '\n';
@@ -128,7 +128,7 @@ static int  addlinetocontent(VALUE_PAIR *vp) {
                        lendiv = vp_prints(&content[concntr],outlen,vp);
                        if ( lendiv > 0 ) {
                                outlen -= lendiv;
-                               
+
                                if (outlen > 3)  {
                                        strcat(content,", ");
                                        concntr += lendiv + 2;
@@ -136,25 +136,25 @@ static int  addlinetocontent(VALUE_PAIR *vp) {
                                } else {
                                        concntr = 0;
                                        return -1;
-                               } 
+                               }
                        }
-                       vp = vp -> next;        
+                       vp = vp -> next;
                }
-       
+
                if ( concntr > 2 ) {  /* remove trailing ',' */
                        content[--concntr] = '\0';
                        content[concntr - 1] = '\n';
                }
        }
-               
-       return 0;       
+
+       return 0;
 }
 
 static int storecontent (const char * username) {
-       
+
         datum d,k;
         int res;
-       
+
        if ( pdb == NULL || concntr < 3 ) return 1;
 
        DOUT2("store:\n%s\ncontent:\n%s",username,content);
@@ -164,7 +164,7 @@ static int storecontent (const char * username) {
 
        k.dptr = username;
        k.dsize = strlen(username) + 1;
-       
+
        res = dbm_store(pdb, k, d, DBM_INSERT);
        if ( res == 1 ) dbm_store(pdb, k, d, DBM_REPLACE);
        if ( res < 0 ) {
@@ -172,16 +172,16 @@ static int storecontent (const char * username) {
          st_errors++;
          st_skiped++;
        }  else st_loaded++;
-       
+
        concntr = 0;
        *content = '\0';
        return 0;
 }
 
 static int getuname(char **p,char *u,int n) {
-       int     i; 
-       
-       for(i=0 ; ( i < n-1 ) && ( **p ) && (! isspace((int) **p) ) ; (*p)++ ) 
+       int     i;
+
+       for(i=0 ; ( i < n-1 ) && ( **p ) && (! isspace((int) **p) ) ; (*p)++ )
            u[i++] = **p;
        u[i] = '\0';
        return ( i == 0) ? 1:0;
@@ -190,7 +190,7 @@ static int getuname(char **p,char *u,int n) {
 static int sm_parse_file(FILE*fp,const char* fname) {
         LRAD_TOKEN tok;
         VALUE_PAIR *vp = NULL;
-       sm_parse_state_t  parse_state = SMP_USER; 
+       sm_parse_state_t  parse_state = SMP_USER;
        unsigned long lino  = 0;
        char *p;
        char buff[MAX_BUFF_SIZE];
@@ -198,7 +198,7 @@ static int sm_parse_file(FILE*fp,const char* fname) {
 
 
        while( parse_state != SMP_INVALID && fgets(buff, sizeof(buff), fp) != NULL ) {
-               
+
                lino ++;
                st_lines++;
                if ( strchr(buff, '\n') == NULL) {
@@ -207,10 +207,10 @@ static int sm_parse_file(FILE*fp,const char* fname) {
                        st_skiped++; /* _LINE_ skiped */
                        continue;
                }
-       
+
                DOUT2("Parseline: %s",buff);
                for ( p = buff; isspace((int) *p); p++);
-                
+
                if ( *p == '#' || *p == 0 ) continue;
 
                /* userparse hack */
@@ -229,7 +229,7 @@ static int sm_parse_file(FILE*fp,const char* fname) {
 
                if ( parse_state == SMP_USER ) {
                    tok = getuname(&p,username,sizeof(username));
-                   
+
                    /* check: is it include. not implemented */
 
                    if ( tok ) {
@@ -239,7 +239,7 @@ static int sm_parse_file(FILE*fp,const char* fname) {
                    } else {
                        parse_state = SMP_PATTERN;
                        DOUT1("Found user: %s\n",username);
-                       
+
                    }
                }
                if ( parse_state == SMP_PATTERN || parse_state == SMP_ACTION ) {
@@ -249,22 +249,22 @@ static int sm_parse_file(FILE*fp,const char* fname) {
 
                    if ( *p && ( *p != ';' ) ) tok = userparse(p,&vp);
                    else tok = T_EOL;  /* ';' - signs empty line */
-                   
+
                    switch(tok) {
                        case T_EOL: /* add to content */
                                        addlinetocontent(vp);
                                        pairfree(&vp);
-                                       if ( parse_state == SMP_PATTERN ) 
+                                       if ( parse_state == SMP_PATTERN )
                                                parse_state = SMP_ACTION;
                                        else parse_state = SMP_PATTERN_OR_USER;
-                                        
+
                        case T_COMMA: break;  /* parse next line */
                        default: /* error: we do  not expect anything else */
-                                       fprintf(stderr ,"%s: %s[%lu]: sintax error\n",progname,fname,lino); 
+                                       fprintf(stderr ,"%s: %s[%lu]: sintax error\n",progname,fname,lino);
                                        librad_perror("Error");
                                        parse_state = SMP_INVALID;
                                        st_errors++;
-                   }   
+                   }
                }
        }
        if ( feof(fp) ) switch (parse_state ) {
@@ -302,25 +302,25 @@ static void sm_usage(void) {
        fprintf(stderr, "-q     do not print statistic\n");
        fprintf(stderr, "-v     print version\n");
        fprintf(stderr, "-r     remove user(s) from database\n");
-       
+
 }
 
 int main(int n,char **argv) {
-        
+
        const char *fname = NULL;
        const char *ofile = NULL;
        FILE    *fp;
        int     print_stat = 1;
        int     ch;
        const char  *sm_radius_dir = NULL;
-       
+
        progname = argv[0];
 
        librad_debug = 0;
-       
-       while ((ch = getopt(n, argv, "d:i:xo:qvc")) != -1) 
+
+       while ((ch = getopt(n, argv, "d:i:xo:qvc")) != -1)
                switch (ch) {
-                       case 'd':       
+                       case 'd':
                                sm_radius_dir = optarg;
                                break;
                        case 'i':
@@ -330,7 +330,7 @@ int main(int n,char **argv) {
                                librad_debug++;
                        case 'o':
                                ofile = optarg;
-                               break;  
+                               break;
                        case 'q':
                                print_stat = 0;
                                break;
@@ -347,7 +347,7 @@ int main(int n,char **argv) {
 
 
        if ( sm_radius_dir == NULL ) sm_radius_dir = RADDBDIR;
-       
+
        DOUT1("Use dictionary in: %s\n",sm_radius_dir);
        if (dict_init(sm_radius_dir, RADIUS_DICTIONARY) < 0 ) {
                        librad_perror("parser: init dictionary:");
@@ -360,8 +360,8 @@ int main(int n,char **argv) {
        } else if ( ( fp = fopen(fname, "r") ) == NULL ) {
                fprintf( stderr,"%s: Couldn't open source file\n", progname);
                exit(1);
-       } 
-       
+       }
+
        if ( ofile == NULL ) ofile = "sandy_db" ;
        if ( open_storage(ofile) ) {
                exit (1);
index 4b2366e..6436721 100644 (file)
@@ -155,7 +155,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
         *      we prolly must create it the dir(s)
         */
        if ((p) && (stat(buffer, &st) < 0)) {
-               *p = '\0';      
+               *p = '\0';
                /*
                 *      NO previously cached directory name, so we've
                 *      got to create a new one.
@@ -167,8 +167,8 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                 *      so we've got to create a new one.
                 */
                if ((inst->last_made_directory == NULL) ||
-                   (strcmp(inst->last_made_directory, buffer) != 0)) { 
-                       
+                   (strcmp(inst->last_made_directory, buffer) != 0)) {
+
                        /*
                         *      Free any previously cached name.
                         */
@@ -176,7 +176,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                                free((char *) inst->last_made_directory);
                                inst->last_made_directory = NULL;
                        }
-                       
+
                        /*
                         *      Go create possibly multiple directories.
                         */
@@ -186,8 +186,8 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                        }
                        inst->last_made_directory = strdup(buffer);
                }
-               
-               *p = '/';       
+
+               *p = '/';
        } /* else there was no directory delimiter. */
 
        /*
@@ -270,7 +270,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
         */
        fseek(outfp, 0L, SEEK_END);
        fputs(CTIME_R(&request->timestamp, buffer, DIRLEN), outfp);
-       
+
        /* Write each attribute/value to the log file */
        while (pair) {
                /*
@@ -314,7 +314,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                else if (request->packet->verified == 1)
                        fputs("\tRequest-Authenticator = None\n", outfp);
        }
-       
+
        fputs("\n", outfp);
 
        if (inst->locking) {
@@ -323,7 +323,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                rad_unlockfd(outfd, 0);
                DEBUG("rlm_detail: Released filelock");
        }
-       
+
        fclose(outfp);
 
        /*
index b70f2ad..877f813 100644 (file)
@@ -90,7 +90,7 @@ static int digest_authorize(void *instance, REQUEST *request)
                        }
 
                        attrlen = p[1]; /* stupid VSA format */
-                       
+
                        /*
                         *      Too short.
                         */
@@ -98,7 +98,7 @@ static int digest_authorize(void *instance, REQUEST *request)
                                DEBUG("ERROR: Received Digest-Attributes with short sub-attribute %d, of length %d", p[0], attrlen);
                                return RLM_MODULE_INVALID;
                        }
-                       
+
                        /*
                         *      Too long.
                         */
@@ -139,7 +139,7 @@ static int digest_authorize(void *instance, REQUEST *request)
                         */
 
                        length -= attrlen;
-                       p += attrlen;                   
+                       p += attrlen;
                } /* loop over this one attribute */
 
                /*
@@ -334,7 +334,7 @@ static int digest_authenticate(void *instance, REQUEST *request)
                a2_len += (body->length >> 1);
 
        } else if ((qop != NULL) &&
-                  (strcasecmp(qop->strvalue, "auth") != 0)) {  
+                  (strcasecmp(qop->strvalue, "auth") != 0)) {
                DEBUG("ERROR: Unknown Digest-QOP \"%s\": Cannot perform Digest authentication", qop->strvalue);
                return RLM_MODULE_INVALID;
        }
@@ -364,7 +364,7 @@ static int digest_authenticate(void *instance, REQUEST *request)
 
        kd[kd_len] = ':';
        kd_len++;
-       
+
        memcpy(&kd[kd_len], nonce->strvalue, nonce->length);
        kd_len += nonce->length;
 
@@ -458,7 +458,7 @@ static int digest_authenticate(void *instance, REQUEST *request)
                        printf("%02x", kd[i]);
                }
                printf("\n");
-               
+
                printf("RECEIVED ");
                for (i = 0; i < 16; i++) {
                        printf("%02x", hash[i]);
@@ -488,7 +488,7 @@ static int digest_authenticate(void *instance, REQUEST *request)
  *     is single-threaded.
  */
 module_t rlm_digest = {
-       "DIGEST",       
+       "DIGEST",
        0,                              /* type */
        NULL,                           /* initialization */
        NULL,                           /* instantiation */
index 7e25e32..39616e1 100644 (file)
@@ -33,7 +33,7 @@
  * +-+-+-+-+
  *
  *
- * EAP Request and Response Packet Format 
+ * EAP Request and Response Packet Format
  * --- ------- --- -------- ------ ------
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -44,7 +44,7 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  *
  *
- * EAP Success and Failure Packet Format 
+ * EAP Success and Failure Packet Format
  * --- ------- --- ------- ------ ------
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -68,7 +68,7 @@ static const char *eap_codes[] = {
 
 /*
  * Load all the required eap authentication types.
- * Get all the supported EAP-types from config file. 
+ * Get all the supported EAP-types from config file.
  */
 int eaptype_load(EAP_TYPES **type, int eap_type, CONF_SECTION *cs)
 {
@@ -84,7 +84,7 @@ int eaptype_load(EAP_TYPES **type, int eap_type, CONF_SECTION *cs)
        /* Link the loaded EAP-Type */
        handle = lt_dlopenext(buffer);
        if (handle == NULL) {
-               radlog(L_ERR, "rlm_eap: Failed to link EAP-Type/%s: %s", 
+               radlog(L_ERR, "rlm_eap: Failed to link EAP-Type/%s: %s",
                       eaptype_name, lt_dlerror());
                return -1;
        }
@@ -110,7 +110,7 @@ int eaptype_load(EAP_TYPES **type, int eap_type, CONF_SECTION *cs)
         */
        node->typename = eaptype_name;
        node->type_data = NULL;
-       
+
        node->type = (EAP_TYPE *)lt_dlsym(node->handle, buffer);
        if (!node->type) {
                radlog(L_ERR, "rlm_eap: Failed linking to %s structure in %s: %s",
@@ -119,7 +119,7 @@ int eaptype_load(EAP_TYPES **type, int eap_type, CONF_SECTION *cs)
                free(node);
                return -1;
        }
-       if ((node->type->attach) && 
+       if ((node->type->attach) &&
            ((node->type->attach)(node->cs, &(node->type_data)) < 0)) {
 
                radlog(L_ERR, "rlm_eap: Failed to initialize type %s",
@@ -181,8 +181,8 @@ static int eaptype_call(EAP_TYPES *atype, EAP_HANDLER *handler)
 
 /*
  * Based on TYPE, call the appropriate EAP-type handler
- * Default to the configured EAP-Type 
- * for all Unsupported EAP-Types 
+ * Default to the configured EAP-Type
+ * for all Unsupported EAP-Types
  */
 int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
 {
@@ -209,14 +209,14 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
        switch(eaptype->type) {
        case PW_EAP_IDENTITY:
                DEBUG2("  rlm_eap: EAP Identity");
-               
+
                /*
                 *      Allow per-user configuration of EAP types.
                 */
                vp = pairfind(handler->request->config_items,
                              PW_EAP_TYPE);
                if (vp) default_eap_type = vp->lvalue;
-               
+
        do_initiate:
                /*
                 *      Ensure it's valid.
@@ -229,10 +229,10 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
                                                 namebuf, sizeof(namebuf)));
                        return EAP_INVALID;
                }
-               
+
                handler->stage = INITIATE;
                handler->eap_type = default_eap_type;
-               
+
                /*
                 *      Wild & crazy stuff!  For TTLS & PEAP, we
                 *      initiate a TLS session, and then pass that
@@ -245,8 +245,8 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
                    (default_eap_type == PW_EAP_PEAP)) {
                        default_eap_type = PW_EAP_TLS;
                }
-               
-               
+
+
                /*
                 *      We don't do TLS inside of TLS, as it's a bad
                 *      idea...
@@ -256,10 +256,10 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
                        DEBUG2(" rlm_eap: Unable to tunnel TLS inside of TLS");
                        return EAP_INVALID;
                }
-               
+
                if (eaptype_call(inst->types[default_eap_type],
                                 handler) == 0) {
-                       DEBUG2(" rlm_eap: Default EAP type %s failed in initiate", 
+                       DEBUG2(" rlm_eap: Default EAP type %s failed in initiate",
                               eaptype_type2name(default_eap_type,
                                                 namebuf, sizeof(namebuf)));
                        return EAP_INVALID;
@@ -302,7 +302,7 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
                eaptype_name = eaptype_type2name(default_eap_type,
                                                 namebuf, sizeof(namebuf));
                DEBUG2(" rlm_eap: EAP-NAK asked for EAP-Type/%s",
-                      eaptype_name);                  
+                      eaptype_name);
 
                /*
                 *      Prevent a firestorm if the client is confused.
@@ -338,7 +338,7 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
                                                         namebuf,
                                                         sizeof(namebuf));
                        DEBUG2("  rlm_eap: EAP/%s", eaptype_name);
-                       
+
                        /*
                         *      We haven't configured it, it doesn't exit.
                         */
@@ -347,7 +347,7 @@ int eaptype_select(rlm_eap_t *inst, EAP_HANDLER *handler)
                                       eaptype->type);
                                return EAP_INVALID;
                        }
-                       
+
                        rad_assert(handler->stage == AUTHENTICATE);
                        handler->eap_type = eaptype->type;
                        if (eaptype_call(inst->types[eaptype->type],
@@ -461,7 +461,7 @@ int eap_compose(EAP_HANDLER *handler)
                 *      mentioned restriction.
                 */
                reply->id = handler->eap_ds->response->id;
-               
+
                switch (reply->code) {
                        /*
                         *      The Id is a simple "ack" for success
@@ -470,7 +470,7 @@ int eap_compose(EAP_HANDLER *handler)
                case PW_EAP_SUCCESS:
                case PW_EAP_FAILURE:
                        break;
-                       
+
                        /*
                         *      We've sent a response to their
                         *      request, the Id is incremented.
@@ -499,7 +499,7 @@ int eap_compose(EAP_HANDLER *handler)
 
                eap_ds->request->type.type = handler->eap_type;
        }
-         
+
 
        if (eap_wireformat(reply) == EAP_INVALID) {
                return RLM_MODULE_INVALID;
@@ -519,7 +519,7 @@ int eap_compose(EAP_HANDLER *handler)
                        eap_len = 0;
                }
 
-               /* 
+               /*
                 * create a value pair & append it to the request reply list
                 * This memory gets freed up when request is freed up
                 */
@@ -681,7 +681,7 @@ int eap_start(rlm_eap_t *inst, REQUEST *request)
                                vp->lvalue = eap_msg->strvalue[4];
                                pairadd(&(request->packet->vps), vp);
                        }
-                       
+
                        /*
                         *      We've been told to ignore unknown EAP
                         *      types, AND it's an unknown type.
@@ -729,7 +729,7 @@ int eap_start(rlm_eap_t *inst, REQUEST *request)
                                return EAP_NOOP;
                        }
                } /* else it's not an EAP-Request or EAP-Response */
+
                /*
                 *      No EAP-Start found.  Proxying: return NOOP.
                 *      Not proxying, return NOTFOUND.
index ef70c50..e720771 100644 (file)
@@ -48,8 +48,8 @@
  * response = Received EAP packet
  * request = Sending EAP packet
  *
- * Note: We are authentication server, 
- *  we get ONLY EAP-Responses and 
+ * Note: We are authentication server,
+ *  we get ONLY EAP-Responses and
  *  we send EAP-Request/EAP-success/EAP-failure
  */
 typedef struct eap_ds {
@@ -60,7 +60,7 @@ typedef struct eap_ds {
 
 /*
  * Currently there are only 2 types
- * of operations defined, 
+ * of operations defined,
  * apart from attach & detach for each EAP-Type.
  */
 typedef enum operation_t {
@@ -75,7 +75,7 @@ typedef enum operation_t {
  * Each handler contains information for one specific EAP-Type.
  * This way we don't need to change any interfaces in future.
  * It is also a list of EAP-request handlers waiting for EAP-response
- * eap_id = copy of the eap packet we sent to the 
+ * eap_id = copy of the eap packet we sent to the
  *
  * next = pointer to next
  * state = state attribute from the reply we sent
@@ -90,9 +90,9 @@ typedef enum operation_t {
  * eap_ds   = Current EAP response.
  * opaque   = EAP-Type holds some data that corresponds to the current
  *             EAP-request/response
- * free_opaque = To release memory held by opaque, 
+ * free_opaque = To release memory held by opaque,
  *             when this handler is timedout & needs to be deleted.
- *             It is the responsibility of the specific EAP-TYPE 
+ *             It is the responsibility of the specific EAP-TYPE
  *             to avoid any memory leaks in opaque
  *             Hence this pointer should be provided by the EAP-Type
  *             if opaque is not NULL
@@ -124,7 +124,7 @@ typedef struct _eap_handler {
        int             stage;
 } EAP_HANDLER;
 
-/* 
+/*
  * Interface to call EAP sub mdoules
  */
 typedef struct eap_type_t {
index 71c08e6..f64d484 100644 (file)
 #define ATTRIBUTE_EAP_SIM_BASE      (6*256)
 
 #define ATTRIBUTE_EAP_SIM_SUBTYPE   1023
-#define ATTRIBUTE_EAP_SIM_RAND1           1024 
-#define ATTRIBUTE_EAP_SIM_RAND2           1025 
-#define ATTRIBUTE_EAP_SIM_RAND3           1026 
+#define ATTRIBUTE_EAP_SIM_RAND1           1024
+#define ATTRIBUTE_EAP_SIM_RAND2           1025
+#define ATTRIBUTE_EAP_SIM_RAND3           1026
 
-#define ATTRIBUTE_EAP_SIM_SRES1           1027 
-#define ATTRIBUTE_EAP_SIM_SRES2           1028 
-#define ATTRIBUTE_EAP_SIM_SRES3           1029 
+#define ATTRIBUTE_EAP_SIM_SRES1           1027
+#define ATTRIBUTE_EAP_SIM_SRES2           1028
+#define ATTRIBUTE_EAP_SIM_SRES3           1029
 
 #define ATTRIBUTE_EAP_SIM_STATE           1030
 #define ATTRIBUTE_EAP_SIM_IMSI            1031
@@ -61,11 +61,11 @@ enum eapsim_subtype {
 enum eapsim_clientstates {
   eapsim_client_init = 0,
   eapsim_client_start = 1,
-  eapsim_client_maxstates 
+  eapsim_client_maxstates
 };
 
 /* server states
- * 
+ *
  * in server_start, we send a EAP-SIM Start message.
  *
  */
@@ -104,14 +104,14 @@ extern int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep);
 extern int unmap_eapsim_types(RADIUS_PACKET *r);
 extern const char *sim_state2name(enum eapsim_clientstates state, char *buf, int buflen);
 extern const char *sim_subtype2name(enum eapsim_subtype subtype, char *buf, int buflen);
-extern int unmap_eapsim_basictypes(RADIUS_PACKET *r, 
+extern int unmap_eapsim_basictypes(RADIUS_PACKET *r,
                                   uint8_t *attr, unsigned int attrlen);
 
 
 /************************/
 /*   CRYPTO FUNCTIONS   */
 /************************/
+
 /*
  * key derivation functions/structures
  *
@@ -142,7 +142,7 @@ struct eapsim_keys {
   unsigned char K_encr[16];
   unsigned char msk[64];
   unsigned char emsk[64];
-};  
+};
 
 
 /*
index db6e2b3..bbcf0fe 100644 (file)
@@ -36,7 +36,7 @@
  * +-+-+-+-+
  *
  *
- * EAP Request and Response Packet Format 
+ * EAP Request and Response Packet Format
  * --- ------- --- -------- ------ ------
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -47,7 +47,7 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  *
  *
- * EAP Success and Failure Packet Format 
+ * EAP Success and Failure Packet Format
  * --- ------- --- ------- ------ ------
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -63,7 +63,7 @@
 static const char rcsid[] = "$Id$";
 
 static const char *eap_types[] = {
-  "",   
+  "",
   "identity",
   "notification",
   "nak",                       /* NAK */
@@ -108,7 +108,7 @@ int eaptype_name2type(const char *name)
                        return i;
                }
        }
-       
+
        return -1;
 }
 
@@ -167,9 +167,9 @@ static int eap_wireformat(EAP_PACKET *reply)
 
        eap_packet_t    *hdr;
        uint16_t total_length = 0;
-       
+
        if (reply == NULL) return EAP_INVALID;
-       
+
        /*
         * if reply->packet is set, then the wire format
         * has already been calculated, just succeed!
@@ -257,7 +257,7 @@ int eap_basic_compose(RADIUS_PACKET *packet, EAP_PACKET *reply)
                        eap_len = 0;
                }
 
-               /* 
+               /*
                 * create a value pair & append it to the packet list
                 * This memory gets freed up when packet is freed up
                 */
@@ -337,13 +337,13 @@ void map_eap_types(RADIUS_PACKET *req)
        }
 
        vp = pairfind(req->vps, ATTRIBUTE_EAP_CODE);
-       if(vp == NULL) {        
+       if(vp == NULL) {
                eapcode = PW_EAP_REQUEST;
        } else {
                eapcode = vp->lvalue;
        }
 
-       
+
        for(vp = req->vps; vp != NULL; vp = vpnext) {
                /* save it in case it changes! */
                vpnext = vp->next;
@@ -359,7 +359,7 @@ void map_eap_types(RADIUS_PACKET *req)
        }
 
        eap_type = vp->attribute - ATTRIBUTE_EAP_BASE;
-               
+
        switch(eap_type) {
        case PW_EAP_IDENTITY:
        case PW_EAP_NOTIFICATION:
@@ -376,10 +376,10 @@ void map_eap_types(RADIUS_PACKET *req)
                 * no known special handling, it is just encoded as an
                 * EAP-message with the given type.
                 */
-               
+
                /* nuke any existing EAP-Messages */
                pairdelete(&req->vps, PW_EAP_MESSAGE);
-               
+
                memset(&ep, 0, sizeof(ep));
                ep.code = eapcode;
                ep.id   = id;
@@ -389,7 +389,7 @@ void map_eap_types(RADIUS_PACKET *req)
                eap_basic_compose(req, &ep);
        }
 }
-                       
+
 /*
  * Handles multiple EAP-Message attrs
  * ie concatenates all to get the complete EAP packet.
@@ -443,7 +443,7 @@ eap_packet_t *eap_attribute(VALUE_PAIR *vps)
        total_len = 0;
        for (vp = first; vp; vp = pairfind(vp->next, PW_EAP_MESSAGE)) {
                total_len += vp->length;
-               
+
                if (total_len > len) {
                        radlog(L_ERR, "rlm_eap: Malformed EAP packet.  Length in packet header does not match actual length");
                        return NULL;
@@ -514,18 +514,18 @@ void unmap_eap_types(RADIUS_PACKET *rep)
        case PW_EAP_FAILURE:
                /* no data */
                break;
-               
+
        case PW_EAP_REQUEST:
        case PW_EAP_RESPONSE:
                /* there is a type field, which we use to create
                 * a new attribute */
-               
+
                /* the length was decode already into the attribute
                 * length, and was checked already. Network byte
                 * order, just pull it out using math.
                 */
                len = e->length[0]*256 + e->length[1];
-               
+
                /* verify the length is big enough to hold type */
                if(len < 5)
                {
@@ -533,7 +533,7 @@ void unmap_eap_types(RADIUS_PACKET *rep)
                }
 
                type = e->data[0];
-               
+
                type += ATTRIBUTE_EAP_BASE;
                len -= 5;
 
@@ -550,4 +550,4 @@ void unmap_eap_types(RADIUS_PACKET *rep)
 
        return;
 }
-                       
+
index 9773116..81ea2ab 100644 (file)
@@ -2,7 +2,7 @@
  * eapcrypto.c      Common key derivation routines for EAP/SIM.
  *
  * The development of the EAP/SIM support was funded by Internet Foundation
- * Austria (http://www.nic.at/ipa). 
+ * Austria (http://www.nic.at/ipa).
  *
  * Version:     $Id$
  *
@@ -51,17 +51,17 @@ void eapsim_calculate_keys(struct eapsim_keys *ek)
        memcpy(p, ek->Kc[2], EAPSIM_Kc_SIZE);       p = p+EAPSIM_Kc_SIZE;
        memcpy(p, ek->nonce_mt, sizeof(ek->nonce_mt)); p=p+sizeof(ek->nonce_mt);
        memcpy(p, ek->versionlist, ek->versionlistlen);p=p+ek->versionlistlen;
-       memcpy(p, ek->versionselect, sizeof(ek->versionselect)); p=p+sizeof(ek->versionselect); 
+       memcpy(p, ek->versionselect, sizeof(ek->versionselect)); p=p+sizeof(ek->versionselect);
        /* *p++ = ek->versionselect[1]; */
-       
+
        blen = p - buf;
 
 #if defined(TEST_CASE) || defined(DUMP_EAPSIM_KEYS)
        {
          unsigned int i, j, k;
-         
+
          j=0; k=0;
-         
+
          printf("SHA1buffer was: ");
          for (i = 0; i < blen; i++) {
            if(j==4) {
@@ -72,7 +72,7 @@ void eapsim_calculate_keys(struct eapsim_keys *ek)
              printf("\n                ");
              k=0;
              j=0;
-           } 
+           }
            j++;
            k++;
 
@@ -80,9 +80,9 @@ void eapsim_calculate_keys(struct eapsim_keys *ek)
          }
          printf("\n");
        }
-#endif   
+#endif
+
 
-         
        /* do the master key first */
        SHA1Init(&context);
        SHA1Update(&context, buf, blen);
@@ -146,7 +146,7 @@ void eapsim_dump_mk(struct eapsim_keys *ek)
        }
 
        printf("\n   select %02x %02x\n",
-              ek->versionselect[0], 
+              ek->versionselect[0],
               ek->versionselect[1]);
 
        printf("\n\nOutput\n");
@@ -194,7 +194,7 @@ void eapsim_dump_mk(struct eapsim_keys *ek)
                        printf("\n            ");
                        k=0;
                        j=0;
-               } 
+               }
                if(j==4) {
                        printf("_");
                        j=0;
@@ -211,7 +211,7 @@ void eapsim_dump_mk(struct eapsim_keys *ek)
                        printf("\n            ");
                        k=0;
                        j=0;
-               } 
+               }
                if(j==4) {
                        printf("_");
                        j=0;
@@ -237,11 +237,11 @@ struct eapsim_keys inputkey1 = {
          0x89, 0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef,
          0x9a, 0xbc, 0xde, 0xf8, 0x9a, 0xbc, 0xde, 0xf8,
          0x9a, 0xbc, 0xde, 0xf8, 0x9a, 0xbc, 0xde, 0xf8,
-         0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef, 0x89,   
+         0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef, 0x89,
          0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef, 0x89,
          0x12, 0x34, 0xab, 0xcd,                             /* sresX */
-         0x12, 0x34, 0xab, 0xcd, 
-         0x23, 0x4a, 0xbc, 0xd1, 
+         0x12, 0x34, 0xab, 0xcd,
+         0x23, 0x4a, 0xbc, 0xd1,
          0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,  /* Kc */
          0x10, 0x21, 0x32, 0x43, 0x54, 0x65, 0x76, 0x87,
          0x30, 0x41, 0x52, 0x63, 0x74, 0x85, 0x96, 0xa7,
@@ -252,7 +252,7 @@ struct eapsim_keys inputkey1 = {
 
 struct eapsim_keys inputkey2 = {
   {'1','2','4','4','0','7','0','1','0','0','0','0','0','0','0','1','@','e','a','p','s','i','m','.','f','o','o'},
-  27, 
+  27,
   0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,   /* nonce_mt */
   0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
@@ -263,14 +263,14 @@ struct eapsim_keys inputkey2 = {
   0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
 
   0xd1, 0xd2, 0xd3, 0xd4,  /* SRES 1 */
-  0xe1, 0xe2, 0xe3, 0xe4, 
-  0xf1, 0xf2, 0xf3, 0xf4, 
+  0xe1, 0xe2, 0xe3, 0xe4,
+  0xf1, 0xf2, 0xf3, 0xf4,
 
   0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,   /* Kc */
   0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
   0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
   /*   {0x00, 0x02, 0x00, 0x01}, */
-  {0x00, 0x01}, 
+  {0x00, 0x01},
   2,
   0x00, 0x01 ,
 };
@@ -293,8 +293,8 @@ main(int argc, char *argv[])
 }
 #endif
 
-       
-       
+
+
 
 
 
index 9430b6d..2e927e4 100644 (file)
@@ -2,7 +2,7 @@
  * eapsimlib.c    based upon draft-haverinen-pppext-eap-sim-11.txt.
  *
  * The development of the EAP/SIM support was funded by Internet Foundation
- * Austria (http://www.nic.at/ipa). 
+ * Austria (http://www.nic.at/ipa).
  *
  * code common to EAP-SIM clients and to servers.
  *
  *  EAP-SIM PACKET FORMAT
  *  ------- ------ ------
  *
- * EAP Request and Response Packet Format 
+ * EAP Request and Response Packet Format
  * --- ------- --- -------- ------ ------
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |     Code      |  Identifier   |            Length             |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |     Type      |  SIM-Type     |   SIM-Length  |     value ... |  
+ * |     Type      |  SIM-Type     |   SIM-Length  |     value ... |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
  * with SIM-Type/SIM-Length/Value... repeating. SIM-Length is in units
@@ -67,7 +67,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
        uint8_t          *encodedmsg, *attr;
        unsigned int      id, eapcode;
        unsigned char    *macspace, *append;
-       int               appendlen; 
+       int               appendlen;
 
        macspace = NULL;
        append = NULL;
@@ -88,7 +88,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
                {
                        continue;
                }
-               
+
                vplen = vp->length;
 
                /*
@@ -117,7 +117,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
        {
                return 0;
        }
-               
+
 
        /*
         * figured out the length, so malloc some space for the results.
@@ -129,11 +129,11 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
         * EAP is 1-code, 1-identifier, 2-length, 1-type = 5 overhead.
         *
         * SIM code adds a subtype, and 2 bytes of reserved = 3.
-        * 
+        *
         */
 
        /* malloc space for it */
-               
+
        encoded_size += 3;
        encodedmsg = malloc(encoded_size);
        if (encodedmsg == NULL) {
@@ -222,7 +222,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
                eapcode = vp->lvalue;
        }
 
-       
+
        ep->code = eapcode;
        ep->id   = (id & 0xff);
        ep->type.type = PW_EAP_SIM;
@@ -241,7 +241,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
                eap_packet_t    *hdr;
                uint16_t         hmaclen, total_length = 0;
                unsigned char    sha1digest[20];
-       
+
                total_length = EAP_HEADER_LEN + 1 + encoded_size;
                hmaclen = total_length + appendlen;
                buffer = (unsigned char *)malloc(hmaclen);
@@ -272,7 +272,7 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
 
                /* done with the buffer, free it */
                free(buffer);
-               
+
                /* now copy the digest to where it belongs in the AT_MAC */
                 /* note that it is truncated to 128-bits */
                memcpy(macspace, sha1digest, 16);
@@ -281,11 +281,11 @@ int map_eapsim_basictypes(RADIUS_PACKET *r, EAP_PACKET *ep)
        /* if we had an AT_MAC and no key, then fail */
        if(macspace != NULL && vp == NULL)
        {
-               if(encodedmsg != NULL) 
+               if(encodedmsg != NULL)
                        free(encodedmsg);
                return 0;
        }
-       
+
        return 1;
 }
 
@@ -311,7 +311,7 @@ int map_eapsim_types(RADIUS_PACKET *r)
  * wrong and the packet should be discarded.
  *
  */
-int unmap_eapsim_basictypes(RADIUS_PACKET *r, 
+int unmap_eapsim_basictypes(RADIUS_PACKET *r,
                            uint8_t *attr, unsigned int attrlen)
 {
        VALUE_PAIR              *newvp;
@@ -385,7 +385,7 @@ int unmap_eapsim_types(RADIUS_PACKET *r)
 
 /*
  * calculate the MAC for the EAP message, given the key.
- * The "extra" will be appended to the EAP message and included in the 
+ * The "extra" will be appended to the EAP message and included in the
  * HMAC.
  *
  */
@@ -461,7 +461,7 @@ eapsim_checkmac(VALUE_PAIR *rvps,
                        attr += attr[1]*4;
                }
        }
-               
+
        /* now, HMAC-SHA1 it with the key. */
        lrad_hmac_sha1(buffer, len,
                       key, 16,
@@ -483,7 +483,7 @@ eapsim_checkmac(VALUE_PAIR *rvps,
  * definitions changed to take a buffer for unknowns
  * as this is more thread safe.
  */
-const char *simstates[]={ "init", "start", NULL };     
+const char *simstates[]={ "init", "start", NULL };
 
 const char *sim_state2name(enum eapsim_clientstates state,
                           char *statenamebuf,
@@ -503,12 +503,12 @@ const char *sim_state2name(enum eapsim_clientstates state,
 
 const char *subtypes[]={ "subtype0", "subtype1", "subtype2", "subtype3",
                         "subtype4", "subtype5", "subtype6", "subtype7",
-                        "subtype8", "subtype9", 
+                        "subtype8", "subtype9",
                         "start",
                         "challenge",
                         "notification",
                         "reauth",
-                        NULL };        
+                        NULL };
 
 const char *sim_subtype2name(enum eapsim_subtype subtype,
                             char *subtypenamebuf,
@@ -580,8 +580,8 @@ main(int argc, char *argv[])
        while(!filedone) {
                if(req->vps) pairfree(&req->vps);
                if(req2->vps) pairfree(&req2->vps);
-               
-               if ((req->vps = readvp2(stdin, &filedone, "eapsimlib:")) == NULL) { 
+
+               if ((req->vps = readvp2(stdin, &filedone, "eapsimlib:")) == NULL) {
                        break;
                }
 
@@ -611,7 +611,7 @@ main(int argc, char *argv[])
                              ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_MAC);
                vpkey   = pairfind(req->vps, ATTRIBUTE_EAP_SIM_KEY);
                vpextra = pairfind(req->vps, ATTRIBUTE_EAP_SIM_EXTRA);
-               
+
                if(vp != NULL && vpkey != NULL && vpextra!=NULL) {
                        uint8_t calcmac[16];
 
@@ -633,7 +633,7 @@ main(int argc, char *argv[])
                                                j=0;
                                        }
                                        j++;
-                                       
+
                                        printf("%02x", calcmac[i]);
                                }
                                printf(" did not match\n");
@@ -645,5 +645,5 @@ main(int argc, char *argv[])
 }
 #endif
 
-       
-       
+
+
index 946bb3a..a5a7e58 100644 (file)
@@ -2,7 +2,7 @@
  * fips186prf.c    An implementation of the FIPS-186-2 SHA1-based PRF.
  *
  * The development of the EAP/SIM support was funded by Internet Foundation
- * Austria (http://www.nic.at/ipa). 
+ * Austria (http://www.nic.at/ipa).
  *
  * This code was written from scratch by Michael Richardson, and it is
  * dual licensed under both GPL and BSD.
@@ -81,7 +81,7 @@ static void onesixty_add_mod(onesixty *sum, onesixty *a, onesixty *b)
        int i, carry;
 
        carry = 0;
-       for(i=19; i>=0; i--) { 
+       for(i=19; i>=0; i--) {
 /*     for(i=0; i<20; i++) {  */
                s = a->p[i] + b->p[i] + carry;
                sum->p[i] = s & 0xff;
@@ -105,32 +105,32 @@ void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160])
        onesixty xval, xkey, w_0, w_1, sum, one;
        uint8_t *f;
        char zeros[64];
-       
+
        /*
         * let XKEY := MK,
         *
-        * Step 3: For j = 0 to 3 do     
-         *   a. XVAL = XKEY 
-         *   b. w_0 = SHA1(XVAL) 
+        * Step 3: For j = 0 to 3 do
+         *   a. XVAL = XKEY
+         *   b. w_0 = SHA1(XVAL)
          *   c. XKEY = (1 + XKEY + w_0) mod 2^160
-         *   d. XVAL = XKEY 
-         *   e. w_1 = SHA1(XVAL) 
+         *   d. XVAL = XKEY
+         *   e. w_1 = SHA1(XVAL)
          *   f. XKEY = (1 + XKEY + w_1) mod 2^160
-         * 3.3 x_j = w_0|w_1 
+         * 3.3 x_j = w_0|w_1
         *
         */
        memcpy(&xkey, mk, sizeof(xkey));
-       
+
        /* make the value 1 */
        memset(&one,  0, sizeof(one));
        one.p[19]=1;
-       
+
        f=finalkey;
-       
+
        for(j=0; j<4; j++) {
                /*   a. XVAL = XKEY  */
                xval = xkey;
-               
+
                /*   b. w_0 = SHA1(XVAL)  */
                SHA1Init(&context);
 
@@ -138,14 +138,14 @@ void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160])
                memcpy(zeros, xval.p, 20);
                SHA1Transform(context.state, zeros);
                SHA1FinalNoLen(w_0.p, &context);
-               
+
                /*   c. XKEY = (1 + XKEY + w_0) mod 2^160 */
                onesixty_add_mod(&sum,  &xkey, &w_0);
                onesixty_add_mod(&xkey, &sum,  &one);
-               
+
                /*   d. XVAL = XKEY  */
                xval = xkey;
-               
+
                /*   e. w_1 = SHA1(XVAL)  */
                SHA1Init(&context);
 
@@ -153,15 +153,15 @@ void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160])
                memcpy(zeros, xval.p, 20);
                SHA1Transform(context.state, zeros);
                SHA1FinalNoLen(w_1.p, &context);
-               
+
                /*   f. XKEY = (1 + XKEY + w_1) mod 2^160 */
                onesixty_add_mod(&sum,  &xkey, &w_1);
                onesixty_add_mod(&xkey, &sum,  &one);
-               
+
                /* now store it away */
                memcpy(f, &w_0, 20);
                f += 20;
-               
+
                memcpy(f, &w_1, 20);
                f += 20;
        }
@@ -173,44 +173,44 @@ void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160])
  *
  * page 5
  *
- * XKEY=     bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6 
- * XSEED=    00000000 00000000 00000000 00000000 00000000 
+ * XKEY=     bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6
+ * XSEED=    00000000 00000000 00000000 00000000 00000000
+ *
  *
+ * The first loop through step 3.2 provides:
+ *
+ * XVAL=     bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6
  *
- * The first loop through step 3.2 provides: 
- * 
- * XVAL=     bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6 
- *  
  * Using the routine in Appendix 3.3, Constructing The Function G From SHA-1,
  * in step 3.2.b of the Change Notice algorithm for computing values of x
- * provides:  
- *
- * w[0]=     2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614 
- * 
- * 
- * The following value is the updated XKEY value from step 3.2.c: 
- *
- * XKEY=     dd734ee0 bd0bcd3b adbaeb27 dd1eaa59 76803ecb 
- * 
- * The second loop through step 3.2 provides: 
- * 
- * XVAL=     dd734ee0 bd0bcd3b adbaeb27 dd1eaa59 76803ecb 
- *  
+ * provides:
+ *
+ * w[0]=     2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614
+ *
+ *
+ * The following value is the updated XKEY value from step 3.2.c:
+ *
+ * XKEY=     dd734ee0 bd0bcd3b adbaeb27 dd1eaa59 76803ecb
+ *
+ * The second loop through step 3.2 provides:
+ *
+ * XVAL=     dd734ee0 bd0bcd3b adbaeb27 dd1eaa59 76803ecb
+ *
  * Using the routine in Appendix 3.3, Constructing The Function G From SHA-1,
  * in step 3.2.b of the Change Notice algorithm for computing values of x
- * provides:  
+ * provides:
+ *
+ * w[1]=     3c6c18ba cb0f6c55 babb1378 8e20d737 a3275116
+ *
+ * The following value is the updated XKEY value from step 3.2.c:
  *
- * w[1]=     3c6c18ba cb0f6c55 babb1378 8e20d737 a3275116 
  *
- * The following value is the updated XKEY value from step 3.2.c: 
+ * XKEY=     19df679b 881b3991 6875fea0 6b3f8191 19a78fe2
  *
- * 
- * XKEY=     19df679b 881b3991 6875fea0 6b3f8191 19a78fe2 
+ * Step 3.3 provides the following values:
  *
- * Step 3.3 provides the following values: 
- * 
- * w[0] || w[1]=  2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614 
- *                3c6c18ba cb0f6c55 babb1378 8e20d737 a3275116 
+ * w[0] || w[1]=  2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614
+ *                3c6c18ba cb0f6c55 babb1378 8e20d737 a3275116
  *
  */
 
@@ -240,7 +240,7 @@ main(int argc, char *argv[])
 
                printf("%02x", mk[i]);
        }
-       
+
        printf("|\nOutput was: ");
        j=0; k=0;
        for (i = 0; i < 160; i++) {
@@ -248,7 +248,7 @@ main(int argc, char *argv[])
                        printf("\n            ");
                        k=0;
                        j=0;
-               } 
+               }
                if(j==4) {
                        printf("_");
                        j=0;
@@ -262,11 +262,18 @@ main(int argc, char *argv[])
 }
 #endif
 
-       
-       
+
+
 /*
  * $Log$
- * Revision 1.2  2003-11-06 15:37:24  aland
+ * Revision 1.3  2004-02-26 19:04:30  aland
+ *     perl -i -npe "s/[ \t]+$//g" `find src -name "*.[ch]" -print`
+ *
+ *     Whitespace changes only, from a fresh checkout.
+ *
+ *     For bug # 13
+ *
+ * Revision 1.2  2003/11/06 15:37:24  aland
  *     Update includes to work a little better
  *
  * Revision 1.1  2003/10/29 02:49:19  mcr
index 096a64e..177ef15 100644 (file)
@@ -73,7 +73,7 @@ void eap_packet_free(EAP_PACKET **eap_packet_ptr)
 EAP_DS *eap_ds_alloc(void)
 {
        EAP_DS  *eap_ds;
-        
+
        eap_ds = rad_malloc(sizeof(EAP_DS));
        memset(eap_ds, 0, sizeof(EAP_DS));
        if ((eap_ds->response = eap_packet_alloc()) == NULL) {
@@ -110,7 +110,7 @@ void eap_ds_free(EAP_DS **eap_ds_p)
 EAP_HANDLER *eap_handler_alloc(void)
 {
        EAP_HANDLER     *handler;
-        
+
        handler = rad_malloc(sizeof(EAP_HANDLER));
        memset(handler, 0, sizeof(EAP_HANDLER));
        return handler;
@@ -173,7 +173,7 @@ void eaplist_free(rlm_eap_t *inst)
                        eap_handler_free(&node);
                        node = next;
                }
-               
+
                inst->sessions[i] = NULL;
        }
 }
@@ -198,7 +198,7 @@ int eaplist_add(rlm_eap_t *inst, EAP_HANDLER *handler)
         */
        state = generate_state(handler->request->timestamp);
        pairadd(&(handler->request->reply->vps), state);
-               
+
        /*
         *      Create a unique 'key' for the handler, based
         *      on State, Client-IP-Address, and EAP ID.
@@ -226,7 +226,7 @@ int eaplist_add(rlm_eap_t *inst, EAP_HANDLER *handler)
        last = &(inst->sessions[state->strvalue[0]]);
 
        while (*last) last = &((*last)->next);
-       
+
        *last = handler;
 
        /*
@@ -294,7 +294,7 @@ EAP_HANDLER *eaplist_find(rlm_eap_t *inst, REQUEST *request,
                next = node->next;
 
                /*
-                *      If the time on this entry has expired, 
+                *      If the time on this entry has expired,
                 *      delete it.  We do this while walking the list,
                 *      in order to spread out the work of deleting old
                 *      sessions.
@@ -330,7 +330,7 @@ EAP_HANDLER *eaplist_find(rlm_eap_t *inst, REQUEST *request,
                                node = NULL;
                                break;
                        }
-                       
+
                        DEBUG2("  rlm_eap: Request found, released from the list");
                        /*
                         *      detach the node from the list
index a38b38a..c716be3 100644 (file)
@@ -85,7 +85,7 @@ struct eapsim_keys eapsim_mk;
 static void usage(void)
 {
        fprintf(stderr, "Usage: radeapclient [options] server[:port] <command> [<secret>]\n");
-       
+
        fprintf(stderr, "  <command>    One of auth, acct, status, or disconnect.\n");
        fprintf(stderr, "  -c count    Send each packet 'count' times.\n");
        fprintf(stderr, "  -d raddb    Set dictionary directory.\n");
@@ -252,7 +252,7 @@ static int process_eap_start(RADIUS_PACKET *req,
                fprintf(stderr, "illegal start message has no VERSION_LIST\n");
                return 0;
        }
-       
+
        versions = (uint16_t *)vp->strvalue;
 
        /* verify that the attribute length is big enough for a length field */
@@ -300,7 +300,7 @@ static int process_eap_start(RADIUS_PACKET *req,
                                ntohs(versions[i+1]));
                }
        }
-       
+
        /*
         * now make sure that we have only FULLAUTH_ID_REQ.
         * I think that it actually might not matter - we can answer in
@@ -351,7 +351,7 @@ static int process_eap_start(RADIUS_PACKET *req,
                newvp->strvalue[0]=0;
                newvp->strvalue[1]=0;
                newvp->length = 18;  /* 16 bytes of nonce + padding */
-               
+
                nonce[0]=lrad_rand();
                nonce[1]=lrad_rand();
                nonce[2]=lrad_rand();
@@ -431,7 +431,7 @@ static int process_eap_challenge(RADIUS_PACKET *req,
          randcfg[0] = &randvp->strvalue[2];
          randcfg[1] = &randvp->strvalue[2+EAPSIM_RAND_SIZE];
          randcfg[2] = &randvp->strvalue[2+EAPSIM_RAND_SIZE*2];
-         
+
          randcfgvp[0] = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_RAND1);
          randcfgvp[1] = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_RAND2);
          randcfgvp[2] = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_RAND3);
@@ -458,7 +458,7 @@ static int process_eap_challenge(RADIUS_PACKET *req,
                  j=0;
                }
                j++;
-                       
+
                fprintf(stderr, "%02x", randcfg[rnum][i]);
              }
              fprintf(stderr, "\nconfigured rand %d: ", rnum);
@@ -469,7 +469,7 @@ static int process_eap_challenge(RADIUS_PACKET *req,
                  j=0;
                }
                j++;
-                       
+
                fprintf(stderr, "%02x", randcfgvp[rnum]->strvalue[i]);
              }
              fprintf(stderr, "\n");
@@ -502,7 +502,7 @@ static int process_eap_challenge(RADIUS_PACKET *req,
        Kc1 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_KC1);
        Kc2 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_KC2);
        Kc3 = pairfind(rep->vps, ATTRIBUTE_EAP_SIM_KC3);
-       
+
        if(Kc1 == NULL ||
           Kc2 == NULL ||
           Kc3 == NULL) {
@@ -535,7 +535,7 @@ static int process_eap_challenge(RADIUS_PACKET *req,
                                j=0;
                        }
                        j++;
-                       
+
                        printf("%02x", calcmac[i]);
                }
                printf(" did not match\n");
@@ -614,7 +614,7 @@ static int respond_eap_sim(RADIUS_PACKET *req,
 
        printf("<+++ EAP-sim decoded packet:\n");
        vp_printlist(stdout, req->vps);
-       
+
        if((vp = pairfind(req->vps, ATTRIBUTE_EAP_SIM_SUBTYPE)) == NULL)
        {
                return 0;
@@ -630,7 +630,7 @@ static int respond_eap_sim(RADIUS_PACKET *req,
                case eapsim_start:
                        newstate = process_eap_start(req, resp);
                        break;
-                       
+
                case eapsim_challenge:
                case eapsim_notification:
                case eapsim_reauth:
@@ -649,7 +649,7 @@ static int respond_eap_sim(RADIUS_PACKET *req,
                        /* NOT SURE ABOUT THIS ONE, retransmit, I guess */
                        newstate = process_eap_start(req, resp);
                        break;
-                       
+
                case eapsim_challenge:
                        newstate = process_eap_challenge(req, resp);
                        break;
@@ -720,7 +720,7 @@ static int respond_eap_md5(RADIUS_PACKET *req,
        value = &vp->strvalue[1];
        name  = &vp->strvalue[valuesize+1];
        namesize = vp->length - (valuesize + 1);
-       
+
        /* sanitize items */
        if(valuesize > vp->length)
        {
@@ -754,20 +754,20 @@ static int respond_eap_md5(RADIUS_PACKET *req,
        return 1;
 }
 
-       
+
 
 static int sendrecv_eap(RADIUS_PACKET *rep)
 {
        RADIUS_PACKET *req = NULL;
        VALUE_PAIR *vp, *vpnext;
        int tried_eap_md5 = 0;
-       
+
        /*
         *      Keep a copy of the the User-Password attribute.
         */
        if ((vp = pairfind(rep->vps, ATTRIBUTE_EAP_MD5_PASSWORD)) != NULL) {
                strNcpy(password, (char *)vp->strvalue, sizeof(vp->strvalue));
-               
+
        } else  if ((vp = pairfind(rep->vps, PW_PASSWORD)) != NULL) {
                strNcpy(password, (char *)vp->strvalue, sizeof(vp->strvalue));
                /*
@@ -779,18 +779,18 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                *password = '\0';
        }
 
- again:        
+ again:
        rep->id++;
 
        printf("\n+++> About to send encoded packet:\n");
        vp_printlist(stdout, rep->vps);
-       
+
        /*
         * if there are EAP types, encode them into an EAP-Message
         *
         */
        map_eap_types(rep);
-       
+
        /*
         *  Fix up Digest-Attributes issues
         */
@@ -798,7 +798,7 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                switch (vp->attribute) {
                default:
                        break;
-                       
+
                case PW_DIGEST_REALM:
                case PW_DIGEST_NONCE:
                case PW_DIGEST_METHOD:
@@ -818,7 +818,7 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                        break;
                }
        }
-       
+
        /*
         *      If we've already sent a packet, free up the old
         *      one, and ensure that the next packet has a unique
@@ -828,19 +828,19 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                free(rep->data);
                rep->data = NULL;
        }
-       
+
        librad_md5_calc(rep->vector, rep->vector,
                        sizeof(rep->vector));
-       
+
        if (*password != '\0') {
                if ((vp = pairfind(rep->vps, PW_PASSWORD)) != NULL) {
                        strNcpy((char *)vp->strvalue, password, strlen(password) + 1);
                        vp->length = strlen(password);
-                       
+
                } else if ((vp = pairfind(rep->vps, PW_CHAP_PASSWORD)) != NULL) {
                        strNcpy((char *)vp->strvalue, password, strlen(password) + 1);
                        vp->length = strlen(password);
-                       
+
                        rad_chap_encode(rep, (char *) vp->strvalue, rep->id, vp);
                        vp->length = 17;
                }
@@ -848,13 +848,13 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
 
        /* send the response, wait for the next request */
        send_packet(rep, &req);
-       
+
        /* okay got back the packet, go and decode the EAP-Message. */
        unmap_eap_types(req);
-       
+
        printf("<+++ EAP decoded packet:\n");
        vp_printlist(stdout, req->vps);
-       
+
        /* now look for the code type. */
        for (vp = req->vps; vp != NULL; vp = vpnext) {
                vpnext = vp->next;
@@ -862,7 +862,7 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                switch (vp->attribute) {
                default:
                        break;
-                       
+
                case ATTRIBUTE_EAP_BASE+PW_EAP_MD5:
                        if(respond_eap_md5(req, rep) && tried_eap_md5 < 3)
                        {
@@ -870,7 +870,7 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                                goto again;
                        }
                        break;
-                       
+
                case ATTRIBUTE_EAP_BASE+PW_EAP_SIM:
                        if(respond_eap_sim(req, rep))
                        {
@@ -879,7 +879,7 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
                        break;
                }
        }
-       
+
        return 1;
 }
 
@@ -904,7 +904,7 @@ int main(int argc, char **argv)
        {
                switch(c) {
                case 'c':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        count = atoi(optarg);
                        break;
@@ -929,12 +929,12 @@ int main(int argc, char **argv)
 
 
                case 'r':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        retries = atoi(optarg);
                        break;
                case 'i':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        id = atoi(optarg);
                        if ((id < 0) || (id > 255)) {
@@ -945,7 +945,7 @@ int main(int argc, char **argv)
                        do_summary = 1;
                        break;
                case 't':
-                       if (!isdigit((int) *optarg)) 
+                       if (!isdigit((int) *optarg))
                                usage();
                        timeout = atof(optarg);
                        break;
@@ -1006,7 +1006,7 @@ int main(int argc, char **argv)
        }
 
 #if 0
-       { 
+       {
                FILE *randinit;
 
                if((randinit = fopen("/dev/urandom", "r")) == NULL)
@@ -1017,7 +1017,7 @@ int main(int argc, char **argv)
                        fclose(randinit);
                }
        }
-       lrad_randinit(&randctx, 1);  
+       lrad_randinit(&randctx, 1);
 #endif
 
        req->id = id;
@@ -1096,7 +1096,7 @@ int main(int argc, char **argv)
        } else {
                fp = stdin;
        }
-       
+
        /*
         *      Send request.
         */
@@ -1107,15 +1107,15 @@ int main(int argc, char **argv)
 
        while(!filedone) {
                if(req->vps) pairfree(&req->vps);
-               
+
                if ((req->vps = readvp2(fp, &filedone, "radeapclient:"))
                    == NULL) {
                        break;
                }
-       
+
                sendrecv_eap(req);
        }
-       
+
        if(do_summary) {
                printf("\n\t   Total approved auths:  %d\n", totalapp);
                printf("\t     Total denied auths:  %d\n", totaldeny);
index f977d14..d9fad7e 100644 (file)
@@ -35,7 +35,7 @@ static const CONF_PARSER module_config[] = {
          offsetof(rlm_eap_t, timer_limit), NULL, "60"},
        { "ignore_unknown_eap_types", PW_TYPE_BOOLEAN,
          offsetof(rlm_eap_t, ignore_unknown_eap_types), NULL, "no" },
-       
+
        { NULL, -1, 0, NULL, NULL }           /* end the list */
 };
 
@@ -83,7 +83,7 @@ static int eap_instantiate(CONF_SECTION *cs, void **instance)
        int             num_types;
        CONF_SECTION    *scs;
        rlm_eap_t       *inst;
-       
+
        inst = (rlm_eap_t *) malloc(sizeof(*inst));
        if (!inst) {
                return -1;
@@ -174,7 +174,7 @@ static int eap_instantiate(CONF_SECTION *cs, void **instance)
        pthread_mutex_init(&(inst->session_mutex), NULL);
        pthread_mutex_init(&(inst->module_mutex), NULL);
 #endif
-       
+
        *instance = inst;
        return 0;
 }
@@ -397,7 +397,7 @@ static int eap_authorize(void *instance, REQUEST *request)
        rlm_eap_t       *inst;
        int             status;
        VALUE_PAIR      *vp;
-       
+
        inst = (rlm_eap_t *)instance;
 
        /*
@@ -429,7 +429,7 @@ static int eap_authorize(void *instance, REQUEST *request)
        default:
                break;
        }
-       
+
        /*
         *      RFC 2869, Section 2.3.1.  If a NAS sends an EAP-Identity,
         *      it MUST copy the identity into the User-Name attribute.
@@ -492,13 +492,13 @@ static int eap_post_proxy(void *inst, REQUEST *request)
                        eap_handler_free(&handler);
                        return RLM_MODULE_REJECT;
                }
-               
+
                /*
                 *      We are done, wrap the EAP-request in RADIUS to send
                 *      with all other required radius attributes
                 */
                rcode = eap_compose(handler);
-               
+
                /*
                 *      Add to the list only if it is EAP-Request, OR if
                 *      it's LEAP, and a response.
@@ -512,7 +512,7 @@ static int eap_post_proxy(void *inst, REQUEST *request)
                        /* handler is not required any more, free it now */
                        eap_handler_free(&handler);
                }
-               
+
                /*
                 *      If it's an Access-Accept, RFC 2869, Section 2.3.1
                 *      says that we MUST include a User-Name attribute in the
@@ -531,7 +531,7 @@ static int eap_post_proxy(void *inst, REQUEST *request)
                                pairadd(&(request->reply->vps), vp);
                        }
                }
-               
+
                return RLM_MODULE_OK;
        }
 
@@ -553,7 +553,7 @@ static int eap_post_proxy(void *inst, REQUEST *request)
                if (!vp) {
                        return RLM_MODULE_NOOP;
                }
-               
+
                /*
                 *      If it's "leap:session-key", then stop.
                 *
index add7b12..42fd5cf 100644 (file)
@@ -156,13 +156,13 @@ VALUE_PAIR *generate_state(time_t timestamp)
 }
 
 /*
- * Returns 0 on success, non-zero otherwise. 
+ * Returns 0 on success, non-zero otherwise.
  */
 int verify_state(VALUE_PAIR *state, time_t timestamp)
 {
        unsigned char hmac[EAP_HMAC_SIZE];
        unsigned char value[EAP_CHALLENGE_LEN + sizeof(timestamp)];
-       
+
        /*
         *      The length is wrong.  Don't do anything.
         */
index 6f30dc9..aff91fd 100644 (file)
@@ -140,7 +140,7 @@ static int gtc_initiate(void *type_data, EAP_HANDLER *handler)
         *      to us...
         */
        handler->stage = AUTHENTICATE;
-       
+
        return 1;
 }
 
@@ -169,7 +169,7 @@ static int gtc_authenticate(void *type_data, EAP_HANDLER *handler)
                eap_ds->request->code = PW_EAP_FAILURE;
                return 0;
        }
-       
+
 #if 0
        if (debug_flag > 2) {
                int i;
@@ -178,7 +178,7 @@ static int gtc_authenticate(void *type_data, EAP_HANDLER *handler)
                        if ((i & 0x0f) == 0) printf("%d: ", i);
 
                        printf("%02x ", eap_ds->response->type.data[i]);
-                       
+
                        if ((i & 0x0f) == 0x0f) printf("\n");
                }
        }
@@ -197,13 +197,13 @@ static int gtc_authenticate(void *type_data, EAP_HANDLER *handler)
                        eap_ds->request->code = PW_EAP_FAILURE;
                        return 0;
                }
-               
+
                if (eap_ds->response->type.length != vp->length) {
                        DEBUG2("  rlm_eap_gtc: ERROR: Passwords are of different length. %d %d", eap_ds->response->type.length, vp->length);
                        eap_ds->request->code = PW_EAP_FAILURE;
                        return 0;
                }
-               
+
                if (memcmp(eap_ds->response->type.data,
                           vp->strvalue, vp->length) != 0) {
                        DEBUG2("  rlm_eap_gtc: ERROR: Passwords are different");
@@ -248,12 +248,12 @@ static int gtc_authenticate(void *type_data, EAP_HANDLER *handler)
                        eap_ds->request->code = PW_EAP_FAILURE;
                        return 0;
                }
-               
+
        } else {
                radlog(L_ERR, "rlm_eap_gtc: Response is too large to understand");
                eap_ds->request->code = PW_EAP_FAILURE;
                return 0;
-               
+
        }
 
        DEBUG2("  rlm_eap_gtc: Everything is OK.");
index b5d10dd..993ced8 100644 (file)
@@ -23,7 +23,7 @@
 /*
  *
  *  LEAP Packet Format in EAP Type-Data
- *  --- ------ ------ -- --- --------- 
+ *  --- ------ ------ -- --- ---------
  *    0                   1                   2                        3
  *   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -82,9 +82,9 @@ void eapleap_free(LEAP_PACKET **leap_packet_ptr)
        *leap_packet_ptr = NULL;
 }
 
-/* 
+/*
  *   Extract the data from the LEAP packet.
- */ 
+ */
 LEAP_PACKET *eapleap_extract(EAP_DS *eap_ds)
 {
        leap_packet_t   *data;
@@ -95,8 +95,8 @@ LEAP_PACKET *eapleap_extract(EAP_DS *eap_ds)
         *      LEAP can have EAP-Response or EAP-Request (step 5)
         *      messages sent to it.
         */
-       if (!eap_ds || 
-           !eap_ds->response || 
+       if (!eap_ds ||
+           !eap_ds->response ||
            ((eap_ds->response->code != PW_EAP_RESPONSE) &&
             (eap_ds->response->code != PW_EAP_REQUEST)) ||
            eap_ds->response->type.type != PW_EAP_LEAP ||
@@ -212,7 +212,7 @@ static void eapleap_ntpwdhash(unsigned char *ntpwdhash, VALUE_PAIR *password)
                         */
                        unicode[(i << 1)] = password->strvalue[i];
                }
-               
+
                /*
                 *  Get the NT Password hash.
                 */
@@ -228,16 +228,16 @@ static void eapleap_ntpwdhash(unsigned char *ntpwdhash, VALUE_PAIR *password)
 }
 
 
-/* 
+/*
  *     Verify the MS-CHAP response from the user.
  */
-int eapleap_stage4(LEAP_PACKET *packet, VALUE_PAIR* password, 
+int eapleap_stage4(LEAP_PACKET *packet, VALUE_PAIR* password,
                   leap_session_t *session)
 {
        unsigned char ntpwdhash[16];
        unsigned char response[24];
-       
-       
+
+
        /*
         *      No password or previous packet.  Die.
         */
@@ -261,11 +261,11 @@ int eapleap_stage4(LEAP_PACKET *packet, VALUE_PAIR* password,
        return 0;
 }
 
-/* 
+/*
  *     Verify ourselves to the AP
  */
 LEAP_PACKET *eapleap_stage6(LEAP_PACKET *packet, REQUEST *request,
-                           VALUE_PAIR *user_name, VALUE_PAIR* password, 
+                           VALUE_PAIR *user_name, VALUE_PAIR* password,
                            leap_session_t *session, VALUE_PAIR **reply_vps)
 {
        int i;
@@ -274,7 +274,7 @@ LEAP_PACKET *eapleap_stage6(LEAP_PACKET *packet, REQUEST *request,
        LEAP_PACKET *reply;
        char *p;
        VALUE_PAIR *vp;
-       
+
        /*
         *      No password or previous packet.  Die.
         */
@@ -305,7 +305,7 @@ LEAP_PACKET *eapleap_stage6(LEAP_PACKET *packet, REQUEST *request,
                eapleap_free(&reply);
                return NULL;
        }
-       
+
        /*
         *      Copy the name over, and ensure it's NUL terminated.
         */
@@ -412,7 +412,7 @@ LEAP_PACKET *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name)
                eapleap_free(&reply);
                return NULL;
        }
-       
+
        /*
         *      Copy the name over, and ensure it's NUL terminated.
         */
@@ -423,7 +423,7 @@ LEAP_PACKET *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name)
        return reply;
 }
 
-/* 
+/*
  * compose the LEAP reply packet in the EAP reply typedata
  */
 int eapleap_compose(EAP_DS *eap_ds, LEAP_PACKET *reply)
@@ -438,7 +438,7 @@ int eapleap_compose(EAP_DS *eap_ds, LEAP_PACKET *reply)
        case PW_EAP_RESPONSE:
                eap_ds->request->type.type = PW_EAP_LEAP;
                eap_ds->request->type.length = reply->length;
-               
+
                eap_ds->request->type.data = malloc(reply->length);
                if (eap_ds->request->type.data == NULL) {
                        radlog(L_ERR, "rlm_eap_leap: out of memory");
index 1412b83..6fc3084 100644 (file)
@@ -64,10 +64,10 @@ void                eapleap_free(LEAP_PACKET **leap_packet_ptr);
 int            eapleap_compose(EAP_DS *auth, LEAP_PACKET *reply);
 LEAP_PACKET    *eapleap_extract(EAP_DS *auth);
 LEAP_PACKET    *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name);
-int            eapleap_stage4(LEAP_PACKET *packet, VALUE_PAIR* password, 
+int            eapleap_stage4(LEAP_PACKET *packet, VALUE_PAIR* password,
                               leap_session_t *session);
 LEAP_PACKET    *eapleap_stage6(LEAP_PACKET *packet, REQUEST *request,
-                               VALUE_PAIR *user_name, VALUE_PAIR* password, 
+                               VALUE_PAIR *user_name, VALUE_PAIR* password,
                                leap_session_t *session,
                                VALUE_PAIR **reply_vps);
 #endif /*_EAP_LEAP_H*/
index 0daa577..1897c97 100644 (file)
@@ -180,7 +180,7 @@ static int leap_authenticate(void *instance, EAP_HANDLER *handler)
 
        /*
         *      Process the packet.  We don't care about any previous
-        *      EAP packets, as 
+        *      EAP packets, as
         */
        if (!reply) {
                return 0;
index b92fa87..2411d4b 100644 (file)
@@ -24,7 +24,7 @@
 /*
  *
  *  MD5 Packet Format in EAP Type-Data
- *  --- ------ ------ -- --- --------- 
+ *  --- ------ ------ -- --- ---------
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -75,9 +75,9 @@ void eapmd5_free(MD5_PACKET **md5_packet_ptr)
        *md5_packet_ptr = NULL;
 }
 
-/* 
+/*
  *     We expect only RESPONSE for which SUCCESS or FAILURE is sent back
- */ 
+ */
 MD5_PACKET *eapmd5_extract(EAP_DS *eap_ds)
 {
        md5_packet_t    *data;
@@ -89,8 +89,8 @@ MD5_PACKET *eapmd5_extract(EAP_DS *eap_ds)
         *      one byte of type data (EAP-MD5) following the 4-byte
         *      EAP-Packet header.
         */
-       if (!eap_ds                                      || 
-           !eap_ds->response                            || 
+       if (!eap_ds                                      ||
+           !eap_ds->response                            ||
            (eap_ds->response->code != PW_MD5_RESPONSE)  ||
            eap_ds->response->type.type != PW_EAP_MD5    ||
            !eap_ds->response->type.data                 ||
@@ -157,10 +157,10 @@ MD5_PACKET *eapmd5_extract(EAP_DS *eap_ds)
 }
 
 
-/* 
+/*
  * verify = MD5(id+password+challenge_sent)
  */
-int eapmd5_verify(MD5_PACKET *packet, VALUE_PAIR* password, 
+int eapmd5_verify(MD5_PACKET *packet, VALUE_PAIR* password,
                  uint8_t *challenge)
 {
        char    *ptr;
@@ -205,7 +205,7 @@ int eapmd5_verify(MD5_PACKET *packet, VALUE_PAIR* password,
        return 1;
 }
 
-/* 
+/*
  *     Compose the portions of the reply packet specific to the
  *     EAP-MD5 protocol, in the EAP reply typedata
  */
index 1965348..9c72346 100644 (file)
@@ -96,7 +96,7 @@ static int md5_initiate(void *type_data, EAP_HANDLER *handler)
         *      to us...
         */
        handler->stage = AUTHENTICATE;
-       
+
        return 1;
 }
 
index 4bfd55d..fc3586d 100644 (file)
@@ -78,9 +78,9 @@ static int eapmschapv2_compose(EAP_HANDLER *handler, VALUE_PAIR *reply)
                length = htons(length);
                memcpy(hdr->ms_length, &length, sizeof(uint16_t));
                hdr->value_size = MSCHAPV2_CHALLENGE_LEN;
-               
+
                ptr += MSCHAPV2_HEADER_LEN;
-               
+
                /*
                 *      Copy the Challenge, success, or error over.
                 */
@@ -119,7 +119,7 @@ static int eapmschapv2_compose(EAP_HANDLER *handler, VALUE_PAIR *reply)
                memcpy((eap_ds->request->type.data + 2), &length, sizeof(uint16_t));
                memcpy((eap_ds->request->type.data + 4), reply->strvalue + 1, 42);
                break;
-               
+
        case PW_MSCHAP_ERROR:
                DEBUG2("MSCHAP Failure\n");
                length = 4 + MSCHAPV2_FAILURE_MESSAGE_LEN;
@@ -141,13 +141,13 @@ static int eapmschapv2_compose(EAP_HANDLER *handler, VALUE_PAIR *reply)
                memcpy((eap_ds->request->type.data + 2), &length, sizeof(uint16_t));
                memcpy((eap_ds->request->type.data + 4), MSCHAPV2_FAILURE_MESSAGE, MSCHAPV2_FAILURE_MESSAGE_LEN);
                break;
-               
+
        default:
                radlog(L_ERR, "rlm_eap_mschapv2: Internal sanity check failed");
                return 0;
                break;
        }
-       
+
        return 1;
 }
 
@@ -192,7 +192,7 @@ static int mschapv2_initiate(void *type_data, EAP_HANDLER *handler)
 
        handler->opaque = data;
        handler->free_opaque = free;
-       
+
        /*
         *      Compose the EAP-MSCHAPV2 packet out of the data structure,
         *      and free it.
@@ -214,7 +214,7 @@ static int mschapv2_initiate(void *type_data, EAP_HANDLER *handler)
         *      to us...
         */
        handler->stage = AUTHENTICATE;
-       
+
        return 1;
 }
 
@@ -284,7 +284,7 @@ static int mschapv2_authenticate(void *arg, EAP_HANDLER *handler)
 
                /*
                 *      4 for EAP header, 1 for EAP-MSCHAPv2 code, and
-                *      50 for 
+                *      50 for
                 */
                if (eap_ds->response->length < (4 + 1 + MSCHAPV2_RESPONSE_LEN)) {
                        radlog(L_ERR, "rlm_eap_mschapv2: MS-CHAPV2-Response is too short (%d)", eap_ds->response->length - 5);
index e4a3839..2665eb7 100644 (file)
@@ -113,7 +113,7 @@ static int eapmessage_verify(const uint8_t *data, unsigned int data_len)
                DEBUG2("  rlm_eap_peap: Identity - %s", identity);
                return 1;
                break;
-               
+
                /*
                 *      If the first byte of the packet is
                 *      EAP-Response, and the EAP data is a TLV,
@@ -200,12 +200,12 @@ static int vp2eap(tls_session_t *tls_session, VALUE_PAIR *vp)
        if (debug_flag > 2) {
                int i;
                int total = vp->length - 4;
-               
+
                if (debug_flag > 0) for (i = 0; i < total; i++) {
                        if ((i & 0x0f) == 0) printf("  PEAP tunnel data out %04x: ", i);
-                       
+
                        printf("%02x ", vp->strvalue[i + 4]);
-                       
+
                        if ((i & 0x0f) == 0x0f) printf("\n");
                }
                if ((total & 0x0f) != 0) printf("\n");
@@ -270,7 +270,7 @@ static int process_reply(EAP_HANDLER *handler, tls_session_t *tls_session,
                t->status = PEAP_STATUS_SENT_TLV_SUCCESS;
                eappeap_success(handler, tls_session);
                rcode = RLM_MODULE_HANDLED;
-               
+
                /*
                 *      If we've been told to use the attributes from
                 *      the reply, then do so.
@@ -371,7 +371,7 @@ static int eappeap_postproxy(EAP_HANDLER *handler, void *data)
                DEBUG2("  PEAP: Reply was rejected");
                eaptls_fail(handler->eap_ds, 0);
                return 0;
-         
+
        case RLM_MODULE_HANDLED:
                DEBUG2("  PEAP: Reply was handled");
                eaptls_request(handler->eap_ds, tls_session);
@@ -380,7 +380,7 @@ static int eappeap_postproxy(EAP_HANDLER *handler, void *data)
        case RLM_MODULE_OK:
                DEBUG2("  PEAP: Reply was OK");
                eaptls_success(handler->eap_ds, 0);
-               eaptls_gen_mppe_keys(&handler->request->reply->vps, 
+               eaptls_gen_mppe_keys(&handler->request->reply->vps,
                                     tls_session->ssl,
                                     "client EAP encryption");
                return 1;
@@ -455,7 +455,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
        /*
         *      If there's no data, maybe this is an ACK to an
         *      MS-CHAP2-Success.
-        */     
+        */
        if (err == 0) {
                /*
                 *      FIXME: Call SSL_get_error() to see what went
@@ -464,7 +464,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                radlog(L_INFO, "rlm_eap_peap: No data inside of the tunnel.");
                return RLM_MODULE_REJECT;
        }
+
        data_len = tls_session->clean_out.used = err;
        data = tls_session->clean_out.data;
 
@@ -472,9 +472,9 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
        if (debug_flag > 2) {
                for (i = 0; i < data_len; i++) {
                        if ((i & 0x0f) == 0) printf("  PEAP tunnel data in %04x: ", i);
-                       
+
                        printf("%02x ", data[i]);
-                       
+
                        if ((i & 0x0f) == 0x0f) printf("\n");
                }
                if ((data_len & 0x0f) != 0) printf("\n");
@@ -543,7 +543,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                if ((data[0] == PW_EAP_IDENTITY) && (data_len > 1)) {
                        t->username = pairmake("User-Name", "", T_OP_EQ);
                        rad_assert(t->username != NULL);
-                               
+
                        memcpy(t->username->strvalue, data+1, data_len - 1);
                        t->username->length = data_len -1;
                        t->username->strvalue[t->username->length] = 0;
@@ -652,7 +652,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
 #ifndef NDEBUG
        if (debug_flag > 0) {
                printf("  PEAP: Sending tunneled request\n");
-               
+
                for (vp = fake->packet->vps; vp != NULL; vp = vp->next) {
                        putchar('\t');vp_print(stdout, vp);putchar('\n');
                }
@@ -673,7 +673,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
        if (debug_flag > 0) {
                printf("  PEAP: Got tunneled reply RADIUS code %d\n",
                 fake->reply->code);
-               
+
                for (vp = fake->reply->vps; vp != NULL; vp = vp->next) {
                        putchar('\t');vp_print(stdout, vp);putchar('\n');
                }
@@ -708,13 +708,13 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                         */
                        if (!t->proxy_tunneled_request_as_eap) {
                                fake->options |= RAD_REQUEST_OPTION_PROXY_EAP;
-                               
+
                                /*
                                 *      Hmm... should we check for
                                 *      Auth-Type & EAP-Message here?
                                 */
 
-                               
+
                                /*
                                 *      Run the EAP authentication.
                                 */
@@ -725,7 +725,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                                        rcode = RLM_MODULE_REJECT;
                                        goto done;
                                }
-                               
+
                                /*
                                 *      The module decided it wasn't
                                 *      done.  Handle it like normal.
@@ -774,12 +774,12 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                        /*
                         *      Associate the callback with the request.
                         */
-                       rcode = request_data_add(request, 
+                       rcode = request_data_add(request,
                                                 request->proxy,
                                                 REQUEST_DATA_EAP_TUNNEL_CALLBACK,
                                                 tunnel, free);
                        rad_assert(rcode == 0);
-                       
+
                        /*
                         *      Didn't authenticate the packet, but
                         *      we're proxying it.
@@ -798,9 +798,9 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                                      fake->reply);
                break;
        }
-       
+
  done:
        request_free(&fake);
-       
+
        return rcode;
 }
index bca3d2c..51617ac 100644 (file)
@@ -179,7 +179,7 @@ static int eappeap_authenticate(void *arg, EAP_HANDLER *handler)
        case EAPTLS_SUCCESS:
                {
                        eap_packet_t eap_packet;
-                       
+
                        eap_packet.code = PW_EAP_REQUEST;
                        eap_packet.id = handler->eap_ds->response->id + 1;
                        eap_packet.length[0] = 0;
@@ -188,7 +188,7 @@ static int eappeap_authenticate(void *arg, EAP_HANDLER *handler)
 
                        record_plus(&tls_session->clean_in,
                                    &eap_packet, sizeof(eap_packet));
-                       
+
                        tls_handshake_send(tls_session);
                        record_init(&tls_session->clean_in);
                }
@@ -235,7 +235,7 @@ static int eappeap_authenticate(void *arg, EAP_HANDLER *handler)
                tls_session->opaque = peap_alloc(inst);
                tls_session->free_opaque = peap_free;
        }
-       
+
        /*
         *      Process the PEAP portion of the request.
         */
@@ -244,14 +244,14 @@ static int eappeap_authenticate(void *arg, EAP_HANDLER *handler)
        case RLM_MODULE_REJECT:
                eaptls_fail(handler->eap_ds, 0);
                return 0;
-         
+
        case RLM_MODULE_HANDLED:
                eaptls_request(handler->eap_ds, tls_session);
                return 1;
 
        case RLM_MODULE_OK:
                eaptls_success(handler->eap_ds, 0);
-               eaptls_gen_mppe_keys(&handler->request->reply->vps, 
+               eaptls_gen_mppe_keys(&handler->request->reply->vps,
                                     tls_session->ssl,
                                     "client EAP encryption");
                return 1;
index 7c25a54..7bcbda7 100644 (file)
@@ -2,7 +2,7 @@
  * rlm_eap_sim.c    Handles that are called from eap for SIM
  *
  * The development of the EAP/SIM support was funded by Internet Foundation
- * Austria (http://www.nic.at/ipa). 
+ * Austria (http://www.nic.at/ipa).
  *
  * Version:     $Id$
  *
 struct eap_sim_server_state {
        enum eapsim_serverstates state;
        struct eapsim_keys keys;
-       
+
 };
 
 /*
  * Add value pair to reply
  */
-static void add_reply(VALUE_PAIR** vp, 
+static void add_reply(VALUE_PAIR** vp,
                      const char* name, const char* value, int len)
 {
        VALUE_PAIR *reply_attr;
        reply_attr = pairmake(name, "", T_OP_EQ);
        if (!reply_attr) {
                DEBUG("rlm_eap_sim: "
-                     "add_reply failed to create attribute %s: %s\n", 
+                     "add_reply failed to create attribute %s: %s\n",
                      name, librad_errstr);
                return;
        }
@@ -67,7 +67,7 @@ static void eap_sim_state_free(void *opaque)
        struct eap_sim_server_state *ess = (struct eap_sim_server_state *)opaque;
 
        if (!ess) return;
-       
+
        free(ess);
 }
 
@@ -93,7 +93,7 @@ static int eap_sim_sendstart(EAP_HANDLER *handler)
        rad_assert(handler->request->reply);
 
        ess = (struct eap_sim_server_state *)handler->opaque;
-       
+
        /* these are the outgoing attributes */
        vps = &handler->request->reply->vps;
 
@@ -208,7 +208,7 @@ static int eap_sim_sendchallenge(EAP_HANDLER *handler)
        ess = (struct eap_sim_server_state *)handler->opaque;
        rad_assert(handler->request != NULL);
        rad_assert(handler->request->reply);
-       
+
        /* invps is the data from the client.
         * but, this is for non-protocol data here. We should
         * already have consumed any client originated data.
@@ -220,7 +220,7 @@ static int eap_sim_sendchallenge(EAP_HANDLER *handler)
 
        printf("+++> EAP-sim decoded packet:\n");
        vp_printlist(stdout, *invps);
-       
+
        /* okay, we got the challenges! Put them into an attribute */
        newvp = paircreate(ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_RAND,
                           PW_TYPE_OCTETS);
@@ -238,12 +238,12 @@ static int eap_sim_sendchallenge(EAP_HANDLER *handler)
        /* all set, calculate keys! */
        eapsim_calculate_keys(&ess->keys);
 
-#ifdef EAP_SIM_DEBUG_PRF       
+#ifdef EAP_SIM_DEBUG_PRF
        eapsim_dump_mk(&ess->keys);
 #endif
 
        /*
-        * need to include an AT_MAC attribute so that it will get 
+        * need to include an AT_MAC attribute so that it will get
         * calculated. The NONCE_MT and the MAC are both 16 bytes, so
         * we store the NONCE_MT in the MAC for the encoder, which
         * will pull it out before it does the operation.
@@ -268,7 +268,7 @@ static int eap_sim_sendchallenge(EAP_HANDLER *handler)
        return 1;
 }
 
-#ifndef EAPTLS_MPPE_KEY_LEN 
+#ifndef EAPTLS_MPPE_KEY_LEN
 #define EAPTLS_MPPE_KEY_LEN     32
 #endif
 
@@ -334,7 +334,7 @@ static void eap_sim_stateenter(EAP_HANDLER *handler,
                 */
                break;
        }
-       
+
        ess->state = newstate;
 
        /* build the target packet */
@@ -410,7 +410,7 @@ static int process_eap_sim_start(EAP_HANDLER *handler, VALUE_PAIR *vps)
 
        nonce_vp = pairfind(vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_NONCE_MT);
        selectedversion_vp = pairfind(vps, ATTRIBUTE_EAP_SIM_BASE+PW_EAP_SIM_SELECTED_VERSION);
-       
+
        if(nonce_vp == NULL ||
           selectedversion_vp == NULL) {
                DEBUG2("   client did not select a version and send a NONCE");
@@ -444,12 +444,12 @@ static int process_eap_sim_start(EAP_HANDLER *handler, VALUE_PAIR *vps)
                return 0;
        }
        memcpy(ess->keys.nonce_mt, nonce_vp->strvalue+2, 16);
-       
+
        /* everything looks good, change states */
        eap_sim_stateenter(handler, ess, eapsim_server_challenge);
        return 1;
 }
-       
+
 
 /*
  * process an EAP-Sim/Response/Challenge
@@ -469,7 +469,7 @@ static int process_eap_sim_challenge(EAP_HANDLER *handler, VALUE_PAIR *vps)
        memcpy(srescat +(0*EAPSIM_SRES_SIZE), ess->keys.sres[0], EAPSIM_SRES_SIZE);
        memcpy(srescat +(1*EAPSIM_SRES_SIZE), ess->keys.sres[1], EAPSIM_SRES_SIZE);
        memcpy(srescat +(2*EAPSIM_SRES_SIZE), ess->keys.sres[2], EAPSIM_SRES_SIZE);
-       
+
        /* verify the MAC, now that we have all the keys. */
        if(eapsim_checkmac(vps, ess->keys.K_aut,
                           srescat, sizeof(srescat),
@@ -487,7 +487,7 @@ static int process_eap_sim_challenge(EAP_HANDLER *handler, VALUE_PAIR *vps)
                          j=0;
                        }
                        j++;
-                       
+
                        sprintf(m, "%02x", calcmac[i]);
                        m = m + strlen(m);
                }
@@ -499,7 +499,7 @@ static int process_eap_sim_challenge(EAP_HANDLER *handler, VALUE_PAIR *vps)
        eap_sim_stateenter(handler, ess, eapsim_server_success);
        return 1;
 }
-       
+
 
 /*
  *     Authenticate a previously sent challenge.
@@ -544,7 +544,7 @@ static int eap_sim_authenticate(void *arg, EAP_HANDLER *handler)
                         */
                        eap_sim_stateenter(handler, ess, eapsim_server_start);
                        return 1;
-                       
+
                case eapsim_start:
                        /*
                         * a response to our EAP-Sim/Request/Start!
@@ -562,7 +562,7 @@ static int eap_sim_authenticate(void *arg, EAP_HANDLER *handler)
                         */
                        eap_sim_stateenter(handler, ess, eapsim_server_challenge);
                        return 1;
-                       
+
                case eapsim_challenge:
                        /*
                         * a response to our EAP-Sim/Request/Challenge!
@@ -598,7 +598,14 @@ EAP_TYPE rlm_eap_sim = {
 
 /*
  * $Log$
- * Revision 1.10  2004-01-30 20:35:33  mcr
+ * Revision 1.11  2004-02-26 19:04:31  aland
+ *     perl -i -npe "s/[ \t]+$//g" `find src -name "*.[ch]" -print`
+ *
+ *     Whitespace changes only, from a fresh checkout.
+ *
+ *     For bug # 13
+ *
+ * Revision 1.10  2004/01/30 20:35:33  mcr
  *     capture the RAND/SRES/Kc when we initialize the SIM
  *     rather than later, when they may have changed.
  *
index 1ccd202..e7f73b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * cb.c 
+ * cb.c
  *
  * Version:     $Id$
  *
@@ -75,7 +75,7 @@ void cbtls_info(const SSL *s, int where, int ret)
  *     4.Verifying that the credentials presented by the certificate
  *     fulfill additional requirements specific to the application,
  *     such as with respect to access control lists or with respect
- *     to OCSP (Online Certificate Status Processing). 
+ *     to OCSP (Online Certificate Status Processing).
  *
  *     NOTE: This callback will be called multiple times based on the
  *     depth of the root certificate chain
@@ -84,7 +84,7 @@ int cbtls_verify(int ok, X509_STORE_CTX *ctx)
 {
        char subject[256]; /* Used for the subject name */
        char issuer[256]; /* Used for the issuer name */
-       char buf[256]; 
+       char buf[256];
        char *user_name = NULL; /* User-Name */
        X509 *client_cert;
        SSL *ssl;
@@ -151,7 +151,7 @@ int cbtls_verify(int ok, X509_STORE_CTX *ctx)
                  }
                */
                radlog(L_INFO, "error=%d", err);
-               
+
                radlog(L_INFO, "--> User-Name = %s", user_name);
                radlog(L_INFO, "--> BUF-Name = %s", buf);
                radlog(L_INFO, "--> subject = %s", subject);
@@ -166,7 +166,7 @@ int cbtls_verify(int ok, X509_STORE_CTX *ctx)
  *     Fill in our 'info' with TLS data.
  */
 void cbtls_msg(int write_p, int msg_version, int content_type,
-              const void *buf, size_t len, 
+              const void *buf, size_t len,
               SSL *ssl UNUSED, void *arg)
 {
        tls_session_t *state = (tls_session_t *)arg;
@@ -181,7 +181,7 @@ void cbtls_msg(int write_p, int msg_version, int content_type,
                state->info.alert_level = ((const unsigned char*)buf)[0];
                state->info.alert_description = ((const unsigned char*)buf)[1];
                state->info.handshake_type = 0x00;
-       
+
        } else if (content_type == SSL3_RT_HANDSHAKE) {
                state->info.handshake_type = ((const unsigned char*)buf)[0];
                state->info.alert_level = 0x00;
@@ -190,9 +190,9 @@ void cbtls_msg(int write_p, int msg_version, int content_type,
        tls_session_information(state);
 }
 
-int cbtls_password(char *buf, 
-                  int num UNUSED, 
-                  int rwflag UNUSED, 
+int cbtls_password(char *buf,
+                  int num UNUSED,
+                  int rwflag UNUSED,
                   void *userdata)
 {
        strcpy(buf, (char *)userdata);
index 3c54e05..8c8177a 100644 (file)
@@ -23,7 +23,7 @@
 
 /*
  *
- *  TLS Packet Format in EAP 
+ *  TLS Packet Format in EAP
  *  --- ------ ------ -- ---
  * 0                   1                   2                   3
  * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -129,7 +129,7 @@ int eaptls_fail(EAP_DS *eap_ds, int peap_flag)
 /*
    A single TLS record may be up to 16384 octets in length, but a TLS
    message may span multiple TLS records, and a TLS certificate message
-   may in principle be as long as 16MB. 
+   may in principle be as long as 16MB.
 */
 
 /*
@@ -145,17 +145,17 @@ int eaptls_request(EAP_DS *eap_ds, tls_session_t *ssn)
        unsigned int    nlen;
        unsigned int    lbit = 0;
 
-       /* This value determines whether we set (L)ength flag for 
-               EVERY packet we send and add corresponding 
+       /* This value determines whether we set (L)ength flag for
+               EVERY packet we send and add corresponding
                "TLS Message Length" field.
 
        length_flag = TRUE;
                This means we include L flag and "TLS Msg Len" in EVERY
                packet we send out.
-       
+
        length_flag = FALSE;
                This means we include L flag and "TLS Msg Len" **ONLY**
-               in First packet of a fragment series. We do not use 
+               in First packet of a fragment series. We do not use
                it anywhere else.
 
                Having L flag in every packet is prefered.
@@ -332,9 +332,9 @@ static eaptls_status_t eaptls_verify(EAP_HANDLER *handler)
         *      Find if this is a reply to the previous request sent
         */
        if ((eaptls_packet == NULL) ||
-           ((eap_ds->response->length == EAP_HEADER_LEN + 2) && 
+           ((eap_ds->response->length == EAP_HEADER_LEN + 2) &&
             ((eaptls_packet->flags & 0xc0) == 0x00))) {
-               
+
                if (prev_eap_ds->request->id == eap_ds->response->id) {
                        /*
                         *      Run the ACK handler directly from here.
@@ -618,8 +618,8 @@ static void eaptls_operation(EAPTLS_PACKET *eaptls_packet UNUSED,
 
        tls_session = (tls_session_t *)handler->opaque;
 
-       if ((status == EAPTLS_MORE_FRAGMENTS) || 
-           (status == EAPTLS_MORE_FRAGMENTS_WITH_LENGTH) || 
+       if ((status == EAPTLS_MORE_FRAGMENTS) ||
+           (status == EAPTLS_MORE_FRAGMENTS_WITH_LENGTH) ||
            (status == EAPTLS_FIRST_FRAGMENT)) {
                /*
                 * Send the ACK.
@@ -686,7 +686,7 @@ eaptls_status_t eaptls_process(EAP_HANDLER *handler)
 
        DEBUG2("  rlm_eap_tls: processing TLS");
 
-       /* This case is when SSL generates Alert then we 
+       /* This case is when SSL generates Alert then we
         * send that alert to the client and then send the EAP-Failure
         */
        status = eaptls_verify(handler);
@@ -740,7 +740,7 @@ eaptls_status_t eaptls_process(EAP_HANDLER *handler)
                return EAPTLS_FAIL;
 
        /*
-        *      Get the session struct from the handler 
+        *      Get the session struct from the handler
         *
         *      update the dirty_in buffer
         *
@@ -749,7 +749,7 @@ eaptls_status_t eaptls_process(EAP_HANDLER *handler)
         *      CAUTION while reinitializing this buffer, it should be
         *      reinitialized only when this M bit is NOT set.
         */
-       if (tlspacket->dlen != 
+       if (tlspacket->dlen !=
            record_plus(&tls_session->dirty_in, tlspacket->data, tlspacket->dlen)) {
                eaptls_free(&tlspacket);
                radlog(L_ERR, "rlm_eap_tls: Exceeded maximum record size");
@@ -770,7 +770,7 @@ eaptls_status_t eaptls_process(EAP_HANDLER *handler)
         *      Continue the handshake.
         */
        eaptls_operation(tlspacket, status, handler);
-               
+
        eaptls_free(&tlspacket);
        return EAPTLS_HANDLED;
 }
index 75c53ba..54439ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * eap_tls.h 
+ * eap_tls.h
  *
  * Version:     $Id$
  *
@@ -70,8 +70,8 @@
  *     use the OpenSSL names for these.
  */
 enum ContentType {
-       change_cipher_spec = 20, 
-       alert = 21, 
+       change_cipher_spec = 20,
+       alert = 21,
        handshake = 22,
        application_data = 23
 };
@@ -124,17 +124,17 @@ enum HandshakeType {
 /*
  * From rfc
    Flags
-  
+
       0 1 2 3 4 5 6 7 8
       +-+-+-+-+-+-+-+-+
       |L M S R R R R R|
       +-+-+-+-+-+-+-+-+
-  
+
       L = Length included
       M = More fragments
       S = EAP-TLS start
       R = Reserved
-  
+
       The L bit (length included) is set to indicate the presence of the
       four octet TLS Message Length field, and MUST be set for the first
       fragment of a fragmented TLS message or set of messages. The M bit
@@ -142,15 +142,15 @@ enum HandshakeType {
       (EAP-TLS start) is set in an EAP-TLS Start message.  This
       differentiates the EAP-TLS Start message from a fragment
       acknowledgement.
-  
+
    TLS Message Length
-  
+
       The TLS Message Length field is four octets, and is present only
       if the L bit is set. This field provides the total length of the
       TLS message or set of messages that is being fragmented.
-  
+
    TLS data
-  
+
       The TLS data consists of the encapsulated TLS packet in TLS record
       format.
  *
@@ -237,8 +237,8 @@ void                session_init(tls_session_t *ssn);
 /* record */
 void           record_init(record_t *buf);
 void           record_close(record_t *buf);
-unsigned int   record_plus(record_t *buf, const unsigned char *ptr, 
+unsigned int   record_plus(record_t *buf, const unsigned char *ptr,
                            unsigned int size);
-unsigned int   record_minus(record_t *buf, unsigned char *ptr, 
+unsigned int   record_minus(record_t *buf, unsigned char *ptr,
                             unsigned int size);
 #endif /*_EAP_TLS_H*/
index 71c74a5..7bd321c 100644 (file)
 /*
  * Add value pair to reply
  */
-static void add_reply(VALUE_PAIR** vp, 
+static void add_reply(VALUE_PAIR** vp,
                      const char* name, const char* value, int len)
 {
        VALUE_PAIR *reply_attr;
        reply_attr = pairmake(name, "", T_OP_EQ);
        if (!reply_attr) {
                DEBUG("rlm_eap_tls: "
-                     "add_reply failed to create attribute %s: %s\n", 
+                     "add_reply failed to create attribute %s: %s\n",
                      name, librad_errstr);
                return;
        }
@@ -47,7 +47,7 @@ static void add_reply(VALUE_PAIR** vp,
 /*
  * TLS PRF from RFC 2246
  */
-static void P_hash(const EVP_MD *evp_md, 
+static void P_hash(const EVP_MD *evp_md,
                   const unsigned char *secret, unsigned int secret_len,
                   const unsigned char *seed,   unsigned int seed_len,
                   unsigned char *out, unsigned int out_len)
@@ -142,7 +142,7 @@ void eaptls_gen_mppe_keys(VALUE_PAIR **reply_vps, SSL *s,
 
        PRF(s->session->master_key, s->session->master_key_length,
            seed, prf_size, out, buf, sizeof(out));
-           
+
        p = out;
        add_reply(reply_vps, "MS-MPPE-Recv-Key", p, EAPTLS_MPPE_KEY_LEN);
        p += EAPTLS_MPPE_KEY_LEN;
index e40c613..7facaa6 100644 (file)
@@ -154,7 +154,7 @@ static SSL_CTX *init_tls_ctx(EAP_TLS_CONF *conf)
        }
        SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(conf->ca_file));
 
-       /* 
+       /*
         * Set the password to load private key
         */
        if (conf->private_key_password) {
@@ -189,7 +189,7 @@ static SSL_CTX *init_tls_ctx(EAP_TLS_CONF *conf)
        ctx_options |= SSL_OP_NO_SSLv2;
        ctx_options |= SSL_OP_NO_SSLv3;
 
-       /* 
+       /*
         *      SSL_OP_SINGLE_DH_USE must be used in order to prevent
         *      small subgroup attacks and forward secrecy. Always
         *      using
@@ -279,7 +279,7 @@ static int eaptls_detach(void *arg)
                conf->private_key_password = NULL;
                if (conf->random_file) free(conf->random_file);
                conf->random_file = NULL;
-               
+
                free(inst->conf);
                inst->conf = NULL;
        }
@@ -513,14 +513,14 @@ static int eaptls_authenticate(void *arg UNUSED, EAP_HANDLER *handler)
                        int i;
                        unsigned int data_len;
                        unsigned char buffer[1024];
-                       
+
                        data_len = record_minus(&tls_session->dirty_in,
                                                buffer, sizeof(buffer));
                        log_debug("  Tunneled data (%u bytes)\n", data_len);
                        for (i = 0; i < data_len; i++) {
                                if ((i & 0x0f) == 0) printf("  %d: ", i);
                                if ((i & 0x0f) == 0x0f) printf("\n");
-                               
+
                                printf("%02x ", buffer[i]);
                        }
                }
@@ -541,7 +541,7 @@ static int eaptls_authenticate(void *arg UNUSED, EAP_HANDLER *handler)
         *      Success: Return MPPE keys.
         */
        eaptls_success(handler->eap_ds, 0);
-       eaptls_gen_mppe_keys(&handler->request->reply->vps, 
+       eaptls_gen_mppe_keys(&handler->request->reply->vps,
                             tls_session->ssl,
                             "client EAP encryption");
        return 1;
index 1a03074..33a8709 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_eap_tls.h 
+ * rlm_eap_tls.h
  *
  * Version:     $Id$
  *
@@ -106,7 +106,7 @@ typedef enum {
  */
 typedef struct _record_t {
        unsigned char data[MAX_RECORD_SIZE];
-       unsigned int  used; 
+       unsigned int  used;
 } record_t;
 
 typedef struct _tls_info_t {
@@ -123,13 +123,13 @@ typedef struct _tls_info_t {
 
 /*
  * tls_session_t Structure gets stored as opaque in EAP_HANDLER
- * This contains EAP-REQUEST specific data 
+ * This contains EAP-REQUEST specific data
  * (ie EAPTLS_DATA(fragment), EAPTLS-ALERT, EAPTLS-REQUEST ...)
  *
  * clean_in  - data that needs to be sent but only after it is soiled.
  * dirty_in  - data EAP server receives.
  * clean_out - data that is cleaned after receiving.
- * dirty_out - data EAP server sends. 
+ * dirty_out - data EAP server sends.
  * offset    - current fragment size transmitted
  * fragment  - Flag, In fragment mode or not.
  * tls_msg_len - Actual/Total TLS message length.
@@ -148,7 +148,7 @@ typedef struct _tls_session_t {
        record_t        dirty_out;
 
        /*
-        * Framed-MTU attribute in RADIUS, 
+        * Framed-MTU attribute in RADIUS,
         * if present, can also be used to set this
         */
        unsigned int    offset;
index c58beb6..125aed5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * tls.c 
+ * tls.c
  *
  * Version:     $Id$
  *
@@ -146,13 +146,13 @@ static void int_ssl_check(SSL *s, int ret, const char *text)
  * We are the server, we always get the dirty data
  * (Handshake data is also considered as dirty data)
  * During handshake, since SSL API handles itself,
- * After clean-up, dirty_out will be filled with 
+ * After clean-up, dirty_out will be filled with
  * the data required for handshaking. So we check
  * if dirty_out is empty then we simply send it back.
  * As of now, if handshake is successful, then it is EAP-Success
  * or else EAP-failure should be sent
  *
- * Fill the Bio with the dirty data to clean it 
+ * Fill the Bio with the dirty data to clean it
  * Get the cleaned data from SSL, if it is not Handshake data
  */
 int tls_handshake_recv(tls_session_t *ssn)
@@ -263,7 +263,7 @@ void session_close(tls_session_t *ssn)
        if(ssn->ssl)
                SSL_free(ssn->ssl);
 #if 0
-/* 
+/*
  * WARNING: SSL_free seems to decrement the reference counts already,
  *     so doing this might crash the application.
  */
@@ -363,7 +363,7 @@ void tls_session_information(tls_session_t *tls_session)
        if (debug_flag == 0) {
                return;
        }
-       
+
        str_write_p = tls_session->info.origin ? ">>>" : "<<<";
 
        switch (tls_session->info.version)
@@ -404,7 +404,7 @@ void tls_session_information(tls_session_t *tls_session)
 
                if (tls_session->info.content_type == SSL3_RT_ALERT) {
                        str_details1 = ", ???";
-                       
+
                        if (tls_session->info.record_len == 2) {
 
                                switch (tls_session->info.alert_level) {
@@ -490,7 +490,7 @@ void tls_session_information(tls_session_t *tls_session)
                                }
                        }
                }
-               
+
                if (tls_session->info.content_type == SSL3_RT_HANDSHAKE) {
                        str_details1 = "???";
 
@@ -531,8 +531,8 @@ void tls_session_information(tls_session_t *tls_session)
                }
        }
 
-       sprintf(tls_session->info.info_description, "%s %s%s [length %04lx]%s%s\n", 
-               str_write_p, str_version, str_content_type, 
+       sprintf(tls_session->info.info_description, "%s %s%s [length %04lx]%s%s\n",
+               str_write_p, str_version, str_content_type,
                (unsigned long)tls_session->info.record_len, str_details1, str_details2);
        DEBUG2("  rlm_eap_tls: %s\n", tls_session->info.info_description);
 }
index 406850c..a4977ae 100644 (file)
@@ -250,7 +250,7 @@ static int eapttls_authenticate(void *arg, EAP_HANDLER *handler)
                 */
        case PW_AUTHENTICATION_ACK:
                eaptls_success(handler->eap_ds, 0);
-               eaptls_gen_mppe_keys(&handler->request->reply->vps, 
+               eaptls_gen_mppe_keys(&handler->request->reply->vps,
                                     tls_session->ssl,
                                     "ttls keying material");
                return 1;
index 19c6c87..59b7215 100644 (file)
 #include "eap_ttls.h"
 
 /*
- *    0                   1                   2                   3 
- *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
- *   |                           AVP Code                            | 
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
- *   |V M r r r r r r|                  AVP Length                   | 
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
- *   |                        Vendor-ID (opt)                        | 
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
- *   |    Data ... 
- *   +-+-+-+-+-+-+-+-+ 
+ *    0                   1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                           AVP Code                            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |V M r r r r r r|                  AVP Length                   |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                        Vendor-ID (opt)                        |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |    Data ...
+ *   +-+-+-+-+-+-+-+-+
  */
 
 /*
@@ -79,7 +79,7 @@ static int diameter_verify(const uint8_t *data, int data_len)
                        attribute = (vendor << 16) | attr;
 
                        da = dict_attrbyvalue(attribute);
-                       
+
                        /*
                         *      SHOULD check ((length & (1 << 30)) != 0)
                         *      for the mandatory bit.
@@ -106,7 +106,7 @@ static int diameter_verify(const uint8_t *data, int data_len)
                /*
                 *      Too short or too long is bad.
                 *
-                *      FIXME: EAP-Message 
+                *      FIXME: EAP-Message
                 */
                if ((length < offset) ||
                    (length > (MAX_STRING_LEN + 8)) ||
@@ -226,7 +226,7 @@ static VALUE_PAIR *diameter2vp(SSL *ssl,
                        pairfree(&first);
                        return NULL;
                }
-               
+
                /*
                 *      If it's a type from our dictionary, then
                 *      we need to put the data in a relevant place.
@@ -256,7 +256,7 @@ static VALUE_PAIR *diameter2vp(SSL *ssl,
                    return NULL;
                  }
                  memcpy(&vp->lvalue, data, vp->length);
-                 
+
                  /*
                   *    Stored in network byte order: don't change it.
                   */
@@ -287,7 +287,7 @@ static VALUE_PAIR *diameter2vp(SSL *ssl,
                case PW_USER_PASSWORD:
                        {
                                int i;
-                               
+
                                for (i = 0; i < vp->length; i++) {
                                        if (vp->strvalue[i] == 0) {
                                                vp->length = i;
@@ -507,13 +507,13 @@ static int vp2diameter(tls_session_t *tls_session, VALUE_PAIR *first)
        if (total > 0) {
 #ifndef NDEBUG
                int i;
-               
+
                if (debug_flag > 2) {
                        for (i = 0; i < total; i++) {
                                if ((i & 0x0f) == 0) printf("  TTLS tunnel data out %04x: ", i);
-                               
+
                                printf("%02x ", buffer[i]);
-                               
+
                                if ((i & 0x0f) == 0x0f) printf("\n");
                        }
                        if ((total & 0x0f) != 0) printf("\n");
@@ -722,7 +722,7 @@ static int eapttls_postproxy(EAP_HANDLER *handler, void *data)
        case RLM_MODULE_REJECT:
                DEBUG2("  TTLS: Reply was rejected");
                return 0;
-         
+
        case RLM_MODULE_HANDLED:
                DEBUG2("  TTLS: Reply was handled");
                eaptls_request(handler->eap_ds, tls_session);
@@ -731,7 +731,7 @@ static int eapttls_postproxy(EAP_HANDLER *handler, void *data)
        case RLM_MODULE_OK:
                DEBUG2("  TTLS: Reply was OK");
                eaptls_success(handler->eap_ds, 0);
-               eaptls_gen_mppe_keys(&handler->request->reply->vps, 
+               eaptls_gen_mppe_keys(&handler->request->reply->vps,
                                     tls_session->ssl,
                                     "ttls keying material");
                return 1;
@@ -803,7 +803,7 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
        /*
         *      If there's no data, maybe this is an ACK to an
         *      MS-CHAP2-Success.
-        */     
+        */
        if (err == 0) {
                if (t->authenticated) {
                        DEBUG2("  TTLS: Got ACK, and the user was already authenticated.");
@@ -825,9 +825,9 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
        if (debug_flag > 2) {
                for (i = 0; i < data_len; i++) {
                        if ((i & 0x0f) == 0) printf("  TTLS tunnel data in %04x: ", i);
-                       
+
                        printf("%02x ", data[i]);
-                       
+
                        if ((i & 0x0f) == 0x0f) printf("\n");
                }
                if ((data_len & 0x0f) != 0) printf("\n");
@@ -897,12 +897,12 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                                 */
                                t->username = pairmake("User-Name", "", T_OP_EQ);
                                rad_assert(t->username != NULL);
-                               
+
                                memcpy(t->username->strvalue, vp->strvalue + 5,
                                       vp->length - 5);
                                t->username->length = vp->length - 5;
                                t->username->strvalue[t->username->length] = 0;
-                               
+
                                DEBUG2("  TTLS: Got tunneled identity of %s",
                                       t->username->strvalue);
 
@@ -1045,7 +1045,7 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
          }
        }
 #endif
-       
+
        /*
         *      Decide what to do with the reply.
         */
@@ -1084,12 +1084,12 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                        /*
                         *      Associate the callback with the request.
                         */
-                       rcode = request_data_add(request, 
+                       rcode = request_data_add(request,
                                                 request->proxy,
                                                 REQUEST_DATA_EAP_TUNNEL_CALLBACK,
                                                 tunnel, free);
                        rad_assert(rcode == 0);
-                       
+
                        /*
                         *      Didn't authenticate the packet, but
                         *      we're proxying it.
@@ -1108,7 +1108,7 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
                                      fake->reply);
                break;
        }
-       
+
        request_free(&fake);
 
        return rcode;
index 833467e..b37ecf6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * other.c     
+ * other.c
  *
  * Version:    $Id$
  *
index 5119c92..ebbe968 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_example.c       
+ * rlm_example.c
  *
  * Version:    $Id$
  *
@@ -94,7 +94,7 @@ static int example_init(void)
 static int example_instantiate(CONF_SECTION *conf, void **instance)
 {
        rlm_example_t *data;
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -112,9 +112,9 @@ static int example_instantiate(CONF_SECTION *conf, void **instance)
                free(data);
                return -1;
        }
-       
+
        *instance = data;
-       
+
        return 0;
 }
 
@@ -169,7 +169,7 @@ static int example_authenticate(void *instance, REQUEST *request)
        /* quiet the compiler */
        instance = instance;
        request = request;
-       
+
        return RLM_MODULE_OK;
 }
 
@@ -181,7 +181,7 @@ static int example_preacct(void *instance, REQUEST *request)
        /* quiet the compiler */
        instance = instance;
        request = request;
-       
+
        return RLM_MODULE_OK;
 }
 
@@ -193,7 +193,7 @@ static int example_accounting(void *instance, REQUEST *request)
        /* quiet the compiler */
        instance = instance;
        request = request;
-       
+
        return RLM_MODULE_OK;
 }
 
@@ -233,7 +233,7 @@ static int example_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_example = {
-       "example",      
+       "example",
        RLM_TYPE_THREAD_SAFE,           /* type */
        example_init,                   /* initialization */
        example_instantiate,            /* instantiation */
index ff634dd..7896a04 100644 (file)
@@ -118,7 +118,7 @@ static VALUE_PAIR **decode_string(REQUEST *request, const char *string)
 
 /*
  *     Do xlat of strings.
- */ 
+ */
 static int exec_xlat(void *instance, REQUEST *request,
                     char *fmt, char *out, int outlen,
                     RADIUS_ESCAPE_STRING func)
@@ -190,16 +190,16 @@ static int exec_instantiate(CONF_SECTION *conf, void **instance)
 {
        rlm_exec_t      *inst;
        char            *xlat_name;
-       
+
        /*
         *      Set up a storage area for instance data
         */
-       
+
        inst = rad_malloc(sizeof(rlm_exec_t));
        if (!inst)
                return -1;
        memset(inst, 0, sizeof(rlm_exec_t));
-               
+
        /*
         *      If the configuration parameters can't be parsed, then
         *      fail.
@@ -209,7 +209,7 @@ static int exec_instantiate(CONF_SECTION *conf, void **instance)
                exec_detach(inst);
                return -1;
        }
-       
+
        /*
         *      No input pairs defined.  Why are we executing a program?
         */
@@ -246,7 +246,7 @@ static int exec_instantiate(CONF_SECTION *conf, void **instance)
                inst->packet_code = 0;
        } else {
                DICT_VALUE      *dval;
-               
+
                dval = dict_valbyname(PW_PACKET_TYPE, inst->packet_type);
                if (!dval) {
                        radlog(L_ERR, "rlm_exec: Unknown packet type %s: See list of VALUEs for Packet-Type in share/dictionary", inst->packet_type);
@@ -257,15 +257,15 @@ static int exec_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        xlat_name = cf_section_name2(conf);
-       if (xlat_name == NULL) 
+       if (xlat_name == NULL)
                xlat_name = cf_section_name1(conf);
-       if (xlat_name){ 
+       if (xlat_name){
                inst->xlat_name = strdup(xlat_name);
-               xlat_register(xlat_name, exec_xlat, inst); 
-       } 
+               xlat_register(xlat_name, exec_xlat, inst);
+       }
 
        *instance = inst;
-       
+
        return 0;
 }
 
index f0d1a36..c6308a6 100644 (file)
@@ -59,7 +59,7 @@ typedef struct expr_map_t {
        expr_token_t token;
 } expr_map_t;
 
-static expr_map_t map[] = 
+static expr_map_t map[] =
 {
        {'+',   TOKEN_ADD },
        {'-',   TOKEN_SUBTRACT },
@@ -148,7 +148,7 @@ static int get_number(REQUEST *request, const char **string, int *answer)
                                DEBUG2("rlm_expr: Not a number at \"%s\"", p);
                                return -1;
                        }
-                       
+
                        /*
                         *  This is doing it the hard way, but it also allows
                         *  us to increment 'p'.
@@ -166,7 +166,7 @@ static int get_number(REQUEST *request, const char **string, int *answer)
                case TOKEN_NONE:
                        result = x;
                        break;
-                       
+
                case TOKEN_ADD:
                        result += x;
                        break;
@@ -212,7 +212,7 @@ static int get_number(REQUEST *request, const char **string, int *answer)
 
 /*
  *  Do xlat of strings!
- */ 
+ */
 static int expr_xlat(void *instance, REQUEST *request, char *fmt, char *out, int outlen,
                                        RADIUS_ESCAPE_STRING func)
 {
@@ -263,25 +263,25 @@ static int expr_instantiate(CONF_SECTION *conf, void **instance)
 {
        rlm_expr_t      *inst;
        char            *xlat_name;
-       
+
        /*
         *      Set up a storage area for instance data
         */
-       
+
        inst = rad_malloc(sizeof(rlm_expr_t));
        if (!inst)
                return -1;
        memset(inst, 0, sizeof(rlm_expr_t));
-               
+
        xlat_name = cf_section_name2(conf);
-       if (xlat_name == NULL) 
+       if (xlat_name == NULL)
                xlat_name = cf_section_name1(conf);
-       if (xlat_name){ 
+       if (xlat_name){
                inst->xlat_name = strdup(xlat_name);
-               xlat_register(xlat_name, expr_xlat, inst); 
-       } 
+               xlat_register(xlat_name, expr_xlat, inst);
+       }
        *instance = inst;
-       
+
        return 0;
 }
 
index adb6a11..9cde83a 100644 (file)
@@ -62,8 +62,8 @@ struct fastuser_instance {
 /* Function declarations */
 static int fallthrough(VALUE_PAIR *vp);
 static int fastuser_buildhash(struct fastuser_instance *inst);
-static int fastuser_getfile(struct fastuser_instance *inst, const char *filename, 
-                                                                                                               PAIR_LIST **default_list, PAIR_LIST **pair_list, 
+static int fastuser_getfile(struct fastuser_instance *inst, const char *filename,
+                                                                                                               PAIR_LIST **default_list, PAIR_LIST **pair_list,
                                                                                                                int isacctfile);
 static int fastuser_hash(const char *s, long hashtablesize);
 static int fastuser_store(PAIR_LIST **hashtable, PAIR_LIST *entry, int idx);
@@ -106,7 +106,7 @@ static int rad_check_return(VALUE_PAIR *list)
 {
       VALUE_PAIR      *authtype;
 
-      /* 
+      /*
        * We check for Auth-Type = Reject here
        */
 
@@ -129,7 +129,7 @@ static int fastuser_buildhash(struct fastuser_instance *inst) {
        int reloadusers = 1;
        int reloadacctusers = 1;
 
-       /* 
+       /*
         * Allocate space for hash table here
         */
        memsize = sizeof(PAIR_LIST *) * inst->hashsize;
@@ -196,7 +196,7 @@ static int fastuser_buildhash(struct fastuser_instance *inst) {
                                        cur = oldhash[hashindex];
                                        pairlist_free(&cur);
                                }
-                       } 
+                       }
                        free(oldhash);
                }
                pairlist_free(&olddefaults);
@@ -208,14 +208,14 @@ static int fastuser_buildhash(struct fastuser_instance *inst) {
                pairlist_free(&oldacctusers);
        }
 
-       if(inst->stats) 
+       if(inst->stats)
                fastuser_tablestats(inst->hashtable, inst->hashsize);
 
-       return 0;       
+       return 0;
 }
 
-static int fastuser_getfile(struct fastuser_instance *inst, const char *filename, 
-                                                                                                               PAIR_LIST **default_list, PAIR_LIST **pair_list, 
+static int fastuser_getfile(struct fastuser_instance *inst, const char *filename,
+                                                                                                               PAIR_LIST **default_list, PAIR_LIST **pair_list,
                                                                                                                int isacctfile) {
        int rcode;
        PAIR_LIST *users = NULL;
@@ -234,7 +234,7 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
        if (strcmp(inst->compat_mode, "cistron") == 0) {
                compat_mode = TRUE;
        }
-        
+
        entry = users;
        while (entry) {
                if (compat_mode) {
@@ -254,13 +254,13 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
                         *      Ignore attributes which are set
                         *      properly.
                         */
-                       if (vp->operator != T_OP_EQ) 
+                       if (vp->operator != T_OP_EQ)
                                continue;
-                               
+
 
                        /*
                         *      If it's a vendor attribute,
-                        *      or it's a wire protocol, 
+                        *      or it's a wire protocol,
                         *      ensure it has '=='.
                         */
                        if (((vp->attribute & ~0xffff) != 0) ||
@@ -275,7 +275,7 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
                                vp->operator = T_OP_CMP_EQ;
                                continue;
                        }
-                               
+
                        /*
                         *      Cistron Compatibility mode.
                         *
@@ -304,10 +304,10 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
                                        vp->operator = T_OP_CMP_EQ;
                                }
                        }
-                               
+
                } /* end of loop over check items */
-                
-                
+
+
                /*
                 *      Look for server configuration items
                 *      in the reply list.
@@ -329,7 +329,7 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
                                log_debug("[%s]:%d WARNING! Check item \"%s\"\n"
                                        "\tfound in reply item list for user \"%s\".\n"
                                        "\tThis attribute MUST go on the first line"
-                                       " with the other check items", 
+                                       " with the other check items",
                                        filename, entry->lineno, vp->name,
                                        entry->name);
                        }
@@ -348,11 +348,11 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
                if(!isacctfile) {
                        /* Save the DEFAULT entry specially */
                        if(strcmp(entry->name, "DEFAULT")==0) {
-                               
+
                                /* Save this as the last default we've seen */
                                lastdefault = entry;
                                numdefaults++;
-       
+
                                /* put it at the end of the list */
                                if(defaults) {
                                        for(cur=defaults; cur->next; cur=cur->next);
@@ -360,18 +360,18 @@ static int fastuser_getfile(struct fastuser_instance *inst, const char *filename
                                        entry->next = NULL;
                                } else {
                                        defaults = entry;
-                                       defaults->next = NULL; 
+                                       defaults->next = NULL;
                                }
-       
+
                        } else {
                                numusers++;
-       
+
                                /* Hash the username */
                                hashindex = fastuser_hash(entry->name, inst->hashsize);
-       
+
                                /* Store the last default before this entry */
                                entry->lastdefault = lastdefault;
-       
+
                                /* Store user in the hash */
                                fastuser_store(pair_list, entry, hashindex);
                        }
@@ -410,7 +410,7 @@ static int fastuser_store(PAIR_LIST **hashtable, PAIR_LIST *new, int idx) {
        cur = hashtable[idx];
        /* store new record at end of list */
        if(cur) {
-               while (cur->next != NULL) 
+               while (cur->next != NULL)
                        cur=cur->next;
                cur->next = new;
                new->next = NULL;
@@ -425,7 +425,7 @@ static int fastuser_store(PAIR_LIST **hashtable, PAIR_LIST *new, int idx) {
  * Looks up user in hashtable.  If user can't be found, returns 0.
  * Otherwise returns a pointer to the structure for the user
  */
-static PAIR_LIST *fastuser_find(REQUEST *request, PAIR_LIST *user, 
+static PAIR_LIST *fastuser_find(REQUEST *request, PAIR_LIST *user,
                                            const char *username)
 {
        PAIR_LIST *cur=user;
@@ -445,7 +445,7 @@ static PAIR_LIST *fastuser_find(REQUEST *request, PAIR_LIST *user,
                        if(mainconfig.do_usercollide) {
                                if((userfound = fastuser_passcheck(request, cur, username))==0) {
                                        cur = cur->next;
-                               } 
+                               }
 
                        } else {
                                userfound = 1;
@@ -486,14 +486,14 @@ static void fastuser_tablestats(PAIR_LIST **hashtable, long size) {
                }
        }
 
-       for(i=0; i<256; i++) 
+       for(i=0; i<256; i++)
                if(countarray[i]) {
                        radlog(L_INFO, "rlm_fastusers:  Hash buckets with %d users:  %d",
                                                i, countarray[i]);
                }
 
        if(toomany) {
-               radlog(L_INFO, "rlm_fastusers:  Hash buckets with more than 256:  %d", 
+               radlog(L_INFO, "rlm_fastusers:  Hash buckets with more than 256:  %d",
                                        toomany);
        }
 }
@@ -504,13 +504,13 @@ static int fastuser_passcheck(REQUEST *request, PAIR_LIST *user,
        int found=0;
        VALUE_PAIR      *check_save;
 
-       /* 
+       /*
         * We check for REJECT specially here or a REJECT
         * user will never match
         */
        check_save = pairfind(user->check, PW_AUTHTYPE);
        if((check_save) && check_save->lvalue == PW_AUTHTYPE_REJECT)  {
-               DEBUG2("  fastusers(uc):  User '%s' line %d is Auth-Type Reject, but usercollide match", 
+               DEBUG2("  fastusers(uc):  User '%s' line %d is Auth-Type Reject, but usercollide match",
                                        user->name, user->lineno);
                return 1;
        }
@@ -518,7 +518,7 @@ static int fastuser_passcheck(REQUEST *request, PAIR_LIST *user,
        /* Save the orginal config items */
        check_save = request->config_items;
        request->config_items = NULL;
-       
+
        DEBUG2("  fastusers(uc): Checking %s at %d", user->name, user->lineno);
 
        /* Copy this users check pairs to the request */
@@ -531,7 +531,7 @@ static int fastuser_passcheck(REQUEST *request, PAIR_LIST *user,
        }
 
        /* Restore check items */
-       pairfree(&request->config_items); 
+       pairfree(&request->config_items);
        request->config_items = check_save;
 
        return found;
@@ -616,10 +616,10 @@ static int fastuser_authorize(void *instance, REQUEST *request)
        hashidx = fastuser_hash(name, inst->hashsize);
        user = inst->hashtable[hashidx];
        if((user=fastuser_find(request, user, name))!=NULL) {
-               userfound = 1;          
+               userfound = 1;
        }
 
-       /* 
+       /*
         * If there's no lastdefault and we
         * don't fallthrough, just copy the
         * pairs for this user and return
@@ -629,7 +629,7 @@ static int fastuser_authorize(void *instance, REQUEST *request)
 
                check_tmp = paircopy(user->check);
                pairmove(&request->config_items, &check_tmp);
-               pairfree(&check_tmp); 
+               pairfree(&check_tmp);
 
                reply_tmp = paircopy(user->reply);
                pairmove(&request->reply->vps, &reply_tmp);
@@ -644,8 +644,8 @@ static int fastuser_authorize(void *instance, REQUEST *request)
                }
        }
 
-       /* 
-        * When we get here, we've either found 
+       /*
+        * When we get here, we've either found
         * the user or not, but to preserve order
         * we start at the top of the default
         * list and work our way thru
@@ -654,27 +654,27 @@ static int fastuser_authorize(void *instance, REQUEST *request)
         * and return
         */
        DEBUG2("rlm_fastusers:  checking defaults");
-                       
+
        curdefault = inst->defaults;
        while(curdefault) {
-               if(paircmp(request, request->packet->vps, curdefault->check, 
+               if(paircmp(request, request->packet->vps, curdefault->check,
                                                        &request->reply->vps) == 0) {
-                       DEBUG2("  fastusers: Matched %s at %d", 
+                       DEBUG2("  fastusers: Matched %s at %d",
                                                        curdefault->name, curdefault->lineno);
                        defaultfound = 1;
 
                        check_tmp = paircopy(curdefault->check);
                        pairmove(&request->config_items, &check_tmp);
-                       pairfree(&check_tmp); 
+                       pairfree(&check_tmp);
 
                        reply_tmp = paircopy(curdefault->reply);
                        pairmove(&request->reply->vps, &reply_tmp);
                        pairfree(&reply_tmp);
 
-                       /*                         
-                        * There's no fallthru on this default which    
-                        * is *before* we find the user in the file,         
-                        * so we know it's safe to quit here                        
+                       /*
+                        * There's no fallthru on this default which
+                        * is *before* we find the user in the file,
+                        * so we know it's safe to quit here
                         */
                        if (!fallthrough(curdefault->reply))
                          break;
@@ -693,7 +693,7 @@ static int fastuser_authorize(void *instance, REQUEST *request)
 
                        check_tmp = paircopy(user->check);
                        pairmove(&request->config_items, &check_tmp);
-                       pairfree(&check_tmp); 
+                       pairfree(&check_tmp);
 
                        reply_tmp = paircopy(user->reply);
                        pairmove(&request->reply->vps, &reply_tmp);
@@ -704,13 +704,13 @@ static int fastuser_authorize(void *instance, REQUEST *request)
                                return(rad_check_return(user->check));
                        }
 
-                       /* 
+                       /*
                         * Find next occurence of THIS user in
                         * the users file
                         */
                        user=user->next;
                        user=fastuser_find(request, user, name);
-               } 
+               }
 
                curdefault = curdefault->next;
        }
@@ -758,7 +758,7 @@ static int fastuser_preacct(void *instance, REQUEST *request)
        name = namepair ? (char *) namepair->strvalue : "NONE";
        request_pairs = request->packet->vps;
        config_pairs = &request->config_items;
-       
+
        /*
         *      Find the entry for the user.
         */
@@ -815,7 +815,7 @@ static int fastuser_detach(void *instance)
                        cur = inst->hashtable[hashindex];
                        pairlist_free(&cur);
                }
-       } 
+       }
 
        free(inst->compat_mode);
        free(inst->hashtable);
index ac27899..c7c0a40 100644 (file)
@@ -100,7 +100,7 @@ static int getusersfile(const char *filename, PAIR_LIST **pair_list, char *compa
                if (strcmp(compat_mode_str, "cistron") == 0) {
                        compat_mode = TRUE;
                }
-       
+
                entry = users;
                while (entry) {
                        if (compat_mode) {
@@ -127,7 +127,7 @@ static int getusersfile(const char *filename, PAIR_LIST **pair_list, char *compa
 
                                /*
                                 *      If it's a vendor attribute,
-                                *      or it's a wire protocol, 
+                                *      or it's a wire protocol,
                                 *      ensure it has '=='.
                                 */
                                if (((vp->attribute & ~0xffff) != 0) ||
@@ -144,7 +144,7 @@ static int getusersfile(const char *filename, PAIR_LIST **pair_list, char *compa
                                        vp->operator = T_OP_CMP_EQ;
                                        continue;
                                }
-                               
+
                                /*
                                 *      Cistron Compatibility mode.
                                 *
@@ -173,10 +173,10 @@ static int getusersfile(const char *filename, PAIR_LIST **pair_list, char *compa
                                                vp->operator = T_OP_CMP_EQ;
                                        }
                                }
-                               
+
                        } /* end of loop over check items */
-               
-               
+
+
                        /*
                         *      Look for server configuration items
                         *      in the reply list.
@@ -198,15 +198,15 @@ static int getusersfile(const char *filename, PAIR_LIST **pair_list, char *compa
                                        log_debug("[%s]:%d WARNING! Check item \"%s\"\n"
                                                        "\tfound in reply item list for user \"%s\".\n"
                                                        "\tThis attribute MUST go on the first line"
-                                                       " with the other check items", 
+                                                       " with the other check items",
                                                        filename, entry->lineno, vp->name,
                                                        entry->name);
                                }
                        }
-               
+
                        entry = entry->next;
                }
-       
+
        }
 
        *pair_list = users;
@@ -322,19 +322,19 @@ static int file_authorize(void *instance, REQUEST *request)
 
                        if((mainconfig.do_usercollide) && (strcmp(pl->name, "DEFAULT"))) {
 
-                               /* 
+                               /*
                                 * We have to make sure the password
                                 * matches as well
                                 */
-       
+
                                /* Save the orginal config items */
                                check_save = paircopy(request->config_items);
-       
+
                                /* Copy this users check pairs to the request */
                                check_tmp = paircopy(pl->check);
                                pairmove(check_pairs, &check_tmp);
                                pairfree(&check_tmp);
-       
+
                                DEBUG2("    users: Checking %s at %d", pl->name, pl->lineno);
                                /* Check the req to see if we matched */
                                if (rad_check_password(request)==0) {
@@ -345,8 +345,8 @@ static int file_authorize(void *instance, REQUEST *request)
                                        /* Free our saved config items */
                                        pairfree(&check_save);
 
-                                       /* 
-                                        * Already copied check items, so 
+                                       /*
+                                        * Already copied check items, so
                                         * just copy reply here
                                         */
                                        reply_tmp = paircopy(pl->reply);
@@ -361,10 +361,10 @@ static int file_authorize(void *instance, REQUEST *request)
                                        check_pairs = &request->config_items;
                                        continue;
                                }
-       
+
                        /* No usercollide */
                        } else {
-               
+
                                DEBUG2("    users: Matched %s at %d", pl->name, pl->lineno);
                                found = 1;
                                check_tmp = paircopy(pl->check);
@@ -381,7 +381,7 @@ static int file_authorize(void *instance, REQUEST *request)
                                break;
                }
        }
-       
+
        /*
         *      See if we succeeded.  If we didn't find the user,
         *      then exit from the module.
@@ -511,12 +511,12 @@ static int file_preproxy(void *instance, REQUEST *request)
                                if (vp->flags.do_xlat) {
                                        int rcode;
                                        char buffer[sizeof(vp->strvalue)];
-                                       
+
                                        vp->flags.do_xlat = 0;
                                        rcode = radius_xlat(buffer, sizeof(buffer),
                                                            vp->strvalue,
                                                            request, NULL);
-                                       
+
                                        /*
                                         *      Parse the string into
                                         *      a new value.
index ad093fc..a0bbe56 100644 (file)
@@ -19,7 +19,7 @@
  *
  * Copyright 2001  The FreeRADIUS server project
  * Copyright 2002  Kostas Kalevras <kkalev@noc.ntua.gr>
- * 
+ *
  * March 2002, Kostas Kalevras <kkalev@noc.ntua.gr>
  * - Initial release
  * April 2002, Kostas Kalevras <kkalev@noc.ntua.gr>
@@ -181,7 +181,7 @@ static int ippool_instantiate(CONF_SECTION *conf, void **instance)
        unsigned j;
        const char *cli = "0";
        char *pool_name = NULL;
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -220,7 +220,7 @@ static int ippool_instantiate(CONF_SECTION *conf, void **instance)
                free(data);
                return -1;
        }
-       
+
        data->gdbm = gdbm_open(data->session_db, sizeof(int),
                        GDBM_WRCREAT | GDBM_IPPOOL_OPTS, 0600, NULL);
        if (data->gdbm == NULL) {
@@ -266,7 +266,7 @@ static int ippool_instantiate(CONF_SECTION *conf, void **instance)
                                      ip_ntoa(str, ntohl(i)));
                                continue;
                        }
-                       
+
                        strcpy(key.nas, nas_init);
                        key.port = j;
                        key_datum.dptr = (char *) &key;
@@ -302,14 +302,14 @@ static int ippool_instantiate(CONF_SECTION *conf, void **instance)
 
        pthread_mutex_init(&data->op_mutex, NULL);
        *instance = data;
-       
+
        return 0;
 }
 
 
 /*
  *     Check for an Accounting-Stop
- *     If we find one and we have allocated an IP to this nas/port combination, deallocate it. 
+ *     If we find one and we have allocated an IP to this nas/port combination, deallocate it.
  */
 static int ippool_accounting(void *instance, REQUEST *request)
 {
@@ -508,7 +508,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
 
        memset(key.nas,0,MAX_NAS_NAME_SIZE);
        strncpy(key.nas,nas,MAX_NAS_NAME_SIZE -1 );
-       key.port = port;        
+       key.port = port;
        DEBUG("rlm_ippool: Searching for an entry for nas/port: %s/%u",key.nas,key.port);
        key_datum.dptr = (char *) &key;
        key_datum.dsize = sizeof(ippool_key);
@@ -604,13 +604,13 @@ static int ippool_postauth(void *instance, REQUEST *request)
        pthread_mutex_lock(&data->op_mutex);
 
        key_datum.dptr = NULL;
-       if (cli != NULL){       
+       if (cli != NULL){
                key_datum = gdbm_firstkey(data->gdbm);
                while(key_datum.dptr){
                        data_datum = gdbm_fetch(data->gdbm, key_datum);
                        if (data_datum.dptr){
                                memcpy(&entry,data_datum.dptr, sizeof(ippool_info));
-                               free(data_datum.dptr);  
+                               free(data_datum.dptr);
                                /*
                                * If we find an entry for the same caller-id and nas with active=1
                                * then we use that for multilink (MPPP) to work properly.
@@ -635,18 +635,18 @@ static int ippool_postauth(void *instance, REQUEST *request)
                        data_datum = gdbm_fetch(data->gdbm, key_datum);
                        if (data_datum.dptr){
                                memcpy(&entry,data_datum.dptr, sizeof(ippool_info));
-                               free(data_datum.dptr);  
+                               free(data_datum.dptr);
 
                                /*
                                 * Find an entry with active == 0
                                 */
                                if (entry.active == 0){
-                                       datum tmp;              
+                                       datum tmp;
 
                                        tmp.dptr = (char *) &entry.ipaddr;
                                        tmp.dsize = sizeof(uint32_t);
                                        data_datum = gdbm_fetch(data->ip, tmp);
-       
+
                                        /*
                                         * If we find an entry in the ip index and the number is zero (meaning
                                         * that we haven't allocated the same ip address to another nas/port pair)
@@ -655,7 +655,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
                                         * Else we don't delete the session entry since we haven't yet deallocated the
                                         * corresponding ip address and we continue our search.
                                         */
-       
+
                                        if (data_datum.dptr){
                                                memcpy(&num,data_datum.dptr, sizeof(int));
                                                free(data_datum.dptr);
@@ -698,7 +698,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
                         */
                        datum key_datum_tmp;
                        datum data_datum_tmp;
-                       ippool_key key_tmp;     
+                       ippool_key key_tmp;
 
                        memset(key_tmp.nas,0,MAX_NAS_NAME_SIZE);
                        strncpy(key_tmp.nas,nas,MAX_NAS_NAME_SIZE -1 );
@@ -758,7 +758,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
                key.port = port;
                key_datum.dptr = (char *) &key;
                key_datum.dsize = sizeof(ippool_key);
-               
+
                DEBUG2("rlm_ippool: Allocating ip to nas/port: %s/%u",key.nas,key.port);
                rcode = gdbm_store(data->gdbm, key_datum, data_datum, GDBM_REPLACE);
                if (rcode < 0) {
@@ -770,7 +770,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
 
                /* Increase the ip index count */
                key_datum.dptr = (char *) &entry.ipaddr;
-               key_datum.dsize = sizeof(uint32_t);     
+               key_datum.dsize = sizeof(uint32_t);
                data_datum = gdbm_fetch(data->ip, key_datum);
                if (data_datum.dptr){
                        memcpy(&num,data_datum.dptr,sizeof(int));
@@ -789,7 +789,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
                        return RLM_MODULE_FAIL;
                }
                pthread_mutex_unlock(&data->op_mutex);
-                       
+
 
                DEBUG("rlm_ippool: Allocated ip %s to client on nas %s,port %u",ip_ntoa(str,entry.ipaddr),
                                key.nas,port);
@@ -849,7 +849,7 @@ static int ippool_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_ippool = {
-       "IPPOOL",       
+       "IPPOOL",
        RLM_TYPE_THREAD_SAFE,           /* type */
        NULL,                           /* initialization */
        ippool_instantiate,             /* instantiation */
index a31fffa..4586ae5 100755 (executable)
@@ -29,7 +29,7 @@
 
 // Copyright 2003 by Edwin Groothuis, edwin@mavetju.org
 // All rights reserved.
-// 
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions
 // are met:
@@ -38,7 +38,7 @@
 // 2. Redistributions in binary form must reproduce the above copyright
 //    notice, this list of conditions and the following disclaimer in the
 //    documentation and/or other materials provided with the distribution.
-// 
+//
 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -117,13 +117,13 @@ void addip(char *sessiondbname,char *indexdbname,char *ipaddress, char* NASname,
                printf("rlm_ippool_tool: Unable to convert IP address '%s'\n", ipaddress);
                return;
        }
-       
+
     if (sessiondb==NULL)
        {
                printf("rlm_ippool_tool: Unable to open DB '%s'\n", sessiondbname);
                return;
        }
-       
+
     if (indexdb==NULL)
        {
                printf("rlm_ippool_tool: Unable to open DB '%s'\n", indexdbname);
@@ -131,7 +131,7 @@ void addip(char *sessiondbname,char *indexdbname,char *ipaddress, char* NASname,
        }
 
        port = strtoul(NASport,NULL,0);
-       
+
        /* Basically from rlm_ippool.c */
 
        memset(key.nas,0,MAX_NAS_NAME_SIZE);
@@ -144,7 +144,7 @@ void addip(char *sessiondbname,char *indexdbname,char *ipaddress, char* NASname,
        if (data_datum.dptr != NULL){
                found = 1;
                memcpy(&entry,data_datum.dptr, sizeof(ippool_info));
-               free(data_datum.dptr);  
+               free(data_datum.dptr);
                if (entry.active){
                        printf("rlm_ippool_tool: Deleting stale entry for ip/port %s/%u",
                                        ipaddress, port);
@@ -191,13 +191,13 @@ void addip(char *sessiondbname,char *indexdbname,char *ipaddress, char* NASname,
        }
        key_datum.dptr = NULL;
 
-       if (cli != NULL){       
+       if (cli != NULL){
                key_datum = gdbm_firstkey(sessiondb);
                while(key_datum.dptr){
                        data_datum = gdbm_fetch(sessiondb, key_datum);
                        if (data_datum.dptr){
                                memcpy(&entry,data_datum.dptr, sizeof(ippool_info));
-                               free(data_datum.dptr);  
+                               free(data_datum.dptr);
                                /*
                                * If we find an entry for the same caller-id and nas with active=1
                                * then we use that for multilink (MPPP) to work properly.
@@ -303,7 +303,7 @@ void addip(char *sessiondbname,char *indexdbname,char *ipaddress, char* NASname,
 
                /* Increase the ip index count */
                key_datum.dptr = (char *) &entry.ipaddr;
-               key_datum.dsize = sizeof(uint32_t);     
+               key_datum.dsize = sizeof(uint32_t);
                data_datum = gdbm_fetch(indexdb, key_datum);
                if (data_datum.dptr){
                        memcpy(&num,data_datum.dptr,sizeof(int));
@@ -464,7 +464,7 @@ int main(int argc,char **argv) {
     if ((argc==2 || argc==3) && !nflag) {
                viewdb(argv[0],argv[1],argv[2]);
                if (cflag) printf("%d\n",active);
-       } else 
+       } else
                if (argc==5 && nflag)
                        addip(argv[0],argv[1],argv[2],argv[3],argv[4]);
                else
index cbc6596..db42077 100644 (file)
@@ -272,7 +272,7 @@ static int krb5_auth(void *instance, REQUEST *request)
         *      Actually perform the authentication
         */
        memset((char *)&kcreds, 0, sizeof(kcreds));
-       
+
        if ( (r = krb5_parse_name(context, user, &kcreds.client)) ) {
                radlog(L_AUTH, "rlm_krb5: [%s] krb5_parse_name failed: %s",
                       user, error_message(r));
@@ -316,7 +316,7 @@ static int krb5_auth(void *instance, REQUEST *request)
                krb5_cc_destroy(context, ccache);
                return r;
        }
-       
+
        return RLM_MODULE_REJECT;
 }
 
@@ -380,7 +380,7 @@ static int krb5_auth(void *instance, REQUEST *request)
               userP->realm);
 
        krb5_cc_default(context, &id);
-       
+
        ret = krb5_verify_user(context,
                               userP,
                               id,
index 821f645..3191272 100644 (file)
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * This module is based on LDAP patch to Cistron radiusd by James Golovich 
- * <james@wwnet.net>, which in turn was based mostly on a Mysql+Cistron patch 
+ * This module is based on LDAP patch to Cistron radiusd by James Golovich
+ * <james@wwnet.net>, which in turn was based mostly on a Mysql+Cistron patch
  * from <oyarzun@wilmington.net>
- * 
+ *
  * 17 Jan 2000,        Adrian Pavlykevych <pam@polynet.lviv.ua>
  *     - OpenLDAP SDK porting, basic TLS support, LDAP authorization,
- *       fault tolerance with multiple LDAP server support 
- * 24 May 2000,        Adrian Pavlykevych <pam@polynet.lviv.ua> 
+ *       fault tolerance with multiple LDAP server support
+ * 24 May 2000,        Adrian Pavlykevych <pam@polynet.lviv.ua>
  *     - Converting to new configuration file format, futher improvements
  *       in fault tolerance, threaded operation
- * 12 Dec 2000,        Adrian Pavlykevych <pam@polynet.lviv.ua> 
+ * 12 Dec 2000,        Adrian Pavlykevych <pam@polynet.lviv.ua>
  *     - Added preliminary support for multiple instances
  *     - moved all instance configuration into dynamicly allocated structure
  *     - Removed connection maintenance thread and all attempts for multihreading
@@ -38,9 +38,9 @@
  *     - Support for generic RADIUS check and reply attribute.
  * Jun 2001, Kostas Kalevras <kkalev@noc.ntua.gr>
  *     - Fix: check and reply attributes from LDAP _replace_ existing ones
- *     - Added "default_profile" directive, which points to radiusProfile 
+ *     - Added "default_profile" directive, which points to radiusProfile
  *       object, which contains default values for RADIUS users
- *     - Added "profile_attribute" directive, which specifies user object 
+ *     - Added "profile_attribute" directive, which specifies user object
  *       attribute pointing to radiusProfile object.
  * Nov 2001, Kostas Kalevras <kkalev@noc.ntua.gr>
  *     - Added support for adding the user password to the check. Based on
@@ -353,7 +353,7 @@ static inline int ldap_get_conn(LDAP_CONN *conns,LDAP_CONN **ret,void *instance)
 
        return -1;
 }
-       
+
 static inline void ldap_release_conn(int i, LDAP_CONN *conns)
 {
        DEBUG("ldap_release_conn: Release Id: %d",i);
@@ -369,7 +369,7 @@ static inline void ldap_release_conn(int i, LDAP_CONN *conns)
  *              to create an instance of the module.
  *
  *************************************************************************/
-static int 
+static int
 ldap_instantiate(CONF_SECTION * conf, void **instance)
 {
        ldap_instance  *inst;
@@ -404,7 +404,7 @@ ldap_instantiate(CONF_SECTION * conf, void **instance)
                inst->port = 0;
        }
 #endif
+
        inst->timeout.tv_usec = 0;
        inst->net_timeout.tv_usec = 0;
        /* workaround for servers which support LDAPS but not START TLS */
@@ -445,14 +445,14 @@ ldap_instantiate(CONF_SECTION * conf, void **instance)
                inst->conns[i].failed_conns = 0;
                inst->conns[i].ld = NULL;
                pthread_mutex_init(&inst->conns[i].mutex, NULL);
-       }       
+       }
 
        if (read_mappings(inst) != 0) {
                radlog(L_ERR, "rlm_ldap: Reading dictionary mappings from file %s failed",
                       inst->dictionary_mapping);
                radlog(L_ERR, "rlm_ldap: Proceeding with no mappings");
        }
-       
+
        pair = inst->check_item_map;
        while(pair != NULL){
                atts_num++;
@@ -505,7 +505,7 @@ ldap_instantiate(CONF_SECTION * conf, void **instance)
                        }
                }
        }
-       inst->atts[atts_num] = NULL;            
+       inst->atts[atts_num] = NULL;
 
        DEBUG("conns: %p",inst->conns);
 
@@ -557,14 +557,14 @@ read_mappings(ldap_instance* inst)
                /* strip comments */
                ptr = strchr(buf, '#');
                if (ptr) *ptr = 0;
-               
+
                /* empty line */
                if (buf[0] == 0) continue;
-               
-               /* extract tokens from the string */            
+
+               /* extract tokens from the string */
                token_count = sscanf(buf, "%s %s %s", itemType, radiusAttribute, ldapAttribute);
 
-               if (token_count <= 0) /* no tokens */                   
+               if (token_count <= 0) /* no tokens */
                        continue;
 
                if (token_count != 3) {
@@ -588,7 +588,7 @@ read_mappings(ldap_instance* inst)
                        fclose(mapfile);
                        return -1;
                }
-                       
+
                /* push node to correct list */
                if (strcasecmp(itemType, "checkItem") == 0) {
                        pair->next = inst->check_item_map;
@@ -597,7 +597,7 @@ read_mappings(ldap_instance* inst)
                        pair->next = inst->reply_item_map;
                        inst->reply_item_map = pair;
                } else {
-                       radlog(L_ERR, "rlm_ldap: file %s: skipping line %i: unknown itemType %s", 
+                       radlog(L_ERR, "rlm_ldap: file %s: skipping line %i: unknown itemType %s",
                               filename, linenumber, itemType);
                        free(pair->attr);
                        free(pair->radius_attr);
@@ -608,14 +608,14 @@ read_mappings(ldap_instance* inst)
                DEBUG("rlm_ldap: LDAP %s mapped to RADIUS %s",
                      pair->attr, pair->radius_attr);
        }
-       
+
        fclose(mapfile);
 
        return 0; /* success */
 }
 
-static int 
-perform_search(void *instance, LDAP_CONN *conn, char *search_basedn, int scope, char *filter, 
+static int
+perform_search(void *instance, LDAP_CONN *conn, char *search_basedn, int scope, char *filter,
                char **attrs, LDAPMessage ** result)
 {
        int             res = RLM_MODULE_OK;
@@ -665,7 +665,7 @@ retry:
                                radlog(L_INFO, "rlm_ldap: Attempting reconnect");
                                search_retry = 1;
                                conn->bound = 0;
-                               ldap_msgfree(*result);  
+                               ldap_msgfree(*result);
                                goto retry;
                        }
                }
@@ -689,20 +689,20 @@ retry:
                /* We don't need to reconnect in these cases so we don't set conn->bound */
                ldap_get_option(conn->ld, LDAP_OPT_ERROR_NUMBER, &ldap_errno);
                radlog(L_ERR, "rlm_ldap: ldap_search() failed: %s", ldap_err2string(ldap_errno));
-               ldap_msgfree(*result);  
+               ldap_msgfree(*result);
                return (RLM_MODULE_FAIL);
        default:
                ldap_get_option(conn->ld, LDAP_OPT_ERROR_NUMBER, &ldap_errno);
                radlog(L_ERR, "rlm_ldap: ldap_search() failed: %s", ldap_err2string(ldap_errno));
                conn->bound = 0;
-               ldap_msgfree(*result);  
+               ldap_msgfree(*result);
                return (RLM_MODULE_FAIL);
        }
 
        if ((ldap_count_entries(conn->ld, *result)) != 1) {
                DEBUG("rlm_ldap: object not found or got ambiguous search result");
                res = RLM_MODULE_NOTFOUND;
-               ldap_msgfree(*result);  
+               ldap_msgfree(*result);
        }
        return res;
 }
@@ -714,7 +714,7 @@ retry:
 static int ldap_escape_func(char *out, int outlen, const char *in)
 {
        int len = 0;
-       
+
        while (in[0]) {
                /*
                 *  Only one byte left.
@@ -722,13 +722,13 @@ static int ldap_escape_func(char *out, int outlen, const char *in)
                if (outlen <= 1) {
                        break;
                }
-               
+
                if (strchr("*", *in)) {
                        in++;
                        outlen--;
                        continue;
                }
-               
+
                /*
                 *      Else it's a nice character.
                 */
@@ -832,14 +832,14 @@ static int ldap_groupcmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALU
                /* This looks like a DN */
                snprintf(filter,sizeof(filter), "%s",gr_filter);
                snprintf(basedn,sizeof(basedn), "%s",(char *)check->strvalue);
-       } else 
+       } else
                snprintf(filter,sizeof(filter), "(&(%s=%s)%s)",inst->groupname_attr,(char *)check->strvalue,gr_filter);
 
        if ((conn_id = ldap_get_conn(inst->conns,&conn,inst)) == -1){
                radlog(L_ERR, "rlm_ldap: All ldap connections are in use");
                return 1;
        }
-       
+
        if ((res = perform_search(inst, conn, basedn, LDAP_SCOPE_SUBTREE,
                                filter, attrs, &result)) == RLM_MODULE_OK){
                DEBUG("rlm_ldap::ldap_groupcmp: User found in group %s",
@@ -848,7 +848,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALU
                ldap_release_conn(conn_id,inst->conns);
                return 0;
        }
-       
+
        ldap_release_conn(conn_id,inst->conns);
 
        if (res != RLM_MODULE_NOTFOUND ) {
@@ -857,7 +857,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALU
        }
 
        if (inst->groupmemb_attr == NULL){
-               /* search returned NOTFOUND and searching for membership 
+               /* search returned NOTFOUND and searching for membership
                 * using user object attributes is not specified in config
                 * file
                 */
@@ -875,7 +875,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALU
                DEBUG("rlm_ldap::ldap_groupcmp: Search returned error");
                ldap_release_conn(conn_id, inst->conns);
                return 1;
-       }               
+       }
 
        if ((msg = ldap_first_entry(conn->ld, result)) == NULL) {
                DEBUG("rlm_ldap::ldap_groupcmp: ldap_first_entry() failed");
@@ -887,7 +887,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALU
                unsigned int i = 0;
                char found = 0;
                for (;i < ldap_count_values(vals);i++){
-                       if (strchr(vals[i],',') != NULL){ 
+                       if (strchr(vals[i],',') != NULL){
                                /* This looks like a DN */
                                LDAPMessage *gr_result = NULL;
                                snprintf(filter,sizeof(filter), "(%s=%s)",
@@ -1043,7 +1043,7 @@ static int ldap_xlat(void *instance, REQUEST *request, char *fmt, char *out, int
  *      Purpose: Check if user is authorized for remote access
  *
  ******************************************************************************/
-static int 
+static int
 ldap_authorize(void *instance, REQUEST * request)
 {
        LDAPMessage     *result = NULL;
@@ -1174,7 +1174,7 @@ ldap_authorize(void *instance, REQUEST * request)
        }
 
        /*
-        * Check for the default profile entry. If it exists then add the 
+        * Check for the default profile entry. If it exists then add the
         * attributes it contains in the check and reply pairs
         */
 
@@ -1187,7 +1187,7 @@ ldap_authorize(void *instance, REQUEST * request)
                        profile = user_profile->strvalue;
                if (profile && strlen(profile)){
                        if ((res = perform_search(instance, conn,
-                               profile, LDAP_SCOPE_BASE, 
+                               profile, LDAP_SCOPE_BASE,
                                filter, inst->atts, &def_result)) == RLM_MODULE_OK){
                                if ((def_msg = ldap_first_entry(conn->ld,def_result))){
                                        if ((check_tmp = ldap_pairget(conn->ld,def_msg,inst->check_item_map,check_pairs,1))) {
@@ -1208,13 +1208,13 @@ ldap_authorize(void *instance, REQUEST * request)
                                        }
                                }
                                ldap_msgfree(def_result);
-                       } else 
+                       } else
                                DEBUG("rlm_ldap: default_profile/user-profile search failed");
                }
        }
 
        /*
-        * Check for the profile attribute. If it exists, we assume that it 
+        * Check for the profile attribute. If it exists, we assume that it
         * contains the DN of an entry containg a profile for the user. That
         * way we can have different general profiles for various user groups
         * (students,faculty,staff etc)
@@ -1226,7 +1226,7 @@ ldap_authorize(void *instance, REQUEST * request)
                        strNcpy(filter,inst->base_filter,sizeof(filter));
                        while(vals[i] != NULL && strlen(vals[i])){
                                if ((res = perform_search(instance, conn,
-                                       vals[i], LDAP_SCOPE_BASE, 
+                                       vals[i], LDAP_SCOPE_BASE,
                                        filter, inst->atts, &def_attr_result)) == RLM_MODULE_OK){
                                        if ((def_attr_msg = ldap_first_entry(conn->ld,def_attr_result))){
                                                if ((check_tmp = ldap_pairget(conn->ld,def_attr_msg,inst->check_item_map,check_pairs,1))) {
@@ -1247,7 +1247,7 @@ ldap_authorize(void *instance, REQUEST * request)
                                                }
                                        }
                                        ldap_msgfree(def_attr_result);
-                               } else 
+                               } else
                                        DEBUG("rlm_ldap: profile_attribute search failed");
                                i++;
                        }
@@ -1357,7 +1357,7 @@ ldap_authorize(void *instance, REQUEST * request)
  *     Purpose: Check the user's password against ldap database
  *
  *****************************************************************************/
-static int 
+static int
 ldap_authenticate(void *instance, REQUEST * request)
 {
        LDAP           *ld_user;
@@ -1412,13 +1412,13 @@ ldap_authenticate(void *instance, REQUEST * request)
        }
 
 
-       DEBUG("rlm_ldap: login attempt by \"%s\" with password \"%s\"", 
+       DEBUG("rlm_ldap: login attempt by \"%s\" with password \"%s\"",
               request->username->strvalue, request->password->strvalue);
 
        while((vp_user_dn = pairfind(request->packet->vps, PW_LDAP_USERDN)) == NULL) {
                if (!radius_xlat(filter, sizeof(filter), inst->filter,
                                request, NULL)) {
-                       radlog (L_ERR, "rlm_ldap: unable to create filter.\n"); 
+                       radlog (L_ERR, "rlm_ldap: unable to create filter.\n");
                        return RLM_MODULE_INVALID;
                }
 
@@ -1671,16 +1671,16 @@ ldap_connect(void *instance, const char *dn, const char *password, int auth, int
                break;
 
        case LDAP_INVALID_CREDENTIALS:
-               if (auth){ 
+               if (auth){
                        DEBUG("rlm_ldap: Bind failed with invalid credentials");
                        *result = RLM_MODULE_REJECT;
                }
                else {
                        radlog(L_ERR, "rlm_ldap: LDAP login failed: check login, password settings in ldap section of radiusd.conf");
                        *result = RLM_MODULE_FAIL;
-               }               
+               }
                break;
-               
+
        default:
                if (inst->is_url)
                        radlog(L_ERR,"rlm_ldap: %s bind to %s failed %s",
@@ -1704,7 +1704,7 @@ ldap_connect(void *instance, const char *dn, const char *password, int auth, int
  *     Detach from the LDAP server and cleanup internal state.
  *
  *****************************************************************************/
-static int 
+static int
 ldap_detach(void *instance)
 {
        ldap_instance  *inst = instance;
@@ -1751,7 +1751,7 @@ ldap_detach(void *instance)
        }
 
        pair = inst->check_item_map;
-       
+
        while (pair != NULL) {
                nextpair = pair->next;
                free(pair->attr);
@@ -1783,7 +1783,7 @@ ldap_detach(void *instance)
 }
 
 #ifdef FIELDCPY
-static void 
+static void
 fieldcpy(char *string, char **uptr)
 {
        char           *ptr;
@@ -1856,14 +1856,14 @@ ldap_pairget(LDAP * ld, LDAPMessage * entry,
                                if (is_generic_attribute) {
                                        /* this is a generic attribute */
                                        LRAD_TOKEN dummy; /* makes pairread happy */
-                                       
+
                                        /* not sure if using pairread here is ok ... */
                                        if ( (newpair = pairread(&ptr, &dummy)) != NULL) {
-                                               DEBUG("rlm_ldap: extracted attribute %s from generic item %s", 
+                                               DEBUG("rlm_ldap: extracted attribute %s from generic item %s",
                                                      newpair->name, vals[vals_idx]);
                                                pairadd(&pairlist, newpair);
                                        } else {
-                                               radlog(L_ERR, "rlm_ldap: parsing %s failed: %s", 
+                                               radlog(L_ERR, "rlm_ldap: parsing %s failed: %s",
                                                       element->attr, vals[vals_idx]);
                                        }
                                } else {
index 85b8b3f..ed787ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_mschap.c        
+ * rlm_mschap.c
  *
  * Version:    $Id$
  *
@@ -39,7 +39,7 @@
  *  aka
  *  ZARAZA             3APA3A@security.nnov.ru
  */
+
 /*  MPPE support from Takahiro Wagatsuma <waga@sic.shibaura-it.ac.jp> */
 
 #include       "autoconf.h"
@@ -69,7 +69,7 @@ static int hex2bin (const char *szHex, unsigned char* szBin, int len)
 {
        char * c1, * c2;
        int i;
-   
+
        for (i = 0; i < len; i++) {
                if( !(c1 = memchr(letters, toupper((int) szHex[i << 1]), 16)) ||
                    !(c2 = memchr(letters, toupper((int) szHex[(i << 1) + 1]), 16)))
@@ -82,7 +82,7 @@ static int hex2bin (const char *szHex, unsigned char* szBin, int len)
 /*
  *     bin2hex creates hexadecimal presentation
  *     of binary data
- */ 
+ */
 static void bin2hex (const unsigned char *szBin, char *szHex, int len)
 {
        int i;
@@ -125,7 +125,7 @@ static int pdb_decode_acct_ctrl(const char *p)
                          break;
 
                        case 'D':  /* 'D'isabled. */
-                         acct_ctrl |= ACB_DISABLED ; 
+                         acct_ctrl |= ACB_DISABLED ;
                          break;
 
                        case 'H':  /* 'H'omedir required. */
@@ -169,7 +169,7 @@ static int pdb_decode_acct_ctrl(const char *p)
 
                        case ':':
                        case '\n':
-                       case '\0': 
+                       case '\0':
                        case ']':
                        default:
                          finished = 1;
@@ -217,7 +217,7 @@ static void challenge_hash( const char *peer_challenge,
 {
        SHA1_CTX Context;
        char hash[20];
-       
+
        SHA1Init(&Context);
        SHA1Update(&Context, peer_challenge, 16);
        SHA1Update(&Context, auth_challenge, 16);
@@ -231,7 +231,7 @@ static void mschap2(const char *peer_challenge, const char *auth_challenge,
                    char *response)
 {
        char challenge[8];
-       
+
        challenge_hash(peer_challenge, auth_challenge, user_name,
                       challenge);
 
@@ -255,7 +255,7 @@ static void auth_response(const char *username, const char *nt_password,
         0x65, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x63, 0x6C, 0x69, 0x65,
         0x6E, 0x74, 0x20, 0x73, 0x69, 0x67, 0x6E, 0x69, 0x6E, 0x67,
         0x20, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74};
-                                             
+
        const char magic2[41] =
        {0x50, 0x61, 0x64, 0x20, 0x74, 0x6F, 0x20, 0x6D, 0x61, 0x6B,
         0x65, 0x20, 0x69, 0x74, 0x20, 0x64, 0x6F, 0x20, 0x6D, 0x6F,
@@ -321,7 +321,7 @@ static CONF_PARSER module_config[] = {
          offsetof(struct mschap_instance, passwd_file), NULL,  NULL },
        { "authtype",   PW_TYPE_STRING_PTR,
          offsetof(struct mschap_instance, auth_type), NULL,  NULL },
-       
+
        { NULL, -1, 0, NULL, NULL }             /* end the list */
 };
 
@@ -337,7 +337,7 @@ static int mschap_detach(void *instance){
        return 0;
 #undef inst
 }
-       
+
 /*
  *     Create instance for our module. Allocate space for
  *     instance structure and read configuration parameters
@@ -546,7 +546,7 @@ static int mschap_authorize(void * instance, REQUEST *request)
        if (!challenge) {
                return RLM_MODULE_NOOP;
        }
-               
+
        response = pairfind(request->packet->vps, PW_MSCHAP_RESPONSE);
        if (!response)
                response = pairfind(request->packet->vps, PW_MSCHAP2_RESPONSE);
@@ -589,7 +589,7 @@ static int mschap_authorize(void * instance, REQUEST *request)
  *     or in configured passwd file.
  *     If one is found we will check paraneters given by NAS.
  *
- *     If PW_SMB_ACCOUNT_CTRL is not set to ACB_PWNOTREQ we must have 
+ *     If PW_SMB_ACCOUNT_CTRL is not set to ACB_PWNOTREQ we must have
  *     one of:
  *             PAP:      PW_PASSWORD or
  *             MS-CHAP:  PW_MSCHAP_CHALLENGE and PW_MSCHAP_RESPONSE or
@@ -613,7 +613,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
         uint8_t mppe_recvkey[34];
        char *username_string;
        int chap = 0;
-       
+
        /*
         *      Find the SMB-Account-Ctrl attribute, or the
         *      SMB-Account-Ctrl-Text attribute.
@@ -720,7 +720,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                DEBUG2("  rlm_mschap: No LM-Password or NT-Password attribute found.  Cannot perform MS-CHAP authentication.");
                return RLM_MODULE_FAIL;
        }
-       
+
        /*
         *      We MAY be asked to take a User-Password attribute from
         *      the packet, and compare it to passwords retrieved from
@@ -774,7 +774,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                        radlog(L_AUTH, "rlm_mschap: MS-CHAP-Challenge has the wrong format.");
                        return RLM_MODULE_INVALID;
                }
-       
+
                /*
                 *      Responses are 50 octets.
                 */
@@ -782,7 +782,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                        radlog(L_AUTH, "rlm_mschap: MS-CHAP-Response has the wrong format.");
                        return RLM_MODULE_INVALID;
                }
-           
+
                /*
                 *      We are doing MS-CHAP.  Calculate the MS-CHAP
                 *      response
@@ -804,7 +804,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                        DEBUG2("  rlm_mschap: FAILED: No NT/LM-Password");
                        return RLM_MODULE_REJECT;
                }
-               
+
                /*
                 *      Calculate the expected response.
                 */
@@ -826,7 +826,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                        radlog(L_AUTH, "rlm_mschap: MS-CHAP-Challenge has the wrong format.");
                        return RLM_MODULE_INVALID;
                }
-       
+
                /*
                 *      Responses are 50 octets.
                 */
@@ -858,7 +858,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                } else {
                        username_string = username->strvalue;
                }
-           
+
                /*
                 *      We are doing MS-CHAPv2
                 *      We need NT hash for it to calculate response
@@ -887,7 +887,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                add_reply( &request->reply->vps, *response->strvalue,
                           "MS-CHAP2-Success", msch2resp, 42);
                chap = 2;
-               
+
        } else {                /* Neither CHAPv1 or CHAPv2 response: die */
                radlog(L_AUTH, "rlm_mschap: No MS-CHAP response found");
                return RLM_MODULE_INVALID;
@@ -934,7 +934,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                        }
 
                        if (nt_password) {
-                               /* 
+                               /*
                                 *      According to RFC 2548 we
                                 *      should send NT hash.  But in
                                 *      practice it doesn't work.
@@ -955,14 +955,14 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                                               nt_password->strvalue,
                                               response->strvalue + 26,
                                               mppe_sendkey, mppe_recvkey);
-                       
+
                        mppe_add_reply(&request->reply->vps,
                                       "MS-MPPE-Recv-Key",
                                       mppe_recvkey, 16);
                        mppe_add_reply(&request->reply->vps,
                                       "MS-MPPE-Send-Key",
                                       mppe_sendkey, 16);
-                       
+
                }
                reply_attr = pairmake("MS-MPPE-Encryption-Policy",
                                      (inst->require_encryption)? "0x00000002":"0x00000001",
@@ -974,7 +974,7 @@ static int mschap_authenticate(void * instance, REQUEST *request)
                                      T_OP_EQ);
                rad_assert(reply_attr != NULL);
                pairadd(&request->reply->vps, reply_attr);
-               
+
        } /* else we weren't asked to use MPPE */
 
        return RLM_MODULE_OK;
index bcee3b0..0ba8bfb 100644 (file)
@@ -69,7 +69,7 @@ int main (int argc, char *argv[])
        char hash[16];
        char ntpass[33];
        char lmpass[33];
-       
+
        fprintf(stderr, "LM Hash                         \tNT Hash\n");
        fprintf(stderr, "--------------------------------\t--------------------------------\n");
        fflush(stderr);
index 0fb8514..53831b9 100644 (file)
@@ -3,12 +3,12 @@
  *             Taken from the hacks for qmail located at nrg4u.com
  *             by Andre Oppermann.
  *
- *             NS-MTA-MD5 passwords are 64 byte strings, the first  
- *             32 bytes being the password hash and the last 32 bytes 
- *             the salt.  The clear text password and the salt are MD5 
+ *             NS-MTA-MD5 passwords are 64 byte strings, the first
+ *             32 bytes being the password hash and the last 32 bytes
+ *             the salt.  The clear text password and the salt are MD5
  *             hashed[1].  If the resulting hash concatenated with the salt
- *             are equivalent to the original NS-MTA-MD5 password the 
- *             password is correct. 
+ *             are equivalent to the original NS-MTA-MD5 password the
+ *             password is correct.
  *
  *             [1] Read the source for details.
  *
@@ -121,7 +121,7 @@ static int ns_mta_md5_pass(const char *clear, const char *encrypted)
 static int module_auth(void *instance, REQUEST *request)
 {
        VALUE_PAIR *md5_password;
-       
+
        /*
         *      We can only authenticate user requests which HAVE
         *      a User-Password attribute.
index 12532d6..913fb62 100644 (file)
@@ -125,11 +125,11 @@ static int PAM_conv (int num_msg,
   struct pam_response *reply = NULL;
   int size = sizeof(struct pam_response);
   my_PAM *pam_config = (my_PAM *) appdata_ptr;
-  
+
 #define GET_MEM if (reply) realloc(reply, size); else reply = rad_malloc(size); \
   size += sizeof(struct pam_response)
 #define COPY_STRING(s) ((s) ? strdup(s) : NULL)
-                                    
+
   for (count = 0; count < num_msg; count++) {
     switch (msg[count]->msg_style) {
     case PAM_PROMPT_ECHO_ON:
@@ -171,7 +171,7 @@ static int PAM_conv (int num_msg,
  *************************************************************************/
 
 /* cjd 19980706
- * 
+ *
  * for most flexibility, passing a pamauth type to this function
  * allows you to have multiple authentication types (i.e. multiple
  * files associated with radius in /etc/pam.d)
index fd64821..8481ccb 100644 (file)
@@ -85,7 +85,7 @@ static void pap_hexify(char *buffer, char *str, int len)
        char *pch = str;
        char ch;
        int i;
-       
+
        for(i = 0;i < len; i ++) {
                ch = pch[i];
                buffer[2*i] = pap_hextab[(ch>>4) & 15];
@@ -182,7 +182,7 @@ static int pap_authenticate(void *instance, REQUEST *request)
                return RLM_MODULE_INVALID;
        }
 
-       DEBUG("rlm_pap: login attempt by \"%s\" with password %s", 
+       DEBUG("rlm_pap: login attempt by \"%s\" with password %s",
                request->username->strvalue, request->password->strvalue);
 
        if (((passwd_item = pairfind(request->config_items, PW_PASSWORD)) == NULL) ||
@@ -196,7 +196,7 @@ static int pap_authenticate(void *instance, REQUEST *request)
 
        DEBUG("rlm_pap: Using password \"%s\" for user %s authentication.",
              passwd_item->strvalue, request->username->strvalue);
-       
+
        if (inst->sch == PAP_ENC_INVALID || inst->sch > PAP_MAX_ENC){
                radlog(L_ERR, "rlm_pap: Wrong password scheme");
                return RLM_MODULE_FAIL;
@@ -303,7 +303,7 @@ static int pap_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_pap = {
-       "PAP",  
+       "PAP",
        0,                              /* type */
        NULL,                           /* initialization */
        pap_instantiate,                /* instantiation */
index 2a44700..f984389 100644 (file)
@@ -127,13 +127,13 @@ static unsigned int hash(const unsigned char * username, unsigned int tablesize)
                h = h * 7907 + *username++;
        }
        return h%tablesize;
-} 
+}
 
 static void release_hash_table(struct hashtable * ht){
        int i;
 
        if (!ht) return;
-       for (i=0; i<ht->tablesize; i++) 
+       for (i=0; i<ht->tablesize; i++)
                if (ht->table[i])
                        destroy_password(ht->table[i]);
        if (ht->table) free(ht->table);
@@ -159,7 +159,7 @@ static struct hashtable * build_hash_table (const char * file, int nfields,
        char *list;
        char *nextlist=0;
        int i;
-       
+
        ht = (struct hashtable *) rad_malloc(sizeof(struct hashtable));
        if(!ht) {
                return NULL;
@@ -202,7 +202,7 @@ static struct hashtable * build_hash_table (const char * file, int nfields,
                                free(hashentry);
                                continue;
                        }
-                       
+
                        if (islist) {
                                list = hashentry->field[keyfield];
                                for (nextlist = list; *nextlist && *nextlist!=','; nextlist++);
@@ -244,7 +244,7 @@ static struct mypasswd * get_next(char *name, struct hashtable *ht)
        char buffer[1024];
        int len;
        char *list, *nextlist;
-       
+
        if (ht->tablesize > 0) {
                /* get saved address of next item to check from buffer */
                hashentry = ht->last_found;
@@ -274,7 +274,7 @@ static struct mypasswd * get_next(char *name, struct hashtable *ht)
                                        if(!strcmp(list, name)) return passwd;
                                }
                        }
-                       
+
                }
        }
        fclose(ht->fp);
@@ -287,7 +287,7 @@ static struct mypasswd * get_pw_nam(char * name, struct hashtable* ht)
 {
        int h;
        struct mypasswd * hashentry;
-       
+
        if (!ht || !name || *name == '\0') return NULL;
        ht->last_found = NULL;
        if (ht->tablesize > 0) {
@@ -314,7 +314,7 @@ int main(void){
  char *buffer;
  struct mypasswd* pw;
  int i;
+
  ht = build_hash_table("/etc/group", 4, 3, 1, 100, 0, ":");
  if(!ht) {
        printf("Hash table not built\n");
@@ -354,7 +354,7 @@ struct passwd_instance {
 
 static CONF_PARSER module_config[] = {
        { "filename",   PW_TYPE_STRING_PTR,
-          offsetof(struct passwd_instance, filename), NULL,  NULL },   
+          offsetof(struct passwd_instance, filename), NULL,  NULL },
        { "format",   PW_TYPE_STRING_PTR,
           offsetof(struct passwd_instance, format), NULL,  NULL },
        { "authtype",   PW_TYPE_STRING_PTR,
@@ -375,11 +375,11 @@ static int passwd_instantiate(CONF_SECTION *conf, void **instance)
 #define inst ((struct passwd_instance *)*instance)
        int nfields=0, keyfield=-1, listable=0;
        char *s;
-       char *lf=NULL; /* destination list flags temporary */ 
+       char *lf=NULL; /* destination list flags temporary */
        int len;
        int i;
        DICT_ATTR * da;
-       
+
        *instance = rad_malloc(sizeof(struct passwd_instance));
        if ( !*instance) {
                radlog(L_ERR, "rlm_passwd: cann't alloc instance");
@@ -411,7 +411,7 @@ static int passwd_instantiate(CONF_SECTION *conf, void **instance)
                        if(*(s+1) == ','){
                                listable = 1;
                                s++;
-                       } 
+                       }
                        if(*(s+1) == '='){
                                lf[nfields]=1;
                                s++;
@@ -428,7 +428,7 @@ static int passwd_instantiate(CONF_SECTION *conf, void **instance)
                radlog(L_ERR, "rlm_passwd: no field market as key in format: %s", inst->format);
                return -1;
        }
-       if (! (inst->ht = build_hash_table (inst->filename, nfields, keyfield, listable, inst->hashsize, inst->ignorenislike, inst->delimiter)) ){ 
+       if (! (inst->ht = build_hash_table (inst->filename, nfields, keyfield, listable, inst->hashsize, inst->ignorenislike, inst->delimiter)) ){
                radlog(L_ERR, "rlm_passwd: can't build hashtable from passwd file");
                return -1;
        }
@@ -442,7 +442,7 @@ static int passwd_instantiate(CONF_SECTION *conf, void **instance)
                release_ht(inst->ht);
                return -1;
        }
-       
+
        memcpy(inst->pwdfmt->listflag, lf, nfields);
 
        free(lf);
@@ -469,7 +469,7 @@ static int passwd_instantiate(CONF_SECTION *conf, void **instance)
        inst->listable = listable;
        radlog(L_INFO, "rlm_passwd: nfields: %d keyfield %d(%s) listable: %s", nfields, keyfield, inst->pwdfmt->field[keyfield], listable?"yes":"no");
        return 0;
-       
+
 #undef inst
 }
 
@@ -489,7 +489,7 @@ static void addresult (struct passwd_instance * inst, VALUE_PAIR ** vp, struct m
 {
        int i;
        VALUE_PAIR *newpair;
-       
+
        for (i=0; i<inst->nfields; i++) {
                if (inst->pwdfmt->field[i] && *inst->pwdfmt->field[i] && pw->field[i] && i != inst->keyfield  && inst->pwdfmt->listflag[i] == when) {
                        if (! (newpair = pairmake (inst->pwdfmt->field[i], pw->field[i], T_OP_EQ))) {
@@ -510,7 +510,7 @@ static int passwd_authorize(void *instance, REQUEST *request)
        VALUE_PAIR * key;
        struct mypasswd * pw;
        int found = 0;
-       
+
        if(!request || !request->packet ||!request->packet->vps)
         return RLM_MODULE_INVALID;
        for (key = request->packet->vps;
@@ -543,7 +543,7 @@ static int passwd_authorize(void *instance, REQUEST *request)
                pairadd (&request->config_items, key);
        }
        return RLM_MODULE_OK;
-       
+
 #undef inst
 }
 
index 8f2c4bc..f9aaba4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_perl.c  
+ * rlm_perl.c
  *
  * Version:    $Id$
  *
@@ -63,7 +63,7 @@ static const char rcsid[] = "$Id$";
 typedef struct perl_inst {
        /* Name of the perl module */
        char    *module;
-       
+
        /* Name of the functions for each module method */
        char    *func_authorize;
        char    *func_authenticate;
@@ -112,10 +112,10 @@ static CONF_PARSER module_config[] = {
 
        { NULL, -1, 0, NULL, NULL }             /* end the list */
 };
-               
+
 /*
  * man perlembed
- */ 
+ */
 EXTERN_C void boot_DynaLoader(pTHX_ CV* cv);
 
 /*
@@ -152,7 +152,7 @@ typedef struct PERL_POOL {
        int             max_request_per_clone;
        int             cleanup_delay;
        perl_mutex      mutex;
-       time_t          time_when_last_added;   
+       time_t          time_when_last_added;
 } PERL_POOL;
 
 static PERL_POOL perl_pool;
@@ -224,12 +224,12 @@ static void **rlm_perl_get_handles(pTHX)
 }
 
 static void rlm_perl_close_handles(void **handles)
-{   
+{
        int i;
 
        if (!handles) {
                return;
-       }   
+       }
 
        for (i=0; handles[i]; i++) {
                radlog(L_DBG, "close 0x%lx\n", (unsigned long)handles[i]);
@@ -243,20 +243,20 @@ static PerlInterpreter *rlm_perl_clone()
 {
        PerlInterpreter *clone;
        UV      clone_flags = CLONEf_KEEP_PTR_TABLE;
-       
+
        PERL_SET_CONTEXT(interp);
-       
+
        clone = perl_clone(interp, clone_flags);
-       {       
+       {
                dTHXa(clone);
        }
-       
+
        ptr_table_free(PL_ptr_table);
        PL_ptr_table = NULL;
 
        PERL_SET_CONTEXT(aTHX);
        rlm_perl_clear_handles(aTHX);
-       
+
        return clone;
 }
 
@@ -275,13 +275,13 @@ static void rlm_perl_destruct(PerlInterpreter *perl)
                dTHXa(perl);
        }
        /*
-        * FIXME: This shouldn't happen 
+        * FIXME: This shouldn't happen
         *
         */
        while (PL_scopestack_ix > 1 ){
                LEAVE;
        }
-       
+
        perl_destruct(perl);
        perl_free(perl);
 
@@ -291,12 +291,12 @@ static void rlm_perl_destruct(PerlInterpreter *perl)
 }
 
 static void rlm_destroy_perl(PerlInterpreter *perl)
-{      
+{
        void    **handles;
-       
+
        dTHXa(perl);
        PERL_SET_CONTEXT(perl);
-       
+
        handles = rlm_perl_get_handles(aTHX);
        rlm_perl_destruct(perl);
        rlm_perl_close_handles(handles);
@@ -309,13 +309,13 @@ static void delete_pool_handle(POOL_HANDLE *handle)
 
         prev = handle->prev;
         next = handle->next;
-       
+
         if (prev == NULL) {
                 perl_pool.head = next;
         } else {
                 prev->next = next;
         }
-  
+
         if (next == NULL) {
                 perl_pool.tail = prev;
         } else {
@@ -344,7 +344,7 @@ static void move2tail(POOL_HANDLE *handle)
 
        prev = handle->prev;
        next = handle->next;
-  
+
        if ((next != NULL) ||
                        (prev != NULL)) {
                if (next == NULL) {
@@ -354,7 +354,7 @@ static void move2tail(POOL_HANDLE *handle)
                if (prev == NULL) {
                        perl_pool.head = next;
                        next->prev = NULL;
-               
+
                } else {
 
                        prev->next = next;
@@ -378,53 +378,53 @@ static POOL_HANDLE *pool_grow () {
        if (perl_pool.max_clones == perl_pool.current_clones) {
                return NULL;
        }
-       
+
        handle = (POOL_HANDLE *)rad_malloc(sizeof(POOL_HANDLE));
-       
+
        if (!handle) {
                radlog(L_ERR,"Could not find free memory for pool. Aborting");
                return NULL;
-       }       
-       
+       }
+
        handle->prev = NULL;
        handle->next = NULL;
        handle->status = idle;
        handle->clone = rlm_perl_clone();
-       handle->request_count = 0;      
+       handle->request_count = 0;
        perl_pool.current_clones++;
        move2tail(handle);
-       
+
        now = time(NULL);
        perl_pool.time_when_last_added = now;
-       
+
        return handle;
 }
 
-static POOL_HANDLE *pool_pop() 
+static POOL_HANDLE *pool_pop()
 {
        POOL_HANDLE     *handle;
        POOL_HANDLE     *found;
        POOL_HANDLE     *tmp;
        /*
-        * Lock the pool and be fast other thread maybe 
+        * Lock the pool and be fast other thread maybe
         * waiting for us to finish
         */
        MUTEX_LOCK(&perl_pool.mutex);
-       
+
        found = NULL;
-       
+
        for (handle = perl_pool.head; handle ; handle = tmp) {
                tmp = handle->next;
-               
+
                if (handle->status == idle){
                        found = handle;
                        break;
                }
        }
-       
+
        if (found == NULL) {
                if (perl_pool.current_clones < perl_pool.max_clones ) {
-                       
+
                        found = pool_grow();
                        perl_pool.current_clones++;
 
@@ -432,7 +432,7 @@ static POOL_HANDLE *pool_pop()
                                radlog(L_ERR,"Cannot grow pool returning");
                                MUTEX_UNLOCK(&perl_pool.mutex);
                                return NULL;
-                       } 
+                       }
                } else {
                        radlog(L_ERR,"reached maximum clones %d cannot grow",
                                        perl_pool.current_clones);
@@ -442,14 +442,14 @@ static POOL_HANDLE *pool_pop()
        }
 
        move2tail(found);
-       found->status = busy;   
+       found->status = busy;
        perl_pool.active_clones++;
        found->request_count++;
        /*
         * Hurry Up
         */
        MUTEX_UNLOCK(&perl_pool.mutex);
-       radlog(L_DBG,"perl_pool: item 0x%lx asigned new request. Handled so far: %d", 
+       radlog(L_DBG,"perl_pool: item 0x%lx asigned new request. Handled so far: %d",
                        (unsigned long) found->clone, found->request_count);
        return found;
 }
@@ -464,11 +464,11 @@ static int pool_release(POOL_HANDLE *handle) {
        MUTEX_LOCK(&perl_pool.mutex);
        handle->status = idle;
        perl_pool.active_clones--;
-       
+
        spare = perl_pool.current_clones - perl_pool.active_clones;
 
        radlog(L_DBG,"perl_pool total/active/spare [%d/%d/%d]"
-                       , perl_pool.current_clones, perl_pool.active_clones, spare);    
+                       , perl_pool.current_clones, perl_pool.active_clones, spare);
 
        if (spare < perl_pool.min_spare_clones) {
                t = perl_pool.min_spare_clones - spare;
@@ -508,24 +508,24 @@ static int pool_release(POOL_HANDLE *handle) {
 }
 static int init_pool (CONF_SECTION *conf) {
        POOL_HANDLE     *handle;
-       int t;  
-       
+       int t;
+
        MUTEX_INIT(&perl_pool.mutex);
-       
+
        /*
-        * Read The Config 
+        * Read The Config
         *
         */
-       
+
        cf_section_parse(conf,NULL,pool_conf);
-       
+
        for(t = 0;t < perl_pool.start_clones ;t++){
                if ((handle = pool_grow()) == NULL) {
                        return -1;
                }
-               
+
        }
-       
+
        return 1;
 }
 #endif
@@ -545,28 +545,28 @@ static int perl_init(void)
        }
 
        perl_construct(interp);
-       PL_perl_destruct_level = 2;     
-       
+       PL_perl_destruct_level = 2;
+
        return 0;
-       
+
 }
 
 static void xs_init(pTHX)
 {
        char *file = __FILE__;
-       
+
        /* DynaLoader is a special case */
-       newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); 
-       
+       newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+
 }
 /*
  *
  * This is wrapper for radlog
- * Now users can call radiusd::radlog(level,msg) wich is the same 
+ * Now users can call radiusd::radlog(level,msg) wich is the same
  * calling radlog from C code.
  * Boyan
  */
-static XS(XS_radiusd_radlog) 
+static XS(XS_radiusd_radlog)
 {
        dXSARGS;
        if (items !=2)
@@ -574,10 +574,10 @@ static XS(XS_radiusd_radlog)
        {
               int     level;
               char    *msg;
-             
+
               level = (int) SvIV(ST(0));
               msg   = (char *) SvPV(ST(1), PL_na);
-              
+
               /*
                *       Because 'msg' is a 'char *', we don't want '%s', etc.
                *       in it to give us printf-style vulnerabilities.
@@ -593,33 +593,33 @@ static XS(XS_radiusd_radlog)
 static int perl_xlat(void *instance, REQUEST *request, char *fmt, char * out,
                     int freespace, RADIUS_ESCAPE_STRING func)
 {
-       
+
        PERL_INST       *inst= (PERL_INST *) instance;
        PerlInterpreter *perl;
        char            params[1024], *tmp_ptr, *ptr, *tmp;
        int             count, ret;
        STRLEN          n_a;
-               
+
        perl = interp;
 
 #ifdef USE_ITHREADS
        POOL_HANDLE     *handle;
-       
+
        if ((handle = pool_pop()) == NULL) {
                return 0;
        }
-       
+
        perl = handle->clone;
 
        radlog(L_DBG,"Found a interpetator 0x%lx",(unsigned long) perl);
        {
        dTHXa(perl);
        }
-#endif 
-       {       
+#endif
+       {
        dSP;
        ENTER;SAVETMPS;
-       
+
        /*
         * Do an xlat on the provided string (nice recursive operation).
        */
@@ -635,27 +635,27 @@ static int perl_xlat(void *instance, REQUEST *request, char *fmt, char * out,
 
        while ((tmp_ptr = strtok(NULL, " ")) != NULL) {
                XPUSHs(sv_2mortal(newSVpv(tmp_ptr,0)));
-       } 
+       }
 
        PUTBACK;
-       
+
        count = call_pv(inst->func_xlat, G_SCALAR | G_EVAL);
 
        SPAGAIN;
-       if (SvTRUE(ERRSV)) { 
+       if (SvTRUE(ERRSV)) {
                radlog(L_ERR, "rlm_perl: perl_xlat exit %s\n",
                       SvPV(ERRSV,n_a));
                return 0;
-       } 
+       }
 
-       if (count > 0) { 
+       if (count > 0) {
                tmp = POPp;
                ret = strlen(tmp);
                strncpy(out,tmp,ret);
 
                radlog(L_DBG,"rlm_perl: Len is %d , out is %s freespace is %d",
                       ret, out,freespace);
-       
+
                PUTBACK ;
                FREETMPS ;
                LEAVE ;
@@ -679,10 +679,10 @@ static int perl_xlat(void *instance, REQUEST *request, char *fmt, char * out,
  *     that must be referenced in later calls, store a handle to it
  *     in *instance otherwise put a null pointer there.
  *
- *     Boyan: 
+ *     Boyan:
  *     Setup a hashes wich we will use later
- *     parse a module and give him a chance to live 
- *     
+ *     parse a module and give him a chance to live
+ *
  */
 static int perl_instantiate(CONF_SECTION *conf, void **instance)
 {
@@ -690,16 +690,16 @@ static int perl_instantiate(CONF_SECTION *conf, void **instance)
        HV              *rad_reply_hv = newHV();
        HV              *rad_check_hv = newHV();
        HV              *rad_request_hv = newHV();
-       
+
        char *embed[4], *xlat_name;
        int exitstatus = 0, argc=0;
-       
+
        /*
         *      Set up a storage area for instance data
         */
        inst = rad_malloc(sizeof(PERL_INST));
        memset(inst, 0, sizeof(PERL_INST));
-               
+
        /*
         *      If the configuration parameters can't be parsed, then
         *      fail.
@@ -708,7 +708,7 @@ static int perl_instantiate(CONF_SECTION *conf, void **instance)
                free(inst);
                return -1;
        }
-       
+
 
        embed[0] = NULL;
        if (inst->perl_flags) {
@@ -721,7 +721,7 @@ static int perl_instantiate(CONF_SECTION *conf, void **instance)
                embed[2] = "0";
                argc = 3;
        }
-       
+
        exitstatus = perl_parse(interp, xs_init, argc, embed, NULL);
 
 #if PERL_REVISION >= 5 && PERL_VERSION >=8
@@ -744,26 +744,26 @@ static int perl_instantiate(CONF_SECTION *conf, void **instance)
        xlat_name = cf_section_name2(conf);
        if (xlat_name == NULL)
                xlat_name = cf_section_name1(conf);
-       if (xlat_name){ 
+       if (xlat_name){
                inst->xlat_name = strdup(xlat_name);
-               xlat_register(xlat_name, perl_xlat, inst); 
-       } 
+               xlat_register(xlat_name, perl_xlat, inst);
+       }
+
+#ifdef USE_ITHREADS
 
-#ifdef USE_ITHREADS    
-       
        if ((init_pool(conf)) == -1) {
                radlog(L_ERR,"Couldn't init a pool of perl clones. Exiting");
                return -1;
        }
-       
+
 #endif
        *instance = inst;
-       
+
        return 0;
 }
 
 /*
- *     get the vps and put them in perl hash 
+ *     get the vps and put them in perl hash
  *     If one VP have multiple values it is added as array_ref
  *     Example for this is Cisco-AVPair that holds multiple values.
  *     Which will be available as array_ref in $RAD_REQUEST{'Cisco-AVPair'}
@@ -777,7 +777,7 @@ static void perl_store_vps(VALUE_PAIR *vp, HV *rad_hv)
 
        hv_clear(rad_hv);
        nvp = paircopy(vp);
-       
+
        while (nvp != NULL) {
                attr = nvp->attribute;
                vpa = paircopy2(nvp,attr);
@@ -806,10 +806,10 @@ static void perl_store_vps(VALUE_PAIR *vp, HV *rad_hv)
                nvp = vpa;
        }
 }
-               
+
 /*
  *
- *     Verify that a Perl SV is a string and save it in FreeRadius 
+ *     Verify that a Perl SV is a string and save it in FreeRadius
  *     Value Pair Format
  *
  */
@@ -817,7 +817,7 @@ static int pairadd_sv(VALUE_PAIR **vp, char *key, SV *sv) {
        char            *val;
        int             val_len;
        VALUE_PAIR      *vpp;
+
        if ((sv != NULL) && (SvPOK(sv))) {
                val = SvPV(sv, val_len);
                vpp = pairmake(key, val, T_OP_EQ);
@@ -837,16 +837,16 @@ static int pairadd_sv(VALUE_PAIR **vp, char *key, SV *sv) {
 
 /*
   *     Boyan :
-  *     Gets the content from hashes 
+  *     Gets the content from hashes
   */
-static int get_hv_content(HV *my_hv, VALUE_PAIR **vp) 
+static int get_hv_content(HV *my_hv, VALUE_PAIR **vp)
 {
        SV              *res_sv, **av_sv;
        AV              *av;
        char            *key;
        I32             key_len, len, i, j;
        int             ret=0;
-        
+
        for (i = hv_iterinit(my_hv); i > 0; i--) {
                res_sv = hv_iternextsv(my_hv,&key,&key_len);
                if (SvROK(res_sv) && (SvTYPE(SvRV(res_sv)) == SVt_PVAV)) {
@@ -858,15 +858,15 @@ static int get_hv_content(HV *my_hv, VALUE_PAIR **vp)
                        }
                } else ret = pairadd_sv(vp, key, res_sv) + ret;
         }
+
         return ret;
 }
 
 /*
- *     Call the function_name inside the module 
+ *     Call the function_name inside the module
  *     Store all vps in hashes %RAD_CHECK %RAD_REPLY %RAD_REQUEST
- *     
- */    
+ *
+ */
 static int rlmperl_call(void *instance, REQUEST *request, char *function_name)
 {
 
@@ -874,27 +874,27 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name)
        VALUE_PAIR      *vp;
        int             exitstatus=0, count;
        STRLEN          n_a;
-       
+
        HV              *rad_reply_hv;
        HV              *rad_check_hv;
        HV              *rad_request_hv;
 
 #ifdef USE_ITHREADS
        POOL_HANDLE     *handle;
-       
+
        if ((handle = pool_pop()) == NULL) {
                return RLM_MODULE_FAIL;
        }
-       
+
        radlog(L_DBG,"found interpetator at address 0x%lx",(unsigned long) handle->clone);
-       {       
+       {
        dTHXa(handle->clone);
        PERL_SET_CONTEXT(handle->clone);
        }
 #endif
        {
        dSP;
-       
+
        ENTER;
        SAVETMPS;
 
@@ -911,38 +911,38 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name)
        rad_check_hv = get_hv("RAD_CHECK",1);
        rad_request_hv = get_hv("RAD_REQUEST",1);
 
-       
-       
+
+
        perl_store_vps(request->reply->vps, rad_reply_hv);
        perl_store_vps(request->config_items, rad_check_hv);
        perl_store_vps(request->packet->vps, rad_request_hv);
        vp = NULL;
-       
-       
-       PUSHMARK(SP);   
-       /*      
+
+
+       PUSHMARK(SP);
+       /*
        * This way %RAD_xx can be pushed onto stack as sub parameters.
        * XPUSHs( newRV_noinc((SV *)rad_request_hv) );
        * XPUSHs( newRV_noinc((SV *)rad_reply_hv) );
        * XPUSHs( newRV_noinc((SV *)rad_check_hv) );
        * PUTBACK;
        */
-       
+
        count = call_pv(function_name, G_SCALAR | G_EVAL | G_NOARGS);
 
-       SPAGAIN;        
-       
+       SPAGAIN;
+
        if (count == 1) {
                exitstatus = POPi;
                if (exitstatus >= 100 || exitstatus < 0) {
                        exitstatus = RLM_MODULE_FAIL;
                }
        }
-               
-       PUTBACK;        
+
+       PUTBACK;
        FREETMPS;
        LEAVE;
-       
+
        if (SvTRUE(ERRSV)) {
                radlog(L_ERR, "rlm_perl: perl_embed:: module = %s , func = %s exit status= %s\n",
                       inst->module,
@@ -952,12 +952,12 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name)
        if ((get_hv_content(rad_reply_hv, &vp)) > 0 ) {
                pairmove(&request->reply->vps, &vp);
                pairfree(&vp);
-       } 
+       }
 
        if ((get_hv_content(rad_check_hv, &vp)) > 0 ) {
                pairmove(&request->config_items, &vp);
                pairfree(&vp);
-       } 
+       }
 
 #if 0
        /*
@@ -1023,11 +1023,11 @@ static int perl_accounting(void *instance, REQUEST *request)
                 radlog(L_ERR, "Invalid Accounting Packet");
                 return RLM_MODULE_INVALID;
         }
-       
+
        switch (acctstatustype) {
 
                case PW_STATUS_START:
-                       
+
                        if (((PERL_INST *)instance)->func_start_accounting) {
                                return rlmperl_call(instance, request,
                                            ((PERL_INST *)instance)->func_start_accounting);
@@ -1054,7 +1054,7 @@ static int perl_accounting(void *instance, REQUEST *request)
        }
 }
 /*
- *     Check for simultaneouse-use 
+ *     Check for simultaneouse-use
  */
 
 static int perl_checksimul(void *instance, REQUEST *request)
@@ -1064,26 +1064,26 @@ static int perl_checksimul(void *instance, REQUEST *request)
 }
 
 /*
- * Detach a instance give a chance to a module to make some internal setup ... 
+ * Detach a instance give a chance to a module to make some internal setup ...
  */
 static int perl_detach(void *instance)
-{      
+{
        PERL_INST       *inst = (PERL_INST *) instance;
        int             exitstatus=0,count=0;
-       
-#ifdef USE_ITHREADS    
+
+#ifdef USE_ITHREADS
        POOL_HANDLE     *handle;
-       
+
        for (handle = perl_pool.head; handle; handle = handle->next) {
-               
+
                radlog(L_INFO,"Detach perl 0x%lx", (unsigned long) handle->clone);
                /*
-                * Wait until clone becomes idle 
+                * Wait until clone becomes idle
                 *
                 */
                while (handle->status == busy) {
                }
-               
+
                /*
                 * Give a clones chance to run detach function
                 */
@@ -1094,7 +1094,7 @@ static int perl_detach(void *instance)
                dSP; PUSHMARK(SP);
                count = call_pv(inst->func_detach, G_SCALAR | G_EVAL );
                SPAGAIN;
-               
+
                if (count == 1) {
                        exitstatus = POPi;
                        /*
@@ -1115,20 +1115,20 @@ static int perl_detach(void *instance)
        /*
         *
         * FIXME: For more efficienty we don't
-        * free entire pool. We only reread config flags thus way 
+        * free entire pool. We only reread config flags thus way
         * we can extend pool_size.
-        * 
+        *
         */
        {
        dTHXa(interp);
        PERL_SET_CONTEXT(interp);
-#endif /* USE_ITHREADS */      
+#endif /* USE_ITHREADS */
        {
        dSP;
-       PUSHMARK(SP);   
+       PUSHMARK(SP);
        count = call_pv(inst->func_detach, G_SCALAR | G_EVAL );
        SPAGAIN;
-       
+
        if (count == 1) {
                exitstatus = POPi;
                if (exitstatus >= 100 || exitstatus < 0) {
@@ -1170,14 +1170,14 @@ module_t rlm_perl = {
        RLM_TYPE_THREAD_SAFE,           /* type */
 #else
        RLM_TYPE_THREAD_UNSAFE,
-#endif 
+#endif
        perl_init,                      /* initialization */
        perl_instantiate,               /* instantiation */
        {
                perl_authenticate,
                perl_authorize,
                perl_preacct,
-               perl_accounting, 
+               perl_accounting,
                perl_checksimul,        /* check simul */
                NULL,                   /* pre-proxy */
                NULL,                   /* post-proxy */
index 191c4ca..3f17d5e 100644 (file)
@@ -147,7 +147,7 @@ static void cisco_vsa_hack(VALUE_PAIR *vp)
                        if (((dattr = dict_attrbyname(newattr)) != NULL) &&
                            (dattr->type == PW_TYPE_STRING)) {
                                VALUE_PAIR *newvp;
-                               
+
                                /*
                                 *  Make a new attribute.
                                 */
@@ -185,7 +185,7 @@ static void rad_mangle(rlm_preprocess_t *data, REQUEST *request)
         */
        request_pairs = request->packet->vps;
        namepair = pairfind(request_pairs, PW_USER_NAME);
-       if ((namepair == NULL) || 
+       if ((namepair == NULL) ||
            (namepair->length <= 0)) {
          return;
        }
@@ -323,8 +323,8 @@ static int hints_setup(PAIR_LIST *hints, REQUEST *request)
        if (hints == NULL || request_pairs == NULL)
                return RLM_MODULE_NOOP;
 
-       /* 
-        *      Check for valid input, zero length names not permitted 
+       /*
+        *      Check for valid input, zero length names not permitted
         */
        if ((tmp = pairfind(request_pairs, PW_USER_NAME)) == NULL)
                name = NULL;
@@ -440,7 +440,7 @@ static int huntgroup_access(PAIR_LIST *huntgroups, VALUE_PAIR *request_pairs)
                                        radlog(L_ERR, "No memory");
                                        exit(1);
                                }
-                               
+
                                strNcpy(vp->strvalue, i->name,
                                        sizeof(vp->strvalue));
                                vp->length = strlen(vp->strvalue);
index ed51de2..0f0aa87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_python.c        
+ * rlm_python.c
  *
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@ typedef struct rlm_python_t {
     /* Names of modules */
     char
         *mod_instantiate,
-        *mod_authorize, 
+        *mod_authorize,
        *mod_authenticate,
        *mod_preacct,
        *mod_accounting,
@@ -57,7 +57,7 @@ typedef struct rlm_python_t {
 
     /* Names of functions */
         *func_instantiate,
-        *func_authorize, 
+        *func_authorize,
        *func_authenticate,
        *func_preacct,
        *func_accounting,
@@ -190,7 +190,7 @@ static void python_error(void) {
     PyErr_Fetch(&pType, &pValue, &pTraceback);
     pStr1 = PyObject_Str(pType);
     pStr2 = PyObject_Str(pValue);
-    
+
     radlog(L_ERR, "%s: %s\n",
           PyString_AsString(pStr1), PyString_AsString(pStr2));
 }
@@ -205,23 +205,23 @@ static void add_vp_tuple(VALUE_PAIR **vpp, PyObject *pValue,
     if (pValue == Py_None) {
        return;
     }
-    
+
     if (!PyTuple_Check(pValue)) {
        radlog(L_ERR, "%s: non-tuple passed", function_name);
     }
 
     /* Get the tuple size. */
     outertuplesize = PyTuple_Size(pValue);
-    
+
     for (i = 0; i < outertuplesize; i++) {
        PyObject *pTupleElement = PyTuple_GetItem(pValue, i);
-                   
+
        if ((pTupleElement != NULL) &&
            (PyTuple_Check(pTupleElement))) {
 
            /* Check if it's a pair */
            int tuplesize;
-                       
+
            if ((tuplesize = PyTuple_Size(pTupleElement)) != 2) {
                radlog(L_ERR, "%s: tuple element %d is a tuple "
                       " of size %d. must be 2\n", function_name,
@@ -229,7 +229,7 @@ static void add_vp_tuple(VALUE_PAIR **vpp, PyObject *pValue,
            }
            else {
                PyObject *pString1, *pString2;
-                           
+
                pString1 = PyTuple_GetItem(pTupleElement, 0);
                pString2 = PyTuple_GetItem(pTupleElement, 1);
 
@@ -241,7 +241,7 @@ static void add_vp_tuple(VALUE_PAIR **vpp, PyObject *pValue,
 
 
                    const char *s1, *s2;
-                               
+
                    /* pairmake() will convert and find any
                     * errors in the pair.
                     */
@@ -301,7 +301,7 @@ static int python_function(REQUEST *request,
 
     PyObject *pValue, *pValuePairContainer, **pValueHolder, **pValueHolderPtr;
     int i, n_tuple, return_value;
-    
+
     /* Return with "OK, continue" if the function is not defined. */
     if (pFunc == NULL) {
        return RLM_MODULE_OK;
@@ -309,8 +309,8 @@ static int python_function(REQUEST *request,
 
     /* Default return value is "OK, continue" */
     return_value = RLM_MODULE_OK;
-    
-    /* We will pass a tuple containing (name, value) tuples 
+
+    /* We will pass a tuple containing (name, value) tuples
      * We can safely use the Python function to build up a tuple,
      * since the tuple is not used elsewhere.
      *
@@ -324,7 +324,7 @@ static int python_function(REQUEST *request,
            n_tuple++;
        }
     }
-       
+
     /* Create the tuple and a holder for the pointers, so that we can
      * decref more efficiently later without the overhead of reading
      * the tuple.
@@ -335,10 +335,10 @@ static int python_function(REQUEST *request,
 
     if (NULL == (pValueHolder = pValueHolderPtr =
                 malloc(sizeof(PyObject *) * n_tuple))) {
-           
+
        radlog(L_ERR, "%s: malloc of %d bytes failed\n",
               function_name, sizeof(PyObject *) * n_tuple);
-           
+
        return -1;
     }
 
@@ -347,14 +347,14 @@ static int python_function(REQUEST *request,
     }
     else {
        pValuePairContainer = PyTuple_New(n_tuple);
-    
+
        i = 0;
        for (vp = request->packet->vps; vp; vp = vp->next) {
            PyObject *pValuePair, *pString1, *pString2;
-       
+
            /* The inside tuple has two only: */
            pValuePair = PyTuple_New(2);
-       
+
            /* The name. logic from vp_prints, lib/print.c */
            if (vp->flags.has_tag) {
                snprintf(buf, BUF_SIZE, "%s:%d", vp->name, vp->flags.tag);
@@ -362,31 +362,31 @@ static int python_function(REQUEST *request,
            else {
                strcpy(buf, vp->name);
            }
-       
+
            pString1 = PyString_FromString(buf);
            PyTuple_SetItem(pValuePair, 0, pString1);
-       
-       
+
+
            /* The value. Use delimiter - don't know what that means */
            vp_prints_value(buf, sizeof(buf), vp, 1);
            pString2 = PyString_FromString(buf);
            PyTuple_SetItem(pValuePair, 1, pString2);
-       
+
            /* Put the tuple inside the container */
            PyTuple_SetItem(pValuePairContainer, i++, pValuePair);
-       
+
            /* Store the pointer in our malloc() storage */
            *pValueHolderPtr++ = pValuePair;
        }
     }
 
-    
+
     /* Call Python function.
      */
-    
+
     if (pFunc && PyCallable_Check(pFunc)) {
        PyObject *pArgs;
-       
+
        /* call the function with a singleton tuple containing the
         * container tuple.
         */
@@ -399,13 +399,13 @@ static int python_function(REQUEST *request,
            radlog(L_ERR, "%s: could not set tuple item", function_name);
            return -1;
        }
-       
+
        if ((pValue = PyObject_CallObject(pFunc, pArgs)) == NULL) {
            radlog(L_ERR, "%s: function call failed", function_name);
            python_error();
            return -1;
        }
-       
+
        /* The function returns either:
         *  1. tuple containing the integer return value,
         *  then the integer reply code (or None to not set),
@@ -438,7 +438,7 @@ static int python_function(REQUEST *request,
                else {
                    /* Now have the return value */
                    return_value = PyInt_AsLong(pTupleInt);
-                   
+
                    /* Reply item tuple */
                    add_vp_tuple(&request->reply->vps,
                                 PyTuple_GetItem(pValue, 1), function_name);
@@ -472,7 +472,7 @@ static int python_function(REQUEST *request,
     /* Decrease reference count for the tuples passed, the
      * container tuple, and the return value.
      */
-           
+
     pValueHolderPtr = pValueHolder;
     i = n_tuple;
     while (i--) {
@@ -482,17 +482,17 @@ static int python_function(REQUEST *request,
     }
     free(pValueHolder);
     Py_DECREF(pValuePairContainer);
-    
+
     /* pDict and pFunc are borrowed and must not be Py_DECREF-ed */
 
     /* Free pairs if we are rejecting.
      * xxx Shouldn't the core do that?
      */
-    
+
     if ((return_value == RLM_MODULE_REJECT) && (request != NULL)) {
        pairfree(&(request->reply->vps));
     }
-    
+
     /* Return the specified by the Python module */
     return return_value;
 }
@@ -533,7 +533,7 @@ static int load_python_function(const char* module, const char* func,
     } else {
        PyObject *pName;
 
-       pName = PyString_FromString(module);    
+       pName = PyString_FromString(module);
        Py_INCREF(pName);
        *pyModule = PyImport_Import(pName);
        Py_DECREF(pName);
@@ -591,12 +591,12 @@ static int python_instantiate(CONF_SECTION *conf, void **instance)
        free(data);
        return -1;
     }
-       
+
 
     /*
      * Setup our 'radiusd' module.
      */
-    
+
     /* Code */
     if ((module = data->pModule_builtin =
         Py_InitModule3("radiusd", radiusd_methods,
@@ -606,7 +606,7 @@ static int python_instantiate(CONF_SECTION *conf, void **instance)
        free(data);
        return -1;
     }
-    
+
     /*
      * Load constants into module
      */
@@ -672,7 +672,7 @@ static int python_instantiate(CONF_SECTION *conf, void **instance)
 /* Wrapper functions */
 static int python_authorize(void *instance, REQUEST *request)
 {
-    return python_function(request, 
+    return python_function(request,
                           ((struct rlm_python_t *)instance)->pFunc_authorize,
                           "authorize");
 }
@@ -680,7 +680,7 @@ static int python_authorize(void *instance, REQUEST *request)
 static int python_authenticate(void *instance, REQUEST *request)
 {
     return python_function(
-       request, 
+       request,
        ((struct rlm_python_t *)instance)->pFunc_authenticate,
        "authenticate");
 }
@@ -688,7 +688,7 @@ static int python_authenticate(void *instance, REQUEST *request)
 static int python_preacct(void *instance, REQUEST *request)
 {
     return python_function(
-       request, 
+       request,
        ((struct rlm_python_t *)instance)->pFunc_preacct,
        "preacct");
 }
@@ -696,7 +696,7 @@ static int python_preacct(void *instance, REQUEST *request)
 static int python_accounting(void *instance, REQUEST *request)
 {
     return python_function(
-       request, 
+       request,
        ((struct rlm_python_t *)instance)->pFunc_accounting,
        "accounting");
 }
@@ -704,7 +704,7 @@ static int python_accounting(void *instance, REQUEST *request)
 static int python_checksimul(void *instance, REQUEST *request)
 {
     return python_function(
-       request, 
+       request,
        ((struct rlm_python_t *)instance)->pFunc_checksimul,
        "checksimul");
 }
@@ -713,21 +713,21 @@ static int python_checksimul(void *instance, REQUEST *request)
 static int python_detach(void *instance)
 {
     int return_value;
-    
+
     /* Default return value is failure */
     return_value = -1;
 
     if (((rlm_python_t *)instance)->pFunc_detach &&
        PyCallable_Check(((rlm_python_t *)instance)->pFunc_detach)) {
-       
+
        PyObject *pArgs, *pValue;
-       
+
        /* call the function with an empty tuple */
 
        pArgs = PyTuple_New(0);
        pValue = PyObject_CallObject(((rlm_python_t *)instance)->pFunc_detach,
                                     pArgs);
-       
+
        if (pValue == NULL) {
            python_error();
            return -1;
@@ -756,7 +756,7 @@ static int python_detach(void *instance)
 #endif
 
     radlog(L_DBG, "python_detach done");
-    
+
     /* Return the specified by the Python module */
     return return_value;
 }
@@ -771,7 +771,7 @@ static int python_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_python = {
-       "python",       
+       "python",
        RLM_TYPE_THREAD_SAFE,           /* type */
        python_init,                    /* initialization */
        python_instantiate,             /* instantiation */
index a81ec10..fd08d64 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_radutmp.c       
+ * rlm_radutmp.c
  *
  * Version:    $Id$
  *
@@ -143,7 +143,7 @@ static int radutmp_zap(rlm_radutmp_t *inst,
         *      Lock the utmp file, prefer lockf() over flock().
         */
        rad_lockfd(fd, LOCK_LEN);
-       
+
        /*
         *      Find the entry for this NAS / portno combination.
         */
@@ -441,7 +441,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
         *      Lock the utmp file, prefer lockf() over flock().
         */
        rad_lockfd(fd, LOCK_LEN);
-       
+
        /*
         *      Find the entry for this NAS / portno combination.
         */
@@ -449,7 +449,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                                   ut.nas_port)) != NULL) {
                lseek(fd, (off_t)cache->offset, SEEK_SET);
        }
-       
+
        r = 0;
        off = 0;
        while (read(fd, &u, sizeof(u)) == sizeof(u)) {
@@ -457,7 +457,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                if (u.nas_address != ut.nas_address ||
                    u.nas_port    != ut.nas_port)
                        continue;
-               
+
                /*
                 *      Don't compare stop records to unused entries.
                 */
@@ -480,7 +480,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                        r = -1;
                        break;
                }
-               
+
                if (status == PW_STATUS_START &&
                    strncmp(ut.session_id, u.session_id,
                            sizeof(u.session_id)) == 0  &&
@@ -496,7 +496,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                        r = -1;
                        break;
                }
-               
+
                /*
                 *      FIXME: the ALIVE record could need
                 *      some more checking, but anyway I'd
@@ -513,7 +513,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                        if (u.login[0] != 0)
                                just_an_update = 1;
                }
-               
+
                if (lseek(fd, -(off_t)sizeof(u), SEEK_CUR) < 0) {
                        radlog(L_ERR, "rlm_radutmp: negative lseek!");
                        lseek(fd, (off_t)0, SEEK_SET);
@@ -542,11 +542,11 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                        cache->next = inst->nas_port_list;
                        inst->nas_port_list = cache;
                }
-               
+
                ut.type = P_LOGIN;
                write(fd, &ut, sizeof(u));
        }
-       
+
        /*
         *      The user has logged off, delete the entry by
         *      re-writing it in place.
@@ -655,7 +655,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
        if ((vp = pairfind(request->packet->vps, PW_FRAMED_IP_ADDRESS)) != NULL)
                ipno = vp->lvalue;
        if ((vp = pairfind(request->packet->vps, PW_CALLING_STATION_ID)) != NULL)
-               call_num = vp->strvalue;        
+               call_num = vp->strvalue;
 
        /*
         *      lock the file while reading/writing.
@@ -706,7 +706,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
                        rcode = rad_check_ts(u.nas_address, u.nas_port,
                                             utmp_login, session_id);
                        rad_lockfd(fd, LOCK_LEN);
-                       
+
                        /*
                         *      Failed to check the terminal server for
                         *      duplicate logins: Return an error.
index 1168026..674481c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * rlm_realm.c 
+ * rlm_realm.c
  *
  * Version:    $Id$
  *
@@ -111,19 +111,19 @@ static REALM *check_for_realm(void *instance, REQUEST *request)
        {
 
        case REALM_FORMAT_SUFFIX:
-         
+
          /* DEBUG2("  rlm_realm: Checking for suffix after \"%c\"", inst->delim[0]); */
-               realmname = strrchr(username, inst->delim[0]);          
+               realmname = strrchr(username, inst->delim[0]);
                if (realmname) {
                        *realmname = '\0';
                        realmname++;
                }
                break;
-               
+
        case REALM_FORMAT_PREFIX:
-               
+
                /* DEBUG2("  rlm_realm: Checking for prefix before \"%c\"", inst->delim[0]); */
-               
+
                ptr = strchr(username, inst->delim[0]);
                if (ptr) {
                        *ptr = '\0';
@@ -132,7 +132,7 @@ static REALM *check_for_realm(void *instance, REQUEST *request)
                     username = ptr;
                }
                break;
-              
+
        default:
                realmname = NULL;
                break;
@@ -161,7 +161,7 @@ static REALM *check_for_realm(void *instance, REQUEST *request)
                return NULL;
        }
        DEBUG2("    rlm_realm: Found realm \"%s\"", realm->realm);
-       
+
        /*
         *      If we've been told to strip the realm off, then do so.
         */
@@ -207,7 +207,7 @@ static REALM *check_for_realm(void *instance, REQUEST *request)
                DEBUG2("    rlm_realm: Unknown packet code %d\n",
                       request->packet->code);
                return NULL;            /* don't do anything */
-               
+
                /*
                 *      Perhaps accounting proxying was turned off.
                 */
@@ -278,7 +278,7 @@ static void add_proxy_to_realm(VALUE_PAIR **vps, REALM *realm)
                radlog(L_ERR|L_CONS, "no memory");
                exit(1);
        }
-       
+
        /*
         *  Add it, even if it's already present.
         */
@@ -329,7 +329,7 @@ static int realm_instantiate(CONF_SECTION *conf, void **instance)
 
 
 
+
 
 /*
  *  Examine a request for a username with an realm, and if it
@@ -373,7 +373,7 @@ static int realm_preacct(void *instance, REQUEST *request)
 
        if (!name)
          return RLM_MODULE_OK;
-       
+
 
        /*
         *      Check if we've got to proxy the request.
index a64bc38..300e607 100644 (file)
@@ -146,7 +146,7 @@ static int sim_file_authorize(void *instance, REQUEST *request)
 
        imsicount = 0;
        lineno = 0;
-       
+
        while(fgets(tripbuf, sizeof(tripbuf), triplets) == tripbuf
              && imsicount < 3)
        {
@@ -208,33 +208,33 @@ static int sim_file_authorize(void *instance, REQUEST *request)
                        /* complain about malformed line */
                        continue;
                }
-               
-                       
+
+
                r = paircreate(ATTRIBUTE_EAP_SIM_RAND1 + imsicount, PW_TYPE_OCTETS);
                r = pairparsevalue(r, chal);
                pairadd(reply_pairs, r);
-               
+
                k = paircreate(ATTRIBUTE_EAP_SIM_KC1 + imsicount, PW_TYPE_OCTETS);
                k = pairparsevalue(k, kc);
                rad_assert(k != NULL);
                pairadd(reply_pairs, k);
-               
+
                s = paircreate(ATTRIBUTE_EAP_SIM_SRES1 + imsicount, PW_TYPE_OCTETS);
                s = pairparsevalue(s, sres);
                pairadd(reply_pairs, s);
-               
+
                imsicount++;
        }
        fclose(triplets);
-       
+
        if (imsicount < 3)
        {
                DEBUG("rlm_sim_files: "
-                     "insufficient number of challenges for imsi %s: %d\n", 
+                     "insufficient number of challenges for imsi %s: %d\n",
                      name, imsicount);
                return RLM_MODULE_NOTFOUND;
        }
-       
+
        DEBUG("rlm_sim_files: "
              "authorized user/imsi %s\n", name);
 
index 899cd6c..2dae575 100644 (file)
@@ -1,32 +1,32 @@
-/* 
+/*
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB Byte handling
    Copyright (C) Andrew Tridgell 1992-1995
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
-   This file implements macros for machine independent short and 
+   This file implements macros for machine independent short and
    int manipulation
 */
 
 #undef CAREFUL_ALIGNMENT
 
-/* we know that the 386 can handle misalignment and has the "right" 
+/* we know that the 386 can handle misalignment and has the "right"
    byteorder */
 #ifdef __i386__
 #define CAREFUL_ALIGNMENT 0
@@ -57,7 +57,7 @@
    alignment errors */
 /*
    WARNING: This section is dependent on the length of int16 and int32
-   being correct 
+   being correct
 */
 #define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
 #define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
index a56d0db..0d7d5dd 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
index 1cc35e5..a942434 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
index 66d3f9f..0869b2a 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -56,7 +56,7 @@ int RFCNB_Set_Timeout(int seconds)
   int temp;
   /* If we are on a Bezerkeley system, use sigvec, else sigaction */
 #ifndef SA_RESTART
-  struct sigvec invec, outvec; 
+  struct sigvec invec, outvec;
 #else
   struct sigaction inact, outact;
 #endif
@@ -112,7 +112,7 @@ int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len)
 
     if (bytes_read <= 0) { /* Error so return */
 
-      if (bytes_read < 0) 
+      if (bytes_read < 0)
        RFCNB_errno = RFCNBE_BadRead;
       else
        RFCNB_errno = RFCNBE_ConGone;
@@ -121,7 +121,7 @@ int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len)
       return(RFCNBE_Bad);
 
     }
-    
+
     rest = rest - bytes_read;
 
   }
@@ -133,9 +133,9 @@ int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len)
 
 /* Send an RFCNB packet to the connection.
 
-   We just send each of the blocks linked together ... 
+   We just send each of the blocks linked together ...
 
-   If we can, try to send it as one iovec ... 
+   If we can, try to send it as one iovec ...
 
 */
 
@@ -160,7 +160,7 @@ int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
     this_len = pkt_ptr -> len;
     this_data = pkt_ptr -> data;
-    if ((tot_sent + this_len) > len) 
+    if ((tot_sent + this_len) > len)
       this_len = len - tot_sent;        /* Adjust so we don't send too much */
 
     /* Now plug into the iovec ... */
@@ -183,7 +183,7 @@ int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
   /* Set up an alarm if timeouts are set ... */
 
-  if (RFCNB_Timeout > 0) 
+  if (RFCNB_Timeout > 0)
     alarm(RFCNB_Timeout);
 
   if ((len_sent = writev(con -> fd, io_list, i)) < 0) { /* An error */
@@ -221,10 +221,10 @@ int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
 }
 
-/* Read an RFCNB packet off the connection. 
+/* Read an RFCNB packet off the connection.
 
    We read the first 4 bytes, that tells us the length, then read the
-   rest. We should implement a timeout, but we don't just yet 
+   rest. We should implement a timeout, but we don't just yet
 
 */
 
@@ -252,7 +252,7 @@ int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
   /* We discard keep alives here ... */
 
-  if (RFCNB_Timeout > 0) 
+  if (RFCNB_Timeout > 0)
     alarm(RFCNB_Timeout);
 
   while (seen_keep_alive) {
@@ -277,9 +277,9 @@ int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
 #ifdef RFCNB_DEBUG
       fprintf(stderr, "Connection closed reading\n");
-#endif 
+#endif
 
-      if (errno == EINTR) 
+      if (errno == EINTR)
        RFCNB_errno = RFCNBE_Timeout;
       else
        RFCNB_errno = RFCNBE_ConGone;
@@ -293,14 +293,14 @@ int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 #ifdef RFCNB_DEBUG
       fprintf(stderr, "RFCNB KEEP ALIVE received\n");
 #endif
-      
+
     }
     else {
       seen_keep_alive = FALSE;
     }
 
   }
+
   /* What if we got less than or equal to a hdr size in bytes? */
 
   if (read_len < sizeof(hdr)) { /* We got a small packet */
@@ -323,7 +323,7 @@ int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
 #ifdef RFCNB_DEBUG
   fprintf(stderr, "Reading Pkt: Length = %i\n", pkt_len);
-#endif  
+#endif
 
   /* Now copy in the hdr */
 
index 753c7ae..9af8e90 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
index d77d876..f2043d4 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -130,7 +130,7 @@ typedef struct RFCNB_Nack_Pkt {
 
   struct RFCNB_Hdr hdr;
   unsigned char error;
+
   } RFCNB_Nack_Pkt;
 
 typedef struct RFCNB_Retarget_Pkt {
index 828044c..e241864 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -48,7 +48,7 @@ void RFCNB_CvtPad_Name(char *name1, char *name2)
     if (i >= len) {
 
      c1 = 'C'; c2 = 'A'; /* CA is a space */
+
     } else {
 
       c = name1[i];
@@ -69,8 +69,8 @@ void RFCNB_CvtPad_Name(char *name1, char *name2)
    Uses the encoding in RFC1001. Each nibble of byte is added to 'A'
    to produce the next byte in the name.
 
-   This routine assumes that AName is 16 bytes long and that NBName has 
-   space for 32 chars, so be careful ... 
+   This routine assumes that AName is 16 bytes long and that NBName has
+   space for 32 chars, so be careful ...
 
 */
 
@@ -132,8 +132,8 @@ void RFCNB_Print_Hex(FILE *fd, struct RFCNB_Pkt *pkt, int Offset, int Len)
 
   while (pkt_ptr != NULL) {
 
-    for (i = 0; 
-        i < ((Len > (pkt_ptr -> len)?pkt_ptr -> len:Len) - Offset); 
+    for (i = 0;
+        i < ((Len > (pkt_ptr -> len)?pkt_ptr -> len:Len) - Offset);
         i++) {
 
       c = pkt_ptr -> data[i + Offset];
@@ -237,10 +237,10 @@ void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len)
 
   switch (RFCNB_Pkt_Type(pkt -> data)) {
 
-  case RFCNB_SESSION_MESSAGE: 
+  case RFCNB_SESSION_MESSAGE:
 
     fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt -> data));
-    RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len, 
+    RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len,
 #ifdef RFCNB_PRINT_DATA
                    RFCNB_Pkt_Len(pkt -> data) - RFCNB_Pkt_Hdr_Len);
 #else
@@ -248,7 +248,7 @@ void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len)
 #endif
 
   if (Prot_Print_Routine != 0) { /* Print the rest of the packet */
-       
+
     Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len,
                       RFCNB_Pkt_Len(pkt -> data) - RFCNB_Pkt_Hdr_Len);
 
@@ -275,7 +275,7 @@ void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len)
       break;
 
  case RFCNB_SESSION_REJ:
-      fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n", 
+      fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n",
                  RFCNB_Pkt_Len(pkt -> data));
 
       if (RFCNB_Pkt_Len(pkt -> data) < 1) {
@@ -366,7 +366,7 @@ int RFCNB_IP_Connect(struct in_addr Dest_IP, int port)
     RFCNB_errno = RFCNBE_BadSocket;
     RFCNB_saved_errno = errno;
     return(RFCNBE_Bad);
-    } 
+    }
 
   bzero((char *)&Socket, sizeof(Socket));
   memcpy((char *)&Socket.sin_addr, (char *)&Dest_IP, sizeof(Dest_IP));
@@ -388,13 +388,13 @@ int RFCNB_IP_Connect(struct in_addr Dest_IP, int port)
 
 }
 
-/* handle the details of establishing the RFCNB session with remote 
-   end 
+/* handle the details of establishing the RFCNB session with remote
+   end
 
 */
 
-int RFCNB_Session_Req(struct RFCNB_Con *con, 
-                     char *Called_Name, 
+int RFCNB_Session_Req(struct RFCNB_Con *con,
+                     char *Called_Name,
                      char *Calling_Name,
                      BOOL *redirect,
                      struct in_addr *Dest_IP,
@@ -433,7 +433,7 @@ int RFCNB_Session_Req(struct RFCNB_Con *con,
 #ifdef RFCNB_DEBUG
 
   fprintf(stderr, "Sending packet: ");
-  
+
 #endif
 
   if ((len = RFCNB_Put_Pkt(con, pkt, RFCNB_Pkt_Sess_Len)) < 0) {
@@ -465,10 +465,10 @@ int RFCNB_Session_Req(struct RFCNB_Con *con,
     case RFCNB_SESSION_REJ:         /* Didnt like us ... too bad */
 
       /* Why did we get rejected ? */
-    
+
       switch (CVAL(resp,RFCNB_Pkt_Error_Offset)) {
 
-      case 0x80: 
+      case 0x80:
        RFCNB_errno = RFCNBE_CallRejNLOCN;
        break;
       case 0x81:
index e471895..b3f2315 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -41,8 +41,8 @@ int RFCNB_Close(int socket);
 
 int RFCNB_IP_Connect(struct in_addr Dest_IP, int port);
 
-int RFCNB_Session_Req(struct RFCNB_Con *con, 
-                     char *Called_Name, 
+int RFCNB_Session_Req(struct RFCNB_Con *con,
+                     char *Called_Name,
                      char *Calling_Name,
                      BOOL *redirect,
                      struct in_addr *Dest_IP,
index 1e68485..72a8cac 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
index 9751d50..fefc87d 100644 (file)
@@ -78,7 +78,7 @@ static CONF_PARSER module_config[] = {
 static int smb_instantiate(CONF_SECTION *conf, void **instance)
 {
        rlm_smb_t *data;
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -96,9 +96,9 @@ static int smb_instantiate(CONF_SECTION *conf, void **instance)
                free(data);
                return -1;
        }
-       
+
        *instance = data;
-       
+
        return 0;
 }
 
@@ -153,7 +153,7 @@ static int smb_authenticate(void *instance, REQUEST *request)
        case 2:                 /* protocol failure */
          return RLM_MODULE_FAIL;
          break;
-         
+
        case 3:                 /* invalid user name or password */
          return RLM_MODULE_REJECT;
        }
@@ -186,7 +186,7 @@ static int smb_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_smb = {
-       "SMB",  
+       "SMB",
        RLM_TYPE_THREAD_UNSAFE,         /* type */
        NULL,                           /* initialization */
        smb_instantiate,                /* instantiation */
index c296cf8..e7c891a 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -45,7 +45,7 @@ void (*Prot_Print_Routine)() = NULL;      /* Pointer to print routine */
 /* Set up a session with a remote name. We are passed Called_Name as a
    string which we convert to a NetBIOS name, ie space terminated, up to
    16 characters only if we need to. If Called_Address is not empty, then
-   we use it to connect to the remote end, but put in Called_Name ... Called 
+   we use it to connect to the remote end, but put in Called_Name ... Called
    Address can be a DNS based name, or a TCP/IP address ...
 */
 
@@ -71,7 +71,7 @@ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
     return(NULL);
 
     }
+
   con -> fd = -0;             /* no descriptor yet */
   con -> rfc_errno = 0;           /* no error yet */
   con -> timeout = 0;         /* no timeout   */
@@ -105,7 +105,7 @@ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
     /* And tack it onto the list of addresses we called        */
 
     if ((redir_addr = (struct redirect_addr *)malloc(sizeof(struct redirect_addr))) == NULL) { /* Could not get space */
-      
+
       RFCNB_errno = RFCNBE_NoSpace;
       RFCNB_saved_errno = errno;
       return(NULL);
@@ -140,10 +140,10 @@ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
     con -> fd = Client;
 
     /* Now send and handle the RFCNB session request              */
-    /* If we get a redirect, we will comeback with redirect true 
+    /* If we get a redirect, we will comeback with redirect true
        and a new IP address in DEST_IP                            */
 
-    if ((errno = RFCNB_Session_Req(con, 
+    if ((errno = RFCNB_Session_Req(con,
                                   Called_Name,
                                   Calling_Name,
                                   &redirect, &Dest_IP, &port)) < 0) {
@@ -169,7 +169,7 @@ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
 
 }
 
-/* We send a packet to the other end ... for the moment, we treat the 
+/* We send a packet to the other end ... for the moment, we treat the
    data as a series of pointers to blocks of data ... we should check the
    length ... */
 
@@ -202,7 +202,7 @@ int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length
 #ifdef RFCNB_DEBUG
 
   fprintf(stderr, "Sending packet: ");
-  
+
 #endif
 
   if ((len = RFCNB_Put_Pkt(Con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) {
@@ -210,7 +210,7 @@ int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length
     /* No need to change RFCNB_errno as it was done by put_pkt ...     */
 
     return(RFCNBE_Bad);   /* Should be able to write that lot ... */
-    
+
   }
 
   /* Now we have sent that lot, let's get rid of the RFCNB Header and return */
@@ -223,7 +223,7 @@ int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length
 
 }
 
-/* We pick up a message from the internet ... We have to worry about 
+/* We pick up a message from the internet ... We have to worry about
    non-message packets ...                                           */
 
 int RFCNB_Recv(void *con_Handle, struct RFCNB_Pkt *Data, int Length)
@@ -298,7 +298,7 @@ int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, BOOL yn)
 
 {
 
-  return(setsockopt(con_Handle -> fd, IPPROTO_TCP, TCP_NODELAY, 
+  return(setsockopt(con_Handle -> fd, IPPROTO_TCP, TCP_NODELAY,
                    (char *)&yn, sizeof(yn)));
 
 }
index e4f8280..93fa330 100644 (file)
@@ -1,32 +1,32 @@
-/* 
+/*
    Unix SMB/Netbios implementation.
    Version 1.9.
 
-   a partial implementation of DES designed for use in the 
+   a partial implementation of DES designed for use in the
    SMB authentication protocol
 
    Copyright (C) Andrew Tridgell 1997
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 
-/* NOTES: 
+/* NOTES:
 
    This code makes no attempt to be fast! In fact, it is a very
-   slow implementation 
+   slow implementation
 
    This code is NOT a complete DES implementation. It implements only
    the minimum necessary for SMB authentication, as used by all SMB
@@ -201,8 +201,8 @@ static void dohash(char *out, char *in, char *key)
                lshift(c, sc[i], 28);
                lshift(d, sc[i], 28);
 
-               concat(cd, c, d, 28, 28); 
-               permute(ki[i], cd, perm2, 48); 
+               concat(cd, c, d, 28, 28);
+               permute(ki[i], cd, perm2, 48);
        }
 
        permute(pd1, in, perm3, 64);
@@ -232,10 +232,10 @@ static void dohash(char *out, char *in, char *key)
                        int m, n;
                        m = (b[j][0]<<1) | b[j][5];
 
-                       n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4]; 
+                       n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4];
 
-                       for (k=0;k<4;k++) 
-                               b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0; 
+                       for (k=0;k<4;k++)
+                               b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0;
                }
 
                for (j=0;j<8;j++)
index d80d827..7bb1969 100644 (file)
@@ -1,20 +1,20 @@
-/* 
+/*
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB parameters and setup
    Copyright (C) Andrew Tridgell 1992-1997
    Modified by Jeremy Allison 1995.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -38,7 +38,7 @@ void strupper(char *s);
 
 /*
    This implements the X/Open SMB password encryption
-   It takes a password, a 8 byte "crypt key" and puts 24 bytes of 
+   It takes a password, a 8 byte "crypt key" and puts 24 bytes of
    encrypted password into p24 */
 void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24)
 {
@@ -49,7 +49,7 @@ void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24)
   StrnCpy((char *)p14,(char *)passwd,14);
 
   strupper((char *)p14);
-  E_P16(p14, p21); 
+  E_P16(p14, p21);
   E_P24(p21, c8, p24);
 }
 
@@ -64,16 +64,16 @@ static int _my_wcslen(int16 *str)
 
 /*
  * Convert a string into an NT UNICODE string.
- * Note that regardless of processor type 
+ * Note that regardless of processor type
  * this must be in intel (little-endian)
  * format.
  */
+
 static int _my_mbstowcs(int16 *dst, uchar *src, int len)
 {
        int i;
        int16 val;
+
        for(i = 0; i < len; i++) {
                val = *src;
                SSVAL(dst,0,val);
@@ -85,15 +85,15 @@ static int _my_mbstowcs(int16 *dst, uchar *src, int len)
        return i;
 }
 
-/* 
+/*
  * Creates the MD4 Hash of the users password in NT UNICODE.
  */
+
 void E_md4hash(uchar *passwd, uchar *p16)
 {
        int len;
        int16 wpwd[129];
-       
+
        /* Password cannot be longer than 128 characters */
        len = strlen((char *)passwd);
        if(len > 128)
@@ -108,14 +108,14 @@ void E_md4hash(uchar *passwd, uchar *p16)
 }
 
 /* Does the NT MD4 hash then des encryption. */
+
 void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24)
 {
        uchar p21[21];
+
        memset(p21,'\0',21);
-       E_md4hash(passwd, p21);    
+
+       E_md4hash(passwd, p21);
        E_P24(p21, c8, p24);
 }
 
@@ -167,7 +167,7 @@ void strupper(char *s)
 #if !defined(KANJI_WIN95_COMPATIBILITY)
     if(lp_client_code_page() == KANJI_CODEPAGE)
     {
-      
+
       if (is_shift_jis (*s))
       {
         if (is_sj_lower (s[0], s[1]))
@@ -180,7 +180,7 @@ void strupper(char *s)
       }
       else
       {
-        if (islower(*s))                           
+        if (islower(*s))
          *s = toupper(*s);
         s++;
       }
@@ -193,4 +193,4 @@ void strupper(char *s)
       s++;
     }
   }
-}                      
+}
index 4a70af6..ff2a160 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #define SMB_P_CorePlus     1
 #define SMB_P_DOSLanMan1   2
 #define SMB_P_LanMan1      3
-#define SMB_P_DOSLanMan2   4 
+#define SMB_P_DOSLanMan2   4
 #define SMB_P_LanMan2      5
 #define SMB_P_DOSLanMan2_1 6
 #define SMB_P_LanMan2_1    7
index 611c440..2f530d8 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -34,7 +34,7 @@ typedef unsigned int   uint32;
 #define max(a,b) (a < b ? b : a)
 
 #define SMB_DEF_IDF 0x424D53FF        /* "\377SMB" */
+
 /* Core protocol commands */
 
 #define SMBmkdir      0x00   /* create directory */
@@ -244,8 +244,8 @@ typedef unsigned char UCHAR;
 
 #define SMB_tconr_mbs_offset    33        /* max buffer size         */
 #define SMB_tconr_tid_offset    35        /* returned tree id        */
-#define SMB_tconr_bcc_offset    37       
-#define SMB_tconr_len           39 
+#define SMB_tconr_bcc_offset    37
+#define SMB_tconr_len           39
 
 #define SMB_tconx_axc_offset    33        /* And X Command                */
 #define SMB_tconx_axr_offset    34        /* reserved                     */
@@ -312,7 +312,7 @@ typedef unsigned char UCHAR;
 
 #define SMB_clos_fid_offset     33        /* FID to close            */
 #define SMB_clos_tim_offset     35        /* Last mod time           */
-#define SMB_clos_bcc_offset     39        /* bcc                     */        
+#define SMB_clos_bcc_offset     39        /* bcc                     */
 #define SMB_clos_len            41
 
 /* Offsets related to Write requests                                 */
@@ -475,7 +475,7 @@ typedef unsigned char UCHAR;
 
 #define SMB_LMapi_SetUserInfo     0x0072
 #define SMB_LMapi_UserPasswordSet 0x0073
+
 /* Structures and defines we use in the client interface */
 
 /* The protocols we might support. Perhaps a bit ambitious, as only RFCNB */
@@ -491,7 +491,7 @@ typedef enum {SMB_State_NoState, SMB_State_Stopped, SMB_State_Started} SMB_State
 /* We must make it possible for callers to specify these ... */
 
 
-static const char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0", 
+static const char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
                            "MICROSOFT NETWORKS 1.03",
                            "MICROSOFT NETWORKS 3.0",
                            "DOS LANMAN1.0",
@@ -564,7 +564,7 @@ struct SMB_Connect_Def {
   int max_xmit;    /* Max xmit permitted by server                  */
   int Security;    /* 0 = share, 1 = user                           */
   int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */
-  BOOL encrypt_passwords; /* FALSE = don't                          */ 
+  BOOL encrypt_passwords; /* FALSE = don't                          */
   int MaxMPX, MaxVC, MaxRaw;
   unsigned int SessionKey, Capabilities;
   int SvrTZ;                                 /* Server Time Zone */
index 9132b9e..6f62971 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -56,7 +56,7 @@ char *SMB_DOSTimToStr(int DOS_time)
   SMB_Time_Temp[0] = 0;
 
   DOS_sec   = (DOS_time & 0x001F) * 2;
-  DOS_min   = (DOS_time & 0x07E0) >> 5;   
+  DOS_min   = (DOS_time & 0x07E0) >> 5;
   DOS_hour  = ((DOS_time & 0xF800) >> 11);
 
   DOS_day   = (DOS_time & 0x001F0000) >> 16;
@@ -71,7 +71,7 @@ char *SMB_DOSTimToStr(int DOS_time)
 }
 
 /* Convert an attribute byte/word etc to a string ... We return a pointer
-   to a static string which we guarantee is long enough. If verbose is 
+   to a static string which we guarantee is long enough. If verbose is
    true, we print out long form of strings ...                            */
 
 char *SMB_AtrToStr(int attribs, BOOL verbose)
@@ -80,22 +80,22 @@ char *SMB_AtrToStr(int attribs, BOOL verbose)
 
   SMB_Attrib_Temp[0] = 0;
 
-  if (attribs & SMB_FA_ROF) 
+  if (attribs & SMB_FA_ROF)
     strcat(SMB_Attrib_Temp, (verbose?"Read Only ":"R"));
 
-  if (attribs & SMB_FA_HID) 
+  if (attribs & SMB_FA_HID)
     strcat(SMB_Attrib_Temp, (verbose?"Hidden ":"H"));
 
-  if (attribs & SMB_FA_SYS) 
+  if (attribs & SMB_FA_SYS)
     strcat(SMB_Attrib_Temp, (verbose?"System ":"S"));
 
-  if (attribs & SMB_FA_VOL) 
+  if (attribs & SMB_FA_VOL)
     strcat(SMB_Attrib_Temp, (verbose?"Volume ":"V"));
 
-  if (attribs & SMB_FA_DIR) 
+  if (attribs & SMB_FA_DIR)
     strcat(SMB_Attrib_Temp, (verbose?"Directory ":"D"));
 
-  if (attribs & SMB_FA_ARC) 
+  if (attribs & SMB_FA_ARC)
     strcat(SMB_Attrib_Temp, (verbose?"Archive ":"A"));
 
   return(SMB_Attrib_Temp);
@@ -308,7 +308,7 @@ int SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     return(SMBlibE_BAD);
 
   }
-  
+
   if (SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset) == 0xFFFF) {
 
 #ifdef DEBUG
@@ -334,7 +334,7 @@ int SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     return(SMBlibE_BAD);
 
   }
-  
+
   switch (CVAL(SMB_Hdr(pkt), SMB_hdr_wct_offset)) {
 
   case 0x01:      /* No more info ... */
@@ -354,7 +354,7 @@ int SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     Con_Handle -> SessionKey = IVAL(SMB_Hdr(pkt), SMB_negrLM_sk_offset);
     Con_Handle -> SvrTZ = SVAL(SMB_Hdr(pkt), SMB_negrLM_stz_offset);
     Con_Handle -> Encrypt_Key_Len = SVAL(SMB_Hdr(pkt), SMB_negrLM_ekl_offset);
-    
+
     p = (SMB_Hdr(pkt) + SMB_negrLM_buf_offset);
     fprintf(stderr, "%d", (char *)(SMB_Hdr(pkt) + SMB_negrLM_buf_offset));
     memcpy(Con_Handle->Encrypt_Key, p, 8);
@@ -432,9 +432,9 @@ void SMB_Get_My_Name(char *name, int len)
 
 /* Send a TCON to the remote server ...               */
 
-SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle, 
+SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle,
                                SMB_Tree_Handle Tree_Handle,
-                               char *path, 
+                               char *path,
                                char *password,
                                char *device)
 
@@ -481,11 +481,11 @@ SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle,
     tree = (SMB_Tree_Handle)malloc(sizeof(struct SMB_Tree_Structure));
 
     if (tree == NULL) {
-    
+
       RFCNB_Free_Pkt(pkt);
       SMBlib_errno = SMBlibE_NoSpace;
       return(NULL);
-      
+
     }
   }
   else {
@@ -548,7 +548,7 @@ SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle,
     fprintf(stderr, "Error receiving response to TCon\n");
 #endif
 
-    if (Tree_Handle == NULL) 
+    if (Tree_Handle == NULL)
       free(tree);
     RFCNB_Free_Pkt(pkt);
     SMBlib_errno = -SMBlibE_RecvFailed;
@@ -600,7 +600,7 @@ SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle,
   }
 
   RFCNB_Free_Pkt(pkt);
-  return(tree); 
+  return(tree);
 
 }
 
@@ -758,7 +758,7 @@ int SMB_Get_Error_Msg(int msg, char *msgbuf, int len)
 
   if (msg >= 0) {
 
-    strncpy(msgbuf, 
+    strncpy(msgbuf,
            SMBlib_Error_Messages[msg>SMBlibE_NoSuchMsg?SMBlibE_NoSuchMsg:msg],
            len - 1);
     msgbuf[len - 1] = 0; /* Make sure it is a string */
index c3e442c..42640ce 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -134,7 +134,7 @@ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
   strcpy(con -> PDomain, NTdomain);
   strcpy(con -> OSName, SMBLIB_DEFAULT_OSNAME);
   strcpy(con -> LMType, SMBLIB_DEFAULT_LMTYPE);
-  con -> first_tree = con -> last_tree = NULL; 
+  con -> first_tree = con -> last_tree = NULL;
 
   SMB_Get_My_Name(con -> myname, sizeof(con -> myname));
 
@@ -144,7 +144,7 @@ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
 
   con -> pid = getpid();
   con -> mid = con -> pid;      /* This will do for now ... */
-  con -> uid = 0;               /* Until we have done a logon, no uid ... */ 
+  con -> uid = 0;               /* Until we have done a logon, no uid ... */
   con -> gid = getgid();
 
   /* Now connect to the remote end, but first upper case the name of the
@@ -152,12 +152,12 @@ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
 
   for (i=0; i < strlen(server); i++)
     called[i] = toupper(server[i]);
-                      
+
   called[strlen(server)] = 0;    /* Make it a string */
 
   for (i=0; i < strlen(con -> myname); i++)
     calling[i] = toupper(con -> myname[i]);
-                      
+
   calling[strlen(con -> myname)] = 0;    /* Make it a string */
 
   if (strcmp(con -> address, "") == 0)
@@ -197,8 +197,8 @@ static const char *SMB_Prots_Restrict[] = {"PC NETWORK PROGRAM 1.0",
 
 SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
                            SMB_Tree_Handle *tree,
-                           char *service, 
-                           char *username, 
+                           char *service,
+                           char *username,
                            char *password)
 
 { SMB_Handle_Type con;
@@ -254,12 +254,12 @@ SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
 
   for (i=0; i < strlen(host); i++)
     called[i] = toupper(host[i]);
-                      
+
   called[strlen(host)] = 0;    /* Make it a string */
 
   for (i=0; i < strlen(con -> myname); i++)
     calling[i] = toupper(con -> myname[i]);
-                      
+
   calling[strlen(con -> myname)] = 0;    /* Make it a string */
 
   if (strcmp(con -> address, "") == 0)
@@ -311,7 +311,7 @@ SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
 /* Logon to the server. That is, do a session setup if we can. We do not do */
 /* Unicode yet!                                                             */
 
-int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName, 
+int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
                     char *PassWord)
 
 { struct RFCNB_Pkt *pkt;
@@ -333,9 +333,9 @@ int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
   if (Con_Handle -> encrypt_passwords)
   {
     pass_len=24;
-    SMBencrypt((uchar *) PassWord, (uchar *)Con_Handle -> Encrypt_Key,(uchar *)pword); 
-  } 
-  else 
+    SMBencrypt((uchar *) PassWord, (uchar *)Con_Handle -> Encrypt_Key,(uchar *)pword);
+  }
+  else
        pass_len=strlen(pword);
 
 
@@ -343,8 +343,8 @@ int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
 
   if (Con_Handle -> protocol < SMB_P_NT1) {
 
-    param_len = strlen(UserName) + 1 + pass_len + 1 + 
-                strlen(Con_Handle -> PDomain) + 1 + 
+    param_len = strlen(UserName) + 1 + pass_len + 1 +
+                strlen(Con_Handle -> PDomain) + 1 +
                strlen(Con_Handle -> OSName) + 1;
 
     pkt_len = SMB_ssetpLM_len + param_len;
@@ -407,8 +407,8 @@ int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
 
     /* We don't admit to UNICODE support ... */
 
-    param_len = strlen(UserName) + 1 + pass_len + 
-                strlen(Con_Handle -> PDomain) + 1 + 
+    param_len = strlen(UserName) + 1 + pass_len +
+                strlen(Con_Handle -> PDomain) + 1 +
                strlen(Con_Handle -> OSName) + 1 +
                strlen(Con_Handle -> LMType) + 1;
 
@@ -525,13 +525,13 @@ int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
        {
                /* do we allow guest login? NO! */
                return(SMBlibE_BAD);
+
        }
  /** @@@ mdz: } **/
 
 
 #ifdef DEBUG
-  fprintf(stderr, "SessSetupAndX response. Action = %i\n", 
+  fprintf(stderr, "SessSetupAndX response. Action = %i\n",
           SVAL(SMB_Hdr(pkt), SMB_ssetpr_act_offset));
 #endif
 
index c6e48f1..0d6428a 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -39,7 +39,7 @@ void *SMB_Connect_Server(void *Con, char *server, char *NTdomain);
 /* Connect to a server and give us back a handle. If Con == NULL, create */
 /* The handle and populate it with defaults                              */
 
-void *SMB_Connect(void *Con, void **tree, 
+void *SMB_Connect(void *Con, void **tree,
                  char *name, char *User, char *Password);
 
 /* Negotiate a protocol                                                  */
@@ -48,7 +48,7 @@ int SMB_Negotiate(void *Con_Handle, char *Prots[]);
 
 /* Connect to a tree ...                                                 */
 
-void *SMB_TreeConnect(void *con_handle, void *tree_handle, 
+void *SMB_TreeConnect(void *con_handle, void *tree_handle,
                      char *path, char *password, char *dev);
 
 /* Disconnect a tree ...                                                 */
@@ -61,7 +61,7 @@ void *SMB_Open(void *tree_handle,
               void *file_handle,
               char *file_name,
               unsigned short mode,
-              unsigned short search); 
+              unsigned short search);
 
 /* Close a file                                                          */
 
@@ -73,8 +73,8 @@ int SMB_Close(void *file_handle);
 int SMB_Discon(void *Con, BOOL KeepHandle);
 
 void *SMB_Create(void *Tree_Handle,
-              void *File_Handle, 
-              char *file_name, 
+              void *File_Handle,
+              char *file_name,
               short search);
 
 int SMB_Delete(void *tree, char *file_name, short search);
index d15a789..c999879 100644 (file)
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
index 7670053..f3b00c0 100644 (file)
@@ -44,7 +44,7 @@ int Valid_User(char *USERNAME,char *PASSWORD,char *SERVER,char *BACKUP, char *DO
   if (con == NULL) { /* Error ... */
    con = SMB_Connect_Server(NULL, BACKUP, DOMAIN);
    if (con == NULL) {
-       return(NTV_SERVER_ERROR);   
+       return(NTV_SERVER_ERROR);
    }
   }
   if (SMB_Negotiate(con, SMB_Prots) < 0) { /* An error */
@@ -62,7 +62,7 @@ int Valid_User(char *USERNAME,char *PASSWORD,char *SERVER,char *BACKUP, char *DO
     SMB_Discon(con,0);
     return(NTV_LOGON_ERROR);
   }
-  
+
   SMB_Discon(con,0);
   return(NTV_NO_ERROR);
 }
index b23ef5e..5a58f97 100644 (file)
@@ -23,8 +23,8 @@
  * Copyright 2001  Joerg Wendland <wendland@scan-plus.de>
  */
 
-/* 
- * Modification of rlm_sql_db2 to handle IBM DB2 UDB V7 
+/*
+ * Modification of rlm_sql_db2 to handle IBM DB2 UDB V7
  * by Joerg Wendland <wendland@scan-plus.de>
  */
 
@@ -87,12 +87,12 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 }
 
 
-/************************************************************************* 
- *                                                                         
- *      Function: sql_destroy_socket                                       
- *                                                                         
- *      Purpose: Free socket and private connection data                   
- *                                                                         
+/*************************************************************************
+ *
+ *      Function: sql_destroy_socket
+ *
+ *      Purpose: Free socket and private connection data
+ *
  *************************************************************************/
 static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 {
@@ -108,7 +108,7 @@ static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
  *     Purpose: Issue a query to the database
  *
  *************************************************************************/
-static int sql_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr) 
+static int sql_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr)
 {
        SQLRETURN retval;
        rlm_sql_db2_sock *sock;
@@ -119,7 +119,7 @@ static int sql_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr)
                radlog(L_DBG,"query:\n%s", querystr);
 
        /* allocate handle for statement */
-       SQLAllocHandle(SQL_HANDLE_STMT, sock->hdbc, 
+       SQLAllocHandle(SQL_HANDLE_STMT, sock->hdbc,
                        &(sock->stmt));
 
        /* execute query */
@@ -141,7 +141,7 @@ static int sql_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr)
  *     Purpose: Issue a select query to the database
  *
  *************************************************************************/
-static int sql_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr) 
+static int sql_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr)
 {
        return sql_query(sqlsocket, config, querystr);
 }
@@ -155,7 +155,7 @@ static int sql_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *query
  *               set for the query.
  *
  *************************************************************************/
-static int sql_store_result(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_store_result(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        return 0;
 }
@@ -169,7 +169,7 @@ static int sql_store_result(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *               of columns from query
  *
  *************************************************************************/
-static int sql_num_fields(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_num_fields(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        SQLSMALLINT c;
        rlm_sql_db2_sock *sock;
@@ -189,7 +189,7 @@ static int sql_num_fields(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *              0 on success, -1 on failure, SQL_DOWN if 'database is down'
  *
  *************************************************************************/
-static int sql_fetch_row(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_fetch_row(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        int c, i;
        SQLINTEGER len, slen;
@@ -231,7 +231,7 @@ static int sql_fetch_row(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *               for a result set
  *
  *************************************************************************/
-static int sql_free_result(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_free_result(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        rlm_sql_db2_sock *sock;
        sock = sqlsocket->conn;
@@ -249,7 +249,7 @@ static int sql_free_result(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *               connection
  *
  *************************************************************************/
-static char *sql_error(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static char *sql_error(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        /* this should really be enough, if not, you still got the sqlstate */
 #define MSGLEN 512
@@ -278,7 +278,7 @@ static char *sql_error(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *               connection
  *
  *************************************************************************/
-static int sql_close(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_close(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        rlm_sql_db2_sock *sock;
 
@@ -297,7 +297,7 @@ static int sql_close(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *     Purpose: End the query, such as freeing memory
  *
  *************************************************************************/
-static int sql_finish_query(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_finish_query(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        return 0;
 }
@@ -311,7 +311,7 @@ static int sql_finish_query(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *     Purpose: End the select query, such as freeing memory or result
  *
  *************************************************************************/
-static int sql_finish_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_finish_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        return sql_finish_query(sqlsocket, config);
 }
@@ -324,7 +324,7 @@ static int sql_finish_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config)
  *     Purpose: Return the number of rows affected by the last query.
  *
  *************************************************************************/
-static int sql_affected_rows(SQLSOCK * sqlsocket, SQL_CONFIG *config) 
+static int sql_affected_rows(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
        SQLINTEGER c;
        rlm_sql_db2_sock *sock;
index a0b7ede..0784232 100644 (file)
@@ -38,7 +38,7 @@ typedef struct rlm_sql_iodbc_sock {
        HSTMT   stmt_handle;
        int             id;
        SQL_ROW row;
-       
+
        struct sql_socket *next;
 
        void    *conn;
@@ -68,21 +68,21 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        memset(iodbc_sock, 0, sizeof(*iodbc_sock));
 
        if(SQLAllocEnv(&iodbc_sock->env_handle) != SQL_SUCCESS) {
-               radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocEnv failed:  %s", 
+               radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocEnv failed:  %s",
                                sql_error(sqlsocket, config));
                return -1;
        }
 
        if(SQLAllocConnect(iodbc_sock->env_handle, &iodbc_sock->dbc_handle) != SQL_SUCCESS) {
-               radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocConnect failed:  %s", 
+               radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocConnect failed:  %s",
                                sql_error(sqlsocket, config));
                return -1;
        }
 
-       if (SQLConnect(iodbc_sock->dbc_handle, config->sql_db, SQL_NTS, 
-                               config->sql_login, SQL_NTS, config->sql_password, 
+       if (SQLConnect(iodbc_sock->dbc_handle, config->sql_db, SQL_NTS,
+                               config->sql_login, SQL_NTS, config->sql_password,
                                SQL_NTS) != SQL_SUCCESS) {
-               radlog(L_CONS|L_ERR, "sql_create_socket: SQLConnectfailed:  %s", 
+               radlog(L_CONS|L_ERR, "sql_create_socket: SQLConnectfailed:  %s",
                                sql_error(sqlsocket, config));
                return -1;
        }
@@ -117,7 +117,7 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
        rlm_sql_iodbc_sock *iodbc_sock = sqlsocket->conn;
 
        if(SQLAllocStmt(iodbc_sock->dbc_handle, &iodbc_sock->stmt_handle) != SQL_SUCCESS) {
-               radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocStmt failed:  %s", 
+               radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocStmt failed:  %s",
                                sql_error(sqlsocket, config));
                return -1;
        }
@@ -155,13 +155,13 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
        rlm_sql_iodbc_sock *iodbc_sock = sqlsocket->conn;
 
        if(sql_query(sqlsocket, config, querystr) < 0) {
-               return -1;      
+               return -1;
        }
 
        numfields = sql_num_fields(sqlsocket, config);
 
        row = (char **) rad_malloc(sizeof(char *) * (numfields+1));
-       memset(row, 0, (sizeof(char *) * (numfields))); 
+       memset(row, 0, (sizeof(char *) * (numfields)));
        row[numfields] = NULL;
 
        for(i=1; i<=numfields; i++) {
@@ -169,8 +169,8 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                                                                                NULL, 0, NULL, &len);
                len++;
 
-               /* 
-                * Allocate space for each column 
+               /*
+                * Allocate space for each column
                 */
                row[i-1] = (SQLCHAR*)rad_malloc((int)len);
 
@@ -261,7 +261,7 @@ static int sql_fetch_row(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                return 0;
        }
        /* XXX Check rc for database down, if so, return SQL_DOWN */
-       
+
        sqlsocket->row = iodbc_sock->row;
        return 0;
 }
@@ -309,7 +309,7 @@ static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        static SQLCHAR error[256] = "";
        rlm_sql_iodbc_sock *iodbc_sock = sqlsocket->conn;
 
-       SQLError(iodbc_sock->env_handle, iodbc_sock->dbc_handle, iodbc_sock->stmt_handle, 
+       SQLError(iodbc_sock->env_handle, iodbc_sock->dbc_handle, iodbc_sock->stmt_handle,
                state, &errornum, error, 256, &length);
        return error;
 }
index 534717e..51ded19 100644 (file)
@@ -58,7 +58,7 @@ static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        static char     msgbuf[512];
        sb4             errcode = 0;
        rlm_sql_oracle_sock *oracle_sock = sqlsocket->conn;
+
        memset((void *) msgbuf, (int)'\0', sizeof(msgbuf));
 
        OCIErrorGet((dvoid *) oracle_sock->errHandle, (ub4) 1, (text *) NULL,
@@ -114,7 +114,7 @@ static int sql_close(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
  *
  *************************************************************************/
 static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
-       
+
        rlm_sql_oracle_sock *oracle_sock;
 
        if (!sqlsocket->conn) {
@@ -129,7 +129,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
        if (OCIEnvCreate(&oracle_sock->env, OCI_DEFAULT|OCI_THREADED, (dvoid *)0,
                (dvoid * (*)(dvoid *, size_t)) 0,
-               (dvoid * (*)(dvoid *, dvoid *, size_t))0, 
+               (dvoid * (*)(dvoid *, dvoid *, size_t))0,
                (void (*)(dvoid *, dvoid *)) 0,
                0, (dvoid **)0 )) {
                radlog(L_ERR,"rlm_sql_oracle: Couldn't init Oracle OCI environment (OCIEnvCreate())");
@@ -194,7 +194,7 @@ static int sql_num_fields(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        ub4             count;
        rlm_sql_oracle_sock *oracle_sock = sqlsocket->conn;
 
-       /* get the number of columns in the select list */ 
+       /* get the number of columns in the select list */
        if (OCIAttrGet ((dvoid *)oracle_sock->queryHandle,
                        (ub4)OCI_HTYPE_STMT,
                        (dvoid *) &count,
@@ -345,7 +345,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                        return -1;
                }
 
-               x=OCIAttrGet((dvoid*)param, OCI_DTYPE_PARAM, 
+               x=OCIAttrGet((dvoid*)param, OCI_DTYPE_PARAM,
                           (dvoid*)&dtype, (ub4*)0, OCI_ATTR_DATA_TYPE,
                           oracle_sock->errHandle);
                if (x != OCI_SUCCESS) {
@@ -455,7 +455,7 @@ static int sql_num_rows(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
        OCIAttrGet((CONST dvoid *)oracle_sock->queryHandle,
                        OCI_HTYPE_STMT,
-                       (dvoid *)&rows, 
+                       (dvoid *)&rows,
                        (ub4 *) sizeof(ub4),
                        OCI_ATTR_ROW_COUNT,
                        oracle_sock->errHandle);
@@ -527,7 +527,7 @@ static int sql_free_result(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                        0,
                        OCI_FETCH_NEXT,
                        OCI_DEFAULT);
-       
+
        num_fields = sql_num_fields(sqlsocket, config);
        if (num_fields >= 0) {
                for(x=0; x < num_fields; x++) {
index 491af1d..3c7d815 100644 (file)
@@ -208,7 +208,7 @@ static int sql_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr) {
        }
 
        pg_sock->result = PQexec(pg_sock->conn, querystr);
-               /* Returns a result pointer or possibly a NULL pointer. 
+               /* Returns a result pointer or possibly a NULL pointer.
                 * A non-NULL pointer will generally be returned except in
                 * out-of-memory conditions or serious errors such as inability
                 * to send the command to the backend. If a NULL is returned,
@@ -217,7 +217,7 @@ static int sql_query(SQLSOCK * sqlsocket, SQL_CONFIG *config, char *querystr) {
                 */
        if (!pg_sock->result)
        {
-               radlog(L_ERR, "rlm_sql_postgresql: PostgreSQL Query failed Error: %s", 
+               radlog(L_ERR, "rlm_sql_postgresql: PostgreSQL Query failed Error: %s",
                                PQerrorMessage(pg_sock->conn));
                return  SQL_DOWN;
        } else {
index dc910d3..efdd860 100644 (file)
@@ -168,7 +168,7 @@ CS_CLIENTMSG       *emsgp;
  *
  *************************************************************************/
 static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
-       
+
        rlm_sql_sybase_sock *sybase_sock;
 
 
@@ -229,7 +229,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                 }
                return -1;
        }
-       
+
        /* Allocate a ctlib connection structure */
 
        if (ct_con_alloc(sybase_sock->context, &sybase_sock->connection) != CS_SUCCEED) {
@@ -239,10 +239,10 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                        cs_ctx_drop(sybase_sock->context);
                }
                return -1;
-       } 
+       }
 
        /* Initialize inline error handling for the connection */
-       
+
 /*     if (ct_diag(sybase_sock->connection, CS_INIT, CS_UNUSED, CS_UNUSED, NULL) != CS_SUCCEED) {
                radlog(L_ERR,"rlm_sql_sybase(sql_init_socket): Unable to initialize error handling (ct_diag())");
                 if (sybase_sock->context != (CS_CONTEXT *)NULL) {
@@ -267,7 +267,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                return -1;
        }
 
-       if (ct_con_props(sybase_sock->connection, CS_SET, CS_PASSWORD, config->sql_password, 
+       if (ct_con_props(sybase_sock->connection, CS_SET, CS_PASSWORD, config->sql_password,
                                        strlen(config->sql_password), NULL) != CS_SUCCEED) {
                radlog(L_ERR,"rlm_sql_sybase(sql_init_socket): Unable to set password for connection (ct_con_props())\n%s",
                sql_error(sqlsocket, config));
@@ -340,7 +340,7 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
                                sql_error(sqlsocket, config));
                return -1;
        }
-       
+
        if (ct_send(sybase_sock->command) != CS_SUCCEED) {
                radlog(L_ERR,"rlm_sql_sybase(sql_query): Unable to send command (ct_send())\n%s",
                                sql_error(sqlsocket, config));
@@ -357,7 +357,7 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
        ** we need returncode CS_SUCCEED
        ** and result_type CS_CMD_SUCCEED.
        */
-       
+
        if ((results_ret = ct_results(sybase_sock->command, &result_type)) == CS_SUCCEED) {
                if (result_type != CS_CMD_SUCCEED) {
                        if  (result_type == CS_ROW_RESULT) {
@@ -367,7 +367,7 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
                                         sql_error(sqlsocket, config));
                        return -1;
                }
-       } 
+       }
        else {
                switch ((int) results_ret)
                {
@@ -396,14 +396,14 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
        ** we need returncode CS_SUCCEED
        ** and result_type CS_CMD_DONE.
        */
-       
+
        if ((results_ret = ct_results(sybase_sock->command, &result_type)) == CS_SUCCEED) {
                if (result_type != CS_CMD_DONE) {
                        radlog(L_ERR,"rlm_sql_sybase(sql_query): Result failure or unexpected result type from query\n%s",
                                         sql_error(sqlsocket, config));
                        return -1;
                }
-       } 
+       }
        else {
                switch ((int) results_ret)
                {
@@ -432,7 +432,7 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
        ** we need returncode CS_END_RESULTS
        ** result_type will be ignored.
        */
-       
+
        results_ret = ct_results(sybase_sock->command, &result_type);
 
        switch ((int) results_ret)
@@ -470,13 +470,13 @@ static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
  *
  *     Purpose: Issue a select query to the database
  *
- *     Note: Only the first row from queries returning several rows 
+ *     Note: Only the first row from queries returning several rows
  *           will be returned by this function, consequitive rows will
  *           be discarded.
  *
  *************************************************************************/
 static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
-       
+
        rlm_sql_sybase_sock *sybase_sock = sqlsocket->conn;
 
        CS_RETCODE      ret, results_ret;
@@ -492,7 +492,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                radlog(L_ERR, "Socket not connected");
                return -1;
        }
-       
+
 
        if (ct_cmd_alloc(sybase_sock->connection, &sybase_sock->command) != CS_SUCCEED) {
                radlog(L_ERR,"rlm_sql_sybase(sql_select_query): Unable to allocate command structure (ct_cmd_alloc())\n%s",
@@ -505,7 +505,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                                sql_error(sqlsocket, config));
                return -1;
        }
-       
+
        if (ct_send(sybase_sock->command) != CS_SUCCEED) {
                radlog(L_ERR,"rlm_sql_sybase(sql_select_query): Unable to send command (ct_send())\n%s",
                                sql_error(sqlsocket, config));
@@ -518,7 +518,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
 
        case CS_SUCCEED:
 
-               switch (result_type) {  
+               switch (result_type) {
 
                case CS_ROW_RESULT:
 
@@ -536,9 +536,9 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                        /*
                        ** Set up the DATAFMT structure that describes our target array
                        ** and tells sybase what we want future ct_fetch calls to do.
-                       */      
+                       */
                        descriptor.datatype = CS_CHAR_TYPE;     /* The target buffer is a string */
-                       descriptor.format = CS_FMT_NULLTERM;    /* Null termination please */ 
+                       descriptor.format = CS_FMT_NULLTERM;    /* Null termination please */
                        descriptor.maxlength = MAX_DATASTR_LEN; /* The string arrays are this large */
                        descriptor.count = 1;                   /* Fetch one row of data */
                        descriptor.locale = NULL;               /* Don't do NLS stuff */
@@ -553,7 +553,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                        for (i=0; i < colcount; i++) {
 
                                rowdata[i]=rad_malloc((MAX_DATASTR_LEN * sizeof(char))+1); /* Space to hold the result data */
-       
+
                                /* Associate the target buffer with the data */
                                if (ct_bind(sybase_sock->command, i+1, &descriptor, rowdata[i], NULL, NULL) != CS_SUCCEED) {
                                        radlog(L_ERR,"rlm_sql_sybase(sql_select_query): ct_bind() failed)\n%s",
@@ -581,8 +581,8 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                        break;
                }
                break;
-       
-       case CS_FAIL:   
+
+       case CS_FAIL:
 
                /*
                ** Serious failure, sybase requires us to cancel
@@ -600,7 +600,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
                break;
 
        default:
-       
+
                radlog(L_ERR,"rlm_sql_sybase(sql_select_query): Unexpected return value from ct_results()\n%s",
                                sql_error(sqlsocket, config));
                return -1;
@@ -619,7 +619,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
  *
  *************************************************************************/
 static int sql_store_result(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
-       /* 
+       /*
        ** Not needed for Sybase, code that may have gone here is
        ** in sql_select_query and sql_fetch_row
        */
@@ -636,7 +636,7 @@ static int sql_store_result(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
  *
  *************************************************************************/
 static int sql_num_fields(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
-       
+
        rlm_sql_sybase_sock *sybase_sock = sqlsocket->conn;
        int     num;
 
@@ -720,12 +720,12 @@ int sql_fetch_row(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                break;
 
        case CS_ROW_FAIL:
-       
+
                radlog(L_ERR,"rlm_sql_sybase(sql_fetch_row): Recoverable failure fething row data, try again perhaps?");
                return -1;
 
        default:
-               
+
                radlog(L_ERR,"rlm_sql_sybase(sql_fetch_row): Unexpected returncode from ct_fetch");
                return -1;
                break;
@@ -748,7 +748,7 @@ static int sql_free_result(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        /*
        ** Not implemented, never called from rlm_sql anyway
        ** result buffer is freed in the finish_query functions.
-       */      
+       */
 
        return 0;
 
@@ -803,7 +803,7 @@ static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                                cmsg.msgstring);
        }
 
-       
+
        if (ct_diag(sybase_sock->connection, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &msgcount) != CS_SUCCEED) {
                radlog(L_ERR,"rlm_sql_sybase(sql_error): Failed to get number of pending Server messages");
                return msgbuf;
@@ -826,7 +826,7 @@ static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
 
        return msgbuf;
 */
-       return &msg; 
+       return &msg;
 }
 
 
@@ -893,7 +893,7 @@ static int sql_finish_query(SQLSOCK *sqlsocket, SQL_CONFIG *config)
  *
  *************************************************************************/
 static int sql_finish_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
-       
+
        rlm_sql_sybase_sock *sybase_sock = sqlsocket->conn;
        int     i=0;
 
@@ -909,7 +909,7 @@ static int sql_finish_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
                 free(sybase_sock->results);
                 sybase_sock->results=NULL;
         }
-       
+
        return 0;
 
 }
index dcfc9f9..d8d1daf 100644 (file)
@@ -39,10 +39,10 @@ typedef struct rlm_sql_unixodbc_sock {
 #include <sqlext.h>
 
 /* Forward declarations */
-static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config); 
-static int sql_free_result(SQLSOCK *sqlsocket, SQL_CONFIG *config); 
-static int sql_affected_rows(SQLSOCK *sqlsocket, SQL_CONFIG *config); 
-static int sql_num_fields(SQLSOCK *sqlsocket, SQL_CONFIG *config); 
+static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config);
+static int sql_free_result(SQLSOCK *sqlsocket, SQL_CONFIG *config);
+static int sql_affected_rows(SQLSOCK *sqlsocket, SQL_CONFIG *config);
+static int sql_num_fields(SQLSOCK *sqlsocket, SQL_CONFIG *config);
 
 
 /*************************************************************************
@@ -55,7 +55,7 @@ static int sql_num_fields(SQLSOCK *sqlsocket, SQL_CONFIG *config);
 static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
     rlm_sql_unixodbc_sock *unixodbc_sock;
     long err_handle;
-    
+
        if (!sqlsocket->conn) {
                sqlsocket->conn = (rlm_sql_unixodbc_sock *)rad_malloc(sizeof(rlm_sql_unixodbc_sock));
                if (!sqlsocket->conn) {
@@ -64,7 +64,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        }
        unixodbc_sock = sqlsocket->conn;
        memset(unixodbc_sock, 0, sizeof(*unixodbc_sock));
-    
+
     /* 1. Allocate environment handle and register version */
     err_handle = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&unixodbc_sock->env_handle);
     if (!SQL_SUCCEEDED(err_handle))
@@ -87,7 +87,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        SQLFreeHandle(SQL_HANDLE_ENV, unixodbc_sock->env_handle);
        return -1;
     }
-    
+
     /* 3. Connect to the datasource */
     err_handle = SQLConnect(unixodbc_sock->dbc_handle,
        (SQLCHAR*) config->sql_server, strlen(config->sql_server),
@@ -100,7 +100,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        SQLFreeHandle(SQL_HANDLE_ENV, unixodbc_sock->env_handle);
        return -1;
     }
-    
+
     /* 4. Allocate the statement */
     err_handle = SQLAllocStmt(unixodbc_sock->dbc_handle, &unixodbc_sock->stmt_handle);
     if (!SQL_SUCCEEDED(err_handle))
@@ -108,17 +108,17 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        radlog(L_ERR, "rlm_sql_unixodbc: Can't allocate the statement %s\n", sql_error(sqlsocket, config));
        return -1;
     }
-    
+
     return 0;
 }
-       
-
-/************************************************************************* 
- *                                                                         
- *      Function: sql_destroy_socket                                       
- *                                                                         
- *      Purpose: Free socket and private connection data                   
- *                                                                         
+
+
+/*************************************************************************
+ *
+ *      Function: sql_destroy_socket
+ *
+ *      Purpose: Free socket and private connection data
+ *
  *************************************************************************/
 static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 {
@@ -127,7 +127,7 @@ static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
        return 0;
 }
 
-      
+
 /*************************************************************************
  *
  *     Function: sql_query
@@ -139,10 +139,10 @@ static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 static int sql_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querystr) {
     rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
     long err_handle;
-       
+
     if (config->sqltrace)
         radlog(L_DBG, "query:  %s", querystr);
-       
+
     /* Executing query */
     err_handle = SQLExecDirect(unixodbc_sock->stmt_handle, (SQLCHAR *)querystr, strlen(querystr));
     if (!SQL_SUCCEEDED(err_handle))
@@ -167,7 +167,7 @@ static int sql_select_query(SQLSOCK *sqlsocket, SQL_CONFIG *config, char *querys
     int numfields;
 
     if(sql_query(sqlsocket, config, querystr) < 0)
-       return -1;      
+       return -1;
 
     numfields=sql_num_fields(sqlsocket, config);
     if(numfields < 0)
@@ -212,7 +212,7 @@ static int sql_num_fields(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
     rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
     long err_handle;
     int num_fields = 0;
-    
+
     err_handle = SQLNumResultCols(unixodbc_sock->stmt_handle,(SQLSMALLINT *)&num_fields);
     if (!SQL_SUCCEEDED(err_handle))
     {
@@ -323,7 +323,7 @@ static int sql_free_result(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
  *************************************************************************/
 static int sql_close(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
     rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
-       
+
     SQLFreeStmt(unixodbc_sock->stmt_handle, SQL_DROP);
     SQLDisconnect(unixodbc_sock->dbc_handle);
     SQLFreeConnect(unixodbc_sock->dbc_handle);
@@ -346,7 +346,7 @@ static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
     SQLINTEGER errornum = 0;
     SQLSMALLINT length = 255;
     char *result;
-    
+
     rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;
 
     SQLError(
@@ -358,7 +358,7 @@ static char *sql_error(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
        error,
        256,
        &length);
-       
+
     result = (char*)rad_malloc(strlen(state)+1+strlen(error));
     sprintf(result, "%s %s", state, error);
     return result;
index 71ee288..52069a8 100644 (file)
@@ -243,7 +243,7 @@ static int sql_xlat(void *instance, REQUEST *request,
 static int sql_escape_func(char *out, int outlen, const char *in)
 {
        int len = 0;
-       
+
        while (in[0]) {
                /*
                 *  Only one byte left.
@@ -251,7 +251,7 @@ static int sql_escape_func(char *out, int outlen, const char *in)
                if (outlen <= 1) {
                        break;
                }
-               
+
                /*
                 *      Non-printable characters get replaced with their
                 *      mime-encoded equivalents.
@@ -265,7 +265,7 @@ static int sql_escape_func(char *out, int outlen, const char *in)
                        len += 3;
                        continue;
                }
-               
+
                /*
                 *      Else it's a nice character.
                 */
@@ -430,7 +430,7 @@ static int rlm_sql_detach(void *instance)
                        if (module_config[i].type != PW_TYPE_STRING_PTR) {
                                continue;
                        }
-                       
+
                        /*
                         *      Treat 'config' as an opaque array of bytes,
                         *      and take the offset into it.  There's a
@@ -674,7 +674,7 @@ static int rlm_sql_authorize(void *instance, REQUEST * request)
        DEBUG2("rlm_sql:  check items");
        vp_listdebug(check_tmp);
        DEBUG2("rlm_sql:  reply items");
-       vp_listdebug(reply_tmp); 
+       vp_listdebug(reply_tmp);
        */
 
        if (paircmp(request, request->packet->vps, check_tmp, &reply_tmp) != 0) {
@@ -735,7 +735,7 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
        switch (acctstatustype) {
                        /*
                         * The Terminal server informed us that it was rebooted
-                        * STOP all records from this NAS 
+                        * STOP all records from this NAS
                         */
                case PW_STATUS_ACCOUNTING_ON:
                case PW_STATUS_ACCOUNTING_OFF:
@@ -809,7 +809,7 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
                                               (char *)(inst->module->sql_error)(sqlsocket, inst->config));
 
                                        /*
-                                        * We failed the insert above.  It's probably because 
+                                        * We failed the insert above.  It's probably because
                                         * the stop record came before the start.  We try an
                                         * our alternate query now (typically an UPDATE)
                                         */
@@ -819,7 +819,7 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
                                        if (*querystr) { /* non-empty query */
                                                if (rlm_sql_query(sqlsocket, inst, querystr)) {
                                                        radlog(L_ERR, "rlm_sql (%s): Couldn't update SQL" "accounting START record - %s",
-                                                              inst->config->xlat_name, 
+                                                              inst->config->xlat_name,
                                                               (char *)(inst->module->sql_error)(sqlsocket, inst->config));
                                                        ret = RLM_MODULE_FAIL;
                                                }
@@ -858,7 +858,7 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
                                        if (numaffected < 1) {
                                                /*
                                                 * If our update above didn't match anything
-                                                * we assume it's because we haven't seen a 
+                                                * we assume it's because we haven't seen a
                                                 * matching Start record.  So we have to
                                                 * insert this stop rather than do an update
                                                 */
@@ -871,7 +871,7 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
                                                 */
                                                if ((pair = pairfind(request->packet->vps, PW_ACCT_SESSION_TIME)) != NULL)
                                                        acctsessiontime = pair->lvalue;
-       
+
                                                if (acctsessiontime <= 0) {
                                                        radius_xlat(logstr, sizeof(logstr), "rlm_sql: Stop packet with zero session length.  (user '%{User-Name}', nas '%{NAS-IP-Address}')", request, sql_escape_func);
                                                        radlog(L_ERR, logstr);
@@ -915,7 +915,7 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
 /*
  *        See if a user is already logged in. Sets request->simul_count to the
  *        current session count for this user.
- * 
+ *
  *        Check twice. If on the first pass the user exceeds his
  *        max. number of logins, do a second pass and validate all
  *        logins by querying the terminal server (using eg. SNMP).
@@ -1008,7 +1008,7 @@ static int rlm_sql_checksimul(void *instance, REQUEST * request) {
         if ((vp = pairfind(request->packet->vps, PW_FRAMED_IP_ADDRESS)) != NULL)
                 ipno = vp->lvalue;
         if ((vp = pairfind(request->packet->vps, PW_CALLING_STATION_ID)) != NULL)
-                call_num = vp->strvalue;        
+                call_num = vp->strvalue;
 
 
        while (rlm_sql_fetch_row(sqlsocket, inst) == 0) {
index 9e66107..7685eb0 100644 (file)
@@ -196,7 +196,7 @@ int sql_close_socket(SQL_INST *inst, SQLSOCK * sqlsocket)
  *
  *     Function: sql_get_socket
  *
- *     Purpose: Return a SQL sqlsocket from the connection pool           
+ *     Purpose: Return a SQL sqlsocket from the connection pool
  *
  *************************************************************************/
 SQLSOCK * sql_get_socket(SQL_INST * inst)
@@ -254,7 +254,7 @@ SQLSOCK * sql_get_socket(SQL_INST * inst)
                if (unconnected != 0 || tried_to_connect != 0) {
                        radlog(L_INFO, "rlm_sql (%s): got socket %d after skipping %d unconnected handles, tried to reconnect %d though", inst->config->xlat_name, cur->id, unconnected, tried_to_connect);
                }
-               
+
                /*
                 *      The socket is returned in the locked
                 *      state.
@@ -285,7 +285,7 @@ SQLSOCK * sql_get_socket(SQL_INST * inst)
                }
 
                /*
-                *      If we're at the socket we started 
+                *      If we're at the socket we started
                 */
                if (cur == start) {
                        break;
@@ -301,7 +301,7 @@ SQLSOCK * sql_get_socket(SQL_INST * inst)
  *
  *     Function: sql_release_socket
  *
- *     Purpose: Frees a SQL sqlsocket back to the connection pool           
+ *     Purpose: Frees a SQL sqlsocket back to the connection pool
  *
  *************************************************************************/
 int sql_release_socket(SQL_INST * inst, SQLSOCK * sqlsocket)
@@ -352,8 +352,8 @@ int sql_userparse(VALUE_PAIR ** first_pair, SQL_ROW row, int querymode)
        if (pairmode <= T_EOL) pairmode = T_OP_CMP_EQ;
 
        /*
-        * If attribute is already there, skip it because we checked usercheck first 
-        * and we want user settings to over ride group settings 
+        * If attribute is already there, skip it because we checked usercheck first
+        * and we want user settings to over ride group settings
         */
        if (pairmode != T_OP_ADD && (check = pairfind(*first_pair, attr->attr)) != NULL &&
 #ifdef ASCEND_BINARY
@@ -557,7 +557,7 @@ void query_log(REQUEST *request, SQL_INST *inst, char *querystr)
                               buffer);
                } else {
                        int fd = fileno(sqlfile);
-                       
+
                        rad_lockfd(fd, MAX_QUERY_LEN);
                        fputs(querystr, sqlfile);
                        fputs(";\n", sqlfile);
index cf501c5..0ae17f6 100644 (file)
 
 
 /*     Note: When your counter spans more than 1 period (ie 3 months or 2 weeks), this module
- *     probably does NOT do what you want!  It calculates the range of dates to count across 
+ *     probably does NOT do what you want!  It calculates the range of dates to count across
  *     by first calculating the End of the Current period and then subtracting the number of
  *     periods you specify from that to determine the beginning of the range.
  *
- *     For example, if you specify a 3 month counter and today is June 15th, the end of the current 
- *     period is June 30. Subtracting 3 months from that gives April 1st.  So, the counter will 
+ *     For example, if you specify a 3 month counter and today is June 15th, the end of the current
+ *     period is June 30. Subtracting 3 months from that gives April 1st.  So, the counter will
  *     sum radacct entries from April 1st to June 30. Then, next month, it will sum entries
  *     from May 1st to July 31st.
  *
- *     To fix this behavior, we need to add some way of storing the Next Reset Time 
+ *     To fix this behavior, we need to add some way of storing the Next Reset Time
  */
 
 
@@ -157,7 +157,7 @@ static int find_next_reset(rlm_sqlcounter_t *data, time_t timeval)
                return -1;
        }
        strftime(sNextTime, sizeof(sNextTime),"%Y-%m-%d %H:%M:%S",tm);
-       DEBUG2("rlm_sqlcounter: Current Time: %d [%s], Next reset %d [%s]", 
+       DEBUG2("rlm_sqlcounter: Current Time: %d [%s], Next reset %d [%s]",
                (int)timeval,sCurrentTime,(int)data->reset_time, sNextTime);
 
        return ret;
@@ -227,7 +227,7 @@ static int find_prev_reset(rlm_sqlcounter_t *data, time_t timeval)
                return -1;
        }
        strftime(sPrevTime, sizeof(sPrevTime),"%Y-%m-%d %H:%M:%S",tm);
-       DEBUG2("rlm_sqlcounter: Current Time: %d [%s], Prev reset %d [%s]", 
+       DEBUG2("rlm_sqlcounter: Current Time: %d [%s], Prev reset %d [%s]",
                (int)timeval,sCurrentTime,(int)data->last_reset, sPrevTime);
 
        return ret;
@@ -264,7 +264,7 @@ static int sqlcounter_expand(char *out, int outlen, const char *fmt, void *insta
                        /*
                         * We check if we're inside an open brace.  If we are
                         * then we assume this brace is NOT literal, but is
-                        * a closing brace and apply it 
+                        * a closing brace and apply it
                         */
                        if((c == '}') && openbraces) {
                                openbraces--;
@@ -295,20 +295,20 @@ static int sqlcounter_expand(char *out, int outlen, const char *fmt, void *insta
                                *q++ = *p;
                        case 'b': /* last_reset */
                                sprintf(tmpdt, "%lu", data->last_reset);
-                               strNcpy(q, tmpdt, freespace); 
+                               strNcpy(q, tmpdt, freespace);
                                q += strlen(q);
                                break;
                        case 'e': /* reset_time */
                                sprintf(tmpdt, "%lu", data->reset_time);
-                               strNcpy(q, tmpdt, freespace); 
+                               strNcpy(q, tmpdt, freespace);
                                q += strlen(q);
                                break;
                        case 'k': /* Key Name */
-                               strNcpy(q, data->key_name, freespace); 
+                               strNcpy(q, data->key_name, freespace);
                                q += strlen(q);
                                break;
                        case 'S': /* SQL module instance */
-                               strNcpy(q, data->sqlmod_inst, freespace); 
+                               strNcpy(q, data->sqlmod_inst, freespace);
                                q += strlen(q);
                                break;
                        default:
@@ -374,7 +374,7 @@ static int sqlcounter_instantiate(CONF_SECTION *conf, void **instance)
        DICT_ATTR *dattr;
        ATTR_FLAGS flags;
        time_t now;
-       
+
        /*
         *      Set up a storage area for instance data
         */
@@ -394,7 +394,7 @@ static int sqlcounter_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        /*
-        *      Discover the attribute number of the key. 
+        *      Discover the attribute number of the key.
         */
        if (data->key_name == NULL) {
                radlog(L_ERR, "rlm_sqlcounter: 'key' must be set.");
@@ -407,7 +407,7 @@ static int sqlcounter_instantiate(CONF_SECTION *conf, void **instance)
                return -1;
        }
        data->key_attr = dattr->attr;
-       
+
 
        /*
         *  Create a new attribute for the counter.
@@ -474,7 +474,7 @@ static int sqlcounter_instantiate(CONF_SECTION *conf, void **instance)
        paircompare_register(data->dict_attr, 0, sqlcounter_cmp, data);
 
        *instance = data;
-       
+
        return 0;
 }
 
@@ -616,12 +616,12 @@ static int sqlcounter_authorize(void *instance, REQUEST *request)
 
                snprintf(module_fmsg, sizeof(module_fmsg), "rlm_sqlcounter: Maximum %s usage time reached", data->reset);
                module_fmsg_vp = pairmake("Module-Failure-Message", module_fmsg, T_OP_EQ);
-               pairadd(&request->packet->vps, module_fmsg_vp); 
+               pairadd(&request->packet->vps, module_fmsg_vp);
 
                ret=RLM_MODULE_REJECT;
 
                DEBUG2("rlm_sqlcounter: Rejected user %s, check_item=%d, counter=%d",
-                               key_vp->strvalue,check_vp->lvalue,counter); 
+                               key_vp->strvalue,check_vp->lvalue,counter);
        }
 
        return ret;
@@ -652,7 +652,7 @@ static int sqlcounter_detach(void *instance)
  *     is single-threaded.
  */
 module_t rlm_sqlcounter = {
-       "SQL Counter",  
+       "SQL Counter",
        RLM_TYPE_THREAD_SAFE,           /* type */
        NULL,                           /* initialization */
        sqlcounter_instantiate,         /* instantiation */
index 5605d95..b05bc1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * cache.c     Offers ability to cache /etc/group, /etc/passwd, 
+ * cache.c     Offers ability to cache /etc/group, /etc/passwd,
  *             /etc/shadow,
  *
  *             All users in the passwd/shadow files are stored in a hash table.
@@ -7,8 +7,8 @@
  *             lookup.  For the unitiated, that's blazing.  You can't have less
  *             than one comparison, for example.
  *
- *             The /etc/group file is stored in a singly linked list, as that 
- *             appears to be fast enough.  It's generally a small enough file 
+ *             The /etc/group file is stored in a singly linked list, as that
+ *             appears to be fast enough.  It's generally a small enough file
  *             that hashing is unnecessary.
  *
  * Version: $Id$
@@ -30,7 +30,7 @@
  * Copyright 2000  The FreeRADIUS server project.
  * Copyright 1999  Jeff Carneal <jeff@apex.com>, Apex Internet Services, Inc.
  * Copyright 2000  Alan DeKok <aland@ox.org>
- */    
+ */
 static const char rcsid[] = "$Id$";
 
 #include "autoconf.h"
@@ -122,7 +122,7 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
 
        while(fgets(buffer, BUFSIZE , passwd) != (char *)NULL) {
                numread++;
-               
+
                bufptr = buffer;
                /* Get usernames from password file */
                for(ptr = bufptr; *ptr!=':'; ptr++);
@@ -132,30 +132,30 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
                }
                strncpy(username, buffer, len);
                username[len] = '\0';
-               
+
                /* Hash the username */
-               hashindex = hashUserName(username);     
+               hashindex = hashUserName(username);
                /*printf("%s:%d\n", username, hashindex);*/
-               
+
                /* Allocate space for structure to go in hashtable */
                new = (struct mypasswd *)rad_malloc(sizeof(struct mypasswd));
                memset(new, 0, sizeof(struct mypasswd));
-               
+
                /* Put username into new structure */
                new->pw_name = (char *)rad_malloc(strlen(username)+1);
                strncpy(new->pw_name, username, strlen(username)+1);
-               
+
                /* Put passwords into array, if not shadowed */
                /* Get passwords from password file (shadow comes later) */
                ptr++;
                bufptr = ptr;
                while(*ptr!=':')
                        ptr++;
-               
+
 #if !HAVE_SHADOW_H
                /* Put passwords into new structure (*/
                len = ptr - bufptr;
-               
+
                if (len > 0) {
                        new->pw_passwd = (char *)rad_malloc(len+1);
                        strncpy(new->pw_passwd, bufptr, len);
@@ -163,11 +163,11 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
                } else {
                        new->pw_passwd = NULL;
                }
-               
-#endif /* !HAVE_SHADOW_H */  
-               
-               /* 
-                * Put uid into structure.  Not sure why, but 
+
+#endif /* !HAVE_SHADOW_H */
+
+               /*
+                * Put uid into structure.  Not sure why, but
                 * at least we'll have it later if we need it
                 */
                ptr++;
@@ -177,10 +177,10 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
                len = ptr - bufptr;
                strncpy(idtmp, bufptr, len);
                idtmp[len] = '\0';
-               new->pw_uid = (uid_t)atoi(idtmp);       
-               
-               /* 
-                * Put gid into structure.  
+               new->pw_uid = (uid_t)atoi(idtmp);
+
+               /*
+                * Put gid into structure.
                 */
                ptr++;
                bufptr = ptr;
@@ -189,26 +189,26 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
                len = ptr - bufptr;
                strncpy(idtmp, bufptr, len);
                idtmp[len] = '\0';
-               new->pw_gid = (gid_t)atoi(idtmp);       
-               
-               /* 
-                * Put name into structure.  
+               new->pw_gid = (gid_t)atoi(idtmp);
+
+               /*
+                * Put name into structure.
                 */
                ptr++;
                bufptr = ptr;
                while(*ptr!=':')
                        ptr++;
-               
+
                len = ptr - bufptr;
                new->pw_gecos = (char *)rad_malloc(len+1);
                strncpy(new->pw_gecos, bufptr, len);
                new->pw_gecos[len] = '\0';
-               
-               /* 
+
+               /*
                 * We'll skip home dir and shell
                 * as I can't think of any use for storing them
                 */
-               
+
                /*printf("User:  %s, UID:  %d, GID:  %d\n", new->pw_name, new->pw_uid, new->pw_gid);*/
                /* Store user in the hash */
                storeHashUser(cache, new, hashindex);
@@ -241,24 +241,24 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
                                continue;
                        }
 
-                       /* 
+                       /*
                         * In order to put passwd in correct structure, we have
                         * to skip any struct that has a passwd already for that
                         * user
-                        */ 
+                        */
                        cur = new;
-                       while(new && (strcmp(new->pw_name, username)<=0) 
+                       while(new && (strcmp(new->pw_name, username)<=0)
                                                && (new->pw_passwd == NULL)) {
                                cur = new;
                                new = new->next;
-                       }               
+                       }
                        /* Go back one, we passed it in the above loop */
                        new = cur;
 
                        /*
                         * When we get here, we should be at the last duplicate
                         * user structure in this hash bucket
-                        */ 
+                        */
 
                        /* Put passwords into struct from shadow file */
                        ptr++;
@@ -305,22 +305,22 @@ struct pwcache *unix_buildpwcache(const char *passwd_file,
                /* Make new mygroup structure in mem */
                g_new = (struct mygroup *)rad_malloc(sizeof(struct mygroup));
                memset(g_new, 0, sizeof(struct mygroup));
-       
+
                /* copy grp entries to my structure */
                len = strlen(grp->gr_name);
                g_new->gr_name = (char *)rad_malloc(len+1);
                strncpy(g_new->gr_name, grp->gr_name, len);
                g_new->gr_name[len] = '\0';
-               
+
                len = strlen(grp->gr_passwd);
                g_new->gr_passwd= (char *)rad_malloc(len+1);
                strncpy(g_new->gr_passwd, grp->gr_passwd, len);
                g_new->gr_passwd[len] = '\0';
 
-               g_new->gr_gid = grp->gr_gid;    
-               
+               g_new->gr_gid = grp->gr_gid;
+
                /* Allocate space for user list, as much as I hate doing groups
-                * that way.  
+                * that way.
                 */
                for(member = grp->gr_mem; *member!=NULL; member++);
                len = member - grp->gr_mem;
@@ -372,7 +372,7 @@ void unix_freepwcache(struct pwcache *cache)
                                cur = next;
                        }
                }
-       }       
+       }
 
        g_cur = cache->grphead;
 
@@ -388,13 +388,13 @@ void unix_freepwcache(struct pwcache *cache)
                free(g_cur->gr_passwd);
                free(g_cur);
                g_cur = g_next;
-       }                                  
+       }
 
        free(cache);
 }
 
 /*
- * Looks up user in hashtable.  If user can't be found, returns 0.  
+ * Looks up user in hashtable.  If user can't be found, returns 0.
  * Otherwise returns a pointer to the structure for the user
  */
 static struct mypasswd *findHashUser(struct pwcache *cache, const char *user)
@@ -441,10 +441,10 @@ static int hashUserName(const char *s) {
        }
 
        return (hash % HASHTABLESIZE);
-}              
+}
 
 /*
- *     Emulate the cistron unix_pass function, but do it using 
+ *     Emulate the cistron unix_pass function, but do it using
  *     our hashtable (iow, make it blaze).
  * return  0 on success
  * return -1 on failure
@@ -472,38 +472,38 @@ int H_unix_pass(struct pwcache *cache, char *name, char *passwd,
 
        if(mainconfig.do_usercollide) {
                while(pwd) {
-                       /* 
+                       /*
                         * Make sure same user still.  If not, return as if
-                        * wrong pass given 
+                        * wrong pass given
                         */
-                       if(strcmp(name, pwd->pw_name)) 
-                               return -1;      
-       
-                       /* 
+                       if(strcmp(name, pwd->pw_name))
+                               return -1;
+
+                       /*
                         * Could still be null passwd
                         */
                        encrypted_pass = pwd->pw_passwd;
                        if (encrypted_pass == NULL) {
                                return 0;
                        }
-       
-                       /* 
+
+                       /*
                         * Check password
                         */
                        if(lrad_crypt_check(passwd, encrypted_pass) == 0) {
-                               /* 
+                               /*
                                 * Add 'Class' pair here with value of full
                                 * name from passwd
                                 */
                                if(strlen(pwd->pw_gecos))
                                        pairadd(reply_items, pairmake("Class", pwd->pw_gecos, T_OP_EQ));
-                               
-                               return 0;       
+
+                               return 0;
                        }
                        pwd = pwd->next;
                }
-               /* 
-                * If we get here, pwd is null, and no users matched 
+               /*
+                * If we get here, pwd is null, and no users matched
                 */
                return -1;
        } else {
@@ -536,8 +536,8 @@ int H_groupcmp(struct pwcache *cache, VALUE_PAIR *check, char *username)
        if(cache->grphead) {
                cur = cache->grphead;
                while((cur) && (strcmp(cur->gr_name, (char *)check->strvalue))){
-                       cur = cur->next;        
-               }       
+                       cur = cur->next;
+               }
                /* found the group, now compare it */
                if(!cur) {
                        /* Default to old function if we can't find it */
index 0feb04d..56e0c6d 100644 (file)
@@ -2,7 +2,7 @@
  * cache.h   Definitions for structures and functions needed in cache.c
  *
  * Version: cache.c  0.99  04-13-1999  jeff@apex.net
- */    
+ */
 #ifndef _CACHE_H
 #define _CACHE_H
 
@@ -27,7 +27,7 @@ struct mygroup {
        gid_t   gr_gid;          /* group id */
        char    **gr_mem;        /* group members */
        struct mygroup *next;    /* next */
-};         
+};
 
 struct pwcache {
   struct mypasswd *hashtable[HASHTABLESIZE];
index 965d4dc..8d12bca 100644 (file)
@@ -21,7 +21,7 @@
  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  * Copyright 2001  The FreeRADIUS server project.
- */    
+ */
 static const char rcsid[] = "$Id$";
 
 #include       "autoconf.h"
@@ -92,7 +92,7 @@ struct passwd *rad_fgetpwent(FILE *pwhandle) {
        ptr = buffer;
        RAD_EXTRACT_FIELD("Username", username);
        pwbuf.pw_name = username;
-       
+
        /* Get (encrypted) password from password file (shadow comes later) */
        if (*ptr != '\0') ptr++;
        RAD_EXTRACT_FIELD("Password", userpwd);
@@ -102,12 +102,12 @@ struct passwd *rad_fgetpwent(FILE *pwhandle) {
        if (*ptr != '\0') ptr++;
        RAD_EXTRACT_FIELD("UID", uidtmp);
        pwbuf.pw_uid = atoi(uidtmp);
-       
+
        /* Get gid from the password file */
        if (*ptr != '\0') ptr++;
        RAD_EXTRACT_FIELD("GID", gidtmp);
        pwbuf.pw_gid = atoi(gidtmp);
-       
+
        /* Get the GECOS (name) field from the password file */
        if (*ptr != '\0') ptr++;
        RAD_EXTRACT_FIELD("GECOS", gecostmp);
@@ -176,7 +176,7 @@ shadow_pwd_t *rad_fgetspent(FILE *sphandle) {
        ptr = buffer;
        RAD_EXTRACT_FIELD("Username", username);
        GET_SP_NAME(&spbuf) = username;
-       
+
        /* Get (encrypted) passwords from the shadow file */
        if (*ptr != '\0') ptr++;
        RAD_EXTRACT_FIELD("Password", userpwd);
index e847aab..751149b 100644 (file)
@@ -3,7 +3,7 @@
  *              of the routines that we would like to use...
  *
  * Version: cache.c  0.99  04-13-1999  jeff@apex.net
- */    
+ */
 #ifndef _COMPAT_H
 #define _COMPAT_H
 
index 16e6729..995b3bb 100644 (file)
@@ -93,7 +93,7 @@ static CONF_PARSER module_config[] = {
          offsetof(struct unix_instance,usegroup), NULL,     "no" },
        { "cache_reload", PW_TYPE_INTEGER,
          offsetof(struct unix_instance,cache_reload), NULL, "600" },
-       
+
        { NULL, -1, 0, NULL, NULL }             /* end the list */
 };
 
@@ -815,7 +815,7 @@ static int unix_accounting(void *instance, REQUEST *request)
                        return RLM_MODULE_FAIL;
                }
                fclose(fp);
-       } else 
+       } else
                return RLM_MODULE_FAIL;
 
        return RLM_MODULE_OK;
index 6693038..e353fe3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * crcalc.c    
+ * crcalc.c
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
index 4bdfda4..43857e7 100644 (file)
@@ -27,7 +27,7 @@
  * An attacker can learn the token's secret by observing two
  * challenge/response pairs.  See ANSI document X9 TG-24-1999
  * <URL:http://www.x9.org/TG24_1999.pdf>.
- * 
+ *
  * Please read the accompanying docs.
  */
 
@@ -851,7 +851,7 @@ x99_token_destroy(void)
  *     is single-threaded.
  */
 module_t rlm_x99_token = {
-       "x99_token",    
+       "x99_token",
        RLM_TYPE_THREAD_SAFE,           /* type */
        x99_token_init,                 /* initialization */
        x99_token_instantiate,          /* instantiation */
index c192a1c..7101a08 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * x99_util.c  
+ * x99_util.c
  * $Id$
  *
  *   This program is free software; you can redistribute it and/or modify