aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsacl.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-10-25 17:17:17 -0400
committerSteve French <sfrench@us.ibm.com>2007-10-25 17:17:17 -0400
commit630f3f0c45a80ab907d216191ef4a205c249fa1b (patch)
treebe1fe069ded6df343f978469160b002c5ae67169 /fs/cifs/cifsacl.c
parent44093ca2fef3c52dc7d186116862d74f9a676e0f (diff)
[CIFS] acl support part 6
Acked-by: Shirish Pargaonkar <shirishp@us.ibm.com> CC: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifsacl.c')
-rw-r--r--fs/cifs/cifsacl.c91
1 files changed, 71 insertions, 20 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 154cb8449b9b..14200bd45b30 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -97,7 +97,7 @@ int match_sid(struct cifs_sid *ctsid)
97 97
98/* if the two SIDs (roughly equivalent to a UUID for a user or group) are 98/* if the two SIDs (roughly equivalent to a UUID for a user or group) are
99 the same returns 1, if they do not match returns 0 */ 99 the same returns 1, if they do not match returns 0 */
100int compare_sids(struct cifs_sid *ctsid, struct cifs_sid *cwsid) 100int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
101{ 101{
102 int i; 102 int i;
103 int num_subauth, num_sat, num_saw; 103 int num_subauth, num_sat, num_saw;
@@ -129,28 +129,77 @@ int compare_sids(struct cifs_sid *ctsid, struct cifs_sid *cwsid)
129 return (1); /* sids compare/match */ 129 return (1); /* sids compare/match */
130} 130}
131 131
132void get_mode_from_acl(struct inode * inode, const char * path) 132/*
133 change posix mode to reflect permissions
134 pmode is the existing mode (we only want to overwrite part of this
135 bits to set can be: S_IRWXU, S_IRWXG or S_IRWXO ie 00700 or 00070 or 00007
136*/
137static void access_flags_to_mode(__u32 access_flags, umode_t * pmode,
138 umode_t bits_to_set)
139{
140
141#ifdef CONFIG_CIFS_DEBUG2
142 cFYI(1, ("access flags 0x%x mode now 0x%x", access_flags, *pmode);
143#endif
144
145 return;
146}
147
148/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
149
150void acl_to_uid_mode(struct inode *inode, const char *path)
133{ 151{
152 struct cifsFileInfo *open_file;
153 int unlock_file = FALSE;
154 int xid;
155 int rc = -EIO;
156 __u16 fid;
157 struct super_block *sb;
158 struct cifs_sb_info *cifs_sb;
134 159
135 cFYI(1, ("get mode from ACL for %s", path)); 160 cFYI(1, ("get mode from ACL for %s", path));
136 161
137 if (inode == NULL) 162 if (inode == NULL)
138 return; 163 return;
139 164
140 /* find an open readable handle 165 xid = GetXid();
141 if handle found 166 open_file = find_readable_file(CIFS_I(inode));
142 lock handle 167 if (open_file) {
143 else open file 168 unlock_file = TRUE;
144 if no open file can not hurt to check if path is null 169 fid = open_file->netfid;
145 GetCIFSACL 170 } else {
146 for all ACEs in ACL { 171 int oplock = FALSE;
147 if U or G or O 172 /* open file */
148 inode->i_mode = parse_ace(file_type, UG or O, ace->perms, inode->i_mode) 173 sb = inode->i_sb;
149 else continue 174 if (sb == NULL) {
150 } 175 FreeXid(xid);
151 if handle open close it 176 return;
152 else unlock handle */ 177 }
178 cifs_sb = CIFS_SB(sb);
179 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
180 GENERIC_READ, 0, &fid, &oplock, NULL,
181 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
182 CIFS_MOUNT_MAP_SPECIAL_CHR);
183 if (rc != 0) {
184 cERROR(1, ("Unable to open file to get ACL"));
185 FreeXid(xid);
186 return;
187 }
188 }
189
190 /* rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, pntsd, acllen,
191 ACL_TYPE_ACCESS); */
192
193 if (unlock_file == TRUE)
194 atomic_dec(&open_file->wrtPending);
195 else
196 CIFSSMBClose(xid, cifs_sb->tcon, fid);
197
198/* parse ACEs e.g.
199 rc = parse_sec_desc(pntsd, acllen, inode);
200*/
153 201
202 FreeXid(xid);
154 return; 203 return;
155} 204}
156 205
@@ -193,7 +242,8 @@ static void parse_ace(struct cifs_ace *pace, char *end_of_acl)
193 242
194 243
195static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, 244static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
196 struct cifs_sid *pownersid, struct cifs_sid *pgrpsid) 245 struct cifs_sid *pownersid, struct cifs_sid *pgrpsid
246 struct inode *inode)
197{ 247{
198 int i; 248 int i;
199 int num_aces = 0; 249 int num_aces = 0;
@@ -281,7 +331,8 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)
281 331
282 332
283/* Convert CIFS ACL to POSIX form */ 333/* Convert CIFS ACL to POSIX form */
284int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len) 334static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
335 struct inode *inode)
285{ 336{
286 int rc; 337 int rc;
287 struct cifs_sid *owner_sid_ptr, *group_sid_ptr; 338 struct cifs_sid *owner_sid_ptr, *group_sid_ptr;
@@ -310,14 +361,14 @@ int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len)
310 if (rc) 361 if (rc)
311 return rc; 362 return rc;
312 363
313 parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr, group_sid_ptr); 364 parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr, group_sid_ptr, inode);
314 365
315/* cifscred->uid = owner_sid_ptr->rid; 366/* cifscred->uid = owner_sid_ptr->rid;
316 cifscred->gid = group_sid_ptr->rid; 367 cifscred->gid = group_sid_ptr->rid;
317 memcpy((void *)(&(cifscred->osid)), (void *)owner_sid_ptr, 368 memcpy((void *)(&(cifscred->osid)), (void *)owner_sid_ptr,
318 sizeof (struct cifs_sid)); 369 sizeof(struct cifs_sid));
319 memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, 370 memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr,
320 sizeof (struct cifs_sid)); */ 371 sizeof(struct cifs_sid)); */
321 372
322 373
323 return (0); 374 return (0);