1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00

Fixed problems with arg parsing as root with smbpasswd.

Jeremy.
(This used to be commit 6399cf490dffbd162afa06f18cdd6e0364db567d)
This commit is contained in:
Jeremy Allison 2001-09-12 20:00:42 +00:00
parent 45762a62ce
commit 31e8101ea2

View File

@ -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;