summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;