s3-security: use shared SECINFO_OWNER define.
[ira/wip.git] / source3 / libsmb / clisecdesc.c
index adc6fba9afa767d3ab706f75016e6ae498fa9a14..5f404d97b332fa58d7b497942be900523b107992 100644 (file)
 /****************************************************************************
   query the security descriptor for a open file
  ****************************************************************************/
-SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum, 
+struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
                            TALLOC_CTX *mem_ctx)
 {
-       char param[8];
-       char *rparam=NULL, *rdata=NULL;
-       unsigned int rparam_count=0, rdata_count=0;
-       SEC_DESC *psd = NULL;
+       uint8_t param[8];
+       uint8_t *rdata=NULL;
+       uint32_t rdata_count=0;
+       struct security_descriptor *psd = NULL;
        NTSTATUS status;
 
        SIVAL(param, 0, fnum);
        SIVAL(param, 4, 0x7);
 
-       if (!cli_send_nt_trans(cli, 
-                              NT_TRANSACT_QUERY_SECURITY_DESC, 
-                              0, 
-                              NULL, 0, 0,
-                              param, 8, 4,
-                              NULL, 0, 0x10000)) {
-               DEBUG(1,("Failed to send NT_TRANSACT_QUERY_SECURITY_DESC\n"));
-               goto cleanup;
-       }
-
+       status = cli_trans(talloc_tos(), cli, SMBnttrans,
+                          NULL, -1, /* name, fid */
+                          NT_TRANSACT_QUERY_SECURITY_DESC, 0, /* function, flags */
+                          NULL, 0, 0, /* setup, length, max */
+                          param, 8, 4, /* param, length, max */
+                          NULL, 0, 0x10000, /* data, length, max */
+                          NULL, 0, NULL, /* rsetup, length */
+                          NULL, 0, NULL,
+                          &rdata, 0, &rdata_count);
 
-       if (!cli_receive_nt_trans(cli, 
-                                 &rparam, &rparam_count,
-                                 &rdata, &rdata_count)) {
-               DEBUG(1,("Failed to recv NT_TRANSACT_QUERY_SECURITY_DESC\n"));
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("NT_TRANSACT_QUERY_SECURITY_DESC failed: %s\n",
+                         nt_errstr(status)));
                goto cleanup;
        }
 
-       if (cli_is_error(cli))
-               goto cleanup;
-
        status = unmarshall_sec_desc(mem_ctx, (uint8 *)rdata, rdata_count,
                                     &psd);
 
@@ -66,8 +61,7 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
 
  cleanup:
 
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
+       TALLOC_FREE(rdata);
 
        return psd;
 }
@@ -75,7 +69,7 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
 /****************************************************************************
   set the security descriptor for a open file
  ****************************************************************************/
-bool cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
+bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, struct security_descriptor *sd)
 {
        char param[8];
        char *rparam=NULL, *rdata=NULL;
@@ -99,7 +93,7 @@ bool cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
        if (sd->dacl)
                sec_info |= DACL_SECURITY_INFORMATION;
        if (sd->owner_sid)
-               sec_info |= OWNER_SECURITY_INFORMATION;
+               sec_info |= SECINFO_OWNER;
        if (sd->group_sid)
                sec_info |= GROUP_SECURITY_INFORMATION;
        SSVAL(param, 4, sec_info);