mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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 commit is contained in:
parent
e3eb6c2cf6
commit
19a9fc2f44
@ -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 ==
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user