diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-09-20 22:22:41 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-09-20 22:22:41 +0000 |
commit | 52e27c4a58fb1bdbb47f26e85c64ba77c42f6e81 (patch) | |
tree | ba43045245e05ee53f78f57245a59be43e4e859f /source3 | |
parent | bcf25cbcfc1044844ff318bce623eb33ad6de573 (diff) | |
download | samba-52e27c4a58fb1bdbb47f26e85c64ba77c42f6e81.tar.gz samba-52e27c4a58fb1bdbb47f26e85c64ba77c42f6e81.tar.bz2 samba-52e27c4a58fb1bdbb47f26e85c64ba77c42f6e81.zip |
Fix a bug and warn when configuration file values are incorrect. Thanks to
Wilco Baan Hofman <wilco@andoburg.nl>
(This used to be commit 2c584efae69f328581d4f863a8f8ef3ff8228423)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/passdb/pdb_mysql.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/source3/passdb/pdb_mysql.c b/source3/passdb/pdb_mysql.c index 9004c97716..7c2c56e359 100644 --- a/source3/passdb/pdb_mysql.c +++ b/source3/passdb/pdb_mysql.c @@ -156,7 +156,7 @@ static const char * config_value_write(pdb_mysql_data * data, const char *name, if (!v) return NULL; - swrite = strchr(v, ':'); + swrite = strrchr(v, ':'); /* Default to the same field as read field */ if (!swrite) @@ -182,7 +182,7 @@ static const char * config_value_read(pdb_mysql_data * data, const char *name, c if (!v) return "NULL"; - swrite = strchr(v, ':'); + swrite = strrchr(v, ':'); /* If no write is specified, there are no problems */ if (!swrite) { @@ -241,14 +241,20 @@ static NTSTATUS row_to_sam_account(MYSQL_RES * r, SAM_ACCOUNT * u) pdb_set_unknown_str(u, row[16], PDB_SET); pdb_set_munged_dial(u, row[17], PDB_SET); - if(row[18])string_to_sid(&sid, row[18]); - pdb_set_user_sid(u, &sid, PDB_SET); - if(row[19])string_to_sid(&sid, row[19]); - pdb_set_group_sid(u, &sid, PDB_SET); + if(!row[18] || !string_to_sid(&sid, row[18])) { + DEBUG(0,("No user SID retrieved from database!\n")); + } else { + pdb_set_user_sid(u, &sid, PDB_SET); + } + + if(row[19]) { + string_to_sid(&sid, row[19]); + pdb_set_group_sid(u, &sid, PDB_SET); + } - if (pdb_gethexpwd(row[20], temp), PDB_SET) + if (pdb_gethexpwd(row[20], temp)) pdb_set_lanman_passwd(u, temp, PDB_SET); - if (pdb_gethexpwd(row[21], temp), PDB_SET) + if (pdb_gethexpwd(row[21], temp)) pdb_set_nt_passwd(u, temp, PDB_SET); /* Only use plaintext password storage when lanman and nt are @@ -335,9 +341,9 @@ static NTSTATUS mysqlsam_setsampwent(struct pdb_methods *methods, BOOL update) CONFIG_LOGON_DIVS_DEFAULT), config_value_read(data, "hours len column", CONFIG_HOURS_LEN_DEFAULT), - config_value_read(data, "bad_password_count column", + config_value_read(data, "bad password count column", CONFIG_BAD_PASSWORD_COUNT_DEFAULT), - config_value_read(data, "logon_count column", + config_value_read(data, "logon count column", CONFIG_LOGON_COUNT_DEFAULT), config_value_read(data, "unknown 6 column", CONFIG_UNKNOWN_6_DEFAULT), @@ -651,6 +657,7 @@ static NTSTATUS mysqlsam_replace_sam_account(struct pdb_methods *methods, const SAM_ACCOUNT * newpwd, char isupdate) { pstring temp; + char *field; struct pdb_mysql_data *data; pdb_mysql_query query; fstring sid_str; @@ -661,6 +668,7 @@ static NTSTATUS mysqlsam_replace_sam_account(struct pdb_methods *methods, } data = (struct pdb_mysql_data *) methods->private_data; + if (data == NULL || data->handle == NULL) { DEBUG(0, ("invalid handle!\n")); return NT_STATUS_INVALID_HANDLE; @@ -878,6 +886,7 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho { NTSTATUS nt_status; struct pdb_mysql_data *data; + const char *sid_column, *username_column; mysqlsam_debug_level = debug_add_class("mysqlsam"); if (mysqlsam_debug_level == -1) { @@ -886,6 +895,7 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho ("mysqlsam: Couldn't register custom debugging class!\n")); } + if (!pdb_context) { DEBUG(0, ("invalid pdb_methods specified\n")); return NT_STATUS_UNSUCCESSFUL; @@ -933,6 +943,14 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho DEBUG(0, ("Failed to connect to server\n")); return NT_STATUS_UNSUCCESSFUL; } + + sid_column = config_value_read(data, "user sid column", CONFIG_USER_SID_DEFAULT); + username_column = config_value_read(data, "username column", CONFIG_USERNAME_DEFAULT); + if(!strcmp(sid_column,"NULL") || !strcmp(username_column, "NULL")) { + DEBUG(0,("Please specify both a valid 'user sid column' and a valid 'username column' in smb.conf\n")); + return NT_STATUS_UNSUCCESSFUL; + } + /* Process correct entry in $HOME/.my.conf */ if (!mysql_real_connect(data->handle, config_value(data, "mysql host", CONFIG_HOST_DEFAULT), |