Merge branch 'master' of ssh://git.samba.org/data/git/samba into master-devel
authorAndrew Bartlett <abartlet@samba.org>
Thu, 5 Mar 2009 00:11:19 +0000 (11:11 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 5 Mar 2009 00:11:19 +0000 (11:11 +1100)
lib/smbconf/smbconf.c
lib/socket_wrapper/socket_wrapper.c
source3/lib/dbwrap_ctdb.c
source3/lib/smbconf/smbconf_reg.c
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_acl_xattr.c
source3/utils/net_conf.c

index f25ccae0d41c9f819bb8256ec3824e904ff41dcd..80fe9aac3722c22772b3bf8e93d22430f2d8f008 100644 (file)
@@ -226,10 +226,6 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
                             const char *param,
                             const char *valstr)
 {
-       if (!smbconf_share_exists(ctx, service)) {
-               return WERR_NO_SUCH_SERVICE;
-       }
-
        return ctx->ops->set_parameter(ctx, service, param, valstr);
 }
 
@@ -265,10 +261,6 @@ WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
                return WERR_INVALID_PARAM;
        }
 
-       if (!smbconf_share_exists(ctx, service)) {
-               return WERR_NO_SUCH_SERVICE;
-       }
-
        return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr);
 }
 
@@ -299,10 +291,6 @@ WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
 WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
                                const char *service, const char *param)
 {
-       if (!smbconf_share_exists(ctx, service)) {
-               return WERR_NO_SUCH_SERVICE;
-       }
-
        return ctx->ops->delete_parameter(ctx, service, param);
 }
 
@@ -329,10 +317,6 @@ WERROR smbconf_get_includes(struct smbconf_ctx *ctx,
                            const char *service,
                            uint32_t *num_includes, char ***includes)
 {
-       if (!smbconf_share_exists(ctx, service)) {
-               return WERR_NO_SUCH_SERVICE;
-       }
-
        return ctx->ops->get_includes(ctx, mem_ctx, service, num_includes,
                                      includes);
 }
@@ -356,10 +340,6 @@ WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
                            const char *service,
                            uint32_t num_includes, const char **includes)
 {
-       if (!smbconf_share_exists(ctx, service)) {
-               return WERR_NO_SUCH_SERVICE;
-       }
-
        return ctx->ops->set_includes(ctx, service, num_includes, includes);
 }
 
@@ -381,10 +361,6 @@ WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
 
 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
 {
-       if (!smbconf_share_exists(ctx, service)) {
-               return WERR_NO_SUCH_SERVICE;
-       }
-
        return ctx->ops->delete_includes(ctx, service);
 }
 
index f9ef48e4d66f5766bf901ecadb0a734dd9d46182..8ad9e1d93eaa31df6cea9870e94cc89644c2afc9 100644 (file)
@@ -831,11 +831,11 @@ static uint8_t *swrap_packet_init(struct timeval *tval,
        size_t icmp_hdr_len = 0;
        size_t icmp_truncate_len = 0;
        uint8_t protocol = 0, icmp_protocol = 0;
-       const struct sockaddr_in *src_in;
-       const struct sockaddr_in *dest_in;
+       const struct sockaddr_in *src_in = NULL;
+       const struct sockaddr_in *dest_in = NULL;
 #ifdef HAVE_IPV6
-       const struct sockaddr_in6 *src_in6;
-       const struct sockaddr_in6 *dest_in6;
+       const struct sockaddr_in6 *src_in6 = NULL;
+       const struct sockaddr_in6 *dest_in6 = NULL;
 #endif
        uint16_t src_port;
        uint16_t dest_port;
index 03667ff3552d62a1e6b2c05f823910df13f07065..4a5bf6d81a793d8d3b46f3e31cc594b70f60553d 100644 (file)
@@ -121,9 +121,9 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
 {
        struct ctdb_rec_data *r;
        size_t m_size, r_size;
-       struct ctdb_marshall_buffer *m2;
+       struct ctdb_marshall_buffer *m2 = NULL;
 
-       r = db_ctdb_marshall_record(mem_ctx, reqid, key, header, data);
+       r = db_ctdb_marshall_record(talloc_tos(), reqid, key, header, data);
        if (r == NULL) {
                talloc_free(m);
                return NULL;
@@ -133,7 +133,7 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
                m = (struct ctdb_marshall_buffer *)talloc_zero_size(
                        mem_ctx, offsetof(struct ctdb_marshall_buffer, data));
                if (m == NULL) {
-                       return NULL;
+                       goto done;
                }
                m->db_id = db_id;
        }
@@ -145,15 +145,15 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
                mem_ctx, m,  m_size + r_size);
        if (m2 == NULL) {
                talloc_free(m);
-               return NULL;
+               goto done;
        }
 
        memcpy(m_size + (uint8_t *)m2, r, r_size);
 
-       talloc_free(r);
-
        m2->count++;
 
+done:
+       talloc_free(r);
        return m2;
 }
 
index 5a5c0ead654516414db37f6ad1bd3de31f78784a..ae6a41151d5c779adcfa9f4fac4f753bc4a87c8f 100644 (file)
@@ -80,12 +80,20 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
                                           uint32 desired_access,
                                           struct registry_key **key)
 {
+       WERROR werr;
+
        if (servicename == NULL) {
                *key = rpd(ctx)->base_key;
                return WERR_OK;
        }
-       return reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
+       werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
                           desired_access, key);
+
+       if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
+               werr = WERR_NO_SUCH_SERVICE;
+       }
+
+       return werr;
 }
 
 /**
@@ -828,9 +836,6 @@ static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
        werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
                                            REG_KEY_READ, &key);
        if (!W_ERROR_IS_OK(werr)) {
-               if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
-                       werr = WERR_NO_SUCH_SERVICE;
-               }
                goto done;
        }
 
index 73dbca4809b00f25e714f2448f5203e75b99b2a4..a77f6d60f40a0b4f5a5bad63266a5352956d32a9 100644 (file)
@@ -195,7 +195,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
        if (fsp && fsp->fh->fd != -1) {
                ret = SMB_VFS_FSTAT(fsp, &sbuf);
        } else {
-               if (fsp->posix_open) {
+               if (fsp && fsp->posix_open) {
                        ret = SMB_VFS_LSTAT(handle->conn, name, &sbuf);
                } else {
                        ret = SMB_VFS_STAT(handle->conn, name, &sbuf);
@@ -513,7 +513,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
                if (fsp && !fsp->is_directory && fsp->fh->fd != -1) {
                        ret = SMB_VFS_FSTAT(fsp, &sbuf);
                } else {
-                       if (fsp->posix_open) {
+                       if (fsp && fsp->posix_open) {
                                ret = SMB_VFS_LSTAT(handle->conn,fname, &sbuf);
                        } else {
                                ret = SMB_VFS_STAT(handle->conn,fname, &sbuf);
index 039e469426bdc5801248f1dbf66d403cfe7caabd..49e48998790872fa146188f36476c252fa3140ce 100644 (file)
@@ -381,7 +381,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
                if (fsp && !fsp->is_directory && fsp->fh->fd != -1) {
                        ret = SMB_VFS_FSTAT(fsp, &sbuf);
                } else {
-                       if (fsp->posix_open) {
+                       if (fsp && fsp->posix_open) {
                                ret = SMB_VFS_LSTAT(handle->conn,fname, &sbuf);
                        } else {
                                ret = SMB_VFS_STAT(handle->conn,fname, &sbuf);
index 05b552c00def11f67cdfb313ac7c719c2a814a43..38a2553e53a1280e51aeec563f95937e42c9886b 100644 (file)
@@ -331,12 +331,6 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
                         "would import the following configuration:\n\n");
        }
 
-       werr = smbconf_transaction_start(conf_ctx);
-       if (!W_ERROR_IS_OK(werr)) {
-               d_printf("error starting transaction: %s\n", win_errstr(werr));
-               goto done;
-       }
-
        if (servicename != NULL) {
                struct smbconf_service *service = NULL;
 
@@ -366,12 +360,45 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
                                goto cancel;
                        }
                }
+
+               /*
+                * Wrap the importing of shares into a transaction,
+                * but only 100 at a time, in order to serve memory.
+                * The allocated memory accumulates across the actions
+                * within the transaction, and for me, some 1500
+                * imported shares, the MAX_TALLOC_SIZE of 256 MB
+                * was exceeded.
+                */
+               werr = smbconf_transaction_start(conf_ctx);
+               if (!W_ERROR_IS_OK(werr)) {
+                       d_printf("error starting transaction: %s\n",
+                                win_errstr(werr));
+                       goto done;
+               }
+
                for (sidx = 0; sidx < num_shares; sidx++) {
                        werr = import_process_service(c, conf_ctx,
                                                      services[sidx]);
                        if (!W_ERROR_IS_OK(werr)) {
                                goto cancel;
                        }
+
+                       if (sidx % 100) {
+                               continue;
+                       }
+
+                       werr = smbconf_transaction_commit(conf_ctx);
+                       if (!W_ERROR_IS_OK(werr)) {
+                               d_printf("error committing transaction: %s\n",
+                                        win_errstr(werr));
+                               goto done;
+                       }
+                       werr = smbconf_transaction_start(conf_ctx);
+                       if (!W_ERROR_IS_OK(werr)) {
+                               d_printf("error starting transaction: %s\n",
+                                        win_errstr(werr));
+                               goto done;
+                       }
                }
        }