struct security_descriptor *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32_t def_access);
struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *servicename,
size_t *psize);
-bool set_share_security(const char *share_name, struct security_descriptor *psd);
+NTSTATUS set_share_security(const char *share_name,
+ struct security_descriptor *psd);
bool delete_share_security(const char *servicename);
bool share_access_check(const struct security_token *token,
const char *sharename,
Store a security descriptor in the share db.
********************************************************************/
-bool set_share_security(const char *share_name, struct security_descriptor *psd)
+NTSTATUS set_share_security(const char *share_name,
+ struct security_descriptor *psd)
{
TALLOC_CTX *frame = talloc_stackframe();
char *key;
- bool ret = False;
TDB_DATA blob;
NTSTATUS status;
char *c_share_name = canonicalize_servicename(frame, share_name);
- if (!c_share_name) {
+ if (c_share_name == NULL) {
+ status = NT_STATUS_INVALID_PARAMETER;
goto out;
}
if (!(key = talloc_asprintf(frame, SHARE_SECURITY_DB_KEY_PREFIX_STR "%s", c_share_name))) {
DEBUG(0, ("talloc_asprintf failed\n"));
+ status = NT_STATUS_NO_MEMORY;
goto out;
}
}
DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name ));
- ret = True;
+ status = NT_STATUS_OK;
out:
TALLOC_FREE(frame);
- return ret;
+ return status;
}
/*******************************************************************
char *canon_name = NULL;
bool added_service = false;
int ret = -1;
+ NTSTATUS status;
/* Ensure share name doesn't contain invalid characters. */
if (!validate_net_name(file_name, INVALID_SHARENAME_CHARS, strlen(file_name))) {
{
TDB_DATA data;
- NTSTATUS status;
status = dbwrap_fetch_bystring(ServiceHash, canon_name,
canon_name, &data);
}
/* Write the ACL of the new/modified share. */
- if (!set_share_security(canon_name, psd)) {
+ status = set_share_security(canon_name, psd);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("process_usershare_file: Failed to set share "
"security for user share %s\n",
canon_name ));
DEBUG(2, ("no share SD to clone for %s snapshot\n",
sc_smap->share_name));
} else {
- bool ok;
- ok = set_share_security(sc_smap->sc_share_name, sd);
+ NTSTATUS status;
+ status = set_share_security(sc_smap->sc_share_name, sd);
TALLOC_FREE(sd);
- if (!ok) {
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("failed to set %s share SD\n",
sc_smap->sc_share_name));
err = HRES_ERROR_V(HRES_E_FAIL);
if (psd) {
struct security_descriptor *old_sd;
size_t sd_size;
+ NTSTATUS status;
old_sd = get_share_security(p->mem_ctx, lp_servicename(talloc_tos(), snum), &sd_size);
if (old_sd && !security_descriptor_equal(old_sd, psd)) {
- if (!set_share_security(share_name, psd))
+ status = set_share_security(share_name, psd);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n",
share_name ));
+ }
}
}
return WERR_ACCESS_DENIED;
if (psd) {
+ NTSTATUS status;
/* Note we use share_name here, not share_name_in as
we need a canonicalized name for setting security. */
- if (!set_share_security(share_name, psd)) {
+ status = set_share_security(share_name, psd);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("_srvsvc_NetShareAdd: Failed to add security info to share %s.\n",
share_name ));
}
struct security_descriptor *old = NULL;
size_t sd_size = 0;
uint32_t i, j;
+ NTSTATUS status;
if (mode != SMB_ACL_SET && mode != SMB_SD_DELETE) {
if (!(old = get_share_security( mem_ctx, sharename, &sd_size )) ) {
/* Denied ACE entries must come before allowed ones */
sort_acl(old->dacl);
- if ( !set_share_security( sharename, old ) ) {
+ status = set_share_security(sharename, old);
+ if (!NT_STATUS_IS_OK(status)) {
fprintf( stderr, "Failed to store acl for share [%s]\n", sharename );
return 2;
}
static int set_sharesec_sddl(const char *sharename, const char *sddl)
{
struct security_descriptor *sd;
- bool ret;
+ NTSTATUS status;
sd = sddl_decode(talloc_tos(), sddl, get_global_sam_sid());
if (sd == NULL) {
return -1;
}
- ret = set_share_security(sharename, sd);
+ status = set_share_security(sharename, sd);
TALLOC_FREE(sd);
- if (!ret) {
+ if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, "Failed to store acl for share [%s]\n",
sharename);
return -1;