Fix a bunch of compiler warnings about wrong format types.
[ira/wip.git] / source3 / utils / net_rpc.c
index 845ceca57356cf1f1909f370f7c2bfd87a2c825e..4de4bef837a16847319b48e5cdb50cdbd92c5820 100644 (file)
@@ -4088,8 +4088,8 @@ static bool get_user_sids(const char *domain, const char *user, NT_USER_TOKEN *t
 
                wbc_status = wbcGidToSid(gid, &wsid);
                if (!WBC_ERROR_IS_OK(wbc_status)) {
-                       DEBUG(1, ("winbind could not find SID of gid %d: %s\n",
-                                 gid, wbcErrorString(wbc_status)));
+                       DEBUG(1, ("winbind could not find SID of gid %u: %s\n",
+                                 (unsigned int)gid, wbcErrorString(wbc_status)));
                        wbcFreeMemory(groups);
                        return false;
                }
@@ -4249,7 +4249,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
                        int num_tokens,
                        struct user_token *tokens)
 {
-       int fnum;
+       uint16_t fnum;
        SEC_DESC *share_sd = NULL;
        SEC_DESC *root_sd = NULL;
        struct cli_state *cli = rpc_pipe_np_smb_conn(pipe_hnd);
@@ -4284,9 +4284,8 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
                return;
        }
 
-       fnum = cli_nt_create(cli, "\\", READ_CONTROL_ACCESS);
-
-       if (fnum != -1) {
+       if (!NT_STATUS_IS_OK(cli_ntcreate(cli, "\\", 0, READ_CONTROL_ACCESS, 0,
+                       FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
                root_sd = cli_query_secdesc(cli, fnum, mem_ctx);
        }
 
@@ -4320,7 +4319,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
                d_printf(" %s\n", tokens[i].name);
        }
 
-       if (fnum != -1)
+       if (fnum != (uint16_t)-1)
                cli_close(cli, fnum);
        cli_tdis(cli);
        cli->cnum = cnum;
@@ -5596,7 +5595,7 @@ static int rpc_trustdom_establish(struct net_context *c, int argc,
                return -1;
        }
 
-       nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_RIGHTS_QUERY_VALUE,
+       nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, KEY_QUERY_VALUE,
                                         &connect_hnd);
        if (NT_STATUS_IS_ERR(nt_status)) {
                DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
@@ -5854,7 +5853,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                return -1;
        };
 
-       nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, SEC_RIGHTS_QUERY_VALUE,
+       nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, KEY_QUERY_VALUE,
                                        &connect_hnd);
        if (NT_STATUS_IS_ERR(nt_status)) {
                DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
@@ -6011,7 +6010,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                return -1;
        };
 
-       nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, SEC_RIGHTS_QUERY_VALUE,
+       nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, KEY_QUERY_VALUE,
                                        &connect_hnd);
        if (NT_STATUS_IS_ERR(nt_status)) {
                DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
@@ -7004,6 +7003,8 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv)
 
 int net_rpc(struct net_context *c, int argc, const char **argv)
 {
+       NET_API_STATUS status;
+
        struct functable func[] = {
                {
                        "audit",
@@ -7184,5 +7185,16 @@ int net_rpc(struct net_context *c, int argc, const char **argv)
                },
                {NULL, NULL, 0, NULL, NULL}
        };
+
+       status = libnetapi_init(&c->netapi_ctx);
+       if (status != 0) {
+               return -1;
+       }
+       libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
+       libnetapi_set_password(c->netapi_ctx, c->opt_password);
+       if (c->opt_kerberos) {
+               libnetapi_set_use_kerberos(c->netapi_ctx);
+       }
+
        return net_run_function(c, argc, argv, "net rpc", func);
 }