Path resolution for error templates.
[shibboleth/sp.git] / shibd / shibd.cpp
index 526d624..7f61f15 100644 (file)
@@ -58,6 +58,7 @@ using namespace std;
 bool shibd_shutdown = false;\r
 const char* shar_config = NULL;\r
 const char* shar_schemadir = NULL;\r
+const char* shar_prefix = NULL;\r
 bool shar_checkonly = false;\r
 bool shar_version = false;\r
 static int unlink_socket = 0;\r
@@ -119,19 +120,16 @@ int real_main(int preinit)
             SPConfig::OutOfProcess |\r
             (shar_checkonly ? SPConfig::RequestMapping : SPConfig::Logging)\r
             );\r
-        if (!shar_config)\r
-            shar_config=getenv("SHIBSP_CONFIG");\r
-        if (!shar_schemadir)\r
-            shar_schemadir=getenv("SHIBSP_SCHEMAS");\r
-        if (!shar_schemadir)\r
-            shar_schemadir=SHIBSP_SCHEMAS;\r
-        if (!shar_config)\r
-            shar_config=SHIBSP_CONFIG;\r
-        if (!conf.init(shar_schemadir)) {\r
+        if (!conf.init(shar_schemadir, shar_prefix)) {\r
             fprintf(stderr, "configuration is invalid, see console for specific problems\n");\r
             return -1;\r
         }\r
         \r
+        if (!shar_config)\r
+            shar_config=getenv("SHIBSP_CONFIG");\r
+        if (!shar_config)\r
+            shar_config=SHIBSP_CONFIG;\r
+\r
         try {\r
             static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h);\r
             static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);\r
@@ -215,7 +213,8 @@ static int setup_signals(void)
 \r
 static void usage(char* whoami)\r
 {\r
-    fprintf(stderr, "usage: %s [-fcdt]\n", whoami);\r
+    fprintf(stderr, "usage: %s [-dcxtfpvh]\n", whoami);\r
+    fprintf(stderr, "  -d\tinstallation prefix to use.\n");\r
     fprintf(stderr, "  -c\tconfig file to use.\n");\r
     fprintf(stderr, "  -x\tXML schema catalogs to use.\n");\r
     fprintf(stderr, "  -t\tcheck configuration file for problems.\n");\r
@@ -230,8 +229,11 @@ static int parse_args(int argc, char* argv[])
 {\r
     int opt;\r
 \r
-    while ((opt = getopt(argc, argv, "c:x:p:ftvh")) > 0) {\r
+    while ((opt = getopt(argc, argv, "d:c:x:p:ftvh")) > 0) {\r
         switch (opt) {\r
+            case 'd':\r
+                shar_prefix=optarg;\r
+                break;\r
             case 'c':\r
                 shar_config=optarg;\r
                 break;\r
@@ -269,15 +271,6 @@ int main(int argc, char *argv[])
     if (setup_signals() != 0)\r
         return -1;\r
 \r
-    if (!shar_config)\r
-        shar_config=getenv("SHIBSP_CONFIG");\r
-    if (!shar_schemadir)\r
-        shar_schemadir=getenv("SHIBSP_SCHEMAS");\r
-    if (!shar_schemadir)\r
-        shar_schemadir=SHIBSP_SCHEMAS;\r
-    if (!shar_config)\r
-        shar_config=SHIBSP_CONFIG;\r
-\r
     // initialize the shib-target library\r
     SPConfig& conf=SPConfig::getConfig();\r
     conf.setFeatures(\r
@@ -291,11 +284,16 @@ int main(int argc, char *argv[])
         SPConfig::OutOfProcess |\r
         (shar_checkonly ? SPConfig::RequestMapping : SPConfig::Logging)\r
         );\r
-    if (!conf.init(shar_schemadir)) {\r
+    if (!conf.init(shar_schemadir, shar_prefix)) {\r
         fprintf(stderr, "configuration is invalid, check console for specific problems\n");\r
         return -1;\r
     }\r
 \r
+    if (!shar_config)\r
+        shar_config=getenv("SHIBSP_CONFIG");\r
+    if (!shar_config)\r
+        shar_config=SHIBSP_CONFIG;\r
+    \r
     try {\r
         static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h);\r
         static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);\r