]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#6035 saslauthz cleanups (no functional change)
authorRyan Tandy <ryan@nardis.ca>
Mon, 31 Aug 2015 18:43:12 +0000 (11:43 -0700)
committerRyan Tandy <ryan@nardis.ca>
Thu, 2 Apr 2020 16:10:51 +0000 (09:10 -0700)
- give authid-rewrite's argument a name
- tidy saslauthz.c whitespace (mixed spaces/tabs)
- always declare slap_sasl_regexp_destroy: fixes an implicit declaration
  warning when configured without librewrite
- delete dead code: ENABLE_REWRITE implies SLAP_AUTH_REWRITE, so this
  code is never compiled
- make slap_sasl_regexp_rewrite_config static
- omit sasl_regexp unused fields when built with librewrite

servers/slapd/bconfig.c
servers/slapd/proto-slap.h
servers/slapd/saslauthz.c

index ceee648683916ef51e329d017828983c16d34a56..0ddc169c4e2cb10025dae993be12233ac5b21d7c 100644 (file)
@@ -333,7 +333,7 @@ static ConfigTable config_back_cf_table[] = {
                        "SUBSTR caseIgnoreSubstringsMatch "
                        "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
                                NULL, NULL },
-       { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
+       { "authid-rewrite", "rewrite", 2, 0, STRLENOF( "authid-rewrite" ),
 #ifdef SLAP_AUTH_REWRITE
                ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
 #else
index 72faf682a35fc30bab0aa143376c926117ddd7d1..79dcc8cabe7d246406c431ce428249f9f54a0882 100644 (file)
@@ -1724,8 +1724,8 @@ LDAP_SLAPD_F (int) slap_sasl_rewrite_config LDAP_P((
        int lineno,
        int argc, 
        char **argv ));
-LDAP_SLAPD_F (void) slap_sasl_regexp_destroy LDAP_P(( void ));
 #endif /* SLAP_AUTH_REWRITE */
+LDAP_SLAPD_F (void) slap_sasl_regexp_destroy LDAP_P(( void ));
 LDAP_SLAPD_F (int) authzValidate LDAP_P((
        Syntax *syn, struct berval *in ));
 #if 0
index 3b9b164b8b0468fa8caafb7bdeb4e19c02bb1c3c..7c2e501517c38169015196ac6d83b581c36aee5c 100644 (file)
 
 typedef struct sasl_regexp {
   char *sr_match;                                              /* regexp match pattern */
-  char *sr_replace;                                    /* regexp replace pattern */
+  char *sr_replace;                                    /* regexp replace pattern */
+#ifndef SLAP_AUTH_REWRITE
   regex_t sr_workspace;                                        /* workspace for regexp engine */
   int sr_offset[SASLREGEX_REPLACE+2];  /* offsets of $1,$2... in *replace */
+#endif
 } SaslRegexp_t;
 
 static int nSaslRegexp = 0;
@@ -1291,13 +1293,13 @@ int slap_sasl_rewrite_config(
 
        /* init at first call */
        if ( sasl_rwinfo == NULL ) {
-               sasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
+               sasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
        }
 
        /* strip "authid-" prefix for parsing */
        savearg0 = argv[0];
        argv[0] += STRLENOF( "authid-" );
-       rc = rewrite_parse( sasl_rwinfo, fname, lineno, argc, argv );
+       rc = rewrite_parse( sasl_rwinfo, fname, lineno, argc, argv );
        argv[0] = savearg0;
 
        return rc;
@@ -1314,7 +1316,8 @@ slap_sasl_rewrite_destroy( void )
        return 0;
 }
 
-int slap_sasl_regexp_rewrite_config(
+static int
+slap_sasl_regexp_rewrite_config(
                const char      *fname,
                int             lineno,
                const char      *match,
@@ -1330,25 +1333,25 @@ int slap_sasl_regexp_rewrite_config(
                char *argvContext[] = { "rewriteContext", NULL, NULL };
 
                /* initialize rewrite engine */
-               sasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
+               sasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
 
                /* switch on rewrite engine */
-               rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvEngine );
-               if (rc != LDAP_SUCCESS) {
+               rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvEngine );
+               if (rc != LDAP_SUCCESS) {
                        return rc;
                }
 
                /* create generic authid context */
                argvContext[1] = AUTHID_CONTEXT;
-               rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvContext );
-               if (rc != LDAP_SUCCESS) {
+               rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvContext );
+               if (rc != LDAP_SUCCESS) {
                        return rc;
                }
        }
 
        argvRule[1] = (char *)match;
        argvRule[2] = (char *)replace;
-       rc = rewrite_parse( sasl_rwinfo, fname, lineno, 4, argvRule );
+       rc = rewrite_parse( sasl_rwinfo, fname, lineno, 4, argvRule );
 
        return rc;
 }
@@ -1375,13 +1378,6 @@ int slap_sasl_regexp_config( const char *match, const char *replace )
                Debug( LDAP_DEBUG_ANY,
                        "SASL match pattern %s could not be compiled by regexp engine\n",
                        match );
-
-#ifdef ENABLE_REWRITE
-               /* Dummy block to force symbol references in librewrite */
-               if ( slapMode == ( SLAP_SERVER_MODE|SLAP_TOOL_MODE )) {
-                       rewrite_info_init( 0 );
-               }
-#endif
                return( LDAP_OTHER );
        }
 
@@ -1534,8 +1530,8 @@ static int slap_authz_regexp( struct berval *in, struct berval *out,
                        "[rw] %s: \"%s\" -> \"%s\"\n",
                        context, in->bv_val, out->bv_val );             
                return 1;
-               
-       case REWRITE_REGEXEC_UNWILLING:
+
+       case REWRITE_REGEXEC_UNWILLING:
        case REWRITE_REGEXEC_ERR:
        default:
                return 0;
@@ -1544,7 +1540,7 @@ static int slap_authz_regexp( struct berval *in, struct berval *out,
 #else /* ! SLAP_AUTH_REWRITE */
        char *saslname = in->bv_val;
        SaslRegexp_t *reg;
-       regmatch_t sr_strings[SASLREGEX_REPLACE];       /* strings matching $1,$2 ... */
+       regmatch_t sr_strings[SASLREGEX_REPLACE];       /* strings matching $1,$2 ... */
        int i;
 
        memset( out, 0, sizeof( *out ) );