Deleted Added
full compact
mountd.c (117684) mountd.c (121556)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Herb Hasler and Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 33 unchanged lines hidden (view full) ---

42
43#if 0
44#ifndef lint
45static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
46#endif /*not lint*/
47#endif
48
49#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Herb Hasler and Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 33 unchanged lines hidden (view full) ---

42
43#if 0
44#ifndef lint
45static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
46#endif /*not lint*/
47#endif
48
49#include <sys/cdefs.h>
50__FBSDID("$FreeBSD: head/usr.sbin/mountd/mountd.c 117684 2003-07-17 10:11:26Z rwatson $");
50__FBSDID("$FreeBSD: head/usr.sbin/mountd/mountd.c 121556 2003-10-26 05:58:21Z peter $");
51
52#include <sys/param.h>
53#include <sys/mount.h>
54#include <sys/fcntl.h>
55#include <sys/stat.h>
56#include <sys/syslog.h>
57#include <sys/sysctl.h>
58#include <sys/linker.h>

--- 485 unchanged lines hidden (view full) ---

544 }
545 lookup_failed = getnameinfo(saddr, saddr->sa_len, host, sizeof host,
546 NULL, 0, 0);
547 getnameinfo(saddr, saddr->sa_len, numerichost,
548 sizeof numerichost, NULL, 0, NI_NUMERICHOST);
549 ai = NULL;
550 switch (rqstp->rq_proc) {
551 case NULLPROC:
51
52#include <sys/param.h>
53#include <sys/mount.h>
54#include <sys/fcntl.h>
55#include <sys/stat.h>
56#include <sys/syslog.h>
57#include <sys/sysctl.h>
58#include <sys/linker.h>

--- 485 unchanged lines hidden (view full) ---

544 }
545 lookup_failed = getnameinfo(saddr, saddr->sa_len, host, sizeof host,
546 NULL, 0, 0);
547 getnameinfo(saddr, saddr->sa_len, numerichost,
548 sizeof numerichost, NULL, 0, NI_NUMERICHOST);
549 ai = NULL;
550 switch (rqstp->rq_proc) {
551 case NULLPROC:
552 if (!svc_sendreply(transp, xdr_void, NULL))
552 if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL))
553 syslog(LOG_ERR, "can't send reply");
554 return;
555 case RPCMNT_MOUNT:
556 if (sport >= IPPORT_RESERVED && resvport_only) {
557 syslog(LOG_NOTICE,
558 "mount request from %s from unprivileged port",
559 numerichost);
560 svcerr_weakauth(transp);
561 return;
562 }
553 syslog(LOG_ERR, "can't send reply");
554 return;
555 case RPCMNT_MOUNT:
556 if (sport >= IPPORT_RESERVED && resvport_only) {
557 syslog(LOG_NOTICE,
558 "mount request from %s from unprivileged port",
559 numerichost);
560 svcerr_weakauth(transp);
561 return;
562 }
563 if (!svc_getargs(transp, xdr_dir, rpcpath)) {
563 if (!svc_getargs(transp, (xdrproc_t)xdr_dir, rpcpath)) {
564 syslog(LOG_NOTICE, "undecodable mount request from %s",
565 numerichost);
566 svcerr_decode(transp);
567 return;
568 }
569
570 /*
571 * Get the real pathname and make sure it is a directory

--- 19 unchanged lines hidden (view full) ---

591 ep = ex_search(&fsb.f_fsid);
592 hostset = defset = 0;
593 if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) ||
594 ((dp = dirp_search(ep->ex_dirl, dirpath)) &&
595 chk_host(dp, saddr, &defset, &hostset)) ||
596 (defset && scan_tree(ep->ex_defdir, saddr) == 0 &&
597 scan_tree(ep->ex_dirl, saddr) == 0))) {
598 if (bad) {
564 syslog(LOG_NOTICE, "undecodable mount request from %s",
565 numerichost);
566 svcerr_decode(transp);
567 return;
568 }
569
570 /*
571 * Get the real pathname and make sure it is a directory

--- 19 unchanged lines hidden (view full) ---

591 ep = ex_search(&fsb.f_fsid);
592 hostset = defset = 0;
593 if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) ||
594 ((dp = dirp_search(ep->ex_dirl, dirpath)) &&
595 chk_host(dp, saddr, &defset, &hostset)) ||
596 (defset && scan_tree(ep->ex_defdir, saddr) == 0 &&
597 scan_tree(ep->ex_dirl, saddr) == 0))) {
598 if (bad) {
599 if (!svc_sendreply(transp, xdr_long,
599 if (!svc_sendreply(transp, (xdrproc_t)xdr_long,
600 (caddr_t)&bad))
601 syslog(LOG_ERR, "can't send reply");
602 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
603 return;
604 }
605 if (hostset & DP_HOSTSET)
606 fhr.fhr_flag = hostset;
607 else
608 fhr.fhr_flag = defset;
609 fhr.fhr_vers = rqstp->rq_vers;
610 /* Get the file handle */
611 memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t));
612 if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) {
613 bad = errno;
614 syslog(LOG_ERR, "can't get fh for %s", dirpath);
600 (caddr_t)&bad))
601 syslog(LOG_ERR, "can't send reply");
602 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
603 return;
604 }
605 if (hostset & DP_HOSTSET)
606 fhr.fhr_flag = hostset;
607 else
608 fhr.fhr_flag = defset;
609 fhr.fhr_vers = rqstp->rq_vers;
610 /* Get the file handle */
611 memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t));
612 if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) {
613 bad = errno;
614 syslog(LOG_ERR, "can't get fh for %s", dirpath);
615 if (!svc_sendreply(transp, xdr_long,
615 if (!svc_sendreply(transp, (xdrproc_t)xdr_long,
616 (caddr_t)&bad))
617 syslog(LOG_ERR, "can't send reply");
618 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
619 return;
620 }
616 (caddr_t)&bad))
617 syslog(LOG_ERR, "can't send reply");
618 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
619 return;
620 }
621 if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr))
621 if (!svc_sendreply(transp, (xdrproc_t)xdr_fhs,
622 (caddr_t)&fhr))
622 syslog(LOG_ERR, "can't send reply");
623 if (!lookup_failed)
624 add_mlist(host, dirpath);
625 else
626 add_mlist(numerichost, dirpath);
627 if (debug)
628 warnx("mount successful");
629 if (log)
630 syslog(LOG_NOTICE,
631 "mount request succeeded from %s for %s",
632 numerichost, dirpath);
633 } else {
634 bad = EACCES;
635 syslog(LOG_NOTICE,
636 "mount request denied from %s for %s",
637 numerichost, dirpath);
638 }
639
623 syslog(LOG_ERR, "can't send reply");
624 if (!lookup_failed)
625 add_mlist(host, dirpath);
626 else
627 add_mlist(numerichost, dirpath);
628 if (debug)
629 warnx("mount successful");
630 if (log)
631 syslog(LOG_NOTICE,
632 "mount request succeeded from %s for %s",
633 numerichost, dirpath);
634 } else {
635 bad = EACCES;
636 syslog(LOG_NOTICE,
637 "mount request denied from %s for %s",
638 numerichost, dirpath);
639 }
640
640 if (bad && !svc_sendreply(transp, xdr_long, (caddr_t)&bad))
641 if (bad && !svc_sendreply(transp, (xdrproc_t)xdr_long,
642 (caddr_t)&bad))
641 syslog(LOG_ERR, "can't send reply");
642 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
643 return;
644 case RPCMNT_DUMP:
643 syslog(LOG_ERR, "can't send reply");
644 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
645 return;
646 case RPCMNT_DUMP:
645 if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL))
647 if (!svc_sendreply(transp, (xdrproc_t)xdr_mlist, (caddr_t)NULL))
646 syslog(LOG_ERR, "can't send reply");
647 else if (log)
648 syslog(LOG_NOTICE,
649 "dump request succeeded from %s",
650 numerichost);
651 return;
652 case RPCMNT_UMOUNT:
653 if (sport >= IPPORT_RESERVED && resvport_only) {
654 syslog(LOG_NOTICE,
655 "umount request from %s from unprivileged port",
656 numerichost);
657 svcerr_weakauth(transp);
658 return;
659 }
648 syslog(LOG_ERR, "can't send reply");
649 else if (log)
650 syslog(LOG_NOTICE,
651 "dump request succeeded from %s",
652 numerichost);
653 return;
654 case RPCMNT_UMOUNT:
655 if (sport >= IPPORT_RESERVED && resvport_only) {
656 syslog(LOG_NOTICE,
657 "umount request from %s from unprivileged port",
658 numerichost);
659 svcerr_weakauth(transp);
660 return;
661 }
660 if (!svc_getargs(transp, xdr_dir, rpcpath)) {
662 if (!svc_getargs(transp, (xdrproc_t)xdr_dir, rpcpath)) {
661 syslog(LOG_NOTICE, "undecodable umount request from %s",
662 numerichost);
663 svcerr_decode(transp);
664 return;
665 }
666 if (realpath(rpcpath, dirpath) == NULL) {
667 syslog(LOG_NOTICE, "umount request from %s "
668 "for non existent path %s",
669 numerichost, dirpath);
670 }
663 syslog(LOG_NOTICE, "undecodable umount request from %s",
664 numerichost);
665 svcerr_decode(transp);
666 return;
667 }
668 if (realpath(rpcpath, dirpath) == NULL) {
669 syslog(LOG_NOTICE, "umount request from %s "
670 "for non existent path %s",
671 numerichost, dirpath);
672 }
671 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
673 if (!svc_sendreply(transp, (xdrproc_t)xdr_void, (caddr_t)NULL))
672 syslog(LOG_ERR, "can't send reply");
673 if (!lookup_failed)
674 del_mlist(host, dirpath);
675 del_mlist(numerichost, dirpath);
676 if (log)
677 syslog(LOG_NOTICE,
678 "umount request succeeded from %s for %s",
679 numerichost, dirpath);
680 return;
681 case RPCMNT_UMNTALL:
682 if (sport >= IPPORT_RESERVED && resvport_only) {
683 syslog(LOG_NOTICE,
684 "umountall request from %s from unprivileged port",
685 numerichost);
686 svcerr_weakauth(transp);
687 return;
688 }
674 syslog(LOG_ERR, "can't send reply");
675 if (!lookup_failed)
676 del_mlist(host, dirpath);
677 del_mlist(numerichost, dirpath);
678 if (log)
679 syslog(LOG_NOTICE,
680 "umount request succeeded from %s for %s",
681 numerichost, dirpath);
682 return;
683 case RPCMNT_UMNTALL:
684 if (sport >= IPPORT_RESERVED && resvport_only) {
685 syslog(LOG_NOTICE,
686 "umountall request from %s from unprivileged port",
687 numerichost);
688 svcerr_weakauth(transp);
689 return;
690 }
689 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
691 if (!svc_sendreply(transp, (xdrproc_t)xdr_void, (caddr_t)NULL))
690 syslog(LOG_ERR, "can't send reply");
691 if (!lookup_failed)
692 del_mlist(host, NULL);
693 del_mlist(numerichost, NULL);
694 if (log)
695 syslog(LOG_NOTICE,
696 "umountall request succeeded from %s",
697 numerichost);
698 return;
699 case RPCMNT_EXPORT:
692 syslog(LOG_ERR, "can't send reply");
693 if (!lookup_failed)
694 del_mlist(host, NULL);
695 del_mlist(numerichost, NULL);
696 if (log)
697 syslog(LOG_NOTICE,
698 "umountall request succeeded from %s",
699 numerichost);
700 return;
701 case RPCMNT_EXPORT:
700 if (!svc_sendreply(transp, xdr_explist, (caddr_t)NULL))
701 if (!svc_sendreply(transp, xdr_explist_brief, (caddr_t)NULL))
702 if (!svc_sendreply(transp, (xdrproc_t)xdr_explist, (caddr_t)NULL))
703 if (!svc_sendreply(transp, (xdrproc_t)xdr_explist_brief,
704 (caddr_t)NULL))
702 syslog(LOG_ERR, "can't send reply");
703 if (log)
704 syslog(LOG_NOTICE,
705 "export request succeeded from %s",
706 numerichost);
707 return;
708 default:
709 svcerr_noproc(transp);

--- 1783 unchanged lines hidden ---
705 syslog(LOG_ERR, "can't send reply");
706 if (log)
707 syslog(LOG_NOTICE,
708 "export request succeeded from %s",
709 numerichost);
710 return;
711 default:
712 svcerr_noproc(transp);

--- 1783 unchanged lines hidden ---