]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/sasl.c
small cleanup
[openldap] / servers / slapd / sasl.c
index 86b6a3d9da924166ebd2a716bf527f2608f7f7c9..13088088afe0de9f69dfad6fecea924867969f29 100644 (file)
 
 static sasl_security_properties_t sasl_secprops;
 
+int slap_sasl_config( int cargc, char **cargv, char *line,
+       const char *fname, int lineno )
+{
+               /* set SASL proxy authorization policy */
+               if ( strcasecmp( cargv[0], "sasl-authz-policy" ) == 0 ) {
+                       if ( cargc != 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: missing policy in \"sasl-authz-policy <policy>\" line\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+           "%s: line %d: missing policy in \"sasl-authz-policy <policy>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return( 1 );
+                       }
+                       if ( slap_sasl_setpolicy( cargv[1] ) ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: unable "
+                                          "to parse value \"%s\" "
+                                          "in \"sasl-authz-policy "
+                                          "<policy>\" line.\n",
+                                          fname, lineno, cargv[1] ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                       "%s: line %d: unable "
+                                       "to parse value \"%s\" "
+                                       "in \"sasl-authz-policy "
+                                       "<policy>\" line\n",
+                                       fname, lineno, cargv[1] );
+#endif
+                               return( 1 );
+                       }
+                       
+
+               /* set SASL host */
+               } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: missing host in \"sasl-host <host>\" line\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+           "%s: line %d: missing host in \"sasl-host <host>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return( 1 );
+                       }
+
+                       if ( global_host != NULL ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: already set sasl-host!\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                       "%s: line %d: already set sasl-host!\n",
+                                       fname, lineno, 0 );
+#endif
+
+                               return 1;
+
+                       } else {
+                               global_host = ch_strdup( cargv[1] );
+                       }
+
+               /* set SASL realm */
+               } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+           "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return( 1 );
+                       }
+
+                       if ( global_realm != NULL ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: already set sasl-realm!\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                       "%s: line %d: already set sasl-realm!\n",
+                                       fname, lineno, 0 );
+#endif
+
+                               return 1;
+
+                       } else {
+                               global_realm = ch_strdup( cargv[1] );
+                       }
+
+               } else if ( !strcasecmp( cargv[0], "sasl-regexp" ) 
+                       || !strcasecmp( cargv[0], "saslregexp" ) )
+               {
+                       int rc;
+                       if ( cargc != 3 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: need 2 args in "
+                                          "\"saslregexp <match> <replace>\"\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY, 
+                               "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return( 1 );
+                       }
+                       rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
+                       if ( rc ) {
+                               return rc;
+                       }
+
+               /* SASL security properties */
+               } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
+                       char *txt;
+
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d: missing flags in "
+                                          "\"sasl-secprops <properties>\" line\n",
+                                          fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+           "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return 1;
+                       }
+
+                       txt = slap_sasl_secprops( cargv[1] );
+                       if ( txt != NULL ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+                                          "%s: line %d sasl-secprops: %s\n",
+                                          fname, lineno, txt ));
+#else
+                               Debug( LDAP_DEBUG_ANY,
+           "%s: line %d: sasl-secprops: %s\n",
+                                   fname, lineno, txt );
+#endif
+
+                               return 1;
+                       }
+           }
+
+           return LDAP_SUCCESS;
+}
+
 static int
 slap_sasl_log(
        void *context,
@@ -638,7 +803,7 @@ slap_sasl_authorize(
                return SASL_NOAUTHZ;
        }
 
-       conn->c_sasl_sdn = authzDN;
+       conn->c_sasl_dn = authzDN;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY,