diff options
author | Jeremy Allison <jra@samba.org> | 1998-05-06 18:45:57 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-05-06 18:45:57 +0000 |
commit | 346abceb277e3354214599cc3c0f9bac6d44dfc8 (patch) | |
tree | 64fa7b94faceb66ebf6564841d4a261b89cdbc50 | |
parent | b54509045d7186fc0526d91bcf429659cba8be1d (diff) | |
download | samba-346abceb277e3354214599cc3c0f9bac6d44dfc8.tar.gz samba-346abceb277e3354214599cc3c0f9bac6d44dfc8.tar.bz2 samba-346abceb277e3354214599cc3c0f9bac6d44dfc8.zip |
smbpass.c: Fixed machine_passwd_lock() problems.
password.c: Fixed machine_passwd_lock() problems.
lib/rpc/server/srv_ldap_helpers.c: Oops - broke proto.h with dummy function. Fixed now.
Jeremy.
(This used to be commit d28427f21fff49da6b38c24625e3e2dae49a9713)
-rw-r--r-- | source3/include/proto.h | 10 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 46 | ||||
-rw-r--r-- | source3/rpc_server/srv_ldap_helpers.c | 5 | ||||
-rw-r--r-- | source3/smbd/password.c | 9 |
4 files changed, 33 insertions, 37 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 720806026b..7c09113259 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -847,6 +847,7 @@ BOOL get_ldap_entries(SAM_USER_INFO_21 *pw_buf, int max_num_entries, uint16 acb_mask, int switch_level); BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid); +void ldap_helper_dummy(void); /*The following definitions come from lib/rpc/server/srv_lsa.c */ @@ -1787,12 +1788,11 @@ struct smb_passwd *getsmbpwuid(unsigned int uid); char *encode_acct_ctrl(uint16 acct_ctrl); BOOL add_smbpwd_entry(struct smb_passwd *newpwd); BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override); -void *machine_password_lock( char *domain, char *name, BOOL update); -BOOL machine_password_unlock( void *token ); +BOOL machine_password_lock( char *domain, char *name, BOOL update); +BOOL machine_password_unlock(void); BOOL machine_password_delete( char *domain, char *name ); -BOOL get_machine_account_password( void *mach_tok, unsigned char *ret_pwd, - time_t *last_change_time); -BOOL set_machine_account_password( void *mach_tok, unsigned char *md4_new_pwd); +BOOL get_machine_account_password( unsigned char *ret_pwd, time_t *last_change_time); +BOOL set_machine_account_password( unsigned char *md4_new_pwd); /*The following definitions come from status.c */ diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index 2fc0c3fb89..56eade7cd3 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -1085,6 +1085,7 @@ BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override) } static int mach_passwd_lock_depth; +static FILE *mach_passwd_fp; /************************************************************************ Routine to get the name for a machine account file. @@ -1119,52 +1120,50 @@ static void get_machine_account_file_name( char *domain, char *name, char *mac_f Routine to lock the machine account password file for a domain. ************************************************************************/ -void *machine_password_lock( char *domain, char *name, BOOL update) +BOOL machine_password_lock( char *domain, char *name, BOOL update) { - FILE *fp; pstring mac_file; if(mach_passwd_lock_depth == 0) { get_machine_account_file_name( domain, name, mac_file); - if((fp = fopen(mac_file, "r+b")) == NULL) { + if((mach_passwd_fp = fopen(mac_file, "r+b")) == NULL) { if(errno == ENOENT && update) { - fp = fopen(mac_file, "w+b"); + mach_passwd_fp = fopen(mac_file, "w+b"); } - if(fp == NULL) { + if(mach_passwd_fp == NULL) { DEBUG(0,("machine_password_lock: cannot open file %s - Error was %s.\n", mac_file, strerror(errno) )); - return NULL; + return False; } } chmod(mac_file, 0600); - if(!pw_file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK), + if(!pw_file_lock(fileno(mach_passwd_fp), (update ? F_WRLCK : F_RDLCK), 60, &mach_passwd_lock_depth)) { DEBUG(0,("machine_password_lock: cannot lock file %s\n", mac_file)); - fclose(fp); - return NULL; + fclose(mach_passwd_fp); + return False; } } - return (void *)fp; + return True; } /************************************************************************ Routine to unlock the machine account password file for a domain. ************************************************************************/ -BOOL machine_password_unlock( void *token ) +BOOL machine_password_unlock(void) { - FILE *fp = (FILE *)token; - BOOL ret = pw_file_unlock(fileno(fp), &mach_passwd_lock_depth); + BOOL ret = pw_file_unlock(fileno(mach_passwd_fp), &mach_passwd_lock_depth); if(mach_passwd_lock_depth == 0) - fclose(fp); + fclose(mach_passwd_fp); return ret; } @@ -1185,10 +1184,8 @@ BOOL machine_password_delete( char *domain, char *name ) The user of this function must have locked the machine password file. ************************************************************************/ -BOOL get_machine_account_password( void *mach_tok, unsigned char *ret_pwd, - time_t *last_change_time) +BOOL get_machine_account_password( unsigned char *ret_pwd, time_t *last_change_time) { - FILE *fp = (FILE *)mach_tok; char linebuf[256]; char *p; int i; @@ -1198,14 +1195,14 @@ BOOL get_machine_account_password( void *mach_tok, unsigned char *ret_pwd, *last_change_time = (time_t)0; memset(ret_pwd, '\0', 16); - if(fseek( fp, 0L, SEEK_SET) == -1) { + if(fseek( mach_passwd_fp, 0L, SEEK_SET) == -1) { DEBUG(0,("get_machine_account_password: Failed to seek to start of file. Error was %s.\n", strerror(errno) )); return False; } - fgets(linebuf, sizeof(linebuf), fp); - if(ferror(fp)) { + fgets(linebuf, sizeof(linebuf), mach_passwd_fp); + if(ferror(mach_passwd_fp)) { DEBUG(0,("get_machine_account_password: Failed to read password. Error was %s.\n", strerror(errno) )); return False; @@ -1268,13 +1265,12 @@ BOOL get_machine_account_password( void *mach_tok, unsigned char *ret_pwd, The user of this function must have locked the machine password file. ************************************************************************/ -BOOL set_machine_account_password( void *mach_tok, unsigned char *md4_new_pwd) +BOOL set_machine_account_password( unsigned char *md4_new_pwd) { char linebuf[64]; int i; - FILE *fp = (FILE *)mach_tok; - if(fseek( fp, 0L, SEEK_SET) == -1) { + if(fseek( mach_passwd_fp, 0L, SEEK_SET) == -1) { DEBUG(0,("set_machine_account_password: Failed to seek to start of file. Error was %s.\n", strerror(errno) )); return False; @@ -1285,12 +1281,12 @@ BOOL set_machine_account_password( void *mach_tok, unsigned char *md4_new_pwd) sprintf(&linebuf[32], ":TLC-%08X\n", (unsigned)time(NULL)); - if(fwrite( linebuf, 1, 45, fp)!= 45) { + if(fwrite( linebuf, 1, 45, mach_passwd_fp)!= 45) { DEBUG(0,("set_machine_account_password: Failed to write file. Warning - the machine \ machine account is now invalid. Please recreate. Error was %s.\n", strerror(errno) )); return False; } - fflush(fp); + fflush(mach_passwd_fp); return True; } diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c index 945c06ad27..66674f4773 100644 --- a/source3/rpc_server/srv_ldap_helpers.c +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -161,5 +161,6 @@ BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) #else /* USE_LDAP */ /* this keeps fussy compilers happy */ -void ldap_helper_dummy(void) {} -#endif +void ldap_helper_dummy(void) +{} +#endif /* USE_LDAP */ diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 53ed8c85f1..1056269490 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -1922,7 +1922,6 @@ BOOL domain_client_validate( char *user, char *domain, struct cli_state cli; uint32 smb_uid_low; BOOL connected_ok = False; - void *vp; /* * Check that the requested domain is not our own machine name. @@ -1971,20 +1970,20 @@ BOOL domain_client_validate( char *user, char *domain, /* * Get the machine account password. */ - if((vp = machine_password_lock( global_myworkgroup, global_myname, False)) == NULL) { + if(!machine_password_lock( global_myworkgroup, global_myname, False)) { DEBUG(0,("domain_client_validate: unable to open the machine account password file for \ machine %s in domain %s.\n", global_myname, global_myworkgroup )); return False; } - if(get_machine_account_password( vp, machine_passwd, &lct) == False) { + if(get_machine_account_password( machine_passwd, &lct) == False) { DEBUG(0,("domain_client_validate: unable to read the machine account password for \ machine %s in domain %s.\n", global_myname, global_myworkgroup )); - machine_password_unlock(vp); + machine_password_unlock(); return False; } - machine_password_unlock(vp); + machine_password_unlock(); unbecome_root(False); |