mountd.c (22990) | mountd.c (23681) |
---|---|
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 --- 27 unchanged lines hidden (view full) --- 36 37#ifndef lint 38static char copyright[] = 39"@(#) Copyright (c) 1989, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /*not lint*/ 42 43#ifndef lint | 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 --- 27 unchanged lines hidden (view full) --- 36 37#ifndef lint 38static char copyright[] = 39"@(#) Copyright (c) 1989, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /*not lint*/ 42 43#ifndef lint |
44/*static char sccsid[] = "From: @(#)mountd.c 8.8 (Berkeley) 2/20/94";*/ | 44/*static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; */ |
45static const char rcsid[] = | 45static const char rcsid[] = |
46 "$Id$"; | 46 "$Id: mountd.c,v 1.13 1997/02/22 14:33:02 peter Exp $"; |
47#endif /*not lint*/ 48 49#include <sys/param.h> 50#include <sys/file.h> 51#include <sys/ioctl.h> 52#include <sys/mount.h> 53#include <sys/socket.h> 54#include <sys/stat.h> 55#include <sys/syslog.h> 56#include <sys/ucred.h> 57 58#include <rpc/rpc.h> 59#include <rpc/pmap_clnt.h> 60#include <rpc/pmap_prot.h> 61#ifdef ISO 62#include <netiso/iso.h> 63#endif 64#include <nfs/rpcv2.h> 65#include <nfs/nfsproto.h> | 47#endif /*not lint*/ 48 49#include <sys/param.h> 50#include <sys/file.h> 51#include <sys/ioctl.h> 52#include <sys/mount.h> 53#include <sys/socket.h> 54#include <sys/stat.h> 55#include <sys/syslog.h> 56#include <sys/ucred.h> 57 58#include <rpc/rpc.h> 59#include <rpc/pmap_clnt.h> 60#include <rpc/pmap_prot.h> 61#ifdef ISO 62#include <netiso/iso.h> 63#endif 64#include <nfs/rpcv2.h> 65#include <nfs/nfsproto.h> |
66#include <ufs/ufs/ufsmount.h> 67#include <msdosfs/msdosfsmount.h> 68#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */ |
|
66 67#include <arpa/inet.h> 68 69#include <ctype.h> 70#include <errno.h> 71#include <grp.h> 72#include <netdb.h> 73#include <pwd.h> --- 171 unchanged lines hidden (view full) --- 245int 246main(argc, argv) 247 int argc; 248 char **argv; 249{ 250 SVCXPRT *udptransp, *tcptransp; 251 int c; 252#ifdef __FreeBSD__ | 69 70#include <arpa/inet.h> 71 72#include <ctype.h> 73#include <errno.h> 74#include <grp.h> 75#include <netdb.h> 76#include <pwd.h> --- 171 unchanged lines hidden (view full) --- 248int 249main(argc, argv) 250 int argc; 251 char **argv; 252{ 253 SVCXPRT *udptransp, *tcptransp; 254 int c; 255#ifdef __FreeBSD__ |
253 struct vfsconf *vfc; | 256 struct vfsconf vfc; 257 int error; |
254 | 258 |
255 vfc = getvfsbyname("nfs"); 256 if(!vfc && vfsisloadable("nfs")) { | 259 error = getvfsbyname("nfs", &vfc); 260 if (error && vfsisloadable("nfs")) { |
257 if(vfsload("nfs")) 258 err(1, "vfsload(nfs)"); 259 endvfsent(); /* flush cache */ | 261 if(vfsload("nfs")) 262 err(1, "vfsload(nfs)"); 263 endvfsent(); /* flush cache */ |
260 vfc = getvfsbyname("nfs"); | 264 error = getvfsbyname("nfs", &vfc); |
261 } | 265 } |
262 if(!vfc) { | 266 if (error) |
263 errx(1, "NFS support is not available in the running kernel"); | 267 errx(1, "NFS support is not available in the running kernel"); |
264 } | |
265#endif /* __FreeBSD__ */ 266 267 while ((c = getopt(argc, argv, "dnr")) != EOF) 268 switch (c) { 269 case 'n': 270 resvport_only = 0; 271 break; 272 case 'r': 273 dir_only = 0; 274 break; 275 case 'd': 276 debug = debug ? 0 : 1; 277 break; 278 default: | 268#endif /* __FreeBSD__ */ 269 270 while ((c = getopt(argc, argv, "dnr")) != EOF) 271 switch (c) { 272 case 'n': 273 resvport_only = 0; 274 break; 275 case 'r': 276 dir_only = 0; 277 break; 278 case 'd': 279 debug = debug ? 0 : 1; 280 break; 281 default: |
279 fprintf(stderr, "Usage: mountd [-r] [-n] [export_file]\n"); | 282 fprintf(stderr, "Usage: mountd [-d] [-r] [-n] [export_file]\n"); |
280 exit(1); 281 }; 282 argc -= optind; 283 argv += optind; 284 grphead = (struct grouplist *)NULL; 285 exphead = (struct exportlist *)NULL; 286 mlhead = (struct mountlist *)NULL; 287 if (argc == 1) { --- 48 unchanged lines hidden (view full) --- 336void 337mntsrv(rqstp, transp) 338 struct svc_req *rqstp; 339 SVCXPRT *transp; 340{ 341 struct exportlist *ep; 342 struct dirlist *dp; 343 struct fhreturn fhr; | 283 exit(1); 284 }; 285 argc -= optind; 286 argv += optind; 287 grphead = (struct grouplist *)NULL; 288 exphead = (struct exportlist *)NULL; 289 mlhead = (struct mountlist *)NULL; 290 if (argc == 1) { --- 48 unchanged lines hidden (view full) --- 339void 340mntsrv(rqstp, transp) 341 struct svc_req *rqstp; 342 SVCXPRT *transp; 343{ 344 struct exportlist *ep; 345 struct dirlist *dp; 346 struct fhreturn fhr; |
344 struct authunix_parms *ucr; | |
345 struct stat stb; 346 struct statfs fsb; 347 struct hostent *hp; 348 u_long saddr; 349 u_short sport; | 347 struct stat stb; 348 struct statfs fsb; 349 struct hostent *hp; 350 u_long saddr; 351 u_short sport; |
350 char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN]; | 352 char rpcpath[RPCMNT_PATHLEN + 1], dirpath[MAXPATHLEN]; |
351 int bad = ENOENT, defset, hostset; 352 sigset_t sighup_mask; 353 354 sigemptyset(&sighup_mask); 355 sigaddset(&sighup_mask, SIGHUP); 356 saddr = transp->xp_raddr.sin_addr.s_addr; 357 sport = ntohs(transp->xp_raddr.sin_port); 358 hp = (struct hostent *)NULL; --- 40 unchanged lines hidden (view full) --- 399 (defset && scan_tree(ep->ex_defdir, saddr) == 0 && 400 scan_tree(ep->ex_dirl, saddr) == 0))) { 401 if (hostset & DP_HOSTSET) 402 fhr.fhr_flag = hostset; 403 else 404 fhr.fhr_flag = defset; 405 fhr.fhr_vers = rqstp->rq_vers; 406 /* Get the file handle */ | 353 int bad = ENOENT, defset, hostset; 354 sigset_t sighup_mask; 355 356 sigemptyset(&sighup_mask); 357 sigaddset(&sighup_mask, SIGHUP); 358 saddr = transp->xp_raddr.sin_addr.s_addr; 359 sport = ntohs(transp->xp_raddr.sin_port); 360 hp = (struct hostent *)NULL; --- 40 unchanged lines hidden (view full) --- 401 (defset && scan_tree(ep->ex_defdir, saddr) == 0 && 402 scan_tree(ep->ex_dirl, saddr) == 0))) { 403 if (hostset & DP_HOSTSET) 404 fhr.fhr_flag = hostset; 405 else 406 fhr.fhr_flag = defset; 407 fhr.fhr_vers = rqstp->rq_vers; 408 /* Get the file handle */ |
407 bzero((caddr_t)&fhr.fhr_fh, sizeof(nfsfh_t)); | 409 memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t)); |
408 if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) { 409 bad = errno; 410 syslog(LOG_ERR, "Can't get fh for %s", dirpath); 411 if (!svc_sendreply(transp, xdr_long, 412 (caddr_t)&bad)) 413 syslog(LOG_ERR, "Can't send reply"); 414 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); 415 return; --- 270 unchanged lines hidden (view full) --- 686 free_grp(tgrp); 687 } 688 grphead = (struct grouplist *)NULL; 689 690 /* 691 * And delete exports that are in the kernel for all local 692 * file systems. 693 * XXX: Should know how to handle all local exportable file systems | 410 if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) { 411 bad = errno; 412 syslog(LOG_ERR, "Can't get fh for %s", dirpath); 413 if (!svc_sendreply(transp, xdr_long, 414 (caddr_t)&bad)) 415 syslog(LOG_ERR, "Can't send reply"); 416 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); 417 return; --- 270 unchanged lines hidden (view full) --- 688 free_grp(tgrp); 689 } 690 grphead = (struct grouplist *)NULL; 691 692 /* 693 * And delete exports that are in the kernel for all local 694 * file systems. 695 * XXX: Should know how to handle all local exportable file systems |
694 * instead of just MOUNT_UFS. | 696 * instead of just "ufs". |
695 */ 696 num = getmntinfo(&fsp, MNT_NOWAIT); 697 for (i = 0; i < num; i++) { 698 union { 699 struct ufs_args ua; 700 struct iso_args ia; 701 struct mfs_args ma; | 697 */ 698 num = getmntinfo(&fsp, MNT_NOWAIT); 699 for (i = 0; i < num; i++) { 700 union { 701 struct ufs_args ua; 702 struct iso_args ia; 703 struct mfs_args ma; |
702#ifdef __NetBSD__ | |
703 struct msdosfs_args da; 704 } targs; 705 | 704 struct msdosfs_args da; 705 } targs; 706 |
706 if (!strcmp(fsp->f_fstypename, MOUNT_MFS) || 707 !strcmp(fsp->f_fstypename, MOUNT_UFS) || 708 !strcmp(fsp->f_fstypename, MOUNT_MSDOS) || 709 !strcmp(fsp->f_fstypename, MOUNT_CD9660)) { | 707 if (!strcmp(fsp->f_fstypename, "mfs") || 708 !strcmp(fsp->f_fstypename, "ufs") || 709 !strcmp(fsp->f_fstypename, "msdos") || 710 !strcmp(fsp->f_fstypename, "cd9660")) { |
710 targs.ua.fspec = NULL; 711 targs.ua.export.ex_flags = MNT_DELEXPORT; 712 if (mount(fsp->f_fstypename, fsp->f_mntonname, | 711 targs.ua.fspec = NULL; 712 targs.ua.export.ex_flags = MNT_DELEXPORT; 713 if (mount(fsp->f_fstypename, fsp->f_mntonname, |
713#else 714 } targs; 715 716 switch (fsp->f_type) { 717 case MOUNT_MFS: 718 case MOUNT_UFS: 719 case MOUNT_CD9660: 720 case MOUNT_MSDOS: 721 targs.ua.fspec = NULL; 722 targs.ua.export.ex_flags = MNT_DELEXPORT; 723 if (mount(fsp->f_type, fsp->f_mntonname, 724#endif | |
725 fsp->f_flags | MNT_UPDATE, 726 (caddr_t)&targs) < 0) 727 syslog(LOG_ERR, "Can't delete exports for %s", 728 fsp->f_mntonname); 729 } 730 fsp++; 731 } 732 --- 225 unchanged lines hidden (view full) --- 958struct exportlist * 959get_exp() 960{ 961 struct exportlist *ep; 962 963 ep = (struct exportlist *)malloc(sizeof (struct exportlist)); 964 if (ep == (struct exportlist *)NULL) 965 out_of_mem(); | 714 fsp->f_flags | MNT_UPDATE, 715 (caddr_t)&targs) < 0) 716 syslog(LOG_ERR, "Can't delete exports for %s", 717 fsp->f_mntonname); 718 } 719 fsp++; 720 } 721 --- 225 unchanged lines hidden (view full) --- 947struct exportlist * 948get_exp() 949{ 950 struct exportlist *ep; 951 952 ep = (struct exportlist *)malloc(sizeof (struct exportlist)); 953 if (ep == (struct exportlist *)NULL) 954 out_of_mem(); |
966 bzero((caddr_t)ep, sizeof (struct exportlist)); | 955 memset(ep, 0, sizeof(struct exportlist)); |
967 return (ep); 968} 969 970/* 971 * Allocate a group list element 972 */ 973struct grouplist * 974get_grp() 975{ 976 struct grouplist *gp; 977 978 gp = (struct grouplist *)malloc(sizeof (struct grouplist)); 979 if (gp == (struct grouplist *)NULL) 980 out_of_mem(); | 956 return (ep); 957} 958 959/* 960 * Allocate a group list element 961 */ 962struct grouplist * 963get_grp() 964{ 965 struct grouplist *gp; 966 967 gp = (struct grouplist *)malloc(sizeof (struct grouplist)); 968 if (gp == (struct grouplist *)NULL) 969 out_of_mem(); |
981 bzero((caddr_t)gp, sizeof (struct grouplist)); | 970 memset(gp, 0, sizeof(struct grouplist)); |
982 return (gp); 983} 984 985/* 986 * Clean up upon an error in get_exportlist(). 987 */ 988void 989getexp_err(ep, grp) --- 275 unchanged lines hidden (view full) --- 1265 cpopt = *cpp; 1266 cpopt++; 1267 cp = *endcpp; 1268 savedc = *cp; 1269 *cp = '\0'; 1270 while (cpopt && *cpopt) { 1271 allflag = 1; 1272 usedarg = -2; | 971 return (gp); 972} 973 974/* 975 * Clean up upon an error in get_exportlist(). 976 */ 977void 978getexp_err(ep, grp) --- 275 unchanged lines hidden (view full) --- 1254 cpopt = *cpp; 1255 cpopt++; 1256 cp = *endcpp; 1257 savedc = *cp; 1258 *cp = '\0'; 1259 while (cpopt && *cpopt) { 1260 allflag = 1; 1261 usedarg = -2; |
1273 if (cpoptend = index(cpopt, ',')) { | 1262 if (cpoptend = strchr(cpopt, ',')) { |
1274 *cpoptend++ = '\0'; | 1263 *cpoptend++ = '\0'; |
1275 if (cpoptarg = index(cpopt, '=')) | 1264 if (cpoptarg = strchr(cpopt, '=')) |
1276 *cpoptarg++ = '\0'; 1277 } else { | 1265 *cpoptarg++ = '\0'; 1266 } else { |
1278 if (cpoptarg = index(cpopt, '=')) | 1267 if (cpoptarg = strchr(cpopt, '=')) |
1279 *cpoptarg++ = '\0'; 1280 else { 1281 *cp = savedc; 1282 nextfield(&cp, &endcp); 1283 **endcpp = '\0'; 1284 if (endcp > cp && *cp != '-') { 1285 cpoptarg = cp; 1286 savedc2 = *endcp; --- 126 unchanged lines hidden (view full) --- 1413 checkgrp = checkgrp->gr_next; 1414 } 1415 1416 grp->gr_type = GT_HOST; 1417 nhp = grp->gr_ptr.gt_hostent = (struct hostent *) 1418 malloc(sizeof(struct hostent)); 1419 if (nhp == (struct hostent *)NULL) 1420 out_of_mem(); | 1268 *cpoptarg++ = '\0'; 1269 else { 1270 *cp = savedc; 1271 nextfield(&cp, &endcp); 1272 **endcpp = '\0'; 1273 if (endcp > cp && *cp != '-') { 1274 cpoptarg = cp; 1275 savedc2 = *endcp; --- 126 unchanged lines hidden (view full) --- 1402 checkgrp = checkgrp->gr_next; 1403 } 1404 1405 grp->gr_type = GT_HOST; 1406 nhp = grp->gr_ptr.gt_hostent = (struct hostent *) 1407 malloc(sizeof(struct hostent)); 1408 if (nhp == (struct hostent *)NULL) 1409 out_of_mem(); |
1421 bcopy((caddr_t)hp, (caddr_t)nhp, 1422 sizeof(struct hostent)); | 1410 memmove(nhp, hp, sizeof(struct hostent)); |
1423 i = strlen(hp->h_name)+1; 1424 nhp->h_name = (char *)malloc(i); 1425 if (nhp->h_name == (char *)NULL) 1426 out_of_mem(); | 1411 i = strlen(hp->h_name)+1; 1412 nhp->h_name = (char *)malloc(i); 1413 if (nhp->h_name == (char *)NULL) 1414 out_of_mem(); |
1427 bcopy(hp->h_name, nhp->h_name, i); | 1415 memmove(nhp->h_name, hp->h_name, i); |
1428 addrp = hp->h_addr_list; 1429 i = 1; 1430 while (*addrp++) 1431 i++; 1432 naddrp = nhp->h_addr_list = (char **) 1433 malloc(i*sizeof(char *)); 1434 if (naddrp == (char **)NULL) 1435 out_of_mem(); 1436 addrp = hp->h_addr_list; 1437 while (*addrp) { 1438 *naddrp = (char *) 1439 malloc(hp->h_length); 1440 if (*naddrp == (char *)NULL) 1441 out_of_mem(); | 1416 addrp = hp->h_addr_list; 1417 i = 1; 1418 while (*addrp++) 1419 i++; 1420 naddrp = nhp->h_addr_list = (char **) 1421 malloc(i*sizeof(char *)); 1422 if (naddrp == (char **)NULL) 1423 out_of_mem(); 1424 addrp = hp->h_addr_list; 1425 while (*addrp) { 1426 *naddrp = (char *) 1427 malloc(hp->h_length); 1428 if (*naddrp == (char *)NULL) 1429 out_of_mem(); |
1442 bcopy(*addrp, *naddrp, 1443 hp->h_length); | 1430 memmove(*naddrp, *addrp, hp->h_length); |
1444 addrp++; 1445 naddrp++; 1446 } 1447 *naddrp = (char *)NULL; 1448 if (debug) 1449 fprintf(stderr, "got host %s\n", hp->h_name); 1450 return (0); 1451} --- 62 unchanged lines hidden (view full) --- 1514 syslog(LOG_ERR, 1515 "iso_addr failed, ignored"); 1516 return (1); 1517 } 1518 isoaddr = (struct sockaddr_iso *) 1519 malloc(sizeof (struct sockaddr_iso)); 1520 if (isoaddr == (struct sockaddr_iso *)NULL) 1521 out_of_mem(); | 1431 addrp++; 1432 naddrp++; 1433 } 1434 *naddrp = (char *)NULL; 1435 if (debug) 1436 fprintf(stderr, "got host %s\n", hp->h_name); 1437 return (0); 1438} --- 62 unchanged lines hidden (view full) --- 1501 syslog(LOG_ERR, 1502 "iso_addr failed, ignored"); 1503 return (1); 1504 } 1505 isoaddr = (struct sockaddr_iso *) 1506 malloc(sizeof (struct sockaddr_iso)); 1507 if (isoaddr == (struct sockaddr_iso *)NULL) 1508 out_of_mem(); |
1522 bzero((caddr_t)isoaddr, sizeof (struct sockaddr_iso)); 1523 bcopy((caddr_t)isop, (caddr_t)&isoaddr->siso_addr, 1524 sizeof (struct iso_addr)); 1525 isoaddr->siso_len = sizeof (struct sockaddr_iso); | 1509 memset(isoaddr, 0, sizeof(struct sockaddr_iso)); 1510 memmove(&isoaddr->siso_addr, isop, sizeof(struct iso_addr)); 1511 isoaddr->siso_len = sizeof(struct sockaddr_iso); |
1526 isoaddr->siso_family = AF_ISO; 1527 grp->gr_type = GT_ISO; 1528 grp->gr_ptr.gt_isoaddr = isoaddr; 1529 return (0); 1530} 1531#endif /* ISO */ 1532 1533/* --- 34 unchanged lines hidden (view full) --- 1568 struct msdosfs_args da; 1569#endif 1570 } args; 1571 u_long net; 1572 1573 args.ua.fspec = 0; 1574 args.ua.export.ex_flags = exflags; 1575 args.ua.export.ex_anon = *anoncrp; | 1512 isoaddr->siso_family = AF_ISO; 1513 grp->gr_type = GT_ISO; 1514 grp->gr_ptr.gt_isoaddr = isoaddr; 1515 return (0); 1516} 1517#endif /* ISO */ 1518 1519/* --- 34 unchanged lines hidden (view full) --- 1554 struct msdosfs_args da; 1555#endif 1556 } args; 1557 u_long net; 1558 1559 args.ua.fspec = 0; 1560 args.ua.export.ex_flags = exflags; 1561 args.ua.export.ex_anon = *anoncrp; |
1576 bzero((char *)&sin, sizeof(sin)); 1577 bzero((char *)&imask, sizeof(imask)); | 1562 memset(&sin, 0, sizeof(sin)); 1563 memset(&imask, 0, sizeof(imask)); |
1578 sin.sin_family = AF_INET; 1579 sin.sin_len = sizeof(sin); 1580 imask.sin_family = AF_INET; 1581 imask.sin_len = sizeof(sin); 1582 if (grp->gr_type == GT_HOST) 1583 addrp = (u_long **)grp->gr_ptr.gt_hostent->h_addr_list; 1584 else 1585 addrp = (u_long **)NULL; --- 49 unchanged lines hidden (view full) --- 1635 return (1); 1636 }; 1637 1638 /* 1639 * XXX: 1640 * Maybe I should just use the fsb->f_mntonname path instead 1641 * of looping back up the dirp to the mount point?? 1642 * Also, needs to know how to export all types of local | 1564 sin.sin_family = AF_INET; 1565 sin.sin_len = sizeof(sin); 1566 imask.sin_family = AF_INET; 1567 imask.sin_len = sizeof(sin); 1568 if (grp->gr_type == GT_HOST) 1569 addrp = (u_long **)grp->gr_ptr.gt_hostent->h_addr_list; 1570 else 1571 addrp = (u_long **)NULL; --- 49 unchanged lines hidden (view full) --- 1621 return (1); 1622 }; 1623 1624 /* 1625 * XXX: 1626 * Maybe I should just use the fsb->f_mntonname path instead 1627 * of looping back up the dirp to the mount point?? 1628 * Also, needs to know how to export all types of local |
1643 * exportable file systems and not just MOUNT_UFS. | 1629 * exportable file systems and not just "ufs". |
1644 */ | 1630 */ |
1645#ifdef __NetBSD__ | |
1646 while (mount(fsb->f_fstypename, dirp, | 1631 while (mount(fsb->f_fstypename, dirp, |
1647#else 1648 while (mount(fsb->f_type, dirp, 1649#endif | |
1650 fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) { 1651 if (cp) 1652 *cp-- = savedc; 1653 else 1654 cp = dirp + dirplen - 1; 1655 if (errno == EPERM) { 1656 syslog(LOG_ERR, 1657 "Can't change attributes for %s.\n", dirp); --- 233 unchanged lines hidden (view full) --- 1891#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50) 1892/* 1893 * Routines that maintain the remote mounttab 1894 */ 1895void 1896get_mountlist() 1897{ 1898 struct mountlist *mlp, **mlpp; | 1632 fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) { 1633 if (cp) 1634 *cp-- = savedc; 1635 else 1636 cp = dirp + dirplen - 1; 1637 if (errno == EPERM) { 1638 syslog(LOG_ERR, 1639 "Can't change attributes for %s.\n", dirp); --- 233 unchanged lines hidden (view full) --- 1873#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50) 1874/* 1875 * Routines that maintain the remote mounttab 1876 */ 1877void 1878get_mountlist() 1879{ 1880 struct mountlist *mlp, **mlpp; |
1899 char *eos, *dirp; | 1881 char *host, *dirp, *cp; |
1900 int len; 1901 char str[STRSIZ]; 1902 FILE *mlfile; 1903 1904 if ((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) { 1905 syslog(LOG_ERR, "Can't open %s", _PATH_RMOUNTLIST); 1906 return; 1907 } 1908 mlpp = &mlhead; 1909 while (fgets(str, STRSIZ, mlfile) != NULL) { | 1882 int len; 1883 char str[STRSIZ]; 1884 FILE *mlfile; 1885 1886 if ((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) { 1887 syslog(LOG_ERR, "Can't open %s", _PATH_RMOUNTLIST); 1888 return; 1889 } 1890 mlpp = &mlhead; 1891 while (fgets(str, STRSIZ, mlfile) != NULL) { |
1910 if ((dirp = index(str, '\t')) == NULL && 1911 (dirp = index(str, ' ')) == NULL) | 1892 cp = str; 1893 host = strsep(&cp, " \t\n"); 1894 dirp = strsep(&cp, " \t\n"); 1895 if (host == NULL || dirp == NULL) |
1912 continue; 1913 mlp = (struct mountlist *)malloc(sizeof (*mlp)); | 1896 continue; 1897 mlp = (struct mountlist *)malloc(sizeof (*mlp)); |
1914 len = dirp-str; 1915 if (len > RPCMNT_NAMELEN) 1916 len = RPCMNT_NAMELEN; 1917 bcopy(str, mlp->ml_host, len); 1918 mlp->ml_host[len] = '\0'; 1919 while (*dirp == '\t' || *dirp == ' ') 1920 dirp++; 1921 if ((eos = index(dirp, '\t')) == NULL && 1922 (eos = index(dirp, ' ')) == NULL && 1923 (eos = index(dirp, '\n')) == NULL) 1924 len = strlen(dirp); 1925 else 1926 len = eos-dirp; 1927 if (len > RPCMNT_PATHLEN) 1928 len = RPCMNT_PATHLEN; 1929 bcopy(dirp, mlp->ml_dirp, len); 1930 mlp->ml_dirp[len] = '\0'; | 1898 strncpy(mlp->ml_host, host, RPCMNT_NAMELEN); 1899 mlp->ml_host[RPCMNT_NAMELEN] = '\0'; 1900 strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN); 1901 mlp->ml_dirp[RPCMNT_PATHLEN] = '\0'; |
1931 mlp->ml_next = (struct mountlist *)NULL; 1932 *mlpp = mlp; 1933 mlpp = &mlp->ml_next; 1934 } 1935 fclose(mlfile); 1936} 1937 1938void --- 201 unchanged lines hidden --- | 1902 mlp->ml_next = (struct mountlist *)NULL; 1903 *mlpp = mlp; 1904 mlpp = &mlp->ml_next; 1905 } 1906 fclose(mlfile); 1907} 1908 1909void --- 201 unchanged lines hidden --- |