Skip to content

Commit

Permalink
ksmbd: fix force create mode' and force directory mode'
Browse files Browse the repository at this point in the history
`force create mode' and `force directory mode' should be bitwise ORed
with the perms after `create mask' and `directory mask' have been
applied, respectively.

Signed-off-by: Atte Heikkilä <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
atheik authored and namjaejeon committed Aug 14, 2023
1 parent 0e251e7 commit 7303078
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions mgmt/share_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,22 @@ struct ksmbd_share_config {
#define KSMBD_SHARE_INVALID_UID ((__u16)-1)
#define KSMBD_SHARE_INVALID_GID ((__u16)-1)

static inline int share_config_create_mode(struct ksmbd_share_config *share,
umode_t posix_mode)
static inline umode_t
share_config_create_mode(struct ksmbd_share_config *share,
umode_t posix_mode)
{
if (!share->force_create_mode) {
if (!posix_mode)
return share->create_mask;
else
return posix_mode & share->create_mask;
}
return share->force_create_mode & share->create_mask;
umode_t mode = (posix_mode ?: (umode_t)-1) & share->create_mask;

return mode | share->force_create_mode;
}

static inline int share_config_directory_mode(struct ksmbd_share_config *share,
umode_t posix_mode)
static inline umode_t
share_config_directory_mode(struct ksmbd_share_config *share,
umode_t posix_mode)
{
if (!share->force_directory_mode) {
if (!posix_mode)
return share->directory_mask;
else
return posix_mode & share->directory_mask;
}
umode_t mode = (posix_mode ?: (umode_t)-1) & share->directory_mask;

return share->force_directory_mode & share->directory_mask;
return mode | share->force_directory_mode;
}

static inline int test_share_config_flag(struct ksmbd_share_config *share,
Expand Down

0 comments on commit 7303078

Please sign in to comment.