Move python modules from source4/scripting/python/ to python/.
[kai/samba-autobuild/.git] / source4 / param / share_classic.c
index ab1b4bf904a2405e44816223fde34644011750b3..50b05f322e94fa402f1dc5781e42b35cd4d8f002 100644 (file)
@@ -1,7 +1,7 @@
 /* 
    Unix SMB/CIFS implementation.
    
-   Classic file based services configuration
+   Classic file based shares configuration
    
    Copyright (C) Simo Sorce    2006
    
 #include "param/share.h"
 #include "param/param.h"
 
+NTSTATUS share_classic_init(void);
+
 static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, 
                              const struct share_ops *ops, 
+                             struct tevent_context *event_ctx,
+                             struct loadparm_context *lp_ctx,
                              struct share_context **ctx)
 {
        *ctx = talloc(mem_ctx, struct share_context);
@@ -34,7 +38,7 @@ static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx,
        }
 
        (*ctx)->ops = ops;
-       (*ctx)->priv_data = global_loadparm;
+       (*ctx)->priv_data = lp_ctx;
 
        return NT_STATUS_OK;
 }
@@ -45,6 +49,8 @@ static const char *sclassic_string_option(struct share_config *scfg,
 {
        struct loadparm_service *s = talloc_get_type(scfg->opaque, 
                                                     struct loadparm_service);
+       struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+                                                         struct loadparm_context);
        char *parm, *val;
        const char *ret;
 
@@ -57,7 +63,7 @@ static const char *sclassic_string_option(struct share_config *scfg,
                *val = '\0';
                val++;
 
-               ret = lp_parm_string(global_loadparm, s, parm, val);
+               ret = lpcfg_parm_string(lp_ctx, s, parm, val);
                if (!ret) {
                        ret = defval;
                }
@@ -70,25 +76,25 @@ static const char *sclassic_string_option(struct share_config *scfg,
        }
 
        if (strcmp(opt_name, SHARE_PATH) == 0) {
-               return lp_pathname(s);
+               return lpcfg_pathname(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_COMMENT) == 0) {
-               return lp_comment(s);
+               return lpcfg_comment(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_VOLUME) == 0) {
-               return volume_label(s);
+               return lpcfg_volume_label(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_TYPE) == 0) {
-               if (lp_print_ok(s)) {
+               if (lpcfg_print_ok(s, lpcfg_default_service(lp_ctx))) {
                        return "PRINTER";
                }
-               if (strcmp("NTFS", lp_fstype(s)) == 0) {
+               if (strcmp("NTFS", lpcfg_fstype(s, lpcfg_default_service(lp_ctx))) == 0) {
                        return "DISK";
                }
-               return lp_fstype(s);
+               return lpcfg_fstype(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_PASSWORD) == 0) {
@@ -105,6 +111,8 @@ static int sclassic_int_option(struct share_config *scfg, const char *opt_name,
 {
        struct loadparm_service *s = talloc_get_type(scfg->opaque, 
                                                     struct loadparm_service);
+       struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+                                                         struct loadparm_context);
        char *parm, *val;
        int ret;
 
@@ -117,7 +125,7 @@ static int sclassic_int_option(struct share_config *scfg, const char *opt_name,
                *val = '\0';
                val++;
 
-               ret = lp_parm_int(global_loadparm, s, parm, val, defval);
+               ret = lpcfg_parm_int(lp_ctx, s, parm, val, defval);
                if (!ret) {
                        ret = defval;
                }
@@ -126,27 +134,27 @@ static int sclassic_int_option(struct share_config *scfg, const char *opt_name,
        }
 
        if (strcmp(opt_name, SHARE_CSC_POLICY) == 0) {
-               return lp_csc_policy(s);
+               return lpcfg_csc_policy(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_MAX_CONNECTIONS) == 0) {
-               return lp_max_connections(s);
+               return lpcfg_max_connections(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_CREATE_MASK) == 0) {
-               return lp_create_mask(s);
+               return lpcfg_create_mask(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_DIR_MASK) == 0) {
-               return lp_dir_mask(s);
+               return lpcfg_dir_mask(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_FORCE_DIR_MODE) == 0) {
-               return lp_force_dir_mode(s);
+               return lpcfg_force_dir_mode(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_FORCE_CREATE_MODE) == 0) {
-               return lp_force_create_mode(s);
+               return lpcfg_force_create_mode(s, lpcfg_default_service(lp_ctx));
        }
 
 
@@ -161,6 +169,8 @@ static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name
 {
        struct loadparm_service *s = talloc_get_type(scfg->opaque, 
                                                     struct loadparm_service);
+       struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+                                                         struct loadparm_context);
        char *parm, *val;
        bool ret;
 
@@ -173,7 +183,7 @@ static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name
                *val = '\0';
                val++;
 
-               ret = lp_parm_bool(global_loadparm, s, parm, val, defval);
+               ret = lpcfg_parm_bool(lp_ctx, s, parm, val, defval);
                talloc_free(parm);
                return ret;
        }
@@ -183,39 +193,68 @@ static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name
        }
 
        if (strcmp(opt_name, SHARE_BROWSEABLE) == 0) {
-               return lp_browseable(s);
+               return lpcfg_browseable(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_READONLY) == 0) {
-               return lp_readonly(s);
+               return lpcfg_readonly(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_MAP_SYSTEM) == 0) {
-               return lp_map_system(s);
+               return lpcfg_map_system(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_MAP_HIDDEN) == 0) {
-               return lp_map_hidden(s);
+               return lpcfg_map_hidden(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_MAP_ARCHIVE) == 0) {
-               return lp_map_archive(s);
+               return lpcfg_map_archive(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_STRICT_LOCKING) == 0) {
-               return lp_strict_locking(s);
+               return lpcfg_strict_locking(s, lpcfg_default_service(lp_ctx));
+       }
+
+       if (strcmp(opt_name, SHARE_OPLOCKS) == 0) {
+               return lpcfg_oplocks(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_STRICT_SYNC) == 0) {
-               return lp_strict_sync(s);
+               return lpcfg_strict_sync(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_MSDFS_ROOT) == 0) {
-               return lp_msdfs_root(s);
+               return lpcfg_msdfs_root(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_CI_FILESYSTEM) == 0) {
-               return lp_ci_filesystem(s);
+               int case_sensitive = lpcfg_casesensitive(s, lpcfg_default_service(lp_ctx));
+               /*
+                * Yes, this confusingly named option means Samba acts
+                * case sensitive, so that the filesystem can act case
+                * insensitive.
+                *
+                */
+               if (case_sensitive == Auto) {
+                       /* Auto is for unix extensions and unix
+                        * clients, which we don't support here.
+                        * Samba needs to do the case changing,
+                        * because the filesystem is case
+                        * sensitive  */
+                       return false;
+               } else if (case_sensitive) {
+                       /* True means that Samba won't do anything to
+                        * change the case of incoming requests.
+                        * Essentially this means we trust the file
+                        * system to be case insensitive */
+                       return true;
+               } else {
+                       /* False means that Smaba needs to do the case
+                        * changing, because the filesystem is case
+                        * sensitive */
+                       return false;
+               }
        }
 
        DEBUG(0,("request for unknown share bool option '%s'\n",
@@ -228,6 +267,8 @@ static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct shar
 {
        struct loadparm_service *s = talloc_get_type(scfg->opaque, 
                                                     struct loadparm_service);
+       struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+                                                         struct loadparm_context);
        char *parm, *val;
        const char **ret;
 
@@ -240,21 +281,21 @@ static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct shar
                *val = '\0';
                val++;
 
-               ret = lp_parm_string_list(mem_ctx, global_loadparm, s, parm, val, ",;");
+               ret = lpcfg_parm_string_list(mem_ctx, lp_ctx, s, parm, val, ",;");
                talloc_free(parm);
                return ret;
        }
 
        if (strcmp(opt_name, SHARE_HOSTS_ALLOW) == 0) {
-               return lp_hostsallow(s);
+               return lpcfg_hostsallow(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_HOSTS_DENY) == 0) {
-               return lp_hostsdeny(s);
+               return lpcfg_hostsdeny(s, lpcfg_default_service(lp_ctx));
        }
 
        if (strcmp(opt_name, SHARE_NTVFS_HANDLER) == 0) {
-               return lp_ntvfs_handler(s);
+               return lpcfg_ntvfs_handler(s, lpcfg_default_service(lp_ctx));
        }
 
        DEBUG(0,("request for unknown share list option '%s'\n",
@@ -272,7 +313,7 @@ static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
        int num_services;
        const char **n;
        
-       num_services = lp_numservices((struct loadparm_context *)ctx->priv_data);
+       num_services = lpcfg_numservices((struct loadparm_context *)ctx->priv_data);
 
        n = talloc_array(mem_ctx, const char *, num_services);
        if (!n) {
@@ -281,7 +322,7 @@ static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
        }
 
        for (i = 0; i < num_services; i++) {
-               n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum((struct loadparm_context *)ctx->priv_data, i)));
+               n[i] = talloc_strdup(n, lpcfg_servicename(lpcfg_servicebynum((struct loadparm_context *)ctx->priv_data, i)));
                if (!n[i]) {
                        DEBUG(0,("ERROR: Out of memory!\n"));
                        talloc_free(n);
@@ -303,7 +344,7 @@ static NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
        struct share_config *s;
        struct loadparm_service *service;
 
-       service = lp_service((struct loadparm_context *)ctx->priv_data, name);
+       service = lpcfg_service((struct loadparm_context *)ctx->priv_data, name);
 
        if (service == NULL) {
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -315,7 +356,7 @@ static NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       s->name = talloc_strdup(s, lp_servicename(service));
+       s->name = talloc_strdup(s, lpcfg_servicename(service));
        if (!s->name) {
                DEBUG(0,("ERROR: Out of memory!\n"));
                talloc_free(s);