From 373d7c62577c13e1a85043844953a8d779858432 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Apr 1998 19:29:51 +0000 Subject: Changing of machine passwords now works !!!!!! smbdes.c: Added cred_hash3. smbpasswd.c: Fixes for adding a machine account (needs more work). lib/rpc/server/srv_netlog.c: Turn on the machine password changing code by default (calls cred_hash3). Jeremy. (This used to be commit 50aa513b969c6e41911aeee8207b065f93af0beb) --- source3/utils/smbpasswd.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'source3/utils/smbpasswd.c') diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index ca59ae52e9..97a38977dc 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -576,6 +576,25 @@ int main(int argc, char **argv) } if(*user_name) { + + if(machine_account) { + int username_len = strlen(user_name); + if(username_len >= sizeof(pstring) - 1) { + fprintf(stderr, "%s: machine account name too long.\n", user_name); + exit(1); + } + + if(user_name[username_len-1] != '$') { + user_name[username_len] = '$'; + user_name[username_len+1] = '\0'; + } + } + + /* + * Setup the pwd struct to point to known + * values for a machine account (it doesn't + * exist in /etc/passwd). + */ if((pwd = getpwnam(user_name)) == NULL) { fprintf(stderr, "%s: User \"%s\" was not found in system password file.\n", prog_name, user_name); @@ -630,6 +649,8 @@ int main(int argc, char **argv) strncpy(new_passwd, user_name, sizeof(fstring)); new_passwd[sizeof(fstring)-1] = '\0'; strlower(new_passwd); + if(new_passwd[strlen(new_passwd)-1] == '$') + new_passwd[strlen(new_passwd)-1] = '\0'; } /* @@ -741,17 +762,7 @@ int main(int argc, char **argv) * a '$' etc.... */ - if(machine_account) { - int username_len = strlen(user_name); - if(username_len >= sizeof(pstring) - 1) { - fprintf(stderr, "%s: machine account name too long.\n", user_name); - exit(1); - } - - if(user_name[username_len] != '$') { - user_name[username_len] = '$'; - user_name[username_len+1] = '\0'; - } + if(machine_account && !pwd) { /* * Setup the pwd struct to point to known -- cgit