diff options
author | Jeremy Allison <jra@samba.org> | 2001-10-11 09:40:03 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-10-11 09:40:03 +0000 |
commit | 6d991fc6ff04b2dc71d4b58815460fd549f705b5 (patch) | |
tree | 78b9bc0a8f2b9f00c3cdc8cf82d9cfc2ce731c68 /source/passdb | |
parent | a2c6bb77915a3bc878128eac2c4ae3e62735b8ff (diff) | |
download | samba-6d991fc6ff04b2dc71d4b58815460fd549f705b5.tar.gz samba-6d991fc6ff04b2dc71d4b58815460fd549f705b5.tar.xz samba-6d991fc6ff04b2dc71d4b58815460fd549f705b5.zip |
New files added.
Jeremy.
Diffstat (limited to 'source/passdb')
-rw-r--r-- | source/passdb/machine_sid.c | 2 | ||||
-rw-r--r-- | source/passdb/pdb_ldap.c | 2 | ||||
-rw-r--r-- | source/passdb/pdb_nisplus.c | 15 | ||||
-rw-r--r-- | source/passdb/pdb_smbpasswd.c | 29 | ||||
-rw-r--r-- | source/passdb/pdb_tdb.c | 25 |
5 files changed, 48 insertions, 25 deletions
diff --git a/source/passdb/machine_sid.c b/source/passdb/machine_sid.c index 859f00b4c6e..e374b0657d6 100644 --- a/source/passdb/machine_sid.c +++ b/source/passdb/machine_sid.c @@ -68,7 +68,7 @@ BOOL pdb_generate_sam_sid(void) generate_wellknown_sids(); - pstrcpy(sid_file, lp_private_dir()); + get_private_directory(sid_file); if (!directory_exist(sid_file, NULL)) { if (mkdir(sid_file, 0700) != 0) { diff --git a/source/passdb/pdb_ldap.c b/source/passdb/pdb_ldap.c index d44a6133f37..1a1dc0915ea 100644 --- a/source/passdb/pdb_ldap.c +++ b/source/passdb/pdb_ldap.c @@ -51,6 +51,8 @@ #define SAM_ACCOUNT struct sam_passwd #endif +extern int DEBUGLEVEL; + struct ldap_enum_info { LDAP *ldap_struct; diff --git a/source/passdb/pdb_nisplus.c b/source/passdb/pdb_nisplus.c index a86d5ecb680..990dcfbe9e0 100644 --- a/source/passdb/pdb_nisplus.c +++ b/source/passdb/pdb_nisplus.c @@ -209,9 +209,6 @@ static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, nis_object *obj) * time values. note: this code assumes 32bit time_t! */ - /* Don't change these timestamp settings without a good reason. They are - important for NT member server compatibility. */ - pdb_set_logon_time(pw_buf, (time_t)0); ptr = (uchar *)ENTRY_VAL(obj, NPF_LOGON_T); if(ptr && *ptr && (StrnCaseCmp(ptr, "LNT-", 4)==0)) { @@ -355,7 +352,8 @@ static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, nis_object *obj) /* Check the lanman password column. */ ptr = (char *)ENTRY_VAL(obj, NPF_LMPWD); - pdb_set_lanman_passwd(pw_buf, NULL); + if (!pdb_set_lanman_passwd(pw_buf, NULL)) + return False; if (!strncasecmp(ptr, "NO PASSWORD", 11)) { pdb_set_acct_ctrl(pw_buf, pdb_get_acct_ctrl(pw_buf) | ACB_PWNOTREQ); @@ -365,12 +363,14 @@ static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, nis_object *obj) pdb_get_username(pw_buf))); return False; } - pdb_set_lanman_passwd(pw_buf, smbpwd); + if (!pdb_set_lanman_passwd(pw_buf, smbpwd)) + return False; } /* Check the NT password column. */ ptr = ENTRY_VAL(obj, NPF_NTPWD); - pdb_set_nt_passwd(pw_buf, NULL); + if (!pdb_set_nt_passwd(pw_buf, NULL)) + return False; if (!(pdb_get_acct_ctrl(pw_buf) & ACB_PWNOTREQ) && strncasecmp(ptr, "NO PASSWORD", 11)) { @@ -380,7 +380,8 @@ static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, nis_object *obj) pdb_get_uid(pw_buf))); return False; } - pdb_set_nt_passwd(pw_buf, smbntpwd); + if (!pdb_set_nt_passwd(pw_buf, smbntpwd)) + return False; } pdb_set_unknown_3(pw_buf, 0xffffff); /* don't know */ diff --git a/source/passdb/pdb_smbpasswd.c b/source/passdb/pdb_smbpasswd.c index 45c983b1ca6..d29a4bfcaf0 100644 --- a/source/passdb/pdb_smbpasswd.c +++ b/source/passdb/pdb_smbpasswd.c @@ -44,10 +44,12 @@ struct smb_passwd }; +extern int DEBUGLEVEL; extern pstring samlogon_user; extern BOOL sam_logon_in_ssb; extern struct passdb_ops pdb_ops; + /* used for maintain locks on the smbpasswd file */ static int pw_file_lock_depth; static void *global_vp; @@ -336,7 +338,7 @@ static struct smb_passwd *getsmbfilepwent(void *vp) DEBUG(6, ("getsmbfilepwent: skipping comment or blank line\n")); continue; } - p = (unsigned char *) strchr_m(linebuf, ':'); + p = (unsigned char *) strchr(linebuf, ':'); if (p == NULL) { DEBUG(0, ("getsmbfilepwent: malformed password entry (no :)\n")); continue; @@ -436,7 +438,7 @@ static struct smb_passwd *getsmbfilepwent(void *vp) if (*p == '[') { - unsigned char *end_p = (unsigned char *)strchr_m((char *)p, ']'); + unsigned char *end_p = (unsigned char *)strchr((char *)p, ']'); pw_buf.acct_ctrl = pdb_decode_acct_ctrl((char*)p); /* Must have some account type set. */ @@ -761,7 +763,7 @@ static BOOL mod_smbfilepwd_entry(struct smb_passwd* pwd, BOOL override) continue; } - p = (unsigned char *) strchr_m(linebuf, ':'); + p = (unsigned char *) strchr(linebuf, ':'); if (p == NULL) { DEBUG(0, ("mod_smbfilepwd_entry: malformed password entry (no :)\n")); @@ -1206,8 +1208,14 @@ static BOOL build_sam_account(SAM_ACCOUNT *sam_pass, struct smb_passwd *pw_buf) pdb_set_group_rid(sam_pass, pdb_gid_to_group_rid(pwfile->pw_gid)); pdb_set_username (sam_pass, pw_buf->smb_name); - pdb_set_nt_passwd (sam_pass, pw_buf->smb_nt_passwd); - pdb_set_lanman_passwd (sam_pass, pw_buf->smb_passwd); + if (!pdb_set_nt_passwd (sam_pass, pw_buf->smb_nt_passwd)) { + if (pw_buf->smb_nt_passwd) + return False; + } + if (!pdb_set_lanman_passwd (sam_pass, pw_buf->smb_passwd)) { + if (pw_buf->smb_passwd) + return False; + } pdb_set_acct_ctrl (sam_pass, pw_buf->acct_ctrl); pdb_set_pass_last_set_time (sam_pass, pw_buf->pass_last_set_time); pdb_set_pass_can_change_time (sam_pass, pw_buf->pass_last_set_time); @@ -1215,11 +1223,10 @@ static BOOL build_sam_account(SAM_ACCOUNT *sam_pass, struct smb_passwd *pw_buf) pdb_set_dir_drive (sam_pass, lp_logon_drive()); - /* the smbpasswd format doesn't have a must change time field, so - we can't get this right. The best we can do is to set this to - some time in the future. 21 days seems as reasonable as any other value :) - */ - pdb_set_pass_must_change_time (sam_pass, pw_buf->pass_last_set_time + MAX_PASSWORD_AGE); + /* FIXME!! What should this be set to? New smb.conf parameter maybe? + max password age? For now, we'll use the current time + 21 days. + --jerry */ + pdb_set_pass_must_change_time (sam_pass, time(NULL)+1814400); /* check if this is a user account or a machine account */ if (samlogon_user[strlen(samlogon_user)-1] != '$') @@ -1341,7 +1348,7 @@ BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, char *username) /* break the username from the domain if we have been given a string in the form 'DOMAIN\user' */ fstrcpy (name, username); - if ((user=strchr_m(name, '\\')) != NULL) { + if ((user=strchr(name, '\\')) != NULL) { domain = name; *user = '\0'; user++; diff --git a/source/passdb/pdb_tdb.c b/source/passdb/pdb_tdb.c index 43eefa5c7a7..6ae7f33b0f1 100644 --- a/source/passdb/pdb_tdb.c +++ b/source/passdb/pdb_tdb.c @@ -138,8 +138,14 @@ static BOOL init_sam_from_buffer (SAM_ACCOUNT *sampass, uint8 *buf, uint32 bufle pdb_set_acct_desc (sampass, acct_desc_len?acct_desc:NULL); pdb_set_workstations (sampass, workstations_len?workstations:NULL); pdb_set_munged_dial (sampass, munged_dial_len?munged_dial:NULL); - pdb_set_lanman_passwd(sampass, lmpwlen?lm_pw_ptr:NULL); - pdb_set_nt_passwd (sampass, ntpwlen?nt_pw_ptr:NULL); + if (!pdb_set_lanman_passwd(sampass, lmpwlen?lm_pw_ptr:NULL)) { + ret = False; + goto done; + } + if (!pdb_set_nt_passwd(sampass, ntpwlen?nt_pw_ptr:NULL)) { + ret = False; + goto done; + } /*pdb_set_uid(sampass, uid); pdb_set_gid(sampass, gid);*/ @@ -466,6 +472,9 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user) pdb_set_uid (user, uid); pdb_set_gid (user, gid); + /* 21 days from present */ + pdb_set_pass_must_change_time(user, time(NULL)+1814400); + standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_logon_script(user)); standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_profile_path(user)); standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_homedir(user)); @@ -498,7 +507,8 @@ BOOL pdb_getsampwnam (SAM_ACCOUNT *user, char *sname) } /* Data is stored in all lower-case */ - unix_strlower(sname, -1, name, sizeof(name)); + fstrcpy(name, sname); + strlower(name); get_private_directory(tdbfile); pstrcat (tdbfile, PASSDB_FILE_NAME); @@ -645,7 +655,8 @@ BOOL pdb_delete_sam_account(char *sname) uint32 rid; fstring name; - unix_strlower(sname, -1, name, sizeof(name)); + fstrcpy(name, sname); + strlower(name); get_private_directory(tdbfile); pstrcat (tdbfile, PASSDB_FILE_NAME); @@ -686,7 +697,7 @@ BOOL pdb_delete_sam_account(char *sname) rid = pdb_get_user_rid(sam_pass); - pdb_free_sam (&sam_pass); + pdb_free_sam (sam_pass); /* it's outaa here! 8^) */ if (tdb_delete(pwd_tdb, key) != TDB_SUCCESS) { @@ -729,6 +740,7 @@ static BOOL tdb_update_sam(SAM_ACCOUNT* newpwd, BOOL override, int flag) pstring tdbfile; fstring name; BOOL ret = True; + int newtdb = FALSE; get_private_directory(tdbfile); pstrcat (tdbfile, PASSDB_FILE_NAME); @@ -751,7 +763,8 @@ static BOOL tdb_update_sam(SAM_ACCOUNT* newpwd, BOOL override, int flag) } data.dptr = buf; - unix_strlower(pdb_get_username(newpwd), -1, name, sizeof(name)); + fstrcpy(name,pdb_get_username(newpwd)); + strlower(name); /* setup the USER index key */ slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name); |