summaryrefslogtreecommitdiff
path: root/examples/libmsrpc/test/reg/shutdown.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-09-03 16:55:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:03:30 -0500
commit3c6b0f965588aab0edbc4d115fb9e72c884ded3b (patch)
treece3740784555e729297955c924e4701feaf69d38 /examples/libmsrpc/test/reg/shutdown.c
parenta44e97c99f61916db3f7cc02cd2581c8d64be73a (diff)
downloadsamba-3c6b0f965588aab0edbc4d115fb9e72c884ded3b.tar.gz
samba-3c6b0f965588aab0edbc4d115fb9e72c884ded3b.tar.bz2
samba-3c6b0f965588aab0edbc4d115fb9e72c884ded3b.zip
r10003: in the rush for 10k, I forgot to run add the rest of Chris' libmsrpc files
(This used to be commit 32bebc452dffa8348b94c5b866350b1fe761986f)
Diffstat (limited to 'examples/libmsrpc/test/reg/shutdown.c')
-rw-r--r--examples/libmsrpc/test/reg/shutdown.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/examples/libmsrpc/test/reg/shutdown.c b/examples/libmsrpc/test/reg/shutdown.c
new file mode 100644
index 0000000000..6184fbd976
--- /dev/null
+++ b/examples/libmsrpc/test/reg/shutdown.c
@@ -0,0 +1,68 @@
+/*tries to shut down a remote pc*/
+
+#include "libmsrpc.h"
+#include "test_util.h"
+
+
+int main(int argc, char **argv) {
+ CacServerHandle *hnd = NULL;
+ TALLOC_CTX *mem_ctx = NULL;
+
+ fstring tmp;
+
+ mem_ctx = talloc_init("cac_shutdown");
+
+ hnd = cac_NewServerHandle(True);
+
+ cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
+
+ cac_parse_cmd_line(argc, argv, hnd);
+
+ hnd->_internal.srv_level = SRV_WIN_NT4;
+
+ if(!cac_Connect(hnd, NULL)) {
+ fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
+ exit(-1);
+ }
+
+ struct Shutdown s;
+ ZERO_STRUCT(s);
+
+ printf("Message: ");
+ cactest_readline(stdin, tmp);
+
+ s.in.message = talloc_strdup(mem_ctx, tmp);
+
+ printf("timeout: ");
+ scanf("%d", &s.in.timeout);
+
+ printf("Reboot? [y/n]: ");
+ cactest_readline(stdin, tmp);
+
+ s.in.reboot = ( tmp[0] == 'y') ? True : False;
+
+ printf("Force? [y/n]: ");
+ cactest_readline(stdin, tmp);
+
+ s.in.force = (tmp[0] == 'y') ? True : False;
+
+ if(!cac_Shutdown(hnd, mem_ctx, &s)) {
+ fprintf(stderr, "could not shut down server: error %s\n", nt_errstr(hnd->status));
+ goto done;
+ }
+
+ printf("Server %s is shutting down. Would you like to try to abort? [y/n]: ", hnd->server);
+ fscanf(stdin, "%s", tmp);
+
+ if(tmp[0] == 'y') {
+ if(!cac_AbortShutdown(hnd, mem_ctx)) {
+ fprintf(stderr, "Could not abort shutdown. Error %s\n", nt_errstr(hnd->status));
+ }
+ }
+
+done:
+ cac_FreeHandle(hnd);
+ talloc_destroy(mem_ctx);
+
+ return 0;
+}