summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-22 20:14:13 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-22 20:14:13 +0000
commitc5a6d0c84de27e1c849a0ec45fcf718e52346b13 (patch)
treec7ff7ac144236f0640178296cfd92bf1a517f802 /source3
parent1ed8653112f8b26cb107e2c1e872565675ba1465 (diff)
downloadsamba-c5a6d0c84de27e1c849a0ec45fcf718e52346b13.tar.gz
samba-c5a6d0c84de27e1c849a0ec45fcf718e52346b13.tar.bz2
samba-c5a6d0c84de27e1c849a0ec45fcf718e52346b13.zip
the last one. that concludes the removal of all next_token() calls
from rpcclient/cmd_*.c. (This used to be commit ca803c17fa51ace5f2b99b09f5c59893f43ba70d)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/cmd_reg.c149
-rw-r--r--source3/rpcclient/rpcclient.c2
2 files changed, 91 insertions, 60 deletions
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 305440c3c5..962772fb8e 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -288,14 +288,16 @@ nt registry enum
****************************************************************************/
void cmd_reg_enum(struct client_info *info, int argc, char *argv[])
{
- fstring full_keyname;
+ char *full_keyname;
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "regenum <key_name>\n");
return;
}
+ full_keyname = argv[1];
+
if (msrpc_reg_enum_key(smb_cli, full_keyname,
reg_display_key,
reg_display_key_info,
@@ -316,7 +318,7 @@ void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
POLICY_HND key_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring key_name;
fstring keyname;
fstring val_name;
@@ -330,12 +332,14 @@ void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "regvalinfo value_name\n");
return;
}
+ full_keyname = argv[1];
+
reg_get_subkey(full_keyname, keyname, val_name);
if (keyname[0] == 0 || val_name[0] == 0)
@@ -402,7 +406,7 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
POLICY_HND key_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring key_name;
/*
@@ -422,12 +426,14 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "regquery key_name\n");
return;
}
+ full_keyname = argv[1];
+
/* open WINREG session. */
res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
@@ -505,11 +511,10 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
POLICY_HND parent_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring keyname;
fstring parent_name;
fstring val_name;
- fstring tmp;
uint32 val_type;
BUFFER3 value;
@@ -523,12 +528,18 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
DEBUG(5, ("cmd_reg_create_val: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 4)
{
- report(out_hnd, "regcreate <val_name> <val_type> <val>\n");
+ report(out_hnd, "regcreate <val_name> <val_type (1|3|4)> <val>\n");
+ report(out_hnd, "(val_type 1=UNISTR, 3=BYTES, 4=DWORD supported\n");
return;
}
+ argc--;
+ argv++;
+
+ full_keyname = argv[0];
+
reg_get_subkey(full_keyname, keyname, val_name);
if (keyname[0] == 0 || val_name[0] == 0)
@@ -537,13 +548,15 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
return;
}
- if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
+ if (argc < 2)
{
- report(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
return;
}
- val_type = atoi(tmp);
+ argc--;
+ argv++;
+
+ val_type = atoi(argv[0]);
if (val_type != 1 && val_type != 3 && val_type != 4)
{
@@ -551,36 +564,24 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
return;
}
- if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- report(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
- return;
- }
+ argc--;
+ argv++;
switch (val_type)
{
case 0x01: /* UNISTR */
{
- make_buffer3_str(&value, tmp, strlen(tmp)+1);
+ make_buffer3_str(&value, argv[0], strlen(argv[0])+1);
break;
}
case 0x03: /* BYTES */
{
- make_buffer3_hex(&value, tmp);
+ make_buffer3_hex(&value, argv[0]);
break;
}
case 0x04: /* DWORD */
{
- uint32 tmp_val;
- if (strnequal(tmp, "0x", 2))
- {
- tmp_val = strtol(tmp, (char**)NULL, 16);
- }
- else
- {
- tmp_val = strtol(tmp, (char**)NULL, 10);
- }
- make_buffer3_uint32(&value, tmp_val);
+ make_buffer3_uint32(&value, get_number(argv[0]));
break;
}
default:
@@ -653,19 +654,21 @@ void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
POLICY_HND parent_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring keyname;
fstring parent_name;
fstring val_name;
DEBUG(5, ("cmd_reg_delete_val: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "regdelete <val_name>\n");
return;
}
+ full_keyname = argv[1];
+
reg_get_subkey(full_keyname, keyname, val_name);
if (keyname[0] == 0 || val_name[0] == 0)
@@ -730,19 +733,21 @@ void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
POLICY_HND parent_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring parent_name;
fstring key_name;
fstring subkey_name;
DEBUG(5, ("cmd_reg_delete_key: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "regdeletekey <key_name>\n");
return;
}
+ full_keyname = argv[1];
+
reg_get_subkey(full_keyname, parent_name, subkey_name);
if (parent_name[0] == 0 || subkey_name[0] == 0)
@@ -811,7 +816,7 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
POLICY_HND parent_pol;
POLICY_HND key_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring parent_key;
fstring parent_name;
fstring key_name;
@@ -820,12 +825,14 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
DEBUG(5, ("cmd_reg_create_key: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "regcreate <key_name> [key_class]\n");
return;
}
+ full_keyname = argv[1];
+
reg_get_subkey(full_keyname, parent_key, key_name);
if (parent_key[0] == 0 || key_name[0] == 0)
@@ -834,7 +841,11 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
return;
}
- if (!next_token(NULL, key_class, NULL, sizeof(key_class)))
+ if (argc < 3)
+ {
+ fstrcpy(key_class, argv[2]);
+ }
+ else
{
memset(key_class, 0, sizeof(key_class));
}
@@ -905,7 +916,7 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
POLICY_HND key_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring key_name;
/*
@@ -917,12 +928,14 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "reggetsec <key_name>\n");
return;
}
+ full_keyname = argv[1];
+
/* open WINREG session. */
res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
@@ -1007,7 +1020,7 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
POLICY_HND key_pol;
POLICY_HND pol_con;
- fstring full_keyname;
+ char *full_keyname;
fstring key_name;
/*
@@ -1019,12 +1032,14 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
+ if (argc < 2)
{
report(out_hnd, "reggetsec <key_name>\n");
return;
}
+ full_keyname = argv[1];
+
/* open WINREG session. */
res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
@@ -1102,35 +1117,52 @@ void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
BOOL res = True;
fstring msg;
- fstring tmp;
uint32 timeout = 20;
uint16 flgs = 0;
+ int opt;
DEBUG(5, ("cmd_reg_shutdown: smb_cli->fd:%d\n", smb_cli->fd));
- while (next_token(NULL, tmp, NULL, sizeof(tmp)))
+ argc--;
+ argv++;
+
+ while ((opt = getopt(argc, argv,"fim:t:r-")) != EOF)
{
- if (strequal(tmp, "-m"))
+ switch (opt)
{
- if (next_token(NULL, msg, NULL, sizeof(msg)))
+ case 'm':
{
- continue;
+ safe_strcpy(msg, optarg, sizeof(msg)-1);
+ break;
}
- }
- else if (strequal(tmp, "-t"))
- {
- if (next_token(NULL, tmp, NULL, sizeof(tmp)))
+ case 't':
{
- timeout = atoi(tmp);
- continue;
+ timeout = atoi(optarg);
+ break;
+ }
+ case 'r':
+ {
+ flgs |= 0x100;
+ break;
+ }
+ case 'f':
+ {
+ flgs |= 0x100;
+ break;
+ }
+ case '-':
+ {
+ if (strequal(optarg, "-reboot"))
+ {
+ flgs |= 0x100;
+ }
+ if (strequal(optarg, "-force-close"))
+ {
+ flgs |= 0x001;
+ }
+ break;
}
}
- else if (strequal(tmp, "-r") || strequal(tmp, "--reboot"))
- {
- flgs = 0x100;
- continue;
- }
- report(out_hnd,"shutdown [-m msg] [-t timeout] [-r or --reboot]\n");
}
/* open WINREG session. */
@@ -1153,4 +1185,3 @@ void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
report(out_hnd,"Failed\n");
}
}
-
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 4888e720b1..33890749ea 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -200,7 +200,7 @@ commands[] =
{
"shutdown",
cmd_reg_shutdown,
- "[-m message] [-t timeout] [-r or --reboot] Server Shutdown",
+ "[-m message] [-t timeout] [-r or --reboot] [-f or --force-close] Remote Shutdown",
{COMPL_NONE, COMPL_NONE}
},
{