summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1997-09-15 06:36:55 +0000
committerAndrew Tridgell <tridge@samba.org>1997-09-15 06:36:55 +0000
commitd55427c85fca8ac7b44e32bdfff344ab573af993 (patch)
tree28117bc593466c3f7c00a9a87aa6b71cdd40dbe2 /source3
parent552818e60eff4a87ece94f98c33424c93354bf6c (diff)
downloadsamba-d55427c85fca8ac7b44e32bdfff344ab573af993.tar.gz
samba-d55427c85fca8ac7b44e32bdfff344ab573af993.tar.bz2
samba-d55427c85fca8ac7b44e32bdfff344ab573af993.zip
- if the user already exists then ignore the -add command
- change the way the smbpasswd file is auto-created if it doesn't exist. It didn't work under IRIX for some unknown reason The smbpasswd.c code is really a bit of a mess. We should probably rewrite it sometime. (This used to be commit 6e3697ad1218264c85c6c1f4b1521960e21e2a67)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/smbpasswd.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index c781427474..d20ff42c0e 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -375,18 +375,24 @@ static void usage(char *name)
* Open the smbpaswd file XXXX - we need to parse smb.conf to get the
* filename
*/
- if ((fp = fopen(pfile, "a+")) == NULL) {
- err = errno;
- fprintf(stderr, "%s: Failed to open password file %s.\n",
- argv[0], pfile);
- errno = err;
- perror(argv[0]);
- exit(err);
+ fp = fopen(pfile, "r+");
+ if (!fp && errno == ENOENT) {
+ fp = fopen(pfile, "w");
+ if (fp) {
+ fprintf(fp, "# Samba SMB password file\n");
+ fclose(fp);
+ fp = fopen(pfile, "r+");
+ }
+ }
+ if (!fp) {
+ err = errno;
+ fprintf(stderr, "%s: Failed to open password file %s.\n",
+ argv[0], pfile);
+ errno = err;
+ perror(argv[0]);
+ exit(err);
}
- /* position at the start of the file */
- fseek(fp, 0, SEEK_SET);
-
/* Set read buffer to 16k for effiecient reads */
setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
@@ -477,6 +483,9 @@ Error was %s. Password file may be corrupt ! Please examine by hand !\n",
pw_file_unlock(lockfd);
exit(0);
}
+ } else {
+ /* the entry already existed */
+ add_user = False;
}
/* If we are root or the password is 'NO PASSWORD' then