r25598: Add missing become_root/unbecome_root around calls of add_aliases.
[Samba/gebeck_regimport.git] / examples / libmsrpc / test / reg / shutdown.c
blob6184fbd97623916b5dd914ca829dfcd23ca506cc
1 /*tries to shut down a remote pc*/
3 #include "libmsrpc.h"
4 #include "test_util.h"
7 int main(int argc, char **argv) {
8 CacServerHandle *hnd = NULL;
9 TALLOC_CTX *mem_ctx = NULL;
11 fstring tmp;
13 mem_ctx = talloc_init("cac_shutdown");
15 hnd = cac_NewServerHandle(True);
17 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
19 cac_parse_cmd_line(argc, argv, hnd);
21 hnd->_internal.srv_level = SRV_WIN_NT4;
23 if(!cac_Connect(hnd, NULL)) {
24 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
25 exit(-1);
28 struct Shutdown s;
29 ZERO_STRUCT(s);
31 printf("Message: ");
32 cactest_readline(stdin, tmp);
34 s.in.message = talloc_strdup(mem_ctx, tmp);
36 printf("timeout: ");
37 scanf("%d", &s.in.timeout);
39 printf("Reboot? [y/n]: ");
40 cactest_readline(stdin, tmp);
42 s.in.reboot = ( tmp[0] == 'y') ? True : False;
44 printf("Force? [y/n]: ");
45 cactest_readline(stdin, tmp);
47 s.in.force = (tmp[0] == 'y') ? True : False;
49 if(!cac_Shutdown(hnd, mem_ctx, &s)) {
50 fprintf(stderr, "could not shut down server: error %s\n", nt_errstr(hnd->status));
51 goto done;
54 printf("Server %s is shutting down. Would you like to try to abort? [y/n]: ", hnd->server);
55 fscanf(stdin, "%s", tmp);
57 if(tmp[0] == 'y') {
58 if(!cac_AbortShutdown(hnd, mem_ctx)) {
59 fprintf(stderr, "Could not abort shutdown. Error %s\n", nt_errstr(hnd->status));
63 done:
64 cac_FreeHandle(hnd);
65 talloc_destroy(mem_ctx);
67 return 0;