Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 2725 Details for
Bug 3582
cp -pr fails on XFS filesystems (fileutils)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fs/xfs/xfs_acl.c from SGI cvs to fix the cp -pr issues
XFS.patch (text/plain), 6.87 KB, created by
Disconnect
on 2002-08-01 10:43:45 UTC
(
hide
)
Description:
Patch to fs/xfs/xfs_acl.c from SGI cvs to fix the cp -pr issues
Filename:
MIME Type:
Creator:
Disconnect
Created:
2002-08-01 10:43:45 UTC
Size:
6.87 KB
patch
obsolete
>--- linux-2.4.19-gentoo-r7/fs/xfs/xfs_acl.c.bak 2002-07-02 15:30:02.000000000 -0400 >+++ linux-2.4.19-gentoo-r7/fs/xfs/xfs_acl.c 2002-07-02 17:08:26.000000000 -0400 >@@ -1,5 +1,5 @@ > /* >- * Copyright (c) 2001 Silicon Graphics, Inc. All Rights Reserved. >+ * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. > * > * This program is free software; you can redistribute it and/or modify it > * under the terms of version 2 of the GNU General Public License as >@@ -39,7 +39,7 @@ > STATIC int xfs_acl_access(uid_t, gid_t, xfs_acl_t *, mode_t, cred_t *); > STATIC int xfs_acl_invalid(xfs_acl_t *); > STATIC void xfs_acl_sync_mode(mode_t, xfs_acl_t *); >-STATIC void xfs_acl_get_attr(vnode_t *, xfs_acl_t *, int, int *); >+STATIC void xfs_acl_get_attr(vnode_t *, xfs_acl_t *, int, int, int *); > STATIC void xfs_acl_set_attr(vnode_t *, xfs_acl_t *, int, int *); > STATIC int xfs_acl_allow_set(vnode_t *, int); > >@@ -67,11 +67,11 @@ > STATIC int > acl_ext_attr_to_xfs(acl_ea_header *src, size_t size, xfs_acl_t *dest) > { >- char *src_acl = (char*)src; >- acl_ea_header *header; >- int n, count; >+ char *src_acl = (char *)src; > xfs_acl_entry_t *dest_entry; >+ acl_ea_header *header; > acl_ea_entry *src_entry; >+ int n; > > if (!src_acl || !dest) > return EINVAL; >@@ -83,18 +83,28 @@ > if (header->a_version != cpu_to_le32(ACL_EA_VERSION)) > return EINVAL; > >- count = acl_ea_count(size); >- if (count <= 0 || count > XFS_ACL_MAX_ENTRIES) >+ memset(dest, 0, sizeof(xfs_acl_t)); >+ dest->acl_cnt = acl_ea_count(size); >+ if (dest->acl_cnt < 0 || dest->acl_cnt > XFS_ACL_MAX_ENTRIES) > return EINVAL; > >- memset(dest, 0, sizeof(xfs_acl_t)); >- dest->acl_cnt = count; >+ /* >+ * acl_set_file(3) may request that we set default ACLs with >+ * zero length -- defend (gracefully) against that here. >+ */ >+ if (!dest->acl_cnt) { >+ dest->acl_cnt = 0; >+ return 0; >+ } >+ > src_entry = (acl_ea_entry*) (src_acl + sizeof(acl_ea_header)); > dest_entry = &dest->acl_entry[0]; > >- for (n = 0; n < count; n++, src_entry++, dest_entry++) { >- dest_entry->ae_tag = le16_to_cpu(src_entry->e_tag); >+ for (n = 0; n < dest->acl_cnt; n++, src_entry++, dest_entry++) { > dest_entry->ae_perm = le16_to_cpu(src_entry->e_perm); >+ if (dest_entry->ae_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) >+ return EINVAL; >+ dest_entry->ae_tag = le16_to_cpu(src_entry->e_tag); > switch(dest_entry->ae_tag) { > case ACL_USER: > case ACL_GROUP: >@@ -113,6 +123,9 @@ > return EINVAL; > } > } >+ if (xfs_acl_invalid(dest)) >+ return EINVAL; >+ > return 0; > } > >@@ -143,7 +156,7 @@ > int n; > > if (size < new_size) >- return -E2BIG; >+ return -ERANGE; > > /* Need to sort src XFS ACL by <ae_tag,ae_id> */ > qsort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]), >@@ -153,9 +166,10 @@ > dest_entry = &ext_acl->a_entries[0]; > src_entry = &src->acl_entry[0]; > for (n=0; n < src->acl_cnt; n++, dest_entry++, src_entry++) { >- dest_entry->e_tag = cpu_to_le16(src_entry->ae_tag); > dest_entry->e_perm = cpu_to_le16(src_entry->ae_perm); >- >+ if (src_entry->ae_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) >+ return -EINVAL; >+ dest_entry->e_tag = cpu_to_le16(src_entry->ae_tag); > switch(src_entry->ae_tag) { > case ACL_USER: > case ACL_GROUP: >@@ -183,19 +197,8 @@ > { > acl_ea_header *ext_acl = acl; > xfs_acl_t xfs_acl; >- vattr_t va; > int error; > >- if (!size) { >- /* >- * This is an overrestimate of the max size - used >- * to size a buffer for a subsequent "get" call. >- */ >- size = sizeof(acl_ea_header); >- size += sizeof(acl_ea_entry) * XFS_ACL_MAX_ENTRIES; >- return size; >- } >- > VN_HOLD(vp); > > error = _MAC_VACCESS(vp, get_current_cred(), VREAD); >@@ -203,34 +206,29 @@ > goto out; > > memset(&xfs_acl, 0, sizeof(xfs_acl)); >- xfs_acl_get_attr(vp, &xfs_acl, kind, &error); >- >- if (!error && xfs_acl_invalid(&xfs_acl)) { >- error = EINVAL; >+ xfs_acl_get_attr(vp, &xfs_acl, kind, size? 0 : ATTR_KERNOVAL, &error); >+ if (error) > goto out; >- } > >- if (!error && (kind == ACL_TYPE_ACCESS)) { >- /* For Access ACLs, get the mode for synchronization. */ >- va.va_mask = AT_MODE; >- VOP_GETATTR(vp, &va, 0, sys_cred, error); >- } >- >- /* XXX: tes TODO - audit use of XFS_ACL_NOT_PRESENT */ >+ if (!size) { >+ error = -acl_ea_size(XFS_ACL_MAX_ENTRIES); >+ } else { >+ if (xfs_acl_invalid(&xfs_acl)) { >+ error = EINVAL; >+ goto out; >+ } > >- /* >- * If there was an error retrieving or validating the ACL or >- * an Access ACL and we had trouble synchronizing the mode with the >- * ACL, then the ACL is deemed NOT PRESENT. >- */ >- if (error) >- xfs_acl.acl_cnt = XFS_ACL_NOT_PRESENT; >- else if (kind == ACL_TYPE_ACCESS) >- xfs_acl_sync_mode(va.va_mode, &xfs_acl); >+ if (kind == ACL_TYPE_ACCESS) { >+ vattr_t va; > >- if (!error) >+ va.va_mask = AT_MODE; >+ VOP_GETATTR(vp, &va, 0, sys_cred, error); >+ if (error) >+ goto out; >+ xfs_acl_sync_mode(va.va_mode, &xfs_acl); >+ } > error = -acl_xfs_to_ext_attr(&xfs_acl, ext_acl, size); >- >+ } > out: > VN_RELE(vp); > return -error; >@@ -267,6 +265,8 @@ > error = acl_ext_attr_to_xfs(ext_acl, size, &xfs_acl); > if (error) > return -error; >+ if (!xfs_acl.acl_cnt) >+ return 0; > > VN_HOLD(vp); > error = xfs_acl_allow_set(vp, kind); >@@ -322,7 +322,7 @@ > VOP_GETATTR(vp, &va, 0, NULL, error); > if (error) > return error; >- error = EACCES; >+ error = EPERM; > if (va.va_uid != current->fsuid && !capable(CAP_FOWNER)) > return error; > return 0; >@@ -531,12 +531,13 @@ > * Get the ACL from the EA and do endian conversion. > */ > STATIC void >-xfs_acl_get_attr(vnode_t *vp, xfs_acl_t *aclp, int kind, int *error) >+xfs_acl_get_attr(vnode_t *vp, xfs_acl_t *aclp, int kind, int flags, int *error) > { >- int len = sizeof(xfs_acl_t) - (sizeof(xfs_acl_entry_t)*(XFS_ACL_MAX_ENTRIES - aclp->acl_cnt)); >+ int len = sizeof(xfs_acl_t); > >- VOP_ATTR_GET(vp, kind==ACL_TYPE_ACCESS ? SGI_ACL_FILE: SGI_ACL_DEFAULT, >- (char *)aclp, &len, ATTR_ROOT, sys_cred, *error); >+ flags |= ATTR_ROOT; >+ VOP_ATTR_GET(vp, kind==ACL_TYPE_ACCESS ? SGI_ACL_FILE : SGI_ACL_DEFAULT, >+ (char *)aclp, &len, flags, sys_cred, *error); > if (*error) > return; > xfs_acl_get_endian(aclp); >@@ -550,7 +551,7 @@ > { > xfs_acl_entry_t *ace, *newace, *end; > xfs_acl_t newacl; >- int len = sizeof(xfs_acl_t); >+ int len = sizeof(xfs_acl_t) - (sizeof(xfs_acl_entry_t)*(XFS_ACL_MAX_ENTRIES - aclp->acl_cnt)); > > end = &aclp->acl_entry[0]+aclp->acl_cnt; > for (ace = &aclp->acl_entry[0], newace = &newacl.acl_entry[0]; >@@ -577,7 +578,7 @@ > * Get the Access ACL and the mode. If either cannot > * be obtained for some reason, invalidate the access ACL. > */ >- xfs_acl_get_attr(vp, access_acl, ACL_TYPE_ACCESS, &error); >+ xfs_acl_get_attr(vp, access_acl, ACL_TYPE_ACCESS, 0, &error); > if (!error) { > /* Got the ACL, need the mode... */ > va.va_mask = AT_MODE; >@@ -591,7 +592,7 @@ > } > > if (default_acl != NULL) { >- xfs_acl_get_attr(vp, default_acl, ACL_TYPE_DEFAULT, &error); >+ xfs_acl_get_attr(vp, default_acl, ACL_TYPE_DEFAULT, 0, &error); > if (error) > default_acl->acl_cnt = XFS_ACL_NOT_PRESENT; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 3582
:
2002
|
2030
|
2068
| 2725