1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/*
* Copyright (c) 2001-2003 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 1998-2001 University of Notre Dame.
* All rights reserved.
* Copyright (c) 1994-1998 The Ohio State University.
* All rights reserved.
*
* This file is part of the LAM/MPI software package. For license
* information, see the LICENSE file in the top level directory of the
* LAM/MPI source distribution.
*
* $HEADER$
*
* $Id: v_main.c,v 1.13 2003/09/27 05:16:16 brbarret Exp $
*
* Function: - version server
*/
#include <lam_config.h>
#include <all_opt.h>
#include <etc_misc.h>
#include <kreq.h>
#include <laminternal.h>
#include <lamdebug.h>
#include <priority.h>
#include <terror.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
/*
* external functions
*/
extern void (*(v_init()))();
extern void (*(versiond()))();
/*
* global (to lam daemons) options
*/
OPT* lam_daemon_optd;
int
main(int argc, char* argv[])
{
char *prefix = NULL;
char *suffix = NULL;
/* Ensure that we are not root */
#ifndef LAM_ALLOW_RUN_AS_ROOT
if (getuid() == 0 || geteuid() == 0) {
show_help(NULL, "deny-root", NULL);
exit(EACCES);
}
#endif
/* Be safe; blanket coverage */
umask(077);
/*
* Parse command line arguments.
*/
lam_daemon_optd = ao_init();
ao_setopt1(lam_daemon_optd, "d", 0, 0, 0);
ao_setopt(lam_daemon_optd, "sessionprefix", 0, 1, 0);
ao_setopt(lam_daemon_optd, "sessionsuffix", 0, 1, 0);
if (ao_parse(lam_daemon_optd, &argc, argv)) {
show_help("versiond", "usage", NULL);
exit(EUSAGE);
}
/*
* See if we're running under a batch system, and if so, set the unix
* socket name
*/
if (ao_taken(lam_daemon_optd, "sessionprefix")) {
prefix = ao_param(lam_daemon_optd, "sessionprefix", 0, 0);
}
if (ao_taken(lam_daemon_optd, "sessionsuffix")) {
suffix = ao_param(lam_daemon_optd, "sessionsuffix", 0, 0);
}
lam_tmpdir_init(prefix, suffix);
/*
* If we were started with '-d', setup to do some syslog debugging messages
*/
if (ao_taken(lam_daemon_optd, "d")) {
lamopenlog("versiond");
lamlog("started (%s), uid %d, gid %d", LAM_VERSION,
getuid(), getgid());
lam_comm_debug_open(0, LAM_COMM_DEBUG_DLI);
}
if (kinit(PRVERSIOND))
lampanic("versiond (kinit)");
/* Initialize */
v_init();
/* server loop */
for (;;) {
if (!versiond()) {
kexit(1);
break;
}
}
return(0);
}
|