r18942: add a ldb_set_create_perms() function in ldb. I didn't call it
authorAndrew Tridgell <tridge@samba.org>
Wed, 27 Sep 2006 05:57:41 +0000 (05:57 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:20:22 +0000 (14:20 -0500)
ldb_set_umask() (which is what we had discussed) as it doesn't
actually set the umask (in effect it sets the inverse of the umask -
the perms to be used for the file)

source/lib/ldb/common/ldb.c
source/lib/ldb/include/ldb.h
source/lib/ldb/include/ldb_private.h
source/lib/ldb/ldb_tdb/ldb_tdb.c

index 00bf5e79babde837b6cea72e52d02e790617d167..0981d9b25b6f1c0d72bab7db645899aec00c84aa 100644 (file)
@@ -52,6 +52,7 @@ struct ldb_context *ldb_init(void *mem_ctx)
        }
 
        ldb_set_utf8_default(ldb);
+       ldb_set_create_perms(ldb, 0666);
 
        return ldb;
 }
@@ -455,6 +456,16 @@ int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *o
        return LDB_SUCCESS;
 }
 
+
+/* 
+   set the permissions for new files to be passed to open() in
+   backends that use local files
+ */
+void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms)
+{
+       ldb->create_perms = perms;
+}
+
 /*
   start an ldb request
   NOTE: the request must be a talloc context.
index cf4a1f282bbd01401de867c36866d9eaac59b2d6..82da9df0ddbd244a2e25efb2e45e8dd2ec5aa210 100644 (file)
@@ -781,6 +781,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type);
 
 int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout);
 int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq);
+void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms);
 
 /**
   Initialise ldbs' global information
index 96b71ff3b470c5ca5f9d13bd8b1a15a9bb9e2155..3cacd5e292479f663054518e6362890d1c28739f 100644 (file)
@@ -119,6 +119,8 @@ struct ldb_context {
        int default_timeout;
 
        unsigned int flags;
+
+       unsigned int create_perms;
 };
 
 #ifndef ARRAY_SIZE
index 5d4378390359077ff37a635de7a8809f7e89a431..579c48791b5387567f539a22557b2a472d4da79c 100644 (file)
@@ -1036,7 +1036,8 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
 
        /* note that we use quite a large default hash size */
        ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, 
-                                  tdb_flags, open_flags, 0644, ldb);
+                                  tdb_flags, open_flags, 
+                                  ldb->create_perms, ldb);
        if (!ltdb->tdb) {
                ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path);
                talloc_free(ltdb);