From 9325bd5003e5baa238c2e4dc2a9989e9f835b79c Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 14 May 2020 07:04:42 +0000 Subject: ntux_cmd_chmod(): properly set errno upon non-system-call failure. --- src/cmds/ntux_cmd_chmod.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/cmds/ntux_cmd_chmod.c b/src/cmds/ntux_cmd_chmod.c index b90acfe..be93f83 100644 --- a/src/cmds/ntux_cmd_chmod.c +++ b/src/cmds/ntux_cmd_chmod.c @@ -155,9 +155,10 @@ int ntux_cmd_chmod(const struct ntux_driver_ctx * dctx, const char * dunit) NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE | NT_FILE_SHARE_DELETE))) - return ntux_cmd_chmod_ret( - fd,ofd,0, - NTUX_SYSTEM_ERROR(dctx)); + if (ntux_errno_set(dctx,EACCES)) + return ntux_cmd_chmod_ret( + fd,ofd,0, + NTUX_SYSTEM_ERROR(dctx)); /* srcsd */ srcsd = (nt_sd *)buf; @@ -168,16 +169,18 @@ int ntux_cmd_chmod(const struct ntux_driver_ctx * dctx, const char * dunit) | NT_GROUP_SECURITY_INFORMATION | NT_DACL_SECURITY_INFORMATION, srcsd,sizeof(buf),&size))) - return ntux_cmd_chmod_ret( - fd,ofd,hasync, - NTUX_SYSTEM_ERROR(dctx)); + if (ntux_errno_set(dctx,ENXIO)) + return ntux_cmd_chmod_ret( + fd,ofd,hasync, + NTUX_SYSTEM_ERROR(dctx)); if ((status = __xfi_acl_init_common_descriptor_meta( &meta,srcsd, NT_ACL_INIT_COMMON_DESCRIPTION_META_STRICT_MODE))) - return ntux_cmd_chmod_ret( - fd,ofd,hasync, - NTUX_SYSTEM_ERROR(dctx)); + if (ntux_errno_set(dctx,EBADF)) + return ntux_cmd_chmod_ret( + fd,ofd,hasync, + NTUX_SYSTEM_ERROR(dctx)); /* source permissions */ access_owner = meta.owner_ace ? meta.owner_ace->mask : 0; @@ -208,9 +211,10 @@ int ntux_cmd_chmod(const struct ntux_driver_ctx * dctx, const char * dunit) if ((status = __xfi_set_security_object( hasync,sec_mask,&dstsd.sd))) - return ntux_cmd_chmod_ret( - fd,ofd,hasync, - NTUX_SYSTEM_ERROR(dctx)); + if (ntux_errno_set(dctx,EPERM)) + return ntux_cmd_chmod_ret( + fd,ofd,hasync, + NTUX_SYSTEM_ERROR(dctx)); /* changes */ (void)fdout; -- cgit v1.2.3