summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-09-29 13:08:26 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-09-29 13:08:26 +0000
commit81697d5ebe33ad95dedfc376118fcdf0367cf052 (patch)
treebe7dbc8cf2713a1ea9cf7088896e7a0e10968ade /source3/utils
parent14cc9a3101f7ec88fa464f934e3dc2c081eccf8a (diff)
downloadsamba-81697d5ebe33ad95dedfc376118fcdf0367cf052.tar.gz
samba-81697d5ebe33ad95dedfc376118fcdf0367cf052.tar.bz2
samba-81697d5ebe33ad95dedfc376118fcdf0367cf052.zip
Fix up a number of intertwined issues:
The big one is a global change to allow us to NULLify the free'ed pointer to a former passdb object. This was done to allow idra's SAFE_FREE() macro to do its magic, and to satisfy the input test in pdb_init_sam() for a NULL pointer to start with. This NULL pointer test was what was breaking the adding of accounts up until now, and this code has been reworked to avoid duplicating work - I hope this will avoid a similar mess-up in future. Finally, I fixed a few nasty bugs where the pdb_ fuctions's return codes were being ignored. Some of these functions malloc() and are permitted to fail. Also, this caught a nasty bug where pdb_set_lanman_password(sam, NULL) acheived precisely didilly-squat, just returning False. Now that we check the returns this bug was spotted. This could allow different LM and NT passwords. - the pdbedit code needs to start checking these too, but I havn't had a chance to fix it. I have also fixed up where some of the password changing code was using the pdb_set functions to store *internal* data. I assume this is from a previous lot of mass conversion work... Most likally (and going on past experience) I have missed somthing, probably in the LanMan password change code which I havn't yet been able to test, but this lot is in much better shape than it was before. If all this is too much to swallow (particularly for 2.2.2) then just adding a sam_pass = NULL to the particular line of passdb.c should do the trick for the ovbious bug. Andrew Bartlett (This used to be commit 762c8758a7869809d89b4da9c2a5249678942930)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/pdbedit.c36
-rw-r--r--source3/utils/smbpasswd.c8
2 files changed, 22 insertions, 22 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index d0629fa258..ce5195a810 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -128,12 +128,12 @@ static int print_user_info (char *username, BOOL verbosity, BOOL smbpwdstyle)
if (ret==False) {
fprintf (stderr, "Username not found!\n");
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return -1;
}
ret=print_sam_info (sam_pwent, verbosity, smbpwdstyle);
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return ret;
}
@@ -151,7 +151,7 @@ static int print_users_list (BOOL verbosity, BOOL smbpwdstyle)
ret = pdb_setsampwent(False);
if (ret && errno == ENOENT) {
fprintf (stderr,"Password database not found!\n");
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
exit(1);
}
@@ -163,7 +163,7 @@ static int print_users_list (BOOL verbosity, BOOL smbpwdstyle)
}
pdb_endsampwent ();
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return 0;
}
@@ -181,7 +181,7 @@ static int set_user_info (char *username, char *fullname, char *homedir, char *d
ret = pdb_getsampwnam (sam_pwent, username);
if (ret==False) {
fprintf (stderr, "Username not found!\n");
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return -1;
}
@@ -200,10 +200,10 @@ static int set_user_info (char *username, char *fullname, char *homedir, char *d
print_user_info (username, True, False);
else {
fprintf (stderr, "Unable to modify entry!\n");
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return -1;
}
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return 0;
}
@@ -222,7 +222,7 @@ static int new_user (char *username, char *fullname, char *homedir, char *drive,
if (!(pwd = sys_getpwnam(username))) {
fprintf (stderr, "User %s does not exist in system passwd!\n", username);
- pdb_free_sam (sam_pwent);
+ pdb_free_sam (&sam_pwent);
return -1;
}
@@ -230,7 +230,7 @@ static int new_user (char *username, char *fullname, char *homedir, char *drive,
password2 = getpass("retype new password:");
if (strcmp (password1, password2)) {
fprintf (stderr, "Passwords does not match!\n");
- pdb_free_sam (sam_pwent);
+ pdb_free_sam (&sam_pwent);
return -1;
}
@@ -260,10 +260,10 @@ static int new_user (char *username, char *fullname, char *homedir, char *drive,
print_user_info (username, True, False);
} else {
fprintf (stderr, "Unable to add user! (does it alredy exist?)\n");
- pdb_free_sam (sam_pwent);
+ pdb_free_sam (&sam_pwent);
return -1;
}
- pdb_free_sam (sam_pwent);
+ pdb_free_sam (&sam_pwent);
return 0;
}
@@ -297,7 +297,7 @@ static int new_machine (char *machinename)
for (uid=BASE_MACHINE_UID; uid<=MAX_MACHINE_UID; uid++) {
pdb_init_sam (&sam_trust);
if (pdb_getsampwuid (sam_trust, uid)) {
- pdb_free_sam (sam_trust);
+ pdb_free_sam (&sam_trust);
} else {
break;
}
@@ -305,7 +305,7 @@ static int new_machine (char *machinename)
if (uid>MAX_MACHINE_UID) {
fprintf (stderr, "No more free UIDs available to Machine accounts!\n");
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return -1;
}
@@ -319,10 +319,10 @@ static int new_machine (char *machinename)
print_user_info (name, True, False);
} else {
fprintf (stderr, "Unable to add machine! (does it already exist?)\n");
- pdb_free_sam (sam_pwent);
+ pdb_free_sam (&sam_pwent);
return -1;
}
- pdb_free_sam (sam_pwent);
+ pdb_free_sam (&sam_pwent);
return 0;
}
@@ -383,7 +383,7 @@ static int import_users (char *filename)
fgets(linebuf, 256, fp);
if (ferror(fp)) {
fprintf (stderr, "%s\n", strerror (ferror (fp)));
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return -1;
}
if ((linebuf_len = strlen(linebuf)) == 0) {
@@ -401,7 +401,7 @@ static int import_users (char *filename)
linebuf[linebuf_len] = '\0';
if ((linebuf[0] == 0) && feof(fp)) {
/*end of file!!*/
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return 0;
}
line++;
@@ -558,7 +558,7 @@ static int import_users (char *filename)
pdb_reset_sam (sam_pwent);
}
printf ("%d lines read.\n%d entryes imported\n", line, good);
- pdb_free_sam(sam_pwent);
+ pdb_free_sam(&sam_pwent);
return 0;
}
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 14b10c1700..168547c712 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -524,7 +524,7 @@ static BOOL password_change(const char *remote_machine, char *user_name,
return False;
}
ret = remote_password_change(remote_machine, user_name,
- old_passwd, new_passwd, err_str, sizeof(err_str));
+ old_passwd, new_passwd, err_str, sizeof(err_str));
if(*err_str)
fprintf(stderr, err_str);
return ret;
@@ -707,7 +707,7 @@ static int process_root(int argc, char *argv[])
usage();
}
- if (!user_name[0] && (pwd = sys_getpwuid(0))) {
+ if (!user_name[0] && (pwd = sys_getpwuid(geteuid()))) {
fstrcpy(user_name, pwd->pw_name);
}
@@ -768,7 +768,7 @@ static int process_root(int argc, char *argv[])
if((sampass != False) && (pdb_get_lanman_passwd(sampass) != NULL)) {
new_passwd = xstrdup("XXXX"); /* Don't care. */
}
- pdb_free_sam(sampass);
+ pdb_free_sam(&sampass);
}
if(!new_passwd)
@@ -799,7 +799,7 @@ static int process_root(int argc, char *argv[])
if((ret != False) && (pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ) )
printf(" User has no password flag set.");
printf("\n");
- pdb_free_sam(sampass);
+ pdb_free_sam(&sampass);
}
done: