X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibd%2Fshibd.cpp;h=c1eaf5f8af31d061fde1633fa28b7b2125841586;hb=HEAD;hp=9c6839b723a84f0ba6c983781fa0ffda4171398b;hpb=cc5dda571c1a756573f4b5e0dde85bd5c2885cd7;p=shibboleth%2Fsp.git diff --git a/shibd/shibd.cpp b/shibd/shibd.cpp index 9c6839b..c1eaf5f 100644 --- a/shibd/shibd.cpp +++ b/shibd/shibd.cpp @@ -58,7 +58,9 @@ using namespace std; bool shibd_shutdown = false; const char* shar_config = NULL; const char* shar_schemadir = NULL; +const char* shar_prefix = NULL; bool shar_checkonly = false; +bool shar_version = false; static int unlink_socket = 0; const char* pidfile = NULL; @@ -118,19 +120,16 @@ int real_main(int preinit) SPConfig::OutOfProcess | (shar_checkonly ? SPConfig::RequestMapping : SPConfig::Logging) ); - if (!shar_config) - shar_config=getenv("SHIBSP_CONFIG"); - if (!shar_schemadir) - shar_schemadir=getenv("SHIBSP_SCHEMAS"); - if (!shar_schemadir) - shar_schemadir=SHIBSP_SCHEMAS; - if (!shar_config) - shar_config=SHIBSP_CONFIG; - if (!conf.init(shar_schemadir)) { + if (!conf.init(shar_schemadir, shar_prefix)) { fprintf(stderr, "configuration is invalid, see console for specific problems\n"); return -1; } + if (!shar_config) + shar_config=getenv("SHIBSP_CONFIG"); + if (!shar_config) + shar_config=SHIBSP_CONFIG; + try { static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h); static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e); @@ -214,12 +213,14 @@ static int setup_signals(void) static void usage(char* whoami) { - fprintf(stderr, "usage: %s [-fcdt]\n", whoami); + fprintf(stderr, "usage: %s [-dcxtfpvh]\n", whoami); + fprintf(stderr, " -d\tinstallation prefix to use.\n"); fprintf(stderr, " -c\tconfig file to use.\n"); fprintf(stderr, " -x\tXML schema catalogs to use.\n"); fprintf(stderr, " -t\tcheck configuration file for problems.\n"); fprintf(stderr, " -f\tforce removal of listener socket.\n"); fprintf(stderr, " -p\tpid file to use.\n"); + fprintf(stderr, " -v\tprint software version.\n"); fprintf(stderr, " -h\tprint this help message.\n"); exit(1); } @@ -228,8 +229,11 @@ static int parse_args(int argc, char* argv[]) { int opt; - while ((opt = getopt(argc, argv, "c:x:p:fth")) > 0) { + while ((opt = getopt(argc, argv, "d:c:x:p:ftvh")) > 0) { switch (opt) { + case 'd': + shar_prefix=optarg; + break; case 'c': shar_config=optarg; break; @@ -242,6 +246,9 @@ static int parse_args(int argc, char* argv[]) case 't': shar_checkonly=true; break; + case 'v': + shar_version=true; + break; case 'p': pidfile=optarg; break; @@ -254,20 +261,15 @@ static int parse_args(int argc, char* argv[]) int main(int argc, char *argv[]) { - if (setup_signals() != 0) - return -1; - if (parse_args(argc, argv) != 0) usage(argv[0]); + else if (shar_version) { + fprintf(stdout, PACKAGE_STRING"\n"); + return 0; + } - if (!shar_config) - shar_config=getenv("SHIBSP_CONFIG"); - if (!shar_schemadir) - shar_schemadir=getenv("SHIBSP_SCHEMAS"); - if (!shar_schemadir) - shar_schemadir=SHIBSP_SCHEMAS; - if (!shar_config) - shar_config=SHIBSP_CONFIG; + if (setup_signals() != 0) + return -1; // initialize the shib-target library SPConfig& conf=SPConfig::getConfig(); @@ -282,11 +284,16 @@ int main(int argc, char *argv[]) SPConfig::OutOfProcess | (shar_checkonly ? SPConfig::RequestMapping : SPConfig::Logging) ); - if (!conf.init(shar_schemadir)) { + if (!conf.init(shar_schemadir, shar_prefix)) { fprintf(stderr, "configuration is invalid, check console for specific problems\n"); return -1; } + if (!shar_config) + shar_config=getenv("SHIBSP_CONFIG"); + if (!shar_config) + shar_config=SHIBSP_CONFIG; + try { static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h); static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);