1c5c4113dSnw141292 /* 2c5c4113dSnw141292 * CDDL HEADER START 3c5c4113dSnw141292 * 4c5c4113dSnw141292 * The contents of this file are subject to the terms of the 5c5c4113dSnw141292 * Common Development and Distribution License (the "License"). 6c5c4113dSnw141292 * You may not use this file except in compliance with the License. 7c5c4113dSnw141292 * 8c5c4113dSnw141292 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9c5c4113dSnw141292 * or http://www.opensolaris.org/os/licensing. 10c5c4113dSnw141292 * See the License for the specific language governing permissions 11c5c4113dSnw141292 * and limitations under the License. 12c5c4113dSnw141292 * 13c5c4113dSnw141292 * When distributing Covered Code, include this CDDL HEADER in each 14c5c4113dSnw141292 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c5c4113dSnw141292 * If applicable, add the following below this CDDL HEADER, with the 16c5c4113dSnw141292 * fields enclosed by brackets "[]" replaced with your own identifying 17c5c4113dSnw141292 * information: Portions Copyright [yyyy] [name of copyright owner] 18c5c4113dSnw141292 * 19c5c4113dSnw141292 * CDDL HEADER END 20c5c4113dSnw141292 */ 21c5c4113dSnw141292 /* 22bda89588Sjp151216 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23c5c4113dSnw141292 * Use is subject to license terms. 24c5c4113dSnw141292 */ 25c5c4113dSnw141292 26c5c4113dSnw141292 #pragma ident "%Z%%M% %I% %E% SMI" 27c5c4113dSnw141292 28c5c4113dSnw141292 /* 29c5c4113dSnw141292 * main() of idmapd(1M) 30c5c4113dSnw141292 */ 31c5c4113dSnw141292 32c5c4113dSnw141292 #include "idmapd.h" 33*71590c90Snw141292 #include <atomic.h> 34c5c4113dSnw141292 #include <signal.h> 35c5c4113dSnw141292 #include <rpc/pmap_clnt.h> /* for pmap_unset */ 36c5c4113dSnw141292 #include <string.h> /* strcmp */ 37c5c4113dSnw141292 #include <unistd.h> /* setsid */ 38c5c4113dSnw141292 #include <sys/types.h> 39c5c4113dSnw141292 #include <memory.h> 40c5c4113dSnw141292 #include <stropts.h> 41c5c4113dSnw141292 #include <netconfig.h> 42c5c4113dSnw141292 #include <sys/resource.h> /* rlimit */ 43c5c4113dSnw141292 #include <syslog.h> 44c5c4113dSnw141292 #include <rpcsvc/daemon_utils.h> /* DAEMON_UID and DAEMON_GID */ 45c5c4113dSnw141292 #include <priv_utils.h> /* privileges */ 46c5c4113dSnw141292 #include <locale.h> 47c5c4113dSnw141292 #include <sys/systeminfo.h> 48c5c4113dSnw141292 #include <errno.h> 49c5c4113dSnw141292 #include <sys/wait.h> 50c5c4113dSnw141292 #include <sys/time.h> 51c5c4113dSnw141292 #include <zone.h> 52c5c4113dSnw141292 #include <door.h> 53c8e26105Sjp151216 #include <port.h> 54c5c4113dSnw141292 #include <tsol/label.h> 55c5c4113dSnw141292 #include <sys/resource.h> 56c5c4113dSnw141292 #include <sys/sid.h> 57c5c4113dSnw141292 #include <sys/idmap.h> 58c5c4113dSnw141292 59c5c4113dSnw141292 static void term_handler(int); 60c5c4113dSnw141292 static void init_idmapd(); 61c5c4113dSnw141292 static void fini_idmapd(); 62c5c4113dSnw141292 63c5c4113dSnw141292 #define _RPCSVC_CLOSEDOWN 120 64c5c4113dSnw141292 65c5c4113dSnw141292 int _rpcsvcstate = _IDLE; /* Set when a request is serviced */ 66c5c4113dSnw141292 int _rpcsvccount = 0; /* Number of requests being serviced */ 67c5c4113dSnw141292 mutex_t _svcstate_lock; /* lock for _rpcsvcstate, _rpcsvccount */ 68c5c4113dSnw141292 idmapd_state_t _idmapdstate; 69c5c4113dSnw141292 70c5c4113dSnw141292 SVCXPRT *xprt = NULL; 71c5c4113dSnw141292 72c5c4113dSnw141292 static int dfd = -1; /* our door server fildes, for unregistration */ 73*71590c90Snw141292 static int degraded = 0; /* whether the FMRI has been marked degraded */ 74c5c4113dSnw141292 75c5c4113dSnw141292 /* 76c5c4113dSnw141292 * This is needed for mech_krb5 -- we run as daemon, yes, but we want 7778b2cb9aSnw141292 * mech_krb5 to think we're root so it can get host/nodename.fqdn 7878b2cb9aSnw141292 * tickets for us so we can authenticate to AD as the machine account 7978b2cb9aSnw141292 * that we are. For more details look at the entry point in mech_krb5 8078b2cb9aSnw141292 * corresponding to gss_init_sec_context(). 8178b2cb9aSnw141292 * 8278b2cb9aSnw141292 * As a side effect of faking our effective UID to mech_krb5 we will use 8378b2cb9aSnw141292 * root's default ccache (/tmp/krb5cc_0). But if that's created by 8478b2cb9aSnw141292 * another process then we won't have access to it: we run as daemon and 8578b2cb9aSnw141292 * keep PRIV_FILE_DAC_READ, which is insufficient to share the ccache 8678b2cb9aSnw141292 * with others. We putenv("KRB5CCNAME=/var/run/idmap/ccache") in main() 8778b2cb9aSnw141292 * to avoid this issue; see main(). 88c5c4113dSnw141292 * 89c5c4113dSnw141292 * Someday we'll have gss/mech_krb5 extensions for acquiring initiator 90c5c4113dSnw141292 * creds with keytabs/raw keys, and someday we'll have extensions to 91c5c4113dSnw141292 * libsasl to specify creds/name to use on the initiator side, and 92c5c4113dSnw141292 * someday we'll have extensions to libldap to pass those through to 93c5c4113dSnw141292 * libsasl. Until then this interposer will have to do. 94c5c4113dSnw141292 * 95c5c4113dSnw141292 * Also, we have to tell lint to shut up: it thinks app_krb5_user_uid() 96c5c4113dSnw141292 * is defined but not used. 97c5c4113dSnw141292 */ 98c5c4113dSnw141292 /*LINTLIBRARY*/ 99c5c4113dSnw141292 uid_t 100c5c4113dSnw141292 app_krb5_user_uid(void) 101c5c4113dSnw141292 { 102c5c4113dSnw141292 return (0); 103c5c4113dSnw141292 } 104c5c4113dSnw141292 105c5c4113dSnw141292 /*ARGSUSED*/ 106c5c4113dSnw141292 static void 1074edd44c5Sjp151216 term_handler(int sig) 1084edd44c5Sjp151216 { 109*71590c90Snw141292 idmapdlog(LOG_INFO, "Terminating."); 110c5c4113dSnw141292 fini_idmapd(); 111c5c4113dSnw141292 _exit(0); 112c5c4113dSnw141292 } 113c5c4113dSnw141292 114*71590c90Snw141292 /*ARGSUSED*/ 115*71590c90Snw141292 static void 116*71590c90Snw141292 usr1_handler(int sig) 117*71590c90Snw141292 { 118*71590c90Snw141292 bool_t saved_debug_mode = _idmapdstate.debug_mode; 119*71590c90Snw141292 120*71590c90Snw141292 _idmapdstate.debug_mode = TRUE; 121*71590c90Snw141292 print_idmapdstate(); 122*71590c90Snw141292 _idmapdstate.debug_mode = saved_debug_mode; 123*71590c90Snw141292 } 124*71590c90Snw141292 125c5c4113dSnw141292 static int pipe_fd = -1; 126c5c4113dSnw141292 127c5c4113dSnw141292 static void 1284edd44c5Sjp151216 daemonize_ready(void) 1294edd44c5Sjp151216 { 130c5c4113dSnw141292 char data = '\0'; 131c5c4113dSnw141292 /* 132c5c4113dSnw141292 * wake the parent 133c5c4113dSnw141292 */ 134c5c4113dSnw141292 (void) write(pipe_fd, &data, 1); 135c5c4113dSnw141292 (void) close(pipe_fd); 136c5c4113dSnw141292 } 137c5c4113dSnw141292 138c5c4113dSnw141292 static int 1394edd44c5Sjp151216 daemonize_start(void) 1404edd44c5Sjp151216 { 141c5c4113dSnw141292 char data; 142c5c4113dSnw141292 int status; 143c5c4113dSnw141292 int devnull; 144c5c4113dSnw141292 int filedes[2]; 145c5c4113dSnw141292 pid_t pid; 146c5c4113dSnw141292 14778b2cb9aSnw141292 (void) sigset(SIGPIPE, SIG_IGN); 148c5c4113dSnw141292 devnull = open("/dev/null", O_RDONLY); 149c5c4113dSnw141292 if (devnull < 0) 150c5c4113dSnw141292 return (-1); 151c5c4113dSnw141292 (void) dup2(devnull, 0); 152c5c4113dSnw141292 (void) dup2(2, 1); /* stderr only */ 153c5c4113dSnw141292 if (pipe(filedes) < 0) 154c5c4113dSnw141292 return (-1); 155c5c4113dSnw141292 if ((pid = fork1()) < 0) 156c5c4113dSnw141292 return (-1); 157c5c4113dSnw141292 if (pid != 0) { 158c5c4113dSnw141292 /* 159c5c4113dSnw141292 * parent 160c5c4113dSnw141292 */ 161c5c4113dSnw141292 (void) close(filedes[1]); 162c5c4113dSnw141292 if (read(filedes[0], &data, 1) == 1) { 163c5c4113dSnw141292 /* presume success */ 164c5c4113dSnw141292 _exit(0); 165c5c4113dSnw141292 } 166c5c4113dSnw141292 status = -1; 167c5c4113dSnw141292 (void) wait4(pid, &status, 0, NULL); 168c5c4113dSnw141292 if (WIFEXITED(status)) 169c5c4113dSnw141292 _exit(WEXITSTATUS(status)); 170c5c4113dSnw141292 else 171c5c4113dSnw141292 _exit(-1); 172c5c4113dSnw141292 } 173c5c4113dSnw141292 174c5c4113dSnw141292 /* 175c5c4113dSnw141292 * child 176c5c4113dSnw141292 */ 177c5c4113dSnw141292 pipe_fd = filedes[1]; 178c5c4113dSnw141292 (void) close(filedes[0]); 179c5c4113dSnw141292 (void) setsid(); 180c5c4113dSnw141292 (void) umask(0077); 181c5c4113dSnw141292 openlog("idmap", LOG_PID, LOG_DAEMON); 182c5c4113dSnw141292 return (0); 183c5c4113dSnw141292 } 184c5c4113dSnw141292 185c5c4113dSnw141292 186c5c4113dSnw141292 int 187c5c4113dSnw141292 main(int argc, char **argv) 188c5c4113dSnw141292 { 189c5c4113dSnw141292 int c; 190c5c4113dSnw141292 191*71590c90Snw141292 _idmapdstate.daemon_mode = TRUE; 192*71590c90Snw141292 _idmapdstate.debug_mode = FALSE; 193*71590c90Snw141292 while ((c = getopt(argc, argv, "d")) != -1) { 194c5c4113dSnw141292 switch (c) { 195c5c4113dSnw141292 case 'd': 196*71590c90Snw141292 _idmapdstate.daemon_mode = FALSE; 197c5c4113dSnw141292 break; 198c5c4113dSnw141292 default: 199*71590c90Snw141292 fprintf(stderr, "Usage: /usr/lib/idmapd"); 200*71590c90Snw141292 return (SMF_EXIT_ERR_CONFIG); 201c5c4113dSnw141292 break; 202c5c4113dSnw141292 } 203c5c4113dSnw141292 } 204c5c4113dSnw141292 205c5c4113dSnw141292 /* set locale and domain for internationalization */ 206c5c4113dSnw141292 (void) setlocale(LC_ALL, ""); 207c5c4113dSnw141292 (void) textdomain(TEXT_DOMAIN); 208c5c4113dSnw141292 209bda89588Sjp151216 if (is_system_labeled() && getzoneid() != GLOBAL_ZONEID) { 210*71590c90Snw141292 idmapdlog(LOG_ERR, 211*71590c90Snw141292 "with Trusted Extensions idmapd runs only in the " 212bda89588Sjp151216 "global zone"); 213c5c4113dSnw141292 exit(1); 214c5c4113dSnw141292 } 215c5c4113dSnw141292 216c5c4113dSnw141292 (void) mutex_init(&_svcstate_lock, USYNC_THREAD, NULL); 217c5c4113dSnw141292 218*71590c90Snw141292 if (_idmapdstate.daemon_mode == TRUE) { 219c5c4113dSnw141292 if (daemonize_start() < 0) { 220*71590c90Snw141292 (void) idmapdlog(LOG_ERR, "unable to daemonize"); 221c5c4113dSnw141292 exit(-1); 222c5c4113dSnw141292 } 223c5c4113dSnw141292 } else 224c5c4113dSnw141292 (void) umask(0077); 225c5c4113dSnw141292 22684decf41Sjp151216 idmap_init_tsd_key(); 22784decf41Sjp151216 228c5c4113dSnw141292 init_idmapd(); 229c5c4113dSnw141292 23078b2cb9aSnw141292 /* signal handlers that should run only after we're initialized */ 23178b2cb9aSnw141292 (void) sigset(SIGTERM, term_handler); 232*71590c90Snw141292 (void) sigset(SIGUSR1, usr1_handler); 2330dcc7149Snw141292 (void) sigset(SIGHUP, idmap_cfg_hup_handler); 23478b2cb9aSnw141292 235c5c4113dSnw141292 if (__init_daemon_priv(PU_RESETGROUPS|PU_CLEARLIMITSET, 236c5c4113dSnw141292 DAEMON_UID, DAEMON_GID, 237c5c4113dSnw141292 PRIV_PROC_AUDIT, PRIV_FILE_DAC_READ, 238c5c4113dSnw141292 (char *)NULL) == -1) { 239*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to drop privileges"); 240c5c4113dSnw141292 exit(1); 241c5c4113dSnw141292 } 242c5c4113dSnw141292 243c5c4113dSnw141292 __fini_daemon_priv(PRIV_PROC_FORK, PRIV_PROC_EXEC, PRIV_PROC_SESSION, 244c5c4113dSnw141292 PRIV_FILE_LINK_ANY, PRIV_PROC_INFO, (char *)NULL); 245c5c4113dSnw141292 246*71590c90Snw141292 if (_idmapdstate.daemon_mode == TRUE) 247c5c4113dSnw141292 daemonize_ready(); 248c5c4113dSnw141292 249c5c4113dSnw141292 /* With doors RPC this just wastes this thread, oh well */ 250c5c4113dSnw141292 svc_run(); 251c5c4113dSnw141292 return (0); 252c5c4113dSnw141292 } 253c5c4113dSnw141292 254c5c4113dSnw141292 static void 2554edd44c5Sjp151216 init_idmapd() 2564edd44c5Sjp151216 { 257c5c4113dSnw141292 int error; 258d3a612caSnw141292 int connmaxrec = IDMAP_MAX_DOOR_RPC; 259c5c4113dSnw141292 26078b2cb9aSnw141292 /* create directories as root and chown to daemon uid */ 26178b2cb9aSnw141292 if (create_directory(IDMAP_DBDIR, DAEMON_UID, DAEMON_GID) < 0) 26278b2cb9aSnw141292 exit(1); 26378b2cb9aSnw141292 if (create_directory(IDMAP_CACHEDIR, DAEMON_UID, DAEMON_GID) < 0) 26478b2cb9aSnw141292 exit(1); 26578b2cb9aSnw141292 26678b2cb9aSnw141292 /* 26778b2cb9aSnw141292 * Set KRB5CCNAME in the environment. See app_krb5_user_uid() 268e3c2d6aaSnw141292 * for more details. We blow away the existing one, if there is 269e3c2d6aaSnw141292 * one. 27078b2cb9aSnw141292 */ 271e3c2d6aaSnw141292 (void) unlink(IDMAP_CACHEDIR "/ccache"); 27278b2cb9aSnw141292 putenv("KRB5CCNAME=" IDMAP_CACHEDIR "/ccache"); 27378b2cb9aSnw141292 274c5c4113dSnw141292 if (sysinfo(SI_HOSTNAME, _idmapdstate.hostname, 275c5c4113dSnw141292 sizeof (_idmapdstate.hostname)) == -1) { 276c5c4113dSnw141292 error = errno; 277*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to determine hostname, error: %d", 278c5c4113dSnw141292 error); 279c5c4113dSnw141292 exit(1); 280c5c4113dSnw141292 } 281c5c4113dSnw141292 282e8c27ec8Sbaban if ((error = init_mapping_system()) < 0) { 283*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to initialize mapping system"); 284e8c27ec8Sbaban exit(error < -2 ? SMF_EXIT_ERR_CONFIG : 1); 285c5c4113dSnw141292 } 286c5c4113dSnw141292 287d3a612caSnw141292 xprt = svc_door_create(idmap_prog_1, IDMAP_PROG, IDMAP_V1, connmaxrec); 288c5c4113dSnw141292 if (xprt == NULL) { 289*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to create door RPC service"); 290c5c4113dSnw141292 goto errout; 291c5c4113dSnw141292 } 292c5c4113dSnw141292 2938e228215Sdm199847 if (!svc_control(xprt, SVCSET_CONNMAXREC, &connmaxrec)) { 294*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to limit RPC request size"); 2958e228215Sdm199847 goto errout; 2968e228215Sdm199847 } 2978e228215Sdm199847 298c5c4113dSnw141292 dfd = xprt->xp_fd; 299c5c4113dSnw141292 300c5c4113dSnw141292 if (dfd == -1) { 301*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to register door"); 302c5c4113dSnw141292 goto errout; 303c5c4113dSnw141292 } 304c5c4113dSnw141292 if ((error = idmap_reg(dfd)) != 0) { 305*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to register door (%s)", 306bda89588Sjp151216 strerror(errno)); 307c5c4113dSnw141292 goto errout; 308c5c4113dSnw141292 } 309c5c4113dSnw141292 310c5c4113dSnw141292 if ((error = allocids(_idmapdstate.new_eph_db, 311c5c4113dSnw141292 8192, &_idmapdstate.next_uid, 312c5c4113dSnw141292 8192, &_idmapdstate.next_gid)) != 0) { 313*71590c90Snw141292 idmapdlog(LOG_ERR, "unable to allocate ephemeral IDs (%s)", 314*71590c90Snw141292 strerror(errno)); 315c5c4113dSnw141292 _idmapdstate.next_uid = _idmapdstate.limit_uid = SENTINEL_PID; 316c5c4113dSnw141292 _idmapdstate.next_gid = _idmapdstate.limit_gid = SENTINEL_PID; 317c5c4113dSnw141292 } else { 318c5c4113dSnw141292 _idmapdstate.limit_uid = _idmapdstate.next_uid + 8192; 319c5c4113dSnw141292 _idmapdstate.limit_gid = _idmapdstate.next_gid + 8192; 320c5c4113dSnw141292 } 321c5c4113dSnw141292 322c5c4113dSnw141292 print_idmapdstate(); 323c5c4113dSnw141292 324c5c4113dSnw141292 return; 325c5c4113dSnw141292 326c5c4113dSnw141292 errout: 327c5c4113dSnw141292 fini_idmapd(); 328c5c4113dSnw141292 exit(1); 329c5c4113dSnw141292 } 330c5c4113dSnw141292 331c5c4113dSnw141292 static void 3324edd44c5Sjp151216 fini_idmapd() 3334edd44c5Sjp151216 { 334c5c4113dSnw141292 idmap_unreg(dfd); 335c5c4113dSnw141292 fini_mapping_system(); 336c5c4113dSnw141292 if (xprt != NULL) 337c5c4113dSnw141292 svc_destroy(xprt); 338c5c4113dSnw141292 } 339c5c4113dSnw141292 340*71590c90Snw141292 static 341*71590c90Snw141292 const char * 342*71590c90Snw141292 get_fmri(void) 343*71590c90Snw141292 { 344*71590c90Snw141292 static char *fmri = NULL; 345*71590c90Snw141292 static char buf[60]; 346*71590c90Snw141292 char *s; 347*71590c90Snw141292 348*71590c90Snw141292 membar_consumer(); 349*71590c90Snw141292 s = fmri; 350*71590c90Snw141292 if (s != NULL && *s == '\0') 351*71590c90Snw141292 return (NULL); 352*71590c90Snw141292 else if (s != NULL) 353*71590c90Snw141292 return (s); 354*71590c90Snw141292 355*71590c90Snw141292 if ((s = getenv("SMF_FMRI")) == NULL || strlen(s) >= sizeof (buf)) 356*71590c90Snw141292 buf[0] = '\0'; 357*71590c90Snw141292 else 358*71590c90Snw141292 (void) strlcpy(buf, s, sizeof (buf)); 359*71590c90Snw141292 360*71590c90Snw141292 membar_producer(); 361*71590c90Snw141292 fmri = buf; 362*71590c90Snw141292 363*71590c90Snw141292 return (get_fmri()); 364*71590c90Snw141292 } 365*71590c90Snw141292 366*71590c90Snw141292 /* 367*71590c90Snw141292 * Wrappers for smf_degrade/restore_instance() 368*71590c90Snw141292 * 369*71590c90Snw141292 * smf_restore_instance() is too heavy duty to be calling every time we 370*71590c90Snw141292 * have a successful AD name<->SID lookup. 371*71590c90Snw141292 */ 372*71590c90Snw141292 void 373*71590c90Snw141292 degrade_svc(const char *reason) 374*71590c90Snw141292 { 375*71590c90Snw141292 const char *fmri; 376*71590c90Snw141292 377*71590c90Snw141292 /* 378*71590c90Snw141292 * If the config update thread is in a state where auto-discovery could 379*71590c90Snw141292 * be re-tried, then this will make it try it -- a sort of auto-refresh. 380*71590c90Snw141292 */ 381*71590c90Snw141292 idmap_cfg_poke_updates(); 382*71590c90Snw141292 383*71590c90Snw141292 membar_consumer(); 384*71590c90Snw141292 if (degraded) 385*71590c90Snw141292 return; 386*71590c90Snw141292 membar_producer(); 387*71590c90Snw141292 degraded = 1; 388*71590c90Snw141292 389*71590c90Snw141292 if ((fmri = get_fmri()) != NULL) 390*71590c90Snw141292 (void) smf_degrade_instance(fmri, 0); 391*71590c90Snw141292 392*71590c90Snw141292 idmapdlog(LOG_ERR, "Degraded operation (%s)", reason); 393*71590c90Snw141292 } 394*71590c90Snw141292 395*71590c90Snw141292 void 396*71590c90Snw141292 restore_svc(void) 397*71590c90Snw141292 { 398*71590c90Snw141292 const char *fmri; 399*71590c90Snw141292 400*71590c90Snw141292 membar_consumer(); 401*71590c90Snw141292 if (!degraded) 402*71590c90Snw141292 return; 403*71590c90Snw141292 404*71590c90Snw141292 if ((fmri = get_fmri()) == NULL) 405*71590c90Snw141292 (void) smf_restore_instance(fmri); 406*71590c90Snw141292 407*71590c90Snw141292 membar_producer(); 408*71590c90Snw141292 degraded = 0; 409*71590c90Snw141292 idmapdlog(LOG_INFO, "Normal operation restored"); 410*71590c90Snw141292 } 411*71590c90Snw141292 412c5c4113dSnw141292 void 4134edd44c5Sjp151216 idmapdlog(int pri, const char *format, ...) 4144edd44c5Sjp151216 { 415c5c4113dSnw141292 va_list args; 416c5c4113dSnw141292 417c5c4113dSnw141292 va_start(args, format); 418*71590c90Snw141292 419*71590c90Snw141292 if (_idmapdstate.debug_mode == TRUE || 420*71590c90Snw141292 _idmapdstate.daemon_mode == FALSE) { 421c5c4113dSnw141292 (void) vfprintf(stderr, format, args); 422c5c4113dSnw141292 (void) fprintf(stderr, "\n"); 423c5c4113dSnw141292 } 424*71590c90Snw141292 425*71590c90Snw141292 /* 426*71590c90Snw141292 * We don't want to fill up the logs with useless messages when 427*71590c90Snw141292 * we're degraded, but we still want to log. 428*71590c90Snw141292 */ 429*71590c90Snw141292 if (degraded) 430*71590c90Snw141292 pri = LOG_DEBUG; 431*71590c90Snw141292 432c5c4113dSnw141292 (void) vsyslog(pri, format, args); 433c5c4113dSnw141292 va_end(args); 434c5c4113dSnw141292 } 435