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 --- 29 unchanged lines hidden (view full) --- 38 39#if 0 40#ifndef lint 41static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; 42#endif /*not lint*/ 43#endif 44 45#include <sys/cdefs.h> |
46__FBSDID("$FreeBSD: head/usr.sbin/mountd/mountd.c 149433 2005-08-24 19:17:06Z pjd $"); |
47 48#include <sys/param.h> 49#include <sys/mount.h> 50#include <sys/fcntl.h> 51#include <sys/stat.h> 52#include <sys/syslog.h> 53#include <sys/sysctl.h> 54#include <sys/linker.h> --- 13 unchanged lines hidden (view full) --- 68#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */ 69 70#include <arpa/inet.h> 71 72#include <ctype.h> 73#include <err.h> 74#include <errno.h> 75#include <grp.h> |
76#include <libutil.h> |
77#include <limits.h> 78#include <netdb.h> 79#include <pwd.h> 80#include <signal.h> 81#include <stdio.h> 82#include <stdlib.h> 83#include <string.h> 84#include <unistd.h> 85#include "pathnames.h" 86 87#ifdef DEBUG 88#include <stdarg.h> 89#endif 90 |
91/* 92 * Structures for keeping the mount list and export list 93 */ 94struct mountlist { 95 struct mountlist *ml_next; 96 char ml_host[RPCMNT_NAMELEN+1]; 97 char ml_dirp[RPCMNT_PATHLEN+1]; 98}; --- 121 unchanged lines hidden (view full) --- 220int resvport_only = 1; 221int dir_only = 1; 222int dolog = 0; 223int got_sighup = 0; 224 225int opt_flags; 226static int have_v6 = 1; 227 |
228struct pidfh *pfh = NULL; |
229/* Bits for opt_flags above */ 230#define OP_MAPROOT 0x01 231#define OP_MAPALL 0x02 232/* 0x4 free */ 233#define OP_MASK 0x08 234#define OP_NET 0x10 235#define OP_ALLDIRS 0x40 236#define OP_HAVEMASK 0x80 /* A mask was specified or inferred. */ --- 21 unchanged lines hidden (view full) --- 258 char **argv; 259{ 260 fd_set readfds; 261 struct sockaddr_in sin; 262 struct sockaddr_in6 sin6; 263 char *endptr; 264 SVCXPRT *udptransp, *tcptransp, *udp6transp, *tcp6transp; 265 struct netconfig *udpconf, *tcpconf, *udp6conf, *tcp6conf; |
266 pid_t otherpid; |
267 int udpsock, tcpsock, udp6sock, tcp6sock; 268 int xcreated = 0, s; 269 int maxrec = RPC_MAXDATASIZE; 270 int one = 1; 271 int c, r; 272 in_port_t svcport = 0; 273 274 udp6conf = tcp6conf = NULL; 275 udp6sock = tcp6sock = 0; 276 277 /* Check that another mountd isn't already running. */ |
278 pfh = pidfile_open(_PATH_MOUNTDPID, 0644, &otherpid); 279 if (pfh == NULL) { 280 if (errno == EEXIST) 281 errx(1, "mountd already running, pid: %d.", otherpid); 282 warn("cannot open or create pidfile"); 283 } |
284 |
285 s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); 286 if (s < 0) 287 have_v6 = 0; 288 else 289 close(s); 290 if (modfind("nfsserver") < 0) { 291 /* Not present in kernel, try loading it */ 292 if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0) --- 48 unchanged lines hidden (view full) --- 341 warnx("here we go"); 342 if (debug == 0) { 343 daemon(0, 0); 344 signal(SIGINT, SIG_IGN); 345 signal(SIGQUIT, SIG_IGN); 346 } 347 signal(SIGHUP, huphandler); 348 signal(SIGTERM, terminate); |
349 350 pidfile_write(pfh); 351 |
352 rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL); 353 rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL); 354 udpsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 355 tcpsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 356 udpconf = getnetconfigent("udp"); 357 tcpconf = getnetconfigent("tcp"); 358 359 rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec); --- 2163 unchanged lines hidden (view full) --- 2523huphandler(int sig) 2524{ 2525 got_sighup = 1; 2526} 2527 2528void terminate(sig) 2529int sig; 2530{ |
2531 pidfile_remove(pfh); |
2532 rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL); 2533 rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL); 2534 exit (0); 2535} |