* if the two SIDs (roughly equivalent to a UUID for a user or group) are
* the same returns zero, if they do not match returns non-zero.
*/
-int
-compare_sids(const struct smb_sid *ctsid, const struct smb_sid *cwsid)
+int compare_sids(const struct smb_sid *ctsid, const struct smb_sid *cwsid)
{
int i;
int num_subauth, num_sat, num_saw;
- if ((!ctsid) || (!cwsid))
+ if (!ctsid || !cwsid)
return 1;
/* compare the revision */
for (i = 0; i < num_subauth; ++i) {
if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) {
if (le32_to_cpu(ctsid->sub_auth[i]) >
- le32_to_cpu(cwsid->sub_auth[i]))
+ le32_to_cpu(cwsid->sub_auth[i]))
return 1;
else
return -1;
return 0; /* sids compare/match */
}
-static void
-smb_copy_sid(struct smb_sid *dst, const struct smb_sid *src)
+static void smb_copy_sid(struct smb_sid *dst, const struct smb_sid *src)
{
int i;
return mode;
}
- if ((flags & GENERIC_READ) ||
- (flags & FILE_READ_RIGHTS))
+ if ((flags & GENERIC_READ) || (flags & FILE_READ_RIGHTS))
mode = 0444;
- if ((flags & GENERIC_WRITE) ||
- (flags & FILE_WRITE_RIGHTS)) {
+ if ((flags & GENERIC_WRITE) || (flags & FILE_WRITE_RIGHTS)) {
mode |= 0222;
if (S_ISDIR(fattr->cf_mode))
mode |= 0111;
}
- if ((flags & GENERIC_EXECUTE) ||
- (flags & FILE_EXEC_RIGHTS))
+ if ((flags & GENERIC_EXECUTE) || (flags & FILE_EXEC_RIGHTS))
mode |= 0111;
- if (type == ACCESS_DENIED_ACE_TYPE ||
- type == ACCESS_DENIED_OBJECT_ACE_TYPE)
+ if (type == ACCESS_DENIED_ACE_TYPE || type == ACCESS_DENIED_OBJECT_ACE_TYPE)
mode = ~mode;
ksmbd_debug(SMB, "access flags 0x%x mode now %04o\n", flags, mode);
id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
if (id > 0) {
uid = make_kuid(&init_user_ns, id);
- if (uid_valid(uid) &&
- kuid_has_mapping(&init_user_ns, uid)) {
+ if (uid_valid(uid) && kuid_has_mapping(&init_user_ns, uid)) {
fattr->cf_uid = uid;
rc = 0;
}
id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
if (id > 0) {
gid = make_kgid(&init_user_ns, id);
- if (gid_valid(gid) &&
- kgid_has_mapping(&init_user_ns, gid)) {
+ if (gid_valid(gid) && kgid_has_mapping(&init_user_ns, gid)) {
fattr->cf_gid = gid;
rc = 0;
}
* enough space for either:
*/
alloc = sizeof(struct posix_ace_state_array)
- + cnt*sizeof(struct posix_user_ace_state);
+ + cnt * sizeof(struct posix_user_ace_state);
state->users = kzalloc(alloc, GFP_KERNEL);
if (!state->users)
return -ENOMEM;
* user/group/other have no permissions
*/
for (i = 0; i < num_aces; ++i) {
- ppace[i] = (struct smb_ace *) (acl_base + acl_size);
+ ppace[i] = (struct smb_ace *)(acl_base + acl_size);
acl_base = (char *)ppace[i];
acl_size = le16_to_cpu(ppace[i]->size);
ppace[i]->access_req =
smb_map_generic_desired_access(ppace[i]->access_req);
- if (!(compare_sids(&(ppace[i]->sid), &sid_unix_NFS_mode))) {
+ if (!(compare_sids(&ppace[i]->sid, &sid_unix_NFS_mode))) {
fattr->cf_mode =
le32_to_cpu(ppace[i]->sid.sub_auth[2]);
break;
- } else if (!compare_sids(&(ppace[i]->sid), pownersid)) {
+ } else if (!compare_sids(&ppace[i]->sid, pownersid)) {
acl_mode = access_flags_to_mode(fattr,
ppace[i]->access_req, ppace[i]->type);
acl_mode &= 0700;
mode |= acl_mode;
}
owner_found = true;
- } else if (!compare_sids(&(ppace[i]->sid), pgrpsid) ||
- ppace[i]->sid.sub_auth[ppace[i]->sid.num_subauth - 1] ==
- DOMAIN_USER_RID_LE) {
+ } else if (!compare_sids(&ppace[i]->sid, pgrpsid) ||
+ ppace[i]->sid.sub_auth[ppace[i]->sid.num_subauth - 1] ==
+ DOMAIN_USER_RID_LE) {
acl_mode = access_flags_to_mode(fattr,
ppace[i]->access_req, ppace[i]->type);
acl_mode &= 0070;
mode |= acl_mode;
}
group_found = true;
- } else if (!compare_sids(&(ppace[i]->sid), &sid_everyone)) {
+ } else if (!compare_sids(&ppace[i]->sid, &sid_everyone)) {
acl_mode = access_flags_to_mode(fattr,
ppace[i]->access_req, ppace[i]->type);
acl_mode &= 0007;
mode |= acl_mode;
}
others_found = true;
- } else if (!compare_sids(&(ppace[i]->sid), &creator_owner))
+ } else if (!compare_sids(&ppace[i]->sid, &creator_owner)) {
continue;
- else if (!compare_sids(&(ppace[i]->sid), &creator_group))
+ } else if (!compare_sids(&ppace[i]->sid, &creator_group)) {
continue;
- else if (!compare_sids(&(ppace[i]->sid), &sid_authusers))
+ } else if (!compare_sids(&ppace[i]->sid, &sid_authusers)) {
continue;
- else {
+ } else {
struct smb_fattr temp_fattr;
acl_mode = access_flags_to_mode(fattr, ppace[i]->access_req,
if (S_ISDIR(fattr->cf_mode) && pace->e_tag == ACL_OTHER)
flags = 0x03;
- ntace = (struct smb_ace *) ((char *)pndace + *size);
+ ntace = (struct smb_ace *)((char *)pndace + *size);
*size += fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, flags,
pace->e_perm, 0777);
(*num_aces)++;
FILE_DELETE_LE | FILE_DELETE_CHILD_LE;
if (S_ISDIR(fattr->cf_mode) &&
- (pace->e_tag == ACL_USER || pace->e_tag == ACL_GROUP)) {
- ntace = (struct smb_ace *) ((char *)pndace + *size);
+ (pace->e_tag == ACL_USER || pace->e_tag == ACL_GROUP)) {
+ ntace = (struct smb_ace *)((char *)pndace + *size);
*size += fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED,
0x03, pace->e_perm, 0777);
(*num_aces)++;
continue;
}
- ntace = (struct smb_ace *) ((char *)pndace + *size);
+ ntace = (struct smb_ace *)((char *)pndace + *size);
*size += fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, 0x0b,
pace->e_perm, 0777);
(*num_aces)++;
__u32 dacloffset;
int pntsd_type;
- if (pntsd == NULL)
+ if (!pntsd)
return -EIO;
owner_sid_ptr = (struct smb_sid *)((char *)pntsd +
dacl_ptr->size = cpu_to_le16(sizeof(struct smb_acl));
dacl_ptr->num_aces = 0;
- if (!ppntsd)
+ if (!ppntsd) {
set_mode_dacl(dacl_ptr, fattr);
- else if (!ppntsd->dacloffset)
+ } else if (!ppntsd->dacloffset) {
goto out;
- else {
+ } else {
struct smb_acl *ppdacl_ptr;
ppdacl_ptr = (struct smb_acl *)((char *)ppntsd +
flags |= INHERIT_ONLY_ACE;
if (flags & NO_PROPAGATE_INHERIT_ACE)
flags = 0;
- } else
+ } else {
flags = 0;
+ }
if (!compare_sids(&creator_owner, &parent_aces->sid)) {
creator = &creator_owner;
aces = (struct smb_ace *)((char *)aces + le16_to_cpu(aces->size));
flags |= INHERIT_ONLY_ACE;
psid = creator;
- } else if (is_dir && !(parent_aces->flags & NO_PROPAGATE_INHERIT_ACE))
+ } else if (is_dir && !(parent_aces->flags & NO_PROPAGATE_INHERIT_ACE)) {
psid = &parent_aces->sid;
+ }
smb_set_ace(aces, psid, parent_aces->type, flags | inherited_flags,
parent_aces->access_req);
ace = (struct smb_ace *)((char *)pdacl + sizeof(struct smb_acl));
for (i = 0; i < le32_to_cpu(pdacl->num_aces); i++) {
granted |= le32_to_cpu(ace->access_req);
- ace = (struct smb_ace *) ((char *)ace + le16_to_cpu(ace->size));
+ ace = (struct smb_ace *)((char *)ace + le16_to_cpu(ace->size));
if (end_of_acl < (char *)ace)
goto err_out;
}
if (!compare_sids(&sid_everyone, &ace->sid))
others_ace = ace;
- ace = (struct smb_ace *) ((char *)ace + le16_to_cpu(ace->size));
+ ace = (struct smb_ace *)((char *)ace + le16_to_cpu(ace->size));
if (end_of_acl < (char *)ace)
goto err_out;
}
posix_acl_release(posix_acls);
if (!found) {
- if (others_ace)
+ if (others_ace) {
ace = others_ace;
- else {
+ } else {
ksmbd_debug(SMB, "Can't find corresponding sid\n");
rc = -EACCES;
goto err_out;
if (type_check && !(le16_to_cpu(pntsd->type) & DACL_PRESENT))
goto out;
- if (test_share_config_flag(tcon->share_conf,
- KSMBD_SHARE_FLAG_ACL_XATTR)) {
+ if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {
/* Update WinACL in xattr */
ksmbd_vfs_remove_sd_xattrs(dentry);
ksmbd_vfs_set_sd_xattr(conn, dentry, pntsd, ntsd_len);