diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-04-24 03:46:17 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-04-24 03:46:17 +0000 |
commit | 1f008c1203b082039a9824c186fa2eda730c6f46 (patch) | |
tree | 4c5bc2f14f34f76a02fd8036161bf229f7d7a152 /source3/passdb | |
parent | 8f6e88dbb6936abdb62a90a6bb0ef947ec8c9bb6 (diff) | |
download | samba-1f008c1203b082039a9824c186fa2eda730c6f46.tar.gz samba-1f008c1203b082039a9824c186fa2eda730c6f46.tar.bz2 samba-1f008c1203b082039a9824c186fa2eda730c6f46.zip |
Patch from Stephan Metzmacher to add default arguments to lp_parm() smb.conf
parameters. Does not break binary compatibility with older modules.
(This used to be commit 147c4d56d873a20a49194c5b036a3694299b1b48)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_mysql.c | 123 | ||||
-rw-r--r-- | source3/passdb/pdb_xml.c | 7 |
2 files changed, 34 insertions, 96 deletions
diff --git a/source3/passdb/pdb_mysql.c b/source3/passdb/pdb_mysql.c index f3cb998ee1..ec8c6f9ab8 100644 --- a/source3/passdb/pdb_mysql.c +++ b/source3/passdb/pdb_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; @@ -893,59 +892,6 @@ static NTSTATUS mysqlsam_update_sam_account(struct pdb_methods *methods, return mysqlsam_replace_sam_account(methods, newpwd, 1); } -static NTSTATUS mysqlsam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map, - DOM_SID sid, BOOL with_priv) -{ - return get_group_map_from_sid(sid, map, with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map, - gid_t gid, BOOL with_priv) -{ - return get_group_map_from_gid(gid, map, with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map, - char *name, BOOL with_priv) -{ - return get_group_map_from_ntname(name, map, with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_add_group_mapping_entry(struct pdb_methods *methods, - GROUP_MAP *map) -{ - return add_mapping_entry(map, TDB_INSERT) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_update_group_mapping_entry(struct pdb_methods *methods, - GROUP_MAP *map) -{ - return add_mapping_entry(map, TDB_REPLACE) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_delete_group_mapping_entry(struct pdb_methods *methods, - DOM_SID sid) -{ - return group_map_remove(sid) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_enum_group_mapping(struct pdb_methods *methods, - enum SID_NAME_USE sid_name_use, - GROUP_MAP **rmap, int *num_entries, - BOOL unix_only, BOOL with_priv) -{ - return enum_group_mapping(sid_name_use, rmap, num_entries, unix_only, - with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - - static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_methods ** pdb_method, const char *location) { @@ -979,13 +925,6 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho (*pdb_method)->add_sam_account = mysqlsam_add_sam_account; (*pdb_method)->update_sam_account = mysqlsam_update_sam_account; (*pdb_method)->delete_sam_account = mysqlsam_delete_sam_account; - (*pdb_method)->getgrsid = mysqlsam_getgrsid; - (*pdb_method)->getgrgid = mysqlsam_getgrgid; - (*pdb_method)->getgrnam = mysqlsam_getgrnam; - (*pdb_method)->add_group_mapping_entry = mysqlsam_add_group_mapping_entry; - (*pdb_method)->update_group_mapping_entry = mysqlsam_update_group_mapping_entry; - (*pdb_method)->delete_group_mapping_entry = mysqlsam_delete_group_mapping_entry; - (*pdb_method)->enum_group_mapping = mysqlsam_enum_group_mapping; data = talloc(pdb_context->mem_ctx, sizeof(struct pdb_mysql_data)); (*pdb_method)->private_data = data; @@ -993,7 +932,7 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho data->pwent = NULL; if (!location) { - DEBUG(0, ("No identifier specified. See README for details\n")); + DEBUG(0, ("No identifier specified. Check the Samba HOWTO Collection for details\n")); return NT_STATUS_INVALID_PARAMETER; } @@ -1032,7 +971,7 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho return NT_STATUS_OK; } -int pdb_mysql_init() +int pdb_mysql_init(void) { return smb_register_passdb("mysql", mysqlsam_init, PASSDB_INTERFACE_VERSION); } diff --git a/source3/passdb/pdb_xml.c b/source3/passdb/pdb_xml.c index ae3199e3a4..26e722dea1 100644 --- a/source3/passdb/pdb_xml.c +++ b/source3/passdb/pdb_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; @@ -564,7 +563,7 @@ NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_context, PDB_METHODS ** pdb_method, return NT_STATUS_OK; } -int pdb_xml_init() +int pdb_xml_init(void) { return smb_register_passdb("xml", xmlsam_init, PASSDB_INTERFACE_VERSION); } |