summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-07-04 04:15:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:59:03 -0500
commitb540bc85ff8140424e9e925aa73f1f1cacfbd64a (patch)
treee3dddae8f6f3324ba7de903eb32d6e70f43c5501
parent80ae1c2a2aeace891d24390f2f639a3c3d18739a (diff)
downloadsamba-b540bc85ff8140424e9e925aa73f1f1cacfbd64a.tar.gz
samba-b540bc85ff8140424e9e925aa73f1f1cacfbd64a.tar.bz2
samba-b540bc85ff8140424e9e925aa73f1f1cacfbd64a.zip
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo speaking of which, this is the first time I've looked closely at the share_classic.c code. It is absolutely and completely braindead and broken. Whatever drugs Simo was on at the time, he better not try to cross a border with them on him! Problems with it: - if you actually set a value, it gets ignored, and the defvalue gets used instead ('ret' is never returned). If you don't set a value, then defvalue gets returned too. Sound useful? - it means we now have to list parameters in source/param/ in lots and lots of places, all of which have to match exactly. code like this is supposed to reduce the likelyhood of errors, not increase it! - code which has a long line of if() statements with strcmp() should cause your fingers to burn on the keyboard when you type it in. That's what structure lists are for. Strangely enough, we have all the info in loadparm.c in a structure list, but instead it gets replicated in share_classic.c in this strange if() strcmp() form expect some changes to this code shortly. I'll need a calming cup of tea first though :-) (This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
-rw-r--r--source4/param/loadparm.c28
-rw-r--r--source4/param/loadparm.h2
-rw-r--r--source4/param/share.h12
-rw-r--r--source4/param/share_classic.c39
4 files changed, 72 insertions, 9 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 8371b94a50..dd52c55edf 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -223,6 +223,10 @@ typedef struct
int bMap_hidden;
int bMap_archive;
int bStrictLocking;
+ int iCreate_mask;
+ int iCreate_force_mode;
+ int iDir_mask;
+ int iDir_force_mode;
int *copymap;
int bMSDfsRoot;
int bStrictSync;
@@ -259,6 +263,10 @@ static service sDefault = {
False, /* bMap_hidden */
True, /* bMap_archive */
True, /* bStrictLocking */
+ 0744, /* iCreate_mask */
+ 0000, /* iCreate_force_mode */
+ 0755, /* iDir_mask */
+ 0000, /* iDir_force_mode */
NULL, /* copymap */
False, /* bMSDfsRoot */
False, /* bStrictSync */
@@ -419,6 +427,11 @@ static struct parm_struct parm_table[] = {
{"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE},
+ {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+
{"hosts allow", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
{"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
@@ -932,6 +945,10 @@ _PUBLIC_ FN_LOCAL_BOOL(lp_ci_filesystem, bCIFileSystem)
_PUBLIC_ FN_LOCAL_BOOL(lp_map_system, bMap_system)
_PUBLIC_ FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
_PUBLIC_ FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
_PUBLIC_ FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
@@ -1489,6 +1506,7 @@ static void copy_service(service * pserviceDest, service * pserviceSource, int *
break;
case P_INTEGER:
+ case P_OCTAL:
case P_ENUM:
*(int *)dest_ptr = *(int *)src_ptr;
break;
@@ -1894,6 +1912,10 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
*(int *)parm_ptr = atoi(pszParmValue);
break;
+ case P_OCTAL:
+ *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
+ break;
+
case P_BYTES:
{
uint64_t val;
@@ -2088,6 +2110,10 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
fprintf(f, "%d", *(int *)ptr);
break;
+ case P_OCTAL:
+ fprintf(f, "0%o", *(int *)ptr);
+ break;
+
case P_LIST:
if ((char ***)ptr && *(char ***)ptr) {
char **list = *(char ***)ptr;
@@ -2120,6 +2146,7 @@ static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
return (*((int *)ptr1) == *((int *)ptr2));
case P_INTEGER:
+ case P_OCTAL:
case P_BYTES:
case P_ENUM:
return (*((int *)ptr1) == *((int *)ptr2));
@@ -2209,6 +2236,7 @@ static BOOL is_default(int i)
return parm_table[i].def.bvalue ==
*(int *)parm_table[i].ptr;
case P_INTEGER:
+ case P_OCTAL:
case P_BYTES:
case P_ENUM:
return parm_table[i].def.ivalue ==
diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h
index d439a435e6..29a2acab1a 100644
--- a/source4/param/loadparm.h
+++ b/source4/param/loadparm.h
@@ -30,7 +30,7 @@
/* the following are used by loadparm for option lists */
typedef enum {
- P_BOOL,P_INTEGER,P_BYTES,P_LIST,P_STRING,P_USTRING,P_ENUM,P_SEP
+ P_BOOL,P_INTEGER,P_OCTAL,P_BYTES,P_LIST,P_STRING,P_USTRING,P_ENUM,P_SEP
} parm_type;
typedef enum {
diff --git a/source4/param/share.h b/source4/param/share.h
index 93b02255b6..94b8181867 100644
--- a/source4/param/share.h
+++ b/source4/param/share.h
@@ -92,6 +92,11 @@ struct share_ops {
#define SHARE_MSDFS_ROOT "msdfs-root"
#define SHARE_CI_FILESYSTEM "ci-filesystem"
+#define SHARE_DIR_MASK "directory mask"
+#define SHARE_CREATE_MASK "create mask"
+#define SHARE_FORCE_CREATE_MODE "force create mode"
+#define SHARE_FORCE_DIR_MODE "force directory mode"
+
/* defaults */
#define SHARE_HOST_ALLOW_DEFAULT NULL
@@ -103,6 +108,13 @@ struct share_ops {
#define SHARE_BROWSEABLE_DEFAULT True
#define SHARE_MAX_CONNECTIONS_DEFAULT 0
+#define SHARE_DIR_MASK_DEFAULT 0755
+#define SHARE_CREATE_MASK_DEFAULT 0744
+#define SHARE_FORCE_CREATE_MODE_DEFAULT 0000
+#define SHARE_FORCE_DIR_MODE_DEFAULT 0000
+
+
+
/* I'd like to see the following options go away
* and always use EAs and SECDESCs */
#define SHARE_READONLY_DEFAULT True
diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c
index 794a21c5bf..0a6e23287c 100644
--- a/source4/param/share_classic.c
+++ b/source4/param/share_classic.c
@@ -90,6 +90,9 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
return lp_fstype(s->snum);
}
+ DEBUG(0,("request for unknown share string option '%s'\n",
+ opt_name));
+
return defval;
}
@@ -117,19 +120,33 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
}
if (strcmp(opt_name, SHARE_CSC_POLICY) == 0) {
- ret = lp_csc_policy(s->snum);
- if (ret == -1) {
- return defval;
- }
+ return lp_csc_policy(s->snum);
}
if (strcmp(opt_name, SHARE_MAX_CONNECTIONS) == 0) {
- ret = lp_max_connections(s->snum);
- if (ret == -1) {
- return defval;
- }
+ return lp_max_connections(s->snum);
+ }
+
+ if (strcmp(opt_name, SHARE_CREATE_MASK) == 0) {
+ return lp_create_mask(s->snum);
+ }
+
+ if (strcmp(opt_name, SHARE_DIR_MASK) == 0) {
+ return lp_dir_mask(s->snum);
}
+ if (strcmp(opt_name, SHARE_FORCE_DIR_MODE) == 0) {
+ return lp_force_dir_mode(s->snum);
+ }
+
+ if (strcmp(opt_name, SHARE_FORCE_CREATE_MODE) == 0) {
+ return lp_force_create_mode(s->snum);
+ }
+
+
+ DEBUG(0,("request for unknown share int option '%s'\n",
+ opt_name));
+
return defval;
}
@@ -193,6 +210,9 @@ BOOL sclassic_bool_option(struct share_config *scfg, const char *opt_name, BOOL
return lp_ci_filesystem(s->snum);
}
+ DEBUG(0,("request for unknown share bool option '%s'\n",
+ opt_name));
+
return defval;
}
@@ -228,6 +248,9 @@ const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_confi
return lp_ntvfs_handler(s->snum);
}
+ DEBUG(0,("request for unknown share list option '%s'\n",
+ opt_name));
+
return NULL;
}