Commit 777cad16 authored by Namjae Jeon's avatar Namjae Jeon

ksmbd: remove select FS_POSIX_ACL in Kconfig

ksmbd is forcing to turn on FS_POSIX_ACL in Kconfig to use vfs acl
functions(posix_acl_alloc, get_acl, set_posix_acl). OpenWRT and other
platform doesn't use acl and this config is disable by default in
kernel. This patch use IS_ENABLED() to know acl config is enable and use
acl function if it is enable.
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent c6ce2b57
...@@ -19,7 +19,6 @@ config SMB_SERVER ...@@ -19,7 +19,6 @@ config SMB_SERVER
select CRYPTO_GCM select CRYPTO_GCM
select ASN1 select ASN1
select OID_REGISTRY select OID_REGISTRY
select FS_POSIX_ACL
default n default n
help help
Choose Y here if you want to allow SMB3 compliant clients Choose Y here if you want to allow SMB3 compliant clients
......
...@@ -2386,11 +2386,14 @@ static void ksmbd_acls_fattr(struct smb_fattr *fattr, struct inode *inode) ...@@ -2386,11 +2386,14 @@ static void ksmbd_acls_fattr(struct smb_fattr *fattr, struct inode *inode)
fattr->cf_uid = inode->i_uid; fattr->cf_uid = inode->i_uid;
fattr->cf_gid = inode->i_gid; fattr->cf_gid = inode->i_gid;
fattr->cf_mode = inode->i_mode; fattr->cf_mode = inode->i_mode;
fattr->cf_acls = NULL;
fattr->cf_dacls = NULL; fattr->cf_dacls = NULL;
fattr->cf_acls = get_acl(inode, ACL_TYPE_ACCESS); if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) {
if (S_ISDIR(inode->i_mode)) fattr->cf_acls = get_acl(inode, ACL_TYPE_ACCESS);
fattr->cf_dacls = get_acl(inode, ACL_TYPE_DEFAULT); if (S_ISDIR(inode->i_mode))
fattr->cf_dacls = get_acl(inode, ACL_TYPE_DEFAULT);
}
} }
/** /**
......
...@@ -533,22 +533,29 @@ static void parse_dacl(struct user_namespace *user_ns, ...@@ -533,22 +533,29 @@ static void parse_dacl(struct user_namespace *user_ns,
if (acl_state.users->n || acl_state.groups->n) { if (acl_state.users->n || acl_state.groups->n) {
acl_state.mask.allow = 0x07; acl_state.mask.allow = 0x07;
fattr->cf_acls = posix_acl_alloc(acl_state.users->n +
acl_state.groups->n + 4, GFP_KERNEL); if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) {
if (fattr->cf_acls) { fattr->cf_acls =
cf_pace = fattr->cf_acls->a_entries; posix_acl_alloc(acl_state.users->n +
posix_state_to_acl(&acl_state, cf_pace); acl_state.groups->n + 4, GFP_KERNEL);
if (fattr->cf_acls) {
cf_pace = fattr->cf_acls->a_entries;
posix_state_to_acl(&acl_state, cf_pace);
}
} }
} }
if (default_acl_state.users->n || default_acl_state.groups->n) { if (default_acl_state.users->n || default_acl_state.groups->n) {
default_acl_state.mask.allow = 0x07; default_acl_state.mask.allow = 0x07;
fattr->cf_dacls =
posix_acl_alloc(default_acl_state.users->n + if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) {
default_acl_state.groups->n + 4, GFP_KERNEL); fattr->cf_dacls =
if (fattr->cf_dacls) { posix_acl_alloc(default_acl_state.users->n +
cf_pdace = fattr->cf_dacls->a_entries; default_acl_state.groups->n + 4, GFP_KERNEL);
posix_state_to_acl(&default_acl_state, cf_pdace); if (fattr->cf_dacls) {
cf_pdace = fattr->cf_dacls->a_entries;
posix_state_to_acl(&default_acl_state, cf_pdace);
}
} }
} }
free_acl_state(&acl_state); free_acl_state(&acl_state);
...@@ -1221,31 +1228,36 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, struct path *path, ...@@ -1221,31 +1228,36 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, struct path *path,
granted = GENERIC_ALL_FLAGS; granted = GENERIC_ALL_FLAGS;
} }
posix_acls = get_acl(d_inode(path->dentry), ACL_TYPE_ACCESS); if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) {
if (posix_acls && !found) { posix_acls = get_acl(d_inode(path->dentry), ACL_TYPE_ACCESS);
unsigned int id = -1; if (posix_acls && !found) {
unsigned int id = -1;
pa_entry = posix_acls->a_entries;
for (i = 0; i < posix_acls->a_count; i++, pa_entry++) { pa_entry = posix_acls->a_entries;
if (pa_entry->e_tag == ACL_USER) for (i = 0; i < posix_acls->a_count; i++, pa_entry++) {
id = from_kuid(user_ns, if (pa_entry->e_tag == ACL_USER)
pa_entry->e_uid); id = from_kuid(user_ns,
else if (pa_entry->e_tag == ACL_GROUP) pa_entry->e_uid);
id = from_kgid(user_ns, else if (pa_entry->e_tag == ACL_GROUP)
pa_entry->e_gid); id = from_kgid(user_ns,
else pa_entry->e_gid);
continue; else
continue;
if (id == uid) {
mode_to_access_flags(pa_entry->e_perm, 0777, &access_bits); if (id == uid) {
if (!access_bits) mode_to_access_flags(pa_entry->e_perm,
access_bits = SET_MINIMUM_RIGHTS; 0777,
goto check_access_bits; &access_bits);
if (!access_bits)
access_bits =
SET_MINIMUM_RIGHTS;
goto check_access_bits;
}
} }
} }
if (posix_acls)
posix_acl_release(posix_acls);
} }
if (posix_acls)
posix_acl_release(posix_acls);
if (!found) { if (!found) {
if (others_ace) { if (others_ace) {
...@@ -1308,7 +1320,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon, ...@@ -1308,7 +1320,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
ksmbd_vfs_remove_acl_xattrs(user_ns, path->dentry); ksmbd_vfs_remove_acl_xattrs(user_ns, path->dentry);
/* Update posix acls */ /* Update posix acls */
if (fattr.cf_dacls) { if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && fattr.cf_dacls) {
rc = set_posix_acl(user_ns, inode, rc = set_posix_acl(user_ns, inode,
ACL_TYPE_ACCESS, fattr.cf_acls); ACL_TYPE_ACCESS, fattr.cf_acls);
if (S_ISDIR(inode->i_mode) && fattr.cf_dacls) if (S_ISDIR(inode->i_mode) && fattr.cf_dacls)
......
...@@ -1365,6 +1365,9 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct user_namespac ...@@ -1365,6 +1365,9 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct user_namespac
struct xattr_acl_entry *xa_entry; struct xattr_acl_entry *xa_entry;
int i; int i;
if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
return NULL;
posix_acls = get_acl(inode, acl_type); posix_acls = get_acl(inode, acl_type);
if (!posix_acls) if (!posix_acls)
return NULL; return NULL;
...@@ -1811,6 +1814,9 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, ...@@ -1811,6 +1814,9 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns,
struct posix_acl *acls; struct posix_acl *acls;
int rc; int rc;
if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
return -EOPNOTSUPP;
ksmbd_debug(SMB, "Set posix acls\n"); ksmbd_debug(SMB, "Set posix acls\n");
rc = init_acl_state(&acl_state, 1); rc = init_acl_state(&acl_state, 1);
if (rc) if (rc)
...@@ -1858,6 +1864,9 @@ int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns, ...@@ -1858,6 +1864,9 @@ int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns,
struct posix_acl_entry *pace; struct posix_acl_entry *pace;
int rc, i; int rc, i;
if (!IS_ENABLED(CONFIG_FS_POSIX_ACL))
return -EOPNOTSUPP;
acls = get_acl(parent_inode, ACL_TYPE_DEFAULT); acls = get_acl(parent_inode, ACL_TYPE_DEFAULT);
if (!acls) if (!acls)
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment