diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-04-24 03:54:54 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-04-24 03:54:54 +0000 |
commit | d13f5f85feb98b28251045d88435a1af8ce3f3ba (patch) | |
tree | 5cac6506e7cc01b728f8f68566870c865c5b7be2 /source3/modules | |
parent | c0960be217bbf1107843b510bb0829e9c6593e85 (diff) | |
download | samba-d13f5f85feb98b28251045d88435a1af8ce3f3ba.tar.gz samba-d13f5f85feb98b28251045d88435a1af8ce3f3ba.tar.bz2 samba-d13f5f85feb98b28251045d88435a1af8ce3f3ba.zip |
Patch from Stefan Metzmacher to add default parameters to the lp_parm()
smb.conf parameters along with some other small fixes. Binary
compatible with older modules.
(This used to be commit aa07b12fda732ca19d8dc41cebc7bb09e2549a30)
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/mysql.c | 59 | ||||
-rw-r--r-- | source3/modules/vfs_recycle.c | 34 | ||||
-rw-r--r-- | source3/modules/xml.c | 5 |
3 files changed, 44 insertions, 54 deletions
diff --git a/source3/modules/mysql.c b/source3/modules/mysql.c index 684eb96645..ec8c6f9ab8 100644 --- a/source3/modules/mysql.c +++ b/source3/modules/mysql.c @@ -25,12 +25,12 @@ #define CONFIG_LOGON_TIME_DEFAULT "logon_time" #define CONFIG_LOGOFF_TIME_DEFAULT "logoff_time" #define CONFIG_KICKOFF_TIME_DEFAULT "kickoff_time" -#define CONFIG_PASS_LAST_SET_TIME_DEFAULT "pass_last_set_time" -#define CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT "pass_can_change_time" -#define CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT "pass_must_change_time" +#define CONFIG_PASS_LAST_SET_TIME_DEFAULT "pass_last_set_time" +#define CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT "pass_can_change_time" +#define CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT "pass_must_change_time" #define CONFIG_USERNAME_DEFAULT "username" #define CONFIG_DOMAIN_DEFAULT "domain" -#define CONFIG_NT_USERNAME_DEFAULT "nt_username" +#define CONFIG_NT_USERNAME_DEFAULT "nt_username" #define CONFIG_FULLNAME_DEFAULT "nt_fullname" #define CONFIG_HOME_DIR_DEFAULT "home_dir" #define CONFIG_DIR_DRIVE_DEFAULT "dir_drive" @@ -40,8 +40,8 @@ #define CONFIG_WORKSTATIONS_DEFAULT "workstations" #define CONFIG_UNKNOWN_STR_DEFAULT "unknown_str" #define CONFIG_MUNGED_DIAL_DEFAULT "munged_dial" -#define CONFIG_UID_DEFAULT "uid" -#define CONFIG_GID_DEFAULT "gid" +#define CONFIG_UID_DEFAULT "uid" +#define CONFIG_GID_DEFAULT "gid" #define CONFIG_USER_SID_DEFAULT "user_sid" #define CONFIG_GROUP_SID_DEFAULT "group_sid" #define CONFIG_LM_PW_DEFAULT "lm_pw" @@ -53,11 +53,11 @@ #define CONFIG_HOURS_LEN_DEFAULT "hours_len" #define CONFIG_UNKNOWN_5_DEFAULT "unknown_5" #define CONFIG_UNKNOWN_6_DEFAULT "unknown_6" -#define CONFIG_HOST_DEFAULT "localhost" -#define CONFIG_USER_DEFAULT "samba" -#define CONFIG_PASS_DEFAULT "" -#define CONFIG_PORT_DEFAULT "3306" -#define CONFIG_DB_DEFAULT "samba" +#define CONFIG_HOST_DEFAULT "localhost" +#define CONFIG_USER_DEFAULT "samba" +#define CONFIG_PASS_DEFAULT "" +#define CONFIG_PORT_DEFAULT "3306" +#define CONFIG_DB_DEFAULT "samba" static int mysqlsam_debug_level = DBGC_ALL; @@ -91,7 +91,7 @@ typedef struct pdb_mysql_query { } static void pdb_mysql_int_field(struct pdb_methods *m, - struct pdb_mysql_query *q, char *name, int value) + struct pdb_mysql_query *q, const char *name, int value) { if (!name || strchr(name, '\'')) return; /* This field shouldn't be set by us */ @@ -110,7 +110,7 @@ static void pdb_mysql_int_field(struct pdb_methods *m, static NTSTATUS pdb_mysql_string_field(struct pdb_methods *methods, struct pdb_mysql_query *q, - char *name, const char *value) + const char *name, const char *value) { char *esc_value; struct pdb_mysql_data *data; @@ -145,20 +145,17 @@ static NTSTATUS pdb_mysql_string_field(struct pdb_methods *methods, return NT_STATUS_OK; } -static char * config_value(pdb_mysql_data * data, char *name, char *default_value) -{ - if (lp_parm_string(NULL, data->location, name)) - return lp_parm_string(NULL, data->location, name); +#define config_value(data,name,default_value) \ + lp_parm_const_string(GLOBAL_SECTION_SNUM, (data)->location, name, default_value) - return default_value; -} +static const char * config_value_write(pdb_mysql_data * data, const char *name, const char *default_value) { + char const *v = NULL; + char const *swrite = NULL; -static char * config_value_write(pdb_mysql_data * data, char *name, char *default_value) { - char *v = config_value(data, name, NULL); - char *swrite; + v = lp_parm_const_string(GLOBAL_SECTION_SNUM, data->location, name, default_value); if (!v) - return default_value; + return NULL; swrite = strchr(v, ':'); @@ -176,13 +173,15 @@ static char * config_value_write(pdb_mysql_data * data, char *name, char *defaul return swrite; } -static const char * config_value_read(pdb_mysql_data * data, char *name, char *default_value) +static const char * config_value_read(pdb_mysql_data * data, const char *name, const char *default_value) { - char *v = config_value(data, name, NULL); + char *v = NULL; char *swrite; + v = lp_parm_talloc_string(GLOBAL_SECTION_SNUM, data->location, name, default_value); + if (!v) - return default_value; + return "NULL"; swrite = strchr(v, ':'); @@ -190,7 +189,7 @@ static const char * config_value_read(pdb_mysql_data * data, char *name, char *d if (!swrite) { if (strlen(v) == 0) return "NULL"; - return v; + return (const char *)v; } /* Otherwise, we have to cut the ':write_part' */ @@ -198,11 +197,11 @@ static const char * config_value_read(pdb_mysql_data * data, char *name, char *d if (strlen(v) == 0) return "NULL"; - return v; + return (const char *)v; } /* Wrapper for atol that returns 0 if 'a' points to NULL */ -static long xatol(char *a) +static long xatol(const char *a) { long ret = 0; @@ -369,7 +368,7 @@ static NTSTATUS mysqlsam_setsampwent(struct pdb_methods *methods, BOOL update) } DEBUG(5, - ("mysqlsam_setsampwent succeeded(%lu results)!\n", + ("mysqlsam_setsampwent succeeded(%llu results)!\n", mysql_num_rows(data->pwent))); return NT_STATUS_OK; diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index 3a23e1a365..85ce257c02 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -126,7 +126,7 @@ static int recycle_connect(struct connection_struct *conn, const char *service, recycle_bin_connections *recconn; recycle_bin_connections *recconnbase; recycle_bin_private_data *recdata; - char *tmp_str; + const char *tmp_str; DEBUG(10, ("Called for service %s (%d) as user %s\n", service, SNUM(conn), user)); @@ -142,42 +142,34 @@ static int recycle_connect(struct connection_struct *conn, const char *service, return -1; } - recbin = talloc(ctx, sizeof(recycle_bin_struct)); + recbin = talloc_zero(ctx, sizeof(recycle_bin_struct)); if (recbin == NULL) { DEBUG(0, ("Failed to allocate memory in VFS module recycle_bin\n")); return -1; } recbin->mem_ctx = ctx; - /* Set defaults */ - recbin->repository = talloc_strdup(recbin->mem_ctx, ".recycle"); - ALLOC_CHECK(recbin->repository, error); - recbin->keep_dir_tree = False; - recbin->versions = False; - recbin->touch = False; - recbin->exclude = ""; - recbin->exclude_dir = ""; - recbin->noversions = ""; - recbin->maxsize = 0; - /* parse configuration options */ - if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "repository")) != NULL) { + if ((tmp_str = lp_parm_const_string(SNUM(conn), "vfs_recycle_bin", "repository", ".recycle")) != NULL) { recbin->repository = talloc_sub_conn(recbin->mem_ctx, conn, tmp_str); ALLOC_CHECK(recbin->repository, error); trim_string(recbin->repository, "/", "/"); DEBUG(5, ("recycle.bin: repository = %s\n", recbin->repository)); + } else { + DEBUG(0,("recycle.bin: no repository found (fail) !\n")); + goto error; } - recbin->keep_dir_tree = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "keeptree"); + recbin->keep_dir_tree = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "keeptree", False); DEBUG(5, ("recycle.bin: keeptree = %d\n", recbin->keep_dir_tree)); - recbin->versions = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "versions"); + recbin->versions = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "versions", False); DEBUG(5, ("recycle.bin: versions = %d\n", recbin->versions)); - recbin->touch = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "touch"); + recbin->touch = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "touch", False); DEBUG(5, ("recycle.bin: touch = %d\n", recbin->touch)); - recbin->maxsize = lp_parm_ulong(SNUM(conn), "vfs_recycle_bin", "maxsize"); + recbin->maxsize = lp_parm_ulong(SNUM(conn), "vfs_recycle_bin", "maxsize" , 0); if (recbin->maxsize == 0) { recbin->maxsize = -1; DEBUG(5, ("recycle.bin: maxsize = -infinite-\n")); @@ -185,17 +177,17 @@ static int recycle_connect(struct connection_struct *conn, const char *service, DEBUG(5, ("recycle.bin: maxsize = %ld\n", (long int)recbin->maxsize)); } - if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "exclude")) != NULL) { + if ((tmp_str = lp_parm_const_string(SNUM(conn), "vfs_recycle_bin", "exclude", "")) != NULL) { recbin->exclude = talloc_strdup(recbin->mem_ctx, tmp_str); ALLOC_CHECK(recbin->exclude, error); DEBUG(5, ("recycle.bin: exclude = %s\n", recbin->exclude)); } - if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "exclude_dir")) != NULL) { + if ((tmp_str = lp_parm_const_string(SNUM(conn), "vfs_recycle_bin", "exclude_dir", "")) != NULL) { recbin->exclude_dir = talloc_strdup(recbin->mem_ctx, tmp_str); ALLOC_CHECK(recbin->exclude_dir, error); DEBUG(5, ("recycle.bin: exclude_dir = %s\n", recbin->exclude_dir)); } - if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "noversions")) != NULL) { + if ((tmp_str = lp_parm_const_string(SNUM(conn), "vfs_recycle_bin", "noversions", "")) != NULL) { recbin->noversions = talloc_strdup(recbin->mem_ctx, tmp_str); ALLOC_CHECK(recbin->noversions, error); DEBUG(5, ("recycle.bin: noversions = %s\n", recbin->noversions)); diff --git a/source3/modules/xml.c b/source3/modules/xml.c index d018175d38..42503c3d39 100644 --- a/source3/modules/xml.c +++ b/source3/modules/xml.c @@ -512,7 +512,7 @@ static NTSTATUS xmlsam_add_sam_account(struct pdb_methods *methods, SAM_ACCOUNT return NT_STATUS_OK; } -NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_context, PDB_METHODS ** pdb_method, +static NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_context, PDB_METHODS ** pdb_method, const char *location) { NTSTATUS nt_status; @@ -553,8 +553,7 @@ NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_context, PDB_METHODS ** pdb_method, (*pdb_method)->enum_group_mapping = NULL; data = talloc(pdb_context->mem_ctx, sizeof(pdb_xml)); - data->location = - (location ? talloc_strdup(pdb_context->mem_ctx, location) : "passdb.xml"); + data->location = talloc_strdup(pdb_context->mem_ctx, (location ? location : "passdb.xml")); data->pwent = NULL; data->written = 0; (*pdb_method)->private_data = data; |