mountd.c (75635) | mountd.c (75641) |
---|---|
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 --- 31 unchanged lines hidden (view full) --- 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /*not lint*/ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; 46#endif 47static const char rcsid[] = | 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 --- 31 unchanged lines hidden (view full) --- 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /*not lint*/ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; 46#endif 47static const char rcsid[] = |
48 "$FreeBSD: head/usr.sbin/mountd/mountd.c 75635 2001-04-17 22:25:48Z iedowse $"; | 48 "$FreeBSD: head/usr.sbin/mountd/mountd.c 75641 2001-04-18 00:28:37Z iedowse $"; |
49#endif /*not lint*/ 50 51#include <sys/param.h> 52#include <sys/mount.h> 53#include <sys/fcntl.h> 54#include <sys/stat.h> 55#include <sys/syslog.h> 56#include <sys/sysctl.h> --- 81 unchanged lines hidden (view full) --- 138 int gr_type; 139 union grouptypes gr_ptr; 140 struct grouplist *gr_next; 141}; 142/* Group types */ 143#define GT_NULL 0x0 144#define GT_HOST 0x1 145#define GT_NET 0x2 | 49#endif /*not lint*/ 50 51#include <sys/param.h> 52#include <sys/mount.h> 53#include <sys/fcntl.h> 54#include <sys/stat.h> 55#include <sys/syslog.h> 56#include <sys/sysctl.h> --- 81 unchanged lines hidden (view full) --- 138 int gr_type; 139 union grouptypes gr_ptr; 140 struct grouplist *gr_next; 141}; 142/* Group types */ 143#define GT_NULL 0x0 144#define GT_HOST 0x1 145#define GT_NET 0x2 |
146#define GT_DEFAULT 0x3 |
|
146#define GT_IGNORE 0x5 147 148struct hostlist { 149 int ht_flag; /* Uses DP_xx bits */ 150 struct grouplist *ht_grp; 151 struct hostlist *ht_next; 152}; 153 --- 720 unchanged lines hidden (view full) --- 874void 875get_exportlist() 876{ 877 struct exportlist *ep, *ep2; 878 struct grouplist *grp, *tgrp; 879 struct exportlist **epp; 880 struct dirlist *dirhead; 881 struct statfs fsb, *fsp; | 147#define GT_IGNORE 0x5 148 149struct hostlist { 150 int ht_flag; /* Uses DP_xx bits */ 151 struct grouplist *ht_grp; 152 struct hostlist *ht_next; 153}; 154 --- 720 unchanged lines hidden (view full) --- 875void 876get_exportlist() 877{ 878 struct exportlist *ep, *ep2; 879 struct grouplist *grp, *tgrp; 880 struct exportlist **epp; 881 struct dirlist *dirhead; 882 struct statfs fsb, *fsp; |
882 struct addrinfo *ai; | |
883 struct xucred anon; 884 char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc; 885 int len, has_host, exflags, got_nondir, dirplen, num, i, netgrp; 886 887 dirp = NULL; 888 dirplen = 0; 889 890 /* --- 191 unchanged lines hidden (view full) --- 1082 nextfield(&cp, &endcp); 1083 len = endcp - cp; 1084 } 1085 if (check_options(dirhead)) { 1086 getexp_err(ep, tgrp); 1087 goto nextline; 1088 } 1089 if (!has_host) { | 883 struct xucred anon; 884 char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc; 885 int len, has_host, exflags, got_nondir, dirplen, num, i, netgrp; 886 887 dirp = NULL; 888 dirplen = 0; 889 890 /* --- 191 unchanged lines hidden (view full) --- 1082 nextfield(&cp, &endcp); 1083 len = endcp - cp; 1084 } 1085 if (check_options(dirhead)) { 1086 getexp_err(ep, tgrp); 1087 goto nextline; 1088 } 1089 if (!has_host) { |
1090 grp->gr_type = GT_HOST; | 1090 grp->gr_type = GT_DEFAULT; |
1091 if (debug) 1092 warnx("adding a default entry"); | 1091 if (debug) 1092 warnx("adding a default entry"); |
1093 /* add a default group and make the grp list NULL */ 1094 ai = malloc(sizeof(struct addrinfo)); 1095 ai->ai_flags = 0; 1096 ai->ai_family = AF_INET; /* XXXX */ 1097 ai->ai_socktype = SOCK_DGRAM; 1098 /* setting the length to 0 will match anything */ 1099 ai->ai_addrlen = 0; 1100 ai->ai_flags = AI_CANONNAME; 1101 ai->ai_canonname = strdup("Default"); 1102 ai->ai_addr = NULL; 1103 ai->ai_next = NULL; 1104 grp->gr_ptr.gt_addrinfo = ai; | |
1105 1106 /* 1107 * Don't allow a network export coincide with a list of 1108 * host(s) on the same line. 1109 */ 1110 } else if ((opt_flags & OP_NET) && tgrp->gr_next) { 1111 getexp_err(ep, tgrp); 1112 goto nextline; --- 544 unchanged lines hidden (view full) --- 1657 grp->gr_ptr.gt_addrinfo = ai; 1658 while (ai != NULL) { 1659 if (ai->ai_canonname == NULL) { 1660 if (getnameinfo(ai->ai_addr, ai->ai_addrlen, host, 1661 sizeof host, NULL, 0, ninumeric) != 0) 1662 strlcpy(host, "?", sizeof(host)); 1663 ai->ai_canonname = strdup(host); 1664 ai->ai_flags |= AI_CANONNAME; | 1093 1094 /* 1095 * Don't allow a network export coincide with a list of 1096 * host(s) on the same line. 1097 */ 1098 } else if ((opt_flags & OP_NET) && tgrp->gr_next) { 1099 getexp_err(ep, tgrp); 1100 goto nextline; --- 544 unchanged lines hidden (view full) --- 1645 grp->gr_ptr.gt_addrinfo = ai; 1646 while (ai != NULL) { 1647 if (ai->ai_canonname == NULL) { 1648 if (getnameinfo(ai->ai_addr, ai->ai_addrlen, host, 1649 sizeof host, NULL, 0, ninumeric) != 0) 1650 strlcpy(host, "?", sizeof(host)); 1651 ai->ai_canonname = strdup(host); 1652 ai->ai_flags |= AI_CANONNAME; |
1665 } else 1666 ai->ai_flags &= ~AI_CANONNAME; | 1653 } |
1667 if (debug) 1668 fprintf(stderr, "got host %s\n", ai->ai_canonname); 1669 /* 1670 * Sanity check: make sure we don't already have an entry 1671 * for this host in the grouplist. 1672 */ 1673 for (checkgrp = tgrp; checkgrp != NULL; 1674 checkgrp = checkgrp->gr_next) { --- 86 unchanged lines hidden (view full) --- 1761 struct exportlist *ep; 1762 struct grouplist *grp; 1763 int exflags; 1764 struct xucred *anoncrp; 1765 char *dirp; 1766 int dirplen; 1767 struct statfs *fsb; 1768{ | 1654 if (debug) 1655 fprintf(stderr, "got host %s\n", ai->ai_canonname); 1656 /* 1657 * Sanity check: make sure we don't already have an entry 1658 * for this host in the grouplist. 1659 */ 1660 for (checkgrp = tgrp; checkgrp != NULL; 1661 checkgrp = checkgrp->gr_next) { --- 86 unchanged lines hidden (view full) --- 1748 struct exportlist *ep; 1749 struct grouplist *grp; 1750 int exflags; 1751 struct xucred *anoncrp; 1752 char *dirp; 1753 int dirplen; 1754 struct statfs *fsb; 1755{ |
1769 struct sockaddr *addrp; | |
1770 struct sockaddr_storage ss; 1771 struct addrinfo *ai; | 1756 struct sockaddr_storage ss; 1757 struct addrinfo *ai; |
1772 int addrlen; | |
1773 char *cp = NULL; 1774 int done; 1775 char savedc = '\0'; 1776 union { 1777 struct ufs_args ua; 1778 struct iso_args ia; 1779 struct mfs_args ma; 1780#ifdef __NetBSD__ 1781 struct msdosfs_args da; 1782 struct adosfs_args aa; 1783#endif 1784 struct ntfs_args na; 1785 } args; 1786 | 1758 char *cp = NULL; 1759 int done; 1760 char savedc = '\0'; 1761 union { 1762 struct ufs_args ua; 1763 struct iso_args ia; 1764 struct mfs_args ma; 1765#ifdef __NetBSD__ 1766 struct msdosfs_args da; 1767 struct adosfs_args aa; 1768#endif 1769 struct ntfs_args na; 1770 } args; 1771 |
1787 ai = NULL; 1788 addrlen = 0; | |
1789 args.ua.fspec = 0; 1790 args.ua.export.ex_flags = exflags; 1791 args.ua.export.ex_anon = *anoncrp; 1792 args.ua.export.ex_indexfile = ep->ex_indexfile; | 1772 args.ua.fspec = 0; 1773 args.ua.export.ex_flags = exflags; 1774 args.ua.export.ex_anon = *anoncrp; 1775 args.ua.export.ex_indexfile = ep->ex_indexfile; |
1793 if (grp->gr_type == GT_HOST) { | 1776 if (grp->gr_type == GT_HOST) |
1794 ai = grp->gr_ptr.gt_addrinfo; | 1777 ai = grp->gr_ptr.gt_addrinfo; |
1795 addrp = ai->ai_addr; 1796 addrlen = ai->ai_addrlen; 1797 } else 1798 addrp = NULL; | 1778 else 1779 ai = NULL; |
1799 done = FALSE; 1800 while (!done) { 1801 switch (grp->gr_type) { 1802 case GT_HOST: | 1780 done = FALSE; 1781 while (!done) { 1782 switch (grp->gr_type) { 1783 case GT_HOST: |
1803 if (addrp != NULL && addrp->sa_family == AF_INET6 && 1804 have_v6 == 0) | 1784 if (ai->ai_addr->sa_family == AF_INET6 && have_v6 == 0) |
1805 goto skip; | 1785 goto skip; |
1806 args.ua.export.ex_addr = addrp; 1807 args.ua.export.ex_addrlen = addrlen; | 1786 args.ua.export.ex_addr = ai->ai_addr; 1787 args.ua.export.ex_addrlen = ai->ai_addrlen; |
1808 args.ua.export.ex_masklen = 0; 1809 break; 1810 case GT_NET: 1811 args.ua.export.ex_addr = (struct sockaddr *) 1812 &grp->gr_ptr.gt_net.nt_net; 1813 if (args.ua.export.ex_addr->sa_family == AF_INET6 && 1814 have_v6 == 0) 1815 goto skip; --- 6 unchanged lines hidden (view full) --- 1822 syslog(LOG_ERR, "Bad network flag"); 1823 if (cp) 1824 *cp = savedc; 1825 return (1); 1826 } 1827 args.ua.export.ex_mask = (struct sockaddr *)&ss; 1828 args.ua.export.ex_masklen = ss.ss_len; 1829 break; | 1788 args.ua.export.ex_masklen = 0; 1789 break; 1790 case GT_NET: 1791 args.ua.export.ex_addr = (struct sockaddr *) 1792 &grp->gr_ptr.gt_net.nt_net; 1793 if (args.ua.export.ex_addr->sa_family == AF_INET6 && 1794 have_v6 == 0) 1795 goto skip; --- 6 unchanged lines hidden (view full) --- 1802 syslog(LOG_ERR, "Bad network flag"); 1803 if (cp) 1804 *cp = savedc; 1805 return (1); 1806 } 1807 args.ua.export.ex_mask = (struct sockaddr *)&ss; 1808 args.ua.export.ex_masklen = ss.ss_len; 1809 break; |
1810 case GT_DEFAULT: 1811 args.ua.export.ex_addr = NULL; 1812 args.ua.export.ex_addrlen = 0; 1813 args.ua.export.ex_mask = NULL; 1814 args.ua.export.ex_masklen = 0; 1815 break; |
|
1830 case GT_IGNORE: 1831 return(0); 1832 break; 1833 default: 1834 syslog(LOG_ERR, "bad grouptype"); 1835 if (cp) 1836 *cp = savedc; 1837 return (1); --- 35 unchanged lines hidden (view full) --- 1873 warnx("mnt unsucc"); 1874 syslog(LOG_ERR, "can't export %s", dirp); 1875 return (1); 1876 } 1877 savedc = *cp; 1878 *cp = '\0'; 1879 } 1880skip: | 1816 case GT_IGNORE: 1817 return(0); 1818 break; 1819 default: 1820 syslog(LOG_ERR, "bad grouptype"); 1821 if (cp) 1822 *cp = savedc; 1823 return (1); --- 35 unchanged lines hidden (view full) --- 1859 warnx("mnt unsucc"); 1860 syslog(LOG_ERR, "can't export %s", dirp); 1861 return (1); 1862 } 1863 savedc = *cp; 1864 *cp = '\0'; 1865 } 1866skip: |
1881 if (addrp) { | 1867 if (ai != NULL) |
1882 ai = ai->ai_next; | 1868 ai = ai->ai_next; |
1883 if (ai == NULL) 1884 done = TRUE; 1885 else { 1886 addrp = ai->ai_addr; 1887 addrlen = ai->ai_addrlen; 1888 } 1889 } else | 1869 if (ai == NULL) |
1890 done = TRUE; 1891 } 1892 if (cp) 1893 *cp = savedc; 1894 return (0); 1895} 1896 1897/* --- 589 unchanged lines hidden --- | 1870 done = TRUE; 1871 } 1872 if (cp) 1873 *cp = savedc; 1874 return (0); 1875} 1876 1877/* --- 589 unchanged lines hidden --- |