/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Usermode daemon which is responsible for sending kerberos credentials
* expiration warnings to the user, syslog or snmp (eventually), depending
* the code in this file was borrowed from gssd.c
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/systeminfo.h>
#include <stdlib.h>
#include <stropts.h>
#include <fcntl.h>
#include <strings.h>
#include <syslog.h>
#include <thread.h>
#include <netdb.h>
#include <libgen.h>
#include "kwarnd.h"
static void usage(void);
static void detachfromtty(void);
extern int svc_create_local_service(void (*) (),
extern void kwarnd_check_warning_list(void);
extern bool_t loadConfigFile(void);
/* following declarations needed in rpcgen-generated code */
int
int argc;
char **argv;
{
extern int optind;
int c;
/* set locale and domain for internationalization */
#if !defined(TEXT_DOMAIN)
#endif
/*
* Take special note that "getuid()" is called here. This call is used
* rather that app_krb5_user_uid(), to ensure ktkt_warnd(1M) is running
* as root.
*/
#ifdef DEBUG
(void) setuid(0); /* DEBUG: set ruid to root */
#endif /* DEBUG */
if (getuid()) {
#ifdef DEBUG
#else /* !DEBUG */
exit(1);
#endif /* DEBUG */
}
switch (c) {
case 'd':
/* turn on debugging */
kwarnd_debug = 1;
break;
default:
usage();
}
usage();
}
/*
* Started by inetd if name of module just below stream
* head is either a sockmod or timod.
*/
char *netid;
netid = "ticotsord";
}
exit(1);
}
gettext("could not get the "
"right module"));
exit(1);
}
}
/* XXX - is nconf even needed here? */
exit(1);
}
/*
* We use a NULL nconf because KWARNPROG has already been
* registered with rpcbind.
*/
gettext("unable to register "
"(KWARNPROG, KWARNVERS)"));
exit(1);
}
if (nconf)
} else {
if (!kwarnd_debug)
"netpath", "kwarnd") == 0) {
exit(1);
}
}
if (kwarnd_debug) {
gettext("kwarnd start: \n"));
}
if (thr_create(NULL, 0,
(void *(*)(void *))kwarnd_check_warning_list, NULL,
NULL)) {
gettext("unable to create cache_cleanup thread"));
exit(1);
}
if (!loadConfigFile()) {
exit(1);
}
exit(1);
}
svc_run();
abort();
/*NOTREACHED*/
#ifdef lint
return (1);
#endif
}
static void
usage(void)
{
exit(1);
}
/*
* detach from tty
*/
static void
detachfromtty(void)
{
switch (fork()) {
case -1:
exit(1);
/*NOTREACHED*/
case 0:
break;
default:
exit(0);
}
/*
* standard input, output, and error, and detach from
* controlling terminal.
*/
closefrom(0);
(void) dup(1);
(void) setsid();
}
/*ARGSUSED*/
int
{
return (1);
}