1 /*tries to shut down a remote pc*/
7 int main(int argc
, char **argv
) {
8 CacServerHandle
*hnd
= NULL
;
9 TALLOC_CTX
*mem_ctx
= NULL
;
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
));
32 cactest_readline(stdin
, tmp
);
34 s
.in
.message
= talloc_strdup(mem_ctx
, tmp
);
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
));
54 printf("Server %s is shutting down. Would you like to try to abort? [y/n]: ", hnd
->server
);
55 fscanf(stdin
, "%s", tmp
);
58 if(!cac_AbortShutdown(hnd
, mem_ctx
)) {
59 fprintf(stderr
, "Could not abort shutdown. Error %s\n", nt_errstr(hnd
->status
));
65 talloc_destroy(mem_ctx
);