/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Usermode daemon which assists the kernel when handling gssapi calls.
* It is gssd that actually implements all gssapi calls.
* Some calls, such as gss_sign, are implemented in the kernel on a per
* mechanism basis.
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/systeminfo.h>
#include <stdlib.h>
#include <stropts.h>
#include <fcntl.h>
#include <strings.h>
#include <signal.h>
#include <syslog.h>
#include "gssd.h"
extern void gsscred_set_options(void);
void gssprog_1();
void gssd_setup(char *);
static void usage(void);
static void daemonize_start();
static void daemonize_ready(unsigned char status);
extern int svc_create_local_service();
/* following declarations needed in rpcgen-generated code */
static void
/* LINTED */
{
/* re-set the signal handler again to catch_hup, for next time */
/* mask any further signals while we're inside the handler. */
(void) sigfillset(&mask_set);
/* let admin know the sighup was caught and conf file re-read */
"catch_hup: read gsscred.conf opts");
if (gssd_debug)
"catch_hup: read gsscred.conf opts");
}
int
int argc;
char **argv;
{
extern int optind;
int c;
/* set locale and domain for internationalization */
/*
* Take special note that "getuid()" is called here. This call is used
* rather than app_krb5_user_uid(), to ensure gssd(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 */
}
gssd_setup(argv[0]);
switch (c) {
case 'd':
/* turn on debugging */
gssd_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);
}
}
gettext("unable to set RPC max record size"));
exit(1);
}
/* XXX - is nconf even needed here? */
exit(1);
}
/*
* We use a NULL nconf because GSSPROG has already been
* registered with rpcbind.
*/
gettext("unable to register "
"(GSSPROG, GSSVERS)"));
exit(1);
}
if (nconf)
} else {
if (!gssd_debug)
"netpath", "gssd") == 0) {
exit(1);
}
/* service created, now the daemon parent can exit */
daemonize_ready(0);
}
if (gssd_debug) {
gettext("gssd start: \n"));
}
svc_run();
abort();
/*NOTREACHED*/
#ifdef lint
return (1);
#endif
}
static void
usage(void)
{
exit(1);
}
/*
* Fork, detach from tty, etc...
*/
static
void
{
closefrom(0);
exit(1);
/* For daemonize_ready() */
switch (fork()) {
case -1:
exit(1);
/* NOTREACHED */
case 0:
break;
default:
/* Wait for child to be ready befor exiting */
}
(void) setsid();
}
static
void
{
if (write_pipe_fd == -1)
return;
(void) close(write_pipe_fd);
write_pipe_fd = -1;
}
/*ARGSUSED*/
int
{
return (1);
}