summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2002-12-30 04:41:27 +0000
committerSimo Sorce <idra@samba.org>2002-12-30 04:41:27 +0000
commit60667264b71d624ec45f567170b85589992567ed (patch)
treec9ccce0ff9c95e8ae9f3059408915eb37b6c73f4
parentb68e6c99103fd0f1e8a25b2fafe14d7540b2ab10 (diff)
downloadsamba-60667264b71d624ec45f567170b85589992567ed.tar.gz
samba-60667264b71d624ec45f567170b85589992567ed.tar.xz
samba-60667264b71d624ec45f567170b85589992567ed.zip
the shutdown call does not have a 16 bit flags, but 2 byte representing booleans
this commit change the structure and code to reflect this some test revelead I'm right. some other revelead currently the abort shutdown does not work against my test machine even if it returns successfully ... need investigation (This used to be commit c5892b656dedd0367adc33d9606311d1dde99a58)
-rw-r--r--source3/include/rpc_reg.h7
-rw-r--r--source3/rpc_client/cli_reg.c5
-rw-r--r--source3/rpc_parse/parse_reg.c12
-rw-r--r--source3/rpc_server/srv_reg_nt.c4
-rw-r--r--source3/rpcclient/cmd_reg.c35
5 files changed, 31 insertions, 32 deletions
diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h
index 92175cf287b..33134e8834d 100644
--- a/source3/include/rpc_reg.h
+++ b/source3/include/rpc_reg.h
@@ -85,10 +85,6 @@
#define REG_FULL_RESOURCE_DESCRIPTOR 9
#define REG_RESOURCE_REQUIREMENTS_LIST 10
-/* Shutdown options */
-#define REG_FORCE_SHUTDOWN 0x001
-#define REG_REBOOT_ON_SHUTDOWN 0x100
-
/* structure to contain registry values */
typedef struct {
@@ -616,7 +612,8 @@ typedef struct q_reg_shutdown_info
UNIHDR hdr_msg; /* shutdown message */
UNISTR2 uni_msg; /* seconds */
uint32 timeout; /* seconds */
- uint16 flags;
+ uint8 force; /* boolean: force shutdown */
+ uint8 reboot; /* boolean: reboot on shutdown */
} REG_Q_SHUTDOWN;
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index aaf18882f76..1e832954145 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -28,7 +28,8 @@
/* Shutdown a server */
NTSTATUS cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
- const char *msg, uint32 timeout, uint16 flags)
+ const char *msg, uint32 timeout, BOOL reboot,
+ BOOL force)
{
prs_struct qbuf;
prs_struct rbuf;
@@ -46,7 +47,7 @@ NTSTATUS cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
/* Marshall data and send request */
- init_reg_q_shutdown(&q_s, msg, timeout, flags);
+ init_reg_q_shutdown(&q_s, msg, timeout, reboot, force);
if (!reg_io_q_shutdown("", &q_s, &qbuf, 0) ||
!rpc_api_pipe_req(cli, REG_SHUTDOWN, &qbuf, &rbuf))
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index 2698e824407..7bb8a6e2b46 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -1736,8 +1736,8 @@ BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int
/*******************************************************************
Inits a structure.
********************************************************************/
-void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s,
- const char *msg, uint32 timeout, uint16 flags)
+void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg,
+ uint32 timeout, BOOL reboot, BOOL force)
{
int msg_len;
msg_len = strlen(msg);
@@ -1750,7 +1750,9 @@ void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s,
init_unistr2(&(q_s->uni_msg), msg, msg_len);
q_s->timeout = timeout;
- q_s->flags = flags;
+
+ q_s->reboot = reboot ? 1 : 0;
+ q_s->force = force ? 1 : 0;
}
@@ -1785,7 +1787,9 @@ BOOL reg_io_q_shutdown(char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
return False;
- if (!prs_uint16("flags ", ps, depth, &(q_s->flags)))
+ if (!prs_uint8("force ", ps, depth, &(q_s->force)))
+ return False;
+ if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
return False;
return True;
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c
index 7435bdb6f79..215d4684044 100644
--- a/source3/rpc_server/srv_reg_nt.c
+++ b/source3/rpc_server/srv_reg_nt.c
@@ -590,9 +590,9 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u
/* timeout */
snprintf(timeout, sizeof(timeout), "%d", q_u->timeout);
/* reboot */
- snprintf(r, sizeof(r), (q_u->flags & REG_REBOOT_ON_SHUTDOWN)?SHUTDOWN_R_STRING:"");
+ snprintf(r, sizeof(r), (q_u->reboot) ? SHUTDOWN_R_STRING : "");
/* force */
- snprintf(f, sizeof(f), (q_u->flags & REG_FORCE_SHUTDOWN)?SHUTDOWN_F_STRING:"");
+ snprintf(f, sizeof(f), (q_u->force) ? SHUTDOWN_F_STRING : "");
pstrcpy(shutdown_script, lp_shutdown_script());
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index e0a3201aa90..5d29b4c51ab 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -900,7 +900,8 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, TALLOC_CTX *mem_ctx,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
fstring msg;
uint32 timeout = 20;
- uint16 flgs = 0;
+ BOOL force = False;
+ BOOL reboot = False;
int opt;
*msg = 0;
@@ -908,37 +909,33 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, TALLOC_CTX *mem_ctx,
while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
{
- fprintf (stderr, "[%s]\n", argv[argc-1]);
+ /*fprintf (stderr, "[%s]\n", argv[argc-1]);*/
switch (opt)
{
case 'm':
- {
safe_strcpy(msg, optarg, sizeof(msg)-1);
- fprintf (stderr, "[%s|%s]\n", optarg, msg);
+ /*fprintf (stderr, "[%s|%s]\n", optarg, msg);*/
break;
- }
+
case 't':
- {
timeout = atoi(optarg);
- fprintf (stderr, "[%s|%d]\n", optarg, timeout);
- break;
- }
+ /*fprintf (stderr, "[%s|%d]\n", optarg, timeout);*/
+ break;
+
case 'r':
- {
- flgs |= 0x100;
- break;
- }
+ reboot = True;
+ break;
+
case 'f':
- {
- flgs |= 0x001;
+ force = True;
break;
- }
+
}
}
/* create an entry */
- result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, flgs);
+ result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, reboot, force);
if (NT_STATUS_IS_OK(result))
DEBUG(5,("cmd_reg_shutdown: query succeeded\n"));
@@ -974,10 +971,10 @@ struct cmd_set reg_commands[] = {
{ "REG" },
{ "shutdown", cmd_reg_shutdown, PI_WINREG, "Remote Shutdown",
- "[-m message] [-t timeout] [-r] [-f] (-r == reboot, -f == force)" },
+ "syntax: shutdown [-m message] [-t timeout] [-r] [-h] [-f] (-r == reboot, -h == halt, -f == force)" },
{ "abortshutdown", cmd_reg_abort_shutdown, PI_WINREG, "Abort Shutdown",
- "" },
+ "syntax: abortshutdown" },
/*
{ "regenum", cmd_reg_enum, "Registry Enumeration",
"<keyname>" },