@@ -103,7 +103,7 @@ void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, st
103
103
case PERM_ANDROID_OBB :
104
104
case PERM_ANDROID_MEDIA :
105
105
appid = get_appid (newdentry -> d_name .name );
106
- if (appid != 0 ) {
106
+ if (appid != 0 && ! is_excluded ( newdentry -> d_name . name , parent_info -> userid ) ) {
107
107
info -> d_uid = multiuser_get_uid (parent_info -> userid , appid );
108
108
}
109
109
set_top (info , & info -> vfs_inode );
@@ -116,8 +116,10 @@ void get_derived_permission(struct dentry *parent, struct dentry *dentry)
116
116
get_derived_permission_new (parent , dentry , dentry );
117
117
}
118
118
119
- static int descendant_may_need_fixup (perm_t perm ) {
120
- if (perm == PERM_PRE_ROOT || perm == PERM_ROOT || perm == PERM_ANDROID )
119
+ static int descendant_may_need_fixup (struct sdcardfs_inode_info * info , struct limit_search * limit ) {
120
+ if (info -> perm == PERM_ROOT )
121
+ return (limit -> flags & BY_USERID )?info -> userid == limit -> userid :1 ;
122
+ if (info -> perm == PERM_PRE_ROOT || info -> perm == PERM_ANDROID )
121
123
return 1 ;
122
124
return 0 ;
123
125
}
@@ -129,7 +131,7 @@ static int needs_fixup(perm_t perm) {
129
131
return 0 ;
130
132
}
131
133
132
- void fixup_perms_recursive (struct dentry * dentry , const char * name , size_t len ) {
134
+ void fixup_perms_recursive (struct dentry * dentry , struct limit_search * limit ) {
133
135
struct dentry * child ;
134
136
struct sdcardfs_inode_info * info ;
135
137
if (!dget (dentry ))
@@ -143,22 +145,22 @@ void fixup_perms_recursive(struct dentry *dentry, const char* name, size_t len)
143
145
if (needs_fixup (info -> perm )) {
144
146
spin_lock (& dentry -> d_lock );
145
147
list_for_each_entry (child , & dentry -> d_subdirs , d_child ) {
146
- dget (child );
147
- if (!strncasecmp (child -> d_name .name , name , len )) {
148
- if (child -> d_inode ) {
149
- get_derived_permission (dentry , child );
150
- fixup_tmp_permissions (child -> d_inode );
151
- dput (child );
152
- break ;
153
- }
148
+ dget (child );
149
+ if (!(limit -> flags & BY_NAME ) || !strncasecmp (child -> d_name .name , limit -> name , limit -> length )) {
150
+ if (child -> d_inode ) {
151
+ get_derived_permission (dentry , child );
152
+ fixup_tmp_permissions (child -> d_inode );
153
+ dput (child );
154
+ break ;
154
155
}
155
- dput (child );
156
+ }
157
+ dput (child );
156
158
}
157
159
spin_unlock (& dentry -> d_lock );
158
- } else if (descendant_may_need_fixup (info -> perm )) {
160
+ } else if (descendant_may_need_fixup (info , limit )) {
159
161
spin_lock (& dentry -> d_lock );
160
162
list_for_each_entry (child , & dentry -> d_subdirs , d_child ) {
161
- fixup_perms_recursive (child , name , len );
163
+ fixup_perms_recursive (child , limit );
162
164
}
163
165
spin_unlock (& dentry -> d_lock );
164
166
}
0 commit comments