summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-09-12 20:00:42 +0000
committerJeremy Allison <jra@samba.org>2001-09-12 20:00:42 +0000
commit31e8101ea2073fa65437d79c6f4bf722831d09c1 (patch)
tree4bd1f6cb816aef7f0cedc717af062b947794c4c8
parent45762a62ce0cecd063f8c97d1ca0789339f300d6 (diff)
downloadsamba-31e8101ea2073fa65437d79c6f4bf722831d09c1.tar.gz
samba-31e8101ea2073fa65437d79c6f4bf722831d09c1.tar.bz2
samba-31e8101ea2073fa65437d79c6f4bf722831d09c1.zip
Fixed problems with arg parsing as root with smbpasswd.
Jeremy. (This used to be commit 6399cf490dffbd162afa06f18cdd6e0364db567d)
-rw-r--r--source3/utils/smbpasswd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 74f4e8833a..da5f817c80 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -550,7 +550,7 @@ static int process_root(int argc, char *argv[])
{
struct passwd *pwd;
int result = 0, ch;
- BOOL joining_domain = False, got_pass = False;
+ BOOL joining_domain = False, got_pass = False, got_username = False;
int local_flags = 0;
BOOL stdin_passwd_get = False;
fstring user_name, user_password;
@@ -559,12 +559,12 @@ static int process_root(int argc, char *argv[])
char *old_passwd = NULL;
char *remote_machine = NULL;
- ZERO_STRUCT(user_name);
- ZERO_STRUCT(user_password);
+ ZERO_STRUCT(user_name);
+ ZERO_STRUCT(user_password);
user_name[0] = '\0';
- while ((ch = getopt(argc, argv, "ax:d:e:hmnj:r:sR:D:U:L")) != EOF) {
+ while ((ch = getopt(argc, argv, "axdehmnj:r:sR:D:U:L")) != EOF) {
switch(ch) {
case 'L':
local_mode = True;
@@ -574,17 +574,14 @@ static int process_root(int argc, char *argv[])
break;
case 'x':
local_flags |= LOCAL_DELETE_USER;
- fstrcpy(user_name, optarg);
new_passwd = xstrdup("XXXXXX");
break;
case 'd':
local_flags |= LOCAL_DISABLE_USER;
- fstrcpy(user_name, optarg);
new_passwd = xstrdup("XXXXXX");
break;
case 'e':
local_flags |= LOCAL_ENABLE_USER;
- fstrcpy(user_name, optarg);
break;
case 'm':
local_flags |= LOCAL_TRUST_ACCOUNT;
@@ -616,6 +613,7 @@ static int process_root(int argc, char *argv[])
case 'U': {
char *lp;
+ got_username = True;
fstrcpy(user_name, optarg);
if ((lp = strchr_m(user_name, '%'))) {
@@ -691,12 +689,17 @@ static int process_root(int argc, char *argv[])
switch(argc) {
case 0:
- fstrcpy(user_name, "");
+ if (!got_username)
+ fstrcpy(user_name, "");
break;
case 1:
+ if (got_username)
+ usage();
fstrcpy(user_name, argv[0]);
break;
case 2:
+ if (got_username || got_pass)
+ usage();
fstrcpy(user_name, argv[0]);
new_passwd = xstrdup(argv[1]);
break;