export verification is now done in fstovp
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 7 Jul 1992 09:25:17 +0000 (01:25 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 7 Jul 1992 09:25:17 +0000 (01:25 -0800)
SCCS-vsn: sys/ufs/ffs/ffs_vfsops.c 7.72

usr/src/sys/ufs/ffs/ffs_vfsops.c

index b60be93..c5e6f66 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ffs_vfsops.c        7.71 (Berkeley) %G%
+ *     @(#)ffs_vfsops.c        7.72 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
 #include <sys/specdev.h>
 #include <sys/mount.h>
 #include <sys/buf.h>
 #include <sys/specdev.h>
 #include <sys/mount.h>
 #include <sys/buf.h>
+#include <sys/mbuf.h>
 #include <sys/file.h>
 #include <sys/disklabel.h>
 #include <sys/ioctl.h>
 #include <sys/errno.h>
 #include <sys/malloc.h>
 #include <sys/file.h>
 #include <sys/disklabel.h>
 #include <sys/ioctl.h>
 #include <sys/errno.h>
 #include <sys/malloc.h>
+#include <sys/socket.h>
 #include "ioctl.h"
 #include "disklabel.h"
 #include "stat.h"
 #include "ioctl.h"
 #include "disklabel.h"
 #include "stat.h"
@@ -610,24 +612,74 @@ ffs_vget(mp, ino, vpp)
  * - check that the inode number is valid
  * - call ffs_vget() to get the locked inode
  * - check for an unallocated inode (i_mode == 0)
  * - check that the inode number is valid
  * - call ffs_vget() to get the locked inode
  * - check for an unallocated inode (i_mode == 0)
+ * - check that the given client host has export rights and return
+ *   those rights via. exflagsp and credanonp
  */
 int
  */
 int
-ffs_fhtovp(mp, fhp, vpp)
+ffs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
        register struct mount *mp;
        struct fid *fhp;
        register struct mount *mp;
        struct fid *fhp;
+       struct mbuf *nam;
        struct vnode **vpp;
        struct vnode **vpp;
+       int *exflagsp;
+       struct ucred **credanonp;
 {
        register struct inode *ip;
        register struct ufid *ufhp;
 {
        register struct inode *ip;
        register struct ufid *ufhp;
+       register struct netaddrhash *np;
+       register struct ufsmount *ump = VFSTOUFS(mp);
        struct fs *fs;
        struct vnode *nvp;
        struct fs *fs;
        struct vnode *nvp;
+       struct sockaddr *saddr;
        int error;
 
        ufhp = (struct ufid *)fhp;
        int error;
 
        ufhp = (struct ufid *)fhp;
-       fs = VFSTOUFS(mp)->um_fs;
+       fs = ump->um_fs;
        if (ufhp->ufid_ino < ROOTINO ||
            ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg)
        if (ufhp->ufid_ino < ROOTINO ||
            ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg)
-               return (EINVAL);
+               return (ESTALE);
+       /*
+        * Get the export permission structure for this <mp, client> tuple.
+        */
+       if ((mp->mnt_flag & MNT_EXPORTED) == 0)
+               return (EACCES);
+       if (nam == NULL) {
+               np = (struct netaddrhash *)0;
+       } else {
+               /*
+                * First search for a network match.
+                */
+               np = ump->um_netaddr[NETMASK_HASH];
+               while (np) {
+                       if (netaddr_match(np->neth_family, &np->neth_haddr,
+                           &np->neth_hmask, nam))
+                               break;
+                       np = np->neth_next;
+               }
+
+               /*
+                * If not found, try for an address match.
+                */
+               if (np == (struct netaddrhash *)0) {
+                       saddr = mtod(nam, struct sockaddr *);
+                       np = ump->um_netaddr[NETADDRHASH(saddr)];
+                       while (np) {
+                               if (netaddr_match(np->neth_family,
+                                   &np->neth_haddr, (struct netaddrhash *)0,
+                                   nam))
+                                       break;
+                               np = np->neth_next;
+                       }
+               }
+       }
+       if (np == (struct netaddrhash *)0) {
+               /*
+                * If no address match, use the default if it exists.
+                */
+               if ((mp->mnt_flag & MNT_DEFEXPORTED) == 0)
+                       return (EACCES);
+               np = &ump->um_defexported;
+       }
        if (error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) {
                *vpp = NULLVP;
                return (error);
        if (error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) {
                *vpp = NULLVP;
                return (error);
@@ -636,9 +688,11 @@ ffs_fhtovp(mp, fhp, vpp)
        if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) {
                ufs_iput(ip);
                *vpp = NULLVP;
        if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) {
                ufs_iput(ip);
                *vpp = NULLVP;
-               return (EINVAL);
+               return (ESTALE);
        }
        *vpp = nvp;
        }
        *vpp = nvp;
+       *exflagsp = np->neth_exflags;
+       *credanonp = &np->neth_anon;
        return (0);
 }
 
        return (0);
 }