Remove unneeded ifdefs.

Reviewed by:	rmacklem
This commit is contained in:
Edward Tomasz Napierala 2009-12-03 18:03:42 +00:00
parent 4c0191c569
commit 74991298d9
7 changed files with 8 additions and 252 deletions

View File

@ -37,7 +37,6 @@ extern int nfsrv_useacl;
static int nfsrv_acemasktoperm(u_int32_t acetype, u_int32_t mask, int owner,
enum vtype type, acl_perm_t *permp);
#if defined(NFS4_ACL_EXTATTR_NAME)
/*
* Handle xdr for an ace.
*/
@ -263,189 +262,7 @@ nfsrv_acemasktoperm(u_int32_t acetype, u_int32_t mask, int owner,
*permp = perm;
return (0);
}
#else
/*
* Handle xdr for an ace.
*/
APPLESTATIC int
nfsrv_dissectace(struct nfsrv_descript *nd, struct acl_entry *acep,
int *aceerrp, int *acesizep, NFSPROC_T *p)
{
u_int32_t *tl;
int len, gotid = 0, owner = 0, error = 0, aceerr = 0;
u_char *name, namestr[NFSV4_SMALLSTR + 1];
u_int32_t flag, mask, acetype;
gid_t gid;
uid_t uid;
*aceerrp = 0;
NFSM_DISSECT(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
acetype = fxdr_unsigned(u_int32_t, *tl++);
flag = fxdr_unsigned(u_int32_t, *tl++);
mask = fxdr_unsigned(u_int32_t, *tl++);
len = fxdr_unsigned(int, *tl);
if (len < 0) {
return (NFSERR_BADXDR);
} else if (len == 0) {
/* Netapp filers return a 0 length who for nil users */
acep->ae_tag = ACL_UNDEFINED_TAG;
acep->ae_id = ACL_UNDEFINED_ID;
acep->ae_perm = (acl_perm_t)0;
if (acesizep)
*acesizep = 4 * NFSX_UNSIGNED;
return (0);
}
if (len > NFSV4_SMALLSTR)
name = malloc(len + 1, M_NFSSTRING, M_WAITOK);
else
name = namestr;
error = nfsrv_mtostr(nd, name, len);
if (error) {
if (len > NFSV4_SMALLSTR)
free(name, M_NFSSTRING);
return (error);
}
if (len == 6) {
if (!NFSBCMP(name, "OWNER@", 6)) {
acep->ae_tag = ACL_USER_OBJ;
acep->ae_id = ACL_UNDEFINED_ID;
owner = 1;
gotid = 1;
} else if (!NFSBCMP(name, "GROUP@", 6)) {
acep->ae_tag = ACL_GROUP_OBJ;
acep->ae_id = ACL_UNDEFINED_ID;
gotid = 1;
flag &= ~NFSV4ACE_IDENTIFIERGROUP;
}
} else if (len == 9 && !NFSBCMP(name, "EVERYONE@", 9)) {
acep->ae_tag = ACL_OTHER;
acep->ae_id = ACL_UNDEFINED_ID;
gotid = 1;
}
if (!gotid) {
if (flag & NFSV4ACE_IDENTIFIERGROUP) {
flag &= ~NFSV4ACE_IDENTIFIERGROUP;
acep->ae_tag = ACL_GROUP;
aceerr = nfsv4_strtogid(name, len, &gid, p);
if (!aceerr)
acep->ae_id = (uid_t)gid;
} else {
acep->ae_tag = ACL_USER;
aceerr = nfsv4_strtouid(name, len, &uid, p);
if (!aceerr)
acep->ae_id = uid;
}
}
if (len > NFSV4_SMALLSTR)
free(name, M_NFSSTRING);
/*
* Now, check for unsupported types or flag bits.
*/
if (!aceerr && ((acetype != NFSV4ACE_ALLOWEDTYPE &&
acetype != NFSV4ACE_AUDITTYPE && acetype != NFSV4ACE_ALARMTYPE
&& acetype != NFSV4ACE_DENIEDTYPE) || flag))
aceerr = NFSERR_ATTRNOTSUPP;
/*
* And turn the mask into perm bits.
*/
if (!aceerr)
aceerr = nfsrv_acemasktoperm(acetype, mask, owner, VREG,
&acep->ae_perm);
*aceerrp = aceerr;
if (acesizep)
*acesizep = NFSM_RNDUP(len) + (4 * NFSX_UNSIGNED);
return (0);
nfsmout:
return (error);
}
/*
* Turn an NFSv4 ace mask into R/W/X flag bits.
*/
static int
nfsrv_acemasktoperm(u_int32_t acetype, u_int32_t mask, int owner,
enum vtype type, acl_perm_t *permp)
{
acl_perm_t perm = 0x0;
if (acetype != NFSV4ACE_ALLOWEDTYPE && acetype != NFSV4ACE_DENIEDTYPE){
if (mask & ~NFSV4ACE_AUDITMASK)
return (NFSERR_ATTRNOTSUPP);
}
if (mask & NFSV4ACE_DELETE) {
return (NFSERR_ATTRNOTSUPP);
}
if (acetype == NFSV4ACE_DENIEDTYPE) {
if (mask & NFSV4ACE_ALLFILESMASK) {
return (NFSERR_ATTRNOTSUPP);
}
if (owner) {
if (mask & NFSV4ACE_OWNERMASK) {
return (NFSERR_ATTRNOTSUPP);
}
} else {
if ((mask & NFSV4ACE_OWNERMASK) != NFSV4ACE_OWNERMASK) {
return (NFSERR_ATTRNOTSUPP);
}
mask &= ~NFSV4ACE_OWNERMASK;
}
} else if (acetype == NFSV4ACE_ALLOWEDTYPE) {
if ((mask & NFSV4ACE_ALLFILESMASK) != NFSV4ACE_ALLFILESMASK) {
return (NFSERR_ATTRNOTSUPP);
}
mask &= ~NFSV4ACE_ALLFILESMASK;
if (owner) {
if ((mask & NFSV4ACE_OWNERMASK) != NFSV4ACE_OWNERMASK) {
return (NFSERR_ATTRNOTSUPP);
}
mask &= ~NFSV4ACE_OWNERMASK;
} else if (mask & NFSV4ACE_OWNERMASK) {
return (NFSERR_ATTRNOTSUPP);
}
}
if (type == VDIR) {
if ((mask & NFSV4ACE_DIRREADMASK) == NFSV4ACE_DIRREADMASK) {
perm |= ACL_READ;
mask &= ~NFSV4ACE_DIRREADMASK;
}
if ((mask & NFSV4ACE_DIRWRITEMASK) == NFSV4ACE_DIRWRITEMASK) {
perm |= ACL_WRITE;
mask &= ~NFSV4ACE_DIRWRITEMASK;
}
if ((mask & NFSV4ACE_DIREXECUTEMASK)==NFSV4ACE_DIREXECUTEMASK){
perm |= ACL_EXECUTE;
mask &= ~NFSV4ACE_DIREXECUTEMASK;
}
} else {
if (acetype == NFSV4ACE_DENIEDTYPE &&
(mask & NFSV4ACE_SYNCHRONIZE)) {
return (NFSERR_ATTRNOTSUPP);
}
mask &= ~(NFSV4ACE_SYNCHRONIZE | NFSV4ACE_DELETECHILD);
if ((mask & NFSV4ACE_READMASK) == NFSV4ACE_READMASK) {
perm |= ACL_READ;
mask &= ~NFSV4ACE_READMASK;
}
if ((mask & NFSV4ACE_WRITEMASK) == NFSV4ACE_WRITEMASK) {
perm |= ACL_WRITE;
mask &= ~NFSV4ACE_WRITEMASK;
}
if ((mask & NFSV4ACE_EXECUTEMASK) == NFSV4ACE_EXECUTEMASK) {
perm |= ACL_EXECUTE;
mask &= ~NFSV4ACE_EXECUTEMASK;
}
}
if (mask) {
return (NFSERR_ATTRNOTSUPP);
}
*permp = perm;
return (0);
}
#endif /* !NFS4_ACL_EXTATTR_NAME */
#ifdef NFS4_ACL_EXTATTR_NAME
/* local functions */
static int nfsrv_buildace(struct nfsrv_descript *, u_char *, int,
enum vtype, int, int, struct acl_entry *);
@ -742,5 +559,3 @@ nfsrv_compareacl(NFSACL_T *aclp1, NFSACL_T *aclp2)
}
return (0);
}
#endif /* NFS4_ACL_EXTATTR_NAME */

View File

@ -421,7 +421,6 @@ newnfs_portinit(void)
mtx_init(&nfs_state_mutex, "nfs_state_mutex", NULL, MTX_DEF);
}
#ifdef NFS4_ACL_EXTATTR_NAME
/*
* Determine if the file system supports NFSv4 ACLs.
* Return 1 if it does, 0 otherwise.
@ -441,7 +440,6 @@ nfs_supportsnfsv4acls(struct mount *mp)
}
return (0);
}
#endif /* NFS4_ACL_EXTATTR_NAME */
extern int (*nfsd_call_nfscommon)(struct thread *, struct nfssvc_args *);

View File

@ -650,10 +650,8 @@ nfsrv_dissectacl(struct nfsrv_descript *nd, NFSACL_T *aclp, int *aclerrp,
int acecnt, error = 0, aceerr = 0, acesize;
*aclerrp = 0;
#ifdef NFS4_ACL_EXTATTR_NAME
if (aclp)
aclp->acl_cnt = 0;
#endif
/*
* Parse out the ace entries and expect them to conform to
* what can be supported by R/W/X bits.
@ -661,28 +659,22 @@ nfsrv_dissectacl(struct nfsrv_descript *nd, NFSACL_T *aclp, int *aclerrp,
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
aclsize = NFSX_UNSIGNED;
acecnt = fxdr_unsigned(int, *tl);
#ifdef NFS4_ACL_EXTATTR_NAME
if (acecnt > ACL_MAX_ENTRIES)
aceerr = 1;
#endif
if (nfsrv_useacl == 0)
aceerr = 1;
for (i = 0; i < acecnt; i++) {
#ifdef NFS4_ACL_EXTATTR_NAME
if (aclp && !aceerr)
error = nfsrv_dissectace(nd, &aclp->acl_entry[i],
&aceerr, &acesize, p);
else
#endif
error = nfsrv_skipace(nd, &acesize);
if (error)
return (error);
aclsize += acesize;
}
#ifdef NFS4_ACL_EXTATTR_NAME
if (aclp && !aceerr)
aclp->acl_cnt = acecnt;
#endif
if (aceerr)
*aclerrp = aceerr;
if (aclsizep)
@ -1014,7 +1006,6 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
case NFSATTRBIT_ACL:
if (compare) {
if (!(*retcmpp)) {
#ifdef NFS4_ACL_EXTATTR_NAME
if (nfsrv_useacl) {
NFSACL_T *naclp;
@ -1028,9 +1019,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
if (aceerr || nfsrv_compareacl(aclp, naclp))
*retcmpp = NFSERR_NOTSAME;
acl_free(naclp);
} else
#endif
{
} else {
error = nfsrv_dissectacl(nd, NULL, &aceerr,
&cnt, p);
*retcmpp = NFSERR_ATTRNOTSUPP;
@ -1932,9 +1921,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
aclp = saclp;
} else {
NFSCLRNOTFILLABLE_ATTRBIT(retbitp);
#ifdef NFS4_ACL_EXTATTR_NAME
naclp = acl_alloc(M_WAITOK);
#endif
aclp = naclp;
}
nfsvno_getfs(&fsinf, isdgram);
@ -1957,21 +1944,15 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
/*
* And the NFSv4 ACL...
*/
if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT)
#ifdef NFS4_ACL_EXTATTR_NAME
&& (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
!NFSHASNFS4ACL(vnode_mount(vp))))
#endif
) {
if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT) &&
(nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
!NFSHASNFS4ACL(vnode_mount(vp))))) {
NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT);
}
if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACL)) {
#ifdef NFS4_ACL_EXTATTR_NAME
if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
!NFSHASNFS4ACL(vnode_mount(vp)))) {
#endif
NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACL);
#ifdef NFS4_ACL_EXTATTR_NAME
} else if (naclp != NULL) {
NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_ACCESS(vp, VREAD_ACL, cred, p);
@ -1987,7 +1968,6 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACL);
}
}
#endif
}
/*
* Put out the attribute bitmap for the ones being filled in
@ -2005,11 +1985,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
switch (bitpos) {
case NFSATTRBIT_SUPPORTEDATTRS:
NFSSETSUPP_ATTRBIT(&attrbits);
#ifdef NFS4_ACL_EXTATTR_NAME
if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL)
&& !NFSHASNFS4ACL(vnode_mount(vp))))
#endif
{
&& !NFSHASNFS4ACL(vnode_mount(vp)))) {
NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACLSUPPORT);
NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACL);
}
@ -2082,7 +2059,6 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
/*
* Recommended Attributes. (Only the supported ones.)
*/
#ifdef NFS4_ACL_EXTATTR_NAME
case NFSATTRBIT_ACL:
retnum += nfsrv_buildacl(nd, aclp, vnode_vtype(vp), p);
break;
@ -2091,7 +2067,6 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
*tl = txdr_unsigned(NFSV4ACE_SUPTYPES);
retnum += NFSX_UNSIGNED;
break;
#endif
case NFSATTRBIT_CANSETTIME:
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
if (fsinf.fs_properties & NFSV3FSINFO_CANSETTIME)
@ -2397,10 +2372,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
};
}
}
#ifdef NFS4_ACL_EXTATTR_NAME
if (naclp != NULL)
acl_free(naclp);
#endif
*retnump = txdr_unsigned(retnum);
return (retnum + prefixnum);
}

View File

@ -329,7 +329,6 @@ void newnfs_timer(void *);
/* nfs_commonacl.c */
int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *,
int *, int *, NFSPROC_T *);
#ifdef NFS4_ACL_EXTATTR_NAME
int nfsrv_buildacl(struct nfsrv_descript *, NFSACL_T *, enum vtype,
NFSPROC_T *);
int nfsrv_aclaccess(vnode_t, accmode_t, u_int32_t, struct ucred *,
@ -337,7 +336,6 @@ int nfsrv_aclaccess(vnode_t, accmode_t, u_int32_t, struct ucred *,
int nfsrv_setacl(vnode_t, NFSACL_T *, struct ucred *,
NFSPROC_T *);
int nfsrv_compareacl(NFSACL_T *, NFSACL_T *);
#endif
/* nfs_clrpcops.c */
int nfsrpc_null(vnode_t, struct ucred *, NFSPROC_T *);

View File

@ -125,11 +125,7 @@
#define NFSPROC_T struct thread
#define NFSDEV_T dev_t
#define NFSSVCARGS nfssvc_args
#ifdef NFS4_ACL_EXTATTR_NAME
#define NFSACL_T struct acl
#else
#define NFSACL_T void
#endif
/*
* These should be defined as the types used for the corresponding VOP's

View File

@ -81,10 +81,8 @@ static int nfsrpc_createv4(vnode_t , char *, int, struct vattr *,
static int nfsrpc_locku(struct nfsrv_descript *, struct nfsmount *,
struct nfscllockowner *, u_int64_t, u_int64_t,
u_int32_t, struct ucred *, NFSPROC_T *, int);
#ifdef NFS4_ACL_EXTATTR_NAME
static int nfsrpc_setaclrpc(vnode_t, struct ucred *, NFSPROC_T *,
struct acl *, nfsv4stateid_t *, void *);
#endif
/*
* nfs null call from vfs.
@ -983,14 +981,9 @@ nfsrpc_setattr(vnode_t vp, struct vattr *vap, NFSACL_T *aclp,
if (vap != NULL)
error = nfsrpc_setattrrpc(vp, vap, &stateid, cred, p,
rnap, attrflagp, stuff);
#ifdef NFS4_ACL_EXTATTR_NAME
else
error = nfsrpc_setaclrpc(vp, cred, p, aclp, &stateid,
stuff);
#else
else
error = EOPNOTSUPP;
#endif
if (error == NFSERR_STALESTATEID)
nfscl_initiate_recovery(nmp->nm_clp);
if (lckp != NULL)
@ -4094,7 +4087,6 @@ nfsrpc_delegreturn(struct nfscldeleg *dp, struct ucred *cred,
return (error);
}
#ifdef NFS4_ACL_EXTATTR_NAME
/*
* nfs getacl call.
*/
@ -4168,5 +4160,3 @@ nfsrpc_setaclrpc(vnode_t vp, struct ucred *cred, NFSPROC_T *p,
mbuf_freem(nd->nd_mrep);
return (nd->nd_repstat);
}
#endif /* NFS4_ACL_EXTATTR_NAME */

View File

@ -128,10 +128,8 @@ static vop_readlink_t nfs_readlink;
static vop_print_t nfs_print;
static vop_advlock_t nfs_advlock;
static vop_advlockasync_t nfs_advlockasync;
#ifdef NFS4_ACL_EXTATTR_NAME
static vop_getacl_t nfs_getacl;
static vop_setacl_t nfs_setacl;
#endif
/*
* Global vfs data structures for nfs
@ -166,10 +164,8 @@ struct vop_vector newnfs_vnodeops = {
.vop_strategy = nfs_strategy,
.vop_symlink = nfs_symlink,
.vop_write = ncl_write,
#ifdef NFS4_ACL_EXTATTR_NAME
.vop_getacl = nfs_getacl,
.vop_setacl = nfs_setacl,
#endif
};
struct vop_vector newnfs_fifoops = {
@ -331,12 +327,9 @@ nfs_access(struct vop_access_args *ap)
* unless the file is a socket, fifo, or a block or character
* device resident on the filesystem.
*/
if ((ap->a_accmode & (VWRITE | VAPPEND
#ifdef NFS4_ACL_EXTATTR_NAME
| VWRITE_NAMED_ATTRS | VDELETE_CHILD | VWRITE_ATTRIBUTES |
VDELETE | VWRITE_ACL | VWRITE_OWNER
#endif
)) != 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
if ((ap->a_accmode & (VWRITE | VAPPEND | VWRITE_NAMED_ATTRS |
VDELETE_CHILD | VWRITE_ATTRIBUTES | VDELETE | VWRITE_ACL |
VWRITE_OWNER)) != 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
switch (vp->v_type) {
case VREG:
case VDIR:
@ -366,10 +359,8 @@ nfs_access(struct vop_access_args *ap)
mode |= NFSACCESS_EXTEND;
if (ap->a_accmode & VEXEC)
mode |= NFSACCESS_EXECUTE;
#ifdef NFS4_ACL_EXTATTR_NAME
if (ap->a_accmode & VDELETE)
mode |= NFSACCESS_DELETE;
#endif
} else {
if (ap->a_accmode & VWRITE)
mode |= (NFSACCESS_MODIFY | NFSACCESS_EXTEND);
@ -377,12 +368,10 @@ nfs_access(struct vop_access_args *ap)
mode |= NFSACCESS_EXTEND;
if (ap->a_accmode & VEXEC)
mode |= NFSACCESS_LOOKUP;
#ifdef NFS4_ACL_EXTATTR_NAME
if (ap->a_accmode & VDELETE)
mode |= NFSACCESS_DELETE;
if (ap->a_accmode & VDELETE_CHILD)
mode |= NFSACCESS_MODIFY;
#endif
}
/* XXX safety belt, only make blanket request if caching */
if (nfsaccess_cache_timeout > 0) {
@ -3136,7 +3125,6 @@ nfs_lock1(struct vop_lock1_args *ap)
ap->a_line));
}
#ifdef NFS4_ACL_EXTATTR_NAME
static int
nfs_getacl(struct vop_getacl_args *ap)
{
@ -3168,5 +3156,3 @@ nfs_setacl(struct vop_setacl_args *ap)
}
return (error);
}
#endif /* NFS4_ACL_EXTATTR_NAME */