From 6bf6e5364a9ad3e5d8186f1226c83ecf16637a37 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 18 Sep 2019 13:37:32 -0700 Subject: [PATCH] sharesec: Return NTSTATUS from delete_share_security Signed-off-by: Christof Schmitt Reviewed-by: Jeremy Allison --- source3/include/proto.h | 2 +- source3/lib/sharesec.c | 14 +++++++------- source3/utils/sharesec.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index effa2778c0e..223f45b69ee 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -144,7 +144,7 @@ struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *ser size_t *psize); NTSTATUS set_share_security(const char *share_name, struct security_descriptor *psd); -bool delete_share_security(const char *servicename); +NTSTATUS delete_share_security(const char *servicename); bool share_access_check(const struct security_token *token, const char *sharename, uint32_t desired_access, diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 1822cec3df2..acbdd8b5df9 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -410,27 +410,27 @@ NTSTATUS set_share_security(const char *share_name, Delete a security descriptor. ********************************************************************/ -bool delete_share_security(const char *servicename) +NTSTATUS delete_share_security(const char *servicename) { TDB_DATA kbuf; char *key; NTSTATUS status; char *c_servicename = canonicalize_servicename(talloc_tos(), servicename); - if (!c_servicename) { - return NULL; + if (c_servicename == NULL) { + return NT_STATUS_INVALID_PARAMETER; } status = share_info_db_init(); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(c_servicename); - return False; + return status; } if (!(key = talloc_asprintf(talloc_tos(), SHARE_SECURITY_DB_KEY_PREFIX_STR "%s", c_servicename))) { TALLOC_FREE(c_servicename); - return False; + return NT_STATUS_NO_MEMORY; } kbuf = string_term_tdb_data(key); @@ -439,11 +439,11 @@ bool delete_share_security(const char *servicename) DEBUG(0, ("delete_share_security: Failed to delete entry for " "share %s: %s\n", c_servicename, nt_errstr(status))); TALLOC_FREE(c_servicename); - return False; + return status; } TALLOC_FREE(c_servicename); - return True; + return NT_STATUS_OK; } /******************************************************************* diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index 96ac50929a3..d22f96be5eb 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -246,7 +246,8 @@ static int change_share_sec(TALLOC_CTX *mem_ctx, const char *sharename, char *th old = sd; break; case SMB_SD_DELETE: - if (!delete_share_security(sharename)) { + status = delete_share_security(sharename); + if (!NT_STATUS_IS_OK(status)) { fprintf( stderr, "Failed to delete security descriptor for " "share [%s]\n", sharename ); return -1; -- 2.47.3