summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Baumbach <bb@sernet.de>2011-07-22 15:11:31 +0200
committerStefan Metzmacher <metze@samba.org>2011-07-23 09:18:57 +0200
commitcb4fc9217727c14cc5f92acf99160b7612974850 (patch)
tree2c6fd13698f8e25e43d45a9c95c34e8e4e0ca141
parent768646c9a23c3b2d295af77826e82d3087076e36 (diff)
downloadsamba-cb4fc9217727c14cc5f92acf99160b7612974850.tar.gz
samba-cb4fc9217727c14cc5f92acf99160b7612974850.tar.bz2
samba-cb4fc9217727c14cc5f92acf99160b7612974850.zip
s3-libsmb: introduce new cli_query_secdesc() which returns NTSTATUS
Replacement for cli_query_secdesc_old() Signed-off-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source3/libsmb/clisecdesc.c50
-rw-r--r--source3/libsmb/proto.h2
2 files changed, 52 insertions, 0 deletions
diff --git a/source3/libsmb/clisecdesc.c b/source3/libsmb/clisecdesc.c
index 71358e8612..1e95043c36 100644
--- a/source3/libsmb/clisecdesc.c
+++ b/source3/libsmb/clisecdesc.c
@@ -69,6 +69,56 @@ struct security_descriptor *cli_query_secdesc_old(struct cli_state *cli, uint16_
return psd;
}
+NTSTATUS cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
+ TALLOC_CTX *mem_ctx, struct security_descriptor **sd)
+{
+ uint8_t param[8];
+ uint8_t *rdata=NULL;
+ uint32_t rdata_count=0;
+ NTSTATUS status;
+ struct security_descriptor *lsd;
+
+ SIVAL(param, 0, fnum);
+ SIVAL(param, 4, 0x7);
+
+ 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, /* recv_flags2 */
+ NULL, 0, NULL, /* rsetup, length */
+ NULL, 0, NULL,
+ &rdata, 0, &rdata_count);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("NT_TRANSACT_QUERY_SECURITY_DESC failed: %s\n",
+ nt_errstr(status)));
+ goto cleanup;
+ }
+
+ status = unmarshall_sec_desc(mem_ctx, (uint8 *)rdata, rdata_count,
+ &lsd);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("unmarshall_sec_desc failed: %s\n",
+ nt_errstr(status)));
+ goto cleanup;
+ }
+
+ if (sd != NULL) {
+ *sd = lsd;
+ } else {
+ TALLOC_FREE(lsd);
+ }
+
+ cleanup:
+
+ TALLOC_FREE(rdata);
+
+ return status;
+}
+
/****************************************************************************
set the security descriptor for a open file
****************************************************************************/
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 7b2dc8c583..195bc75d14 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -787,6 +787,8 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
struct security_descriptor *cli_query_secdesc_old(struct cli_state *cli, uint16_t fnum,
TALLOC_CTX *mem_ctx);
+NTSTATUS cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
+ TALLOC_CTX *mem_ctx, struct security_descriptor **sd);
NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
struct security_descriptor *sd);