summaryrefslogtreecommitdiff
path: root/source3/utils/smbpasswd.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-04-17 19:29:51 +0000
committerJeremy Allison <jra@samba.org>1998-04-17 19:29:51 +0000
commit373d7c62577c13e1a85043844953a8d779858432 (patch)
treebaefa96a0cdba07e3d71ce6c3ecf26396347d886 /source3/utils/smbpasswd.c
parenta406ad5039bcdefb67b2093a42275882e71078c9 (diff)
downloadsamba-373d7c62577c13e1a85043844953a8d779858432.tar.gz
samba-373d7c62577c13e1a85043844953a8d779858432.tar.bz2
samba-373d7c62577c13e1a85043844953a8d779858432.zip
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)
Diffstat (limited to 'source3/utils/smbpasswd.c')
-rw-r--r--source3/utils/smbpasswd.c33
1 files changed, 22 insertions, 11 deletions
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