nfsd-acl
Subsystems (3)
PATCH 10/11 nfsd-acl
Server nfsacl support
Add support for the nfsacl protocol extension to nfsd. This patch also contains a few pieces of infrastructure reused in the client-side code.
Andreas Gruenbacher <[email protected]>, SUSE Labs
fs/Kconfig +14 -0
@@ -1377,6 +1377,7 @@ config NFSD depends on INET select LOCKD select SUNRPC + select NFS_ACL_SUPPORT if NFSD_ACL help If you want your Linux box to act as an NFS *server*, so that other computers on your local network which support NFS can access certain
@@ -1407,6 +1408,19 @@ config NFSD_V3 If you would like to include the NFSv3 server as well as the NFSv2 server, say Y here. If unsure, say Y. +config NFSD_ACL + bool "NFS_ACL protocol extension" + depends on NFSD_V3 + select QSORT + help + Implement the NFS_ACL protocol extension for manipulating POSIX + Access Control Lists on exported file systems. The clients must + also implement the NFS_ACL protocol extension; see the + CONFIG_NFS_ACL option. If unsure, say N. + +config NFS_ACL_SUPPORT + tristate + config NFSD_V4 bool "Provide NFSv4 server support (EXPERIMENTAL)" depends on NFSD_V3 && EXPERIMENTAL
fs/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat obj-$(CONFIG_FS_MBCACHE) += mbcache.o obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o +obj-$(CONFIG_NFS_ACL_SUPPORT) += nfsacl.o obj-$(CONFIG_QUOTA) += dquot.o obj-$(CONFIG_QFMT_V1) += quota_v1.o
fs/nfsacl.c +251 -0
251 lines not on this page · raw message
fs/nfsd/nfs3proc.c +118 -0
145 lines not on this page · raw message
fs/nfsd/nfs3xdr.c +114 -0
135 lines not on this page · raw message
fs/nfsd/nfssvc.c +24 -0
@@ -49,6 +49,9 @@#define SIG_NOCLEAN SIGHUPextern struct svc_program nfsd_program; +#ifdef CONFIG_NFSD_ACL +extern struct svc_program nfsd_acl_program; +#endif static void nfsd (struct svc_rqst *rqstp);struct timeval nfssvc_boot;static struct svc_serv *nfsd_serv;
@@ -369,8 +372,29 @@ static struct svc_version * nfsd_version#endif }; +#ifdef CONFIG_NFSD_ACL +extern struct svc_version nfsd_acl_version3; + +static struct svc_version * nfsd_acl_version[] = { + [3 ] = &nfsd_acl_version3, +}; + +#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0])) +struct svc_program nfsd_acl_program = { + .pg_prog =NFS3_ACL_PROGRAM , + .pg_nvers =NFSD_ACL_NRVERS , + .pg_vers = nfsd_acl_version, + .pg_name ="nfsd" , + .pg_stats = &nfsd_acl_svcstats, +}; +# define nfsd_acl_program_p &nfsd_acl_program +#else +# define nfsd_acl_program_p NULL +#endif +#define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0]))struct svc_program nfsd_program = { + .pg_next = nfsd_acl_program_p, .pg_prog =NFS_PROGRAM ,/* program number */ .pg_nvers =NFSD_NRVERS ,/* nr of entries in nfsd_version */ .pg_vers = nfsd_version,/* version table */
fs/nfsd/stats.c +6 -0
@@ -40,6 +40,12 @@ struct svc_stat nfsd_svcstats = { .program = &nfsd_program, }; +#ifdef CONFIG_NFSD_ACL +struct svc_stat nfsd_acl_svcstats = { + .program = &nfsd_acl_program, +}; +#endif +static int nfsd_proc_show (struct seq_file *seq,void *v) {int i;
fs/nfsd/vfs.c +107 -0
116 lines not on this page · raw message
include/linux/nfs3.h +13 -0
@@ -37,6 +37,15 @@ enum nfs3_createmode { NFS3_CREATE_EXCLUSIVE = 2 }; +/* Flags for the getacl/setacl mode */ +#define NFS3_ACL 0x0001 +#define NFS3_ACLCNT 0x0002 +#define NFS3_DFACL 0x0004 +#define NFS3_DFACLCNT 0x0008 + +/* Flag for Default ACL entries */ +#define NFS3_ACL_DEFAULT 0x1000 +/* NFSv3 file system properties */ #define NFS3_FSF_LINK 0x0001#define NFS3_FSF_SYMLINK 0x0002
@@ -88,6 +97,10 @@ struct nfs3_fh {#define NFS3PROC_PATHCONF 20#define NFS3PROC_COMMIT 21 +#define NFS3_ACL_PROGRAM 100227 +#define NFS3PROC_GETACL 1 +#define NFS3PROC_SETACL 2 +#define NFS_MNT3_PROGRAM 100005#define NFS_MNT3_VERSION 3#define MOUNTPROC3_NULL 0
include/linux/nfsacl.h +37 -0
@@ -0,0 +1,37 @@ +/* +* File: linux/nfsacl.h +* +* (C) 2003 Andreas Gruenbacher <[email protected]> +*/ + + +#ifndef __LINUX_NFSACL_H +#define __LINUX_NFSACL_H + +#include <linux/posix_acl.h> + +/* Maximum number of ACL entries over NFS */ +#define NFS3_ACL_MAX_ENTRIES 1024 + +#define NFSACL_MAXWORDS (2*(2+3*NFS3_ACL_MAX_ENTRIES)) +#define NFSACL_MAXPAGES ((2*(8+12*NFS3_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \ + >> PAGE_SHIFT) + +static inline unsigned int +nfsacl_size (struct posix_acl *acl_access,struct posix_acl *acl_default) +{ +unsigned int w =16 ; + w +=max (acl_access ? (int )acl_access->a_count :3 ,4 ) *12 ; +if (acl_default) + w +=max ((int )acl_default->a_count,4 ) *12 ; +return w; +} + +extern unsigned int +nfsacl_encode (struct xdr_buf *buf,unsigned int base,struct inode *inode, +struct posix_acl *acl,int encode_entries,int typeflag); +extern unsigned int +nfsacl_decode (struct xdr_buf *buf,unsigned int base,unsigned int *aclcnt, +struct posix_acl **pacl); + +#endif /* __LINUX_NFSACL_H */
include/linux/nfsd/nfsd.h +19 -0
@@ -15,6 +15,7 @@#include <linux/unistd.h> #include <linux/dirent.h> #include <linux/fs.h> +#include <linux/posix_acl.h> #include <linux/mount.h> #include <linux/nfsd/debug.h>
@@ -60,6 +61,8 @@ extern struct svc_program nfsd_program;extern struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; +extern struct svc_program nfsd_acl_program; +extern struct svc_version nfsd_acl_version3;/* * Function prototypes. */
@@ -119,6 +122,22 @@ int nfsd_statfs(struct svc_rqst *, struint nfsd_notify_change (struct inode *,struct iattr *);int nfsd_permission (struct svc_export *,struct dentry *,int ); +#ifdef CONFIG_NFSD_ACL +struct posix_acl *nfsd_get_posix_acl (struct svc_fh *,int ); +int nfsd_set_posix_acl (struct svc_fh *,int ,struct posix_acl *); +#else +static inline struct posix_acl * +nfsd_get_posix_acl (struct svc_fh *fhp,int acl_type) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline int +nfsd_set_posix_acl (struct svc_fh *fhp,int type,struct posix_acl *acl) +{ +return -EOPNOTSUPP ; +} +#endif +/* * NFSv4 State
include/linux/nfsd/stats.h +1 -0
@@ -36,6 +36,7 @@ struct nfsd_stats {extern struct nfsd_stats nfsdstats;extern struct svc_stat nfsd_svcstats; +extern struct svc_stat nfsd_acl_svcstats;void nfsd_stat_init (void );void nfsd_stat_shutdown (void );
include/linux/nfsd/xdr3.h +32 -0
@@ -10,6 +10,7 @@#define _LINUX_NFSD_XDR3_H#include <linux/nfsd/xdr.h> +#include <linux/posix_acl.h> struct nfsd3_sattrargs {struct svc_fh fh;
@@ -110,6 +111,18 @@ struct nfsd3_commitargs {__u32 count; }; +struct nfsd3_getaclargs { +struct svc_fh fh; +int mask; +}; + +struct nfsd3_setaclargs { +struct svc_fh fh; +int mask; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +}; +struct nfsd3_attrstat {__u32 status;struct svc_fh fh;
@@ -208,6 +221,14 @@ struct nfsd3_commitres {struct svc_fh fh; }; +struct nfsd3_getaclres { +__u32 status; +struct svc_fh fh; +int mask; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +}; +/* dummy type for release */ struct nfsd3_fhandle_pair {__u32 dummy;
@@ -240,6 +261,7 @@ union nfsd3_xdrstore {struct nfsd3_fsinfores fsinfores;struct nfsd3_pathconfres pathconfres;struct nfsd3_commitres commitres; +struct nfsd3_getaclres getaclres; };#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
@@ -275,6 +297,10 @@ int nfs3svc_decode_readdirplusargs(struc struct nfsd3_readdirargs *);int nfs3svc_decode_commitargs (struct svc_rqst *,u32 *,struct nfsd3_commitargs *); +int nfs3svc_decode_getaclargs (struct svc_rqst *,u32 *, +struct nfsd3_getaclargs *); +int nfs3svc_decode_setaclargs (struct svc_rqst *,u32 *, +struct nfsd3_setaclargs *);int nfs3svc_encode_voidres (struct svc_rqst *,u32 *,void *);int nfs3svc_encode_attrstat (struct svc_rqst *,u32 *,struct nfsd3_attrstat *);
@@ -304,11 +330,17 @@ int nfs3svc_encode_pathconfres(struct sv struct nfsd3_pathconfres *);int nfs3svc_encode_commitres (struct svc_rqst *,u32 *,struct nfsd3_commitres *); +int nfs3svc_encode_getaclres (struct svc_rqst *,u32 *, +struct nfsd3_getaclres *); +int nfs3svc_encode_setaclres (struct svc_rqst *,u32 *, +struct nfsd3_attrstat *);int nfs3svc_release_fhandle (struct svc_rqst *,u32 *,struct nfsd3_attrstat *);int nfs3svc_release_fhandle2 (struct svc_rqst *,u32 *,struct nfsd3_fhandle_pair *); +int nfs3svc_release_getacl (struct svc_rqst *rqstp,u32 *p, +struct nfsd3_getaclres *resp);int nfs3svc_encode_entry (struct readdir_cd *,const char *name,int namlen,loff_t offset,ino_t ino,unsigned int );