/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 1999-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "med_local.h"
#include <sdssc.h>
#include <grp.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
#include <netdir.h>
#include <netdb.h>
#include <sys/resource.h>
#include <sys/priocntl.h>
#include <sys/rtpriocntl.h>
/* daemon name */
/*
* reset and exit daemon
*/
void
int eval
)
{
if (med_db_finit(&status))
/* log exit */
/* exit with value */
}
/*
* signal catchers
*/
static void
int sig
)
{
char *msg;
/* log signal */
}
/* let default handler do it's thing */
med_perror("kill(getpid())");
}
}
/*
* initialize daemon
*/
static int
)
{
/* catch common signals */
}
/* ignore SIGALRM (used in med_cv_timedwait) */
}
/* return success */
return (0);
}
/*
* (re)initalize daemon
*/
static int
)
{
static int already = 0;
/* setup */
if (! already) {
return (-1);
already = 1;
}
/* return success */
return (0);
}
/*
* get my nodename
*/
char *
mynode(void)
{
static int done = 0;
if (! done) {
med_perror("uname");
assert(0);
}
done = 1;
}
}
/*
* check for trusted host and user
*/
static int
)
{
int i;
/* check for root */
/*LINTED*/
goto out;
/* get hostnames */
med_eprintf("transp->xp_netid == NULL\n");
goto out;
}
#ifdef DEBUG
nc_perror("getnetconfigent(transp->xp_netid)");
#endif
goto out;
}
!= 0) || (hservlistp == NULL)) {
#ifdef DEBUG
netdir_perror("netdir_getbyaddr(transp->xp_rtaddr)");
#endif
goto out;
}
/* check hostnames */
for (i = 0; (i < hservlistp->h_cnt); ++i) {
/*
* If the names are now different it indicates
* that hostname was converted to a nodeid. This
* will only occur if hostname is part of the same
* cluster that the current node is in.
* If the machine is not running in a cluster than
* sdssc_cm_nm2nid is a noop which leaves inplace
* alone.
*/
rval = 0;
goto out;
}
/* localhost is OK */
rval = 0;
goto out;
}
rval = 0;
goto out;
}
/* check for remote root access */
rval = 0;
goto out;
}
}
/* cleanup, return success */
out:
if (inplace)
if (hservlistp != NULL)
return (rval);
}
/*
* check for user in local group 14
*/
static int
)
{
char **namep;
/* get user info, check default GID */
return (-1);
return (0);
/* check in group */
return (-1);
++namep) {
return (0);
}
return (-1);
}
/*
* check AUTH_SYS
*/
static int
int amode, /* R_OK | W_OK */
)
{
#ifdef _REENTRANT
#endif /* _REENTRANT */
/* for read, anything is OK */
return (0);
#ifdef _REENTRANT
/* single thread (not really needed if daemon stays single threaded) */
mutex_lock(&mx);
#endif /* _REENTRANT */
/* check for remote root or METAMED_GID */
/*LINTED*/
(check_host(rqstp) == 0)) {
#ifdef _REENTRANT
mutex_unlock(&mx);
#endif /* _REENTRANT */
return (0);
}
/* return failure */
#ifdef _REENTRANT
mutex_unlock(&mx);
#endif /* _REENTRANT */
}
/*
* setup RPC service
*
* if can't authenticate return < 0
* if any other error return > 0
*/
int
int amode, /* R_OK | W_OK */
)
{
/*
* initialize
*/
if (sdssc_bind_library() == SDSSC_ERROR) {
"can't bind to cluster library");
return (1);
}
/*
* check credentials
*/
/* UNIX flavor */
case AUTH_SYS:
{
return (1); /* error */
break;
}
/* can't authenticate anything else */
default:
return (-1); /* weak authentication */
}
/*
* (re)initialize
*/
if (med_init_daemon(medep) != 0)
return (1); /* error */
/* return success */
return (0);
}