4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Joyent, Inc. All rights reserved.
25 * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
26 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
30 /* All Rights Reserved */
31
32 /*
33 * Portions of this source code were derived from Berkeley 4.3 BSD
34 * under license from the Regents of the University of California.
35 */
36
37 #include <stdio.h>
38 #include <stdio_ext.h>
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include <sys/types.h>
42 #include <string.h>
43 #include <syslog.h>
44 #include <sys/param.h>
469 * /etc/rmtab updates (we could chown it to daemon)
470 * /etc/dfs/dfstab reading (it wants to lock out share which
471 * doesn't do any locking before first truncate;
472 * NFS share does; should use fcntl locking instead)
473 * Needed privileges:
474 * auditing
475 * nfs syscall
476 * file dac search (so it can stat all files)
477 * Optional privileges:
478 * MLP
479 */
480 can_do_mlp = priv_ineffect(PRIV_NET_BINDMLP);
481 if (__init_daemon_priv(PU_RESETGROUPS|PU_CLEARLIMITSET, -1, -1,
482 PRIV_SYS_NFS, PRIV_PROC_AUDIT, PRIV_FILE_DAC_SEARCH,
483 PRIV_NET_PRIVADDR,
484 can_do_mlp ? PRIV_NET_BINDMLP : NULL, NULL) == -1) {
485 (void) fprintf(stderr,
486 "%s: must be run with sufficient privileges\n",
487 argv[0]);
488 exit(1);
489 }
490
491 /* Mountd cannot run in a non-global zone. */
492 if (getzoneid() != GLOBAL_ZONEID) {
493 (void) fprintf(stderr, "%s: can only run in the global zone\n",
494 argv[0]);
495 exit(1);
496 }
497
498 if (getrlimit(RLIMIT_NOFILE, &rl) != 0) {
499 syslog(LOG_ERR, "getrlimit failed");
500 } else {
501 rl.rlim_cur = rl.rlim_max;
502 if (setrlimit(RLIMIT_NOFILE, &rl) != 0)
503 syslog(LOG_ERR, "setrlimit failed");
504 }
505
506 (void) enable_extended_FILE_stdio(-1, -1);
507
508 ret = nfs_smf_get_iprop("mountd_max_threads", &max_threads,
509 DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD);
510 if (ret != SA_OK) {
511 syslog(LOG_ERR, "Reading of mountd_max_threads from SMF "
512 "failed, using default value");
513 }
514
515 ret = nfs_smf_get_iprop("mountd_port", &mountd_port,
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
25 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
26 */
27
28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
30
31 /*
32 * Portions of this source code were derived from Berkeley 4.3 BSD
33 * under license from the Regents of the University of California.
34 */
35
36 #include <stdio.h>
37 #include <stdio_ext.h>
38 #include <stdlib.h>
39 #include <ctype.h>
40 #include <sys/types.h>
41 #include <string.h>
42 #include <syslog.h>
43 #include <sys/param.h>
468 * /etc/rmtab updates (we could chown it to daemon)
469 * /etc/dfs/dfstab reading (it wants to lock out share which
470 * doesn't do any locking before first truncate;
471 * NFS share does; should use fcntl locking instead)
472 * Needed privileges:
473 * auditing
474 * nfs syscall
475 * file dac search (so it can stat all files)
476 * Optional privileges:
477 * MLP
478 */
479 can_do_mlp = priv_ineffect(PRIV_NET_BINDMLP);
480 if (__init_daemon_priv(PU_RESETGROUPS|PU_CLEARLIMITSET, -1, -1,
481 PRIV_SYS_NFS, PRIV_PROC_AUDIT, PRIV_FILE_DAC_SEARCH,
482 PRIV_NET_PRIVADDR,
483 can_do_mlp ? PRIV_NET_BINDMLP : NULL, NULL) == -1) {
484 (void) fprintf(stderr,
485 "%s: must be run with sufficient privileges\n",
486 argv[0]);
487 exit(1);
488 }
489
490 if (getrlimit(RLIMIT_NOFILE, &rl) != 0) {
491 syslog(LOG_ERR, "getrlimit failed");
492 } else {
493 rl.rlim_cur = rl.rlim_max;
494 if (setrlimit(RLIMIT_NOFILE, &rl) != 0)
495 syslog(LOG_ERR, "setrlimit failed");
496 }
497
498 (void) enable_extended_FILE_stdio(-1, -1);
499
500 ret = nfs_smf_get_iprop("mountd_max_threads", &max_threads,
501 DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD);
502 if (ret != SA_OK) {
503 syslog(LOG_ERR, "Reading of mountd_max_threads from SMF "
504 "failed, using default value");
505 }
506
507 ret = nfs_smf_get_iprop("mountd_port", &mountd_port,
|