[Fedora-directory-commits] adminserver/admserv/newinst/src ux-update.cc, 1.14, 1.15

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Thu Nov 17 17:43:46 UTC 2005


Author: rmeggins

Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17654/adminserver/admserv/newinst/src

Modified Files:
	ux-update.cc 
Log Message:
Admin server post install was core dumping in express mode because it did
not have the apache root information.  This information is obtained in
the other install modes.  The fix is to copy some code from the preinstaller
that figures out the value of ApacheRoot from the Apache binary.



Index: ux-update.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-update.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ux-update.cc	10 Nov 2005 01:12:59 -0000	1.14
+++ ux-update.cc	17 Nov 2005 17:43:38 -0000	1.15
@@ -209,6 +209,61 @@
    return result;
 }
 
+static char *get_value(char * file, char * attr) {
+   char cmd[1024];
+   char buf[1024];
+   FILE *fp;
+
+   sprintf(cmd, "%s -V", file);
+   fp = popen(cmd, "r");
+
+   if (fp != NULL) {
+      char *x, *t;
+      while ((fgets(buf,  sizeof(buf), fp)) > 0) {
+         x = (char *)strstr(buf, attr);
+         if (x) {
+            t = (char *)strtok(buf, "\"");
+            if (t) {
+               t = (char *)strtok(NULL, "\"");
+               if (t) {
+                  pclose(fp);
+                  return (char *)(strdup(t));
+               }
+            }
+         }
+      }
+   }
+   pclose(fp);
+   return NULL;
+}
+
+static NSString
+findApacheRoot(const char *dir)
+{
+   char path[1024];
+   char errMsg[SML_BUF];
+   struct stat st;
+   char *v;
+
+   snprintf(path, sizeof(path), "%s/httpd.worker", dir);
+   if (stat(path, &st) != 0) {
+      snprintf(path, sizeof(path), "%s/httpd", dir);
+      if (stat(path, &st) != 0) {
+         return NULL;
+      }
+   }
+
+   v = get_value(path, "HTTPD_ROOT");
+   if (v) {
+	   sprintf(path, "%s/modules", v);
+	   if (stat(path, &st) != 0) {
+		   return NULL;
+	   }
+   }
+
+   return v;
+}
+
 void
 configTasks(const Ldap *ldap, const char *sroot, const char *sieDN)
 {
@@ -490,12 +545,17 @@
    s = adminInfo->get("SysUser");
    strcpy(adminUser, s);
 
-   s = adminInfo->get("ApacheRoot");
-   strcpy(apacheRoot, s);
-
    s = adminInfo->get("ApacheDir");
    strcpy(apacheDir, s);
 
+   s = adminInfo->get("ApacheRoot");
+   if (!s) {
+	   NSString ar = findApacheRoot(apacheDir);
+	   strcpy(apacheRoot, (const char *)ar);
+   } else {
+	   strcpy(apacheRoot, s);
+   }
+
    snprintf(apacheBin, sizeof(apacheBin), "%s/httpd.worker", apacheDir);
    if (stat(apacheBin, &st) != 0) {
       snprintf(apacheBin, sizeof(apacheBin), "%s/httpd", apacheDir);




More information about the Fedora-directory-commits mailing list