]> git.sur5r.net Git - openldap/commitdiff
Fix: obey be->be_readonly. Also add & obey global_readonly.
authorHallvard Furuseth <hallvard@openldap.org>
Thu, 2 Sep 1999 10:39:51 +0000 (10:39 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Thu, 2 Sep 1999 10:39:51 +0000 (10:39 +0000)
servers/slapd/add.c
servers/slapd/config.c
servers/slapd/delete.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/proto-slap.h

index 1d37dad4e35cc0ab3fcab2d781754ae798cd7f39..d02c9f4501d15b6dafddf1f394afba0a91b0a2a7 100644 (file)
@@ -145,6 +145,15 @@ do_add( Connection *conn, Operation *op )
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_add: database is read-only\n",
+                      0, 0, 0 );
+               entry_free( e );
+               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               return LDAP_UNWILLING_TO_PERFORM;
+       }
+
        /*
         * do the add if 1 && (2 || 3)
         * 1) there is an add function implemented in this backend;
index 91523367532cfbb40416b91dde2a22c627190091..2da09086e6e9624853e805bb2b4a0cfeaa28e052 100644 (file)
@@ -28,6 +28,7 @@ int           defsize = SLAPD_DEFAULT_SIZELIMIT;
 int            deftime = SLAPD_DEFAULT_TIMELIMIT;
 AccessControl  *global_acl = NULL;
 int            global_default_access = ACL_READ;
+int            global_readonly = 0;
 char           *replogfile;
 int            global_lastmod = ON;
 int            global_idletimeout = 0;
@@ -366,9 +367,7 @@ read_config( const char *fname )
                                return( 1 );
                        }
                        if ( be == NULL ) {
-                               Debug( LDAP_DEBUG_ANY,
-"%s: line %d: readonly line must appear inside a database definition (ignored)\n",
-                                   fname, lineno, 0 );
+                               global_readonly = (strcasecmp( cargv[1], "on" ) == 0);
                        } else {
                                if ( strcasecmp( cargv[1], "on" ) == 0 ) {
                                        be->be_readonly = 1;
index 03d9c16ab58578b981b92ab38258d2bf8be76e4d..2378475971e6874382d476cee8665f9c55d089b1 100644 (file)
@@ -85,6 +85,15 @@ do_delete(
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_delete: database is read-only\n",
+                      0, 0, 0 );
+               free( ndn );
+               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               return LDAP_UNWILLING_TO_PERFORM;
+       }
+
        /* deref suffix alias if appropriate */
        ndn = suffix_alias( be, ndn );
 
index 1316668523a109401505a491236c4e6c93e8356d..f1e1a52a435e98c93e1d1787eefbc8b046ba1637 100644 (file)
@@ -178,6 +178,14 @@ do_modify(
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_modify: database is read-only\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               goto done;
+       }
+
        /* deref suffix alias if appropriate */
        ndn = suffix_alias( be, ndn );
 
@@ -235,6 +243,7 @@ do_modify(
                    NULL, "Function not implemented", NULL, NULL );
        }
 
+done:
        free( ndn );
        modlist_free( modlist );
        return rc;
index 578751613934889b98ca41d9d95ffb1902ba5b4b..20c5249f898fe41ef15784692750a3761a1ecb2d 100644 (file)
@@ -181,6 +181,14 @@ do_modrdn(
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_modrdn: database is read-only\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               goto done;
+       }
+
        /* Make sure that the entry being changed and the newSuperior are in 
         * the same backend, otherwise we return an error.
         */
@@ -247,6 +255,7 @@ do_modrdn(
                        NULL, "Function not implemented", NULL, NULL );
        }
 
+done:
        free( ndn );
        free( newrdn ); 
        free( newSuperior );
index 154d8b3bb174d16694280fac31e46ed34e0fcc67..feeabf55560d2adbd0b1a62c0432f52f17f1a524 100644 (file)
@@ -432,6 +432,7 @@ extern int          defsize;
 extern int             deftime;
 extern int             g_argc;
 extern int             global_default_access;
+extern int             global_readonly;
 extern int             global_lastmod;
 extern int             global_idletimeout;
 extern int             global_schemacheck;