-n option allows access from non-priviledged ports (from cgd)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1994 12:57:33 +0000 (04:57 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1994 12:57:33 +0000 (04:57 -0800)
SCCS-vsn: sbin/mountd/mountd.c 8.10
SCCS-vsn: sbin/mountd/mountd.8 8.2

usr/src/sbin/mountd/mountd.8
usr/src/sbin/mountd/mountd.c

index eb1923b..bcf5b7c 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)mountd.8   8.1 (Berkeley) %G%
+.\"     @(#)mountd.8   8.2 (Berkeley) %G%
 .\"
 .Dd 
 .Dt MOUNTD 8
 .\"
 .Dd 
 .Dt MOUNTD 8
@@ -33,11 +33,10 @@ Options and operands available for
 .Nm mountd :
 .Bl -tag -width Ds
 .It Fl n
 .Nm mountd :
 .Bl -tag -width Ds
 .It Fl n
-The
-.Fl n
-option allows non-root mount requests to be served.
-This should only be specified if there are clients such as PC's,
-that require it.
+Do not require that clients make mount requests from reserved ports.
+(Normally, only mount requsts from reserved ports are accepted.)
+This option should only be specified if there are clients, such as PC's,
+that need it.
 .It Ar exportsfile
 The
 .Ar exportsfile
 .It Ar exportsfile
 The
 .Ar exportsfile
index 22b03d3..029d55f 100644 (file)
@@ -15,7 +15,7 @@ static char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)mountd.c   8.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)mountd.c   8.10 (Berkeley) %G%";
 #endif not lint
 
 #include <sys/param.h>
 #endif not lint
 
 #include <sys/param.h>
@@ -176,7 +176,7 @@ struct ucred def_anon = {
        1,
        { (gid_t) -2 }
 };
        1,
        { (gid_t) -2 }
 };
-int root_only = 1;
+int resvport_only = 1;
 int opt_flags;
 /* Bits for above */
 #define        OP_MAPROOT      0x01
 int opt_flags;
 /* Bits for above */
 #define        OP_MAPROOT      0x01
@@ -213,7 +213,7 @@ main(argc, argv)
        while ((c = getopt(argc, argv, "n")) != EOF)
                switch (c) {
                case 'n':
        while ((c = getopt(argc, argv, "n")) != EOF)
                switch (c) {
                case 'n':
-                       root_only = 0;
+                       resvport_only = 0;
                        break;
                default:
                        fprintf(stderr, "Usage: mountd [-n] [export_file]\n");
                        break;
                default:
                        fprintf(stderr, "Usage: mountd [-n] [export_file]\n");
@@ -277,27 +277,16 @@ mntsrv(rqstp, transp)
        struct exportlist *ep;
        struct dirlist *dp;
        nfsv2fh_t nfh;
        struct exportlist *ep;
        struct dirlist *dp;
        nfsv2fh_t nfh;
-       struct authunix_parms *ucr;
        struct stat stb;
        struct statfs fsb;
        struct hostent *hp;
        u_long saddr;
        struct stat stb;
        struct statfs fsb;
        struct hostent *hp;
        u_long saddr;
+       u_short sport;
        char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN];
        int bad = ENOENT, omask, defset;
        char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN];
        int bad = ENOENT, omask, defset;
-       uid_t uid = -2;
-
-       /* Get authorization */
-       switch (rqstp->rq_cred.oa_flavor) {
-       case AUTH_UNIX:
-               ucr = (struct authunix_parms *)rqstp->rq_clntcred;
-               uid = ucr->aup_uid;
-               break;
-       case AUTH_NULL:
-       default:
-               break;
-       }
 
        saddr = transp->xp_raddr.sin_addr.s_addr;
 
        saddr = transp->xp_raddr.sin_addr.s_addr;
+       sport = ntohs(transp->xp_raddr.sin_port);
        hp = (struct hostent *)NULL;
        switch (rqstp->rq_proc) {
        case NULLPROC:
        hp = (struct hostent *)NULL;
        switch (rqstp->rq_proc) {
        case NULLPROC:
@@ -305,7 +294,7 @@ mntsrv(rqstp, transp)
                        syslog(LOG_ERR, "Can't send reply");
                return;
        case RPCMNT_MOUNT:
                        syslog(LOG_ERR, "Can't send reply");
                return;
        case RPCMNT_MOUNT:
-               if ((uid != 0 && root_only) || uid == -2) {
+               if (sport >= IPPORT_RESERVED && resvport_only) {
                        svcerr_weakauth(transp);
                        return;
                }
                        svcerr_weakauth(transp);
                        return;
                }
@@ -315,8 +304,8 @@ mntsrv(rqstp, transp)
                }
 
                /*
                }
 
                /*
-                * Get the real pathname and make sure it is a directory
-                * that exists.
+                * Get the real pathname and make sure it is a file or
+                * directory that exists.
                 */
                if (realpath(rpcpath, dirpath) == 0 ||
                    stat(dirpath, &stb) < 0 ||
                 */
                if (realpath(rpcpath, dirpath) == 0 ||
                    stat(dirpath, &stb) < 0 ||
@@ -374,7 +363,7 @@ mntsrv(rqstp, transp)
                        syslog(LOG_ERR, "Can't send reply");
                return;
        case RPCMNT_UMOUNT:
                        syslog(LOG_ERR, "Can't send reply");
                return;
        case RPCMNT_UMOUNT:
-               if ((uid != 0 && root_only) || uid == -2) {
+               if (sport >= IPPORT_RESERVED && resvport_only) {
                        svcerr_weakauth(transp);
                        return;
                }
                        svcerr_weakauth(transp);
                        return;
                }
@@ -390,7 +379,7 @@ mntsrv(rqstp, transp)
                del_mlist(inet_ntoa(transp->xp_raddr.sin_addr), dirpath);
                return;
        case RPCMNT_UMNTALL:
                del_mlist(inet_ntoa(transp->xp_raddr.sin_addr), dirpath);
                return;
        case RPCMNT_UMNTALL:
-               if ((uid != 0 && root_only) || uid == -2) {
+               if (sport >= IPPORT_RESERVED && resvport_only) {
                        svcerr_weakauth(transp);
                        return;
                }
                        svcerr_weakauth(transp);
                        return;
                }