00001
00002
00003 #include "libmsrpc.h"
00004 #include "test_util.h"
00005
00006 int main(int argc, char **argv) {
00007 CacServerHandle *hnd = NULL;
00008 TALLOC_CTX *mem_ctx = NULL;
00009
00010 fstring tmp;
00011
00012 mem_ctx = talloc_init("regsetval");
00013
00014 hnd = cac_NewServerHandle(True);
00015
00016 cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
00017
00018 cac_parse_cmd_line(argc, argv, hnd);
00019
00020 if(!cac_Connect(hnd, NULL)) {
00021 fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
00022 exit(-1);
00023 }
00024
00025 struct RegOpenKey rok;
00026 ZERO_STRUCT(rok);
00027
00028 printf("enter key to query: ");
00029 cactest_readline(stdin, tmp);
00030
00031 rok.in.name = talloc_strdup(mem_ctx, tmp);
00032 rok.in.access = REG_KEY_ALL;
00033
00034 if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
00035 fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status));
00036 exit(-1);
00037 }
00038
00039 struct RegGetKeySecurity rks;
00040 ZERO_STRUCT(rks);
00041
00042 rks.in.key = rok.out.key;
00043 rks.in.info_type = ALL_SECURITY_INFORMATION;
00044
00045 if(!cac_RegGetKeySecurity(hnd, mem_ctx, &rks)) {
00046 fprintf(stderr, "Could not query security for %s. Error: %s\n", rok.in.name, nt_errstr(hnd->status));
00047 goto done;
00048 }
00049
00050 printf("resetting key security...\n");
00051
00052 struct RegSetKeySecurity rss;
00053 ZERO_STRUCT(rss);
00054
00055 rss.in.key = rok.out.key;
00056 rss.in.info_type = ALL_SECURITY_INFORMATION;
00057 rss.in.size = rks.out.size;
00058 rss.in.descriptor = rks.out.descriptor;
00059
00060 if(!cac_RegSetKeySecurity(hnd, mem_ctx, &rss)) {
00061 fprintf(stderr, "Could not set security. Error %s\n", nt_errstr(hnd->status));
00062 }
00063
00064 done:
00065 cac_RegClose(hnd, mem_ctx, rok.out.key);
00066
00067 cac_FreeHandle(hnd);
00068
00069 talloc_destroy(mem_ctx);
00070
00071 return 0;
00072 }
00073
00074