Merge from HEAD - idra's fix for the fact that the shutdown command takes two 1
authorAndrew Bartlett <abartlet@samba.org>
Sat, 4 Jan 2003 07:50:04 +0000 (07:50 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 4 Jan 2003 07:50:04 +0000 (07:50 +0000)
byte boolean flags, not a 16 bit bitmask.

Andrew Bartlett
(This used to be commit a4f7777ca08c732ace2ba60bc0ecffbea1239fc3)

source3/include/rpc_reg.h
source3/rpc_client/cli_reg.c
source3/rpcclient/cmd_reg.c
source3/utils/net_rpc.c

index 9ab24e30c62bc46b3b9bf566e90c1cd31538b0f1..46ec88283df35bad85eadc28c339e354263184ae 100644 (file)
 #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;
 
index aaf18882f7622d62c8455830f98e8c6df0137c3c..1e83295414541869441f8144410bef3f7ee026fa 100644 (file)
@@ -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))
index e0a3201aa903e556d8177418cff54da93533d9f0..5d29b4c51ab1a720bbc492dfdf042528cb22fe8d 100644 (file)
@@ -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>" },
index e0390a1afbb7ed61613fd0d0e2122489250b845c..60adcfdf6e2967af0c2a4baeab4a5c7a1ca9286c 100644 (file)
@@ -1444,9 +1444,6 @@ static NTSTATUS rpc_shutdown_internals(const DOM_SID *domain_sid, struct cli_sta
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
         const char *msg = "This machine will be shutdown shortly";
        uint32 timeout = 20;
-       uint16 flgs = 0;
-       BOOL reboot = opt_reboot;
-       BOOL force = opt_force;
 #if 0
        poptContext pc;
        int rc;
@@ -1472,12 +1469,6 @@ static NTSTATUS rpc_shutdown_internals(const DOM_SID *domain_sid, struct cli_sta
                return NT_STATUS_INVALID_PARAMETER;
        }
 #endif
-       if (reboot) {
-               flgs |= REG_REBOOT_ON_SHUTDOWN;
-       }
-       if (force) {
-               flgs |= REG_FORCE_SHUTDOWN;
-       }
        if (opt_comment) {
                msg = opt_comment;
        }
@@ -1486,7 +1477,7 @@ static NTSTATUS rpc_shutdown_internals(const DOM_SID *domain_sid, struct cli_sta
        }
 
        /* create an entry */
-       result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, flgs);
+       result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, opt_reboot, opt_force);
 
        if (NT_STATUS_IS_OK(result))
                DEBUG(5,("Shutdown of remote machine succeeded\n"));