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

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Wed Feb 22 02:28:59 UTC 2006


Author: rmeggins

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

Modified Files:
	ux-update.cc 
Log Message:
Apache 2.2 uses different modules for auth/authz than 2.0.  This change allows admin server post install to figure out what version of Apache is being used (via httpd -v) and select the appropriate httpd.conf template file based on that version.



Index: ux-update.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-update.cc,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ux-update.cc	12 Dec 2005 18:34:14 -0000	1.18
+++ ux-update.cc	22 Feb 2006 02:28:51 -0000	1.19
@@ -241,7 +241,6 @@
 findApacheRoot(const char *dir)
 {
    char path[1024];
-   char errMsg[SML_BUF];
    struct stat st;
    char *v;
 
@@ -264,6 +263,53 @@
    return v;
 }
 
+static char *get_version(char * file) {
+   char cmd[1024];
+   char buf[1024];
+   FILE *fp;
+   const char *versstr = "Server version: Apache/";
+
+   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, versstr);
+         if (x) {
+            t = x + strlen(versstr);
+            if (x = strchr(buf, '\n')) {
+                *x = '\0';
+            }
+            pclose(fp);
+            return (char *)(strdup(t));
+         }
+      }
+   }
+   pclose(fp);
+   return NULL;
+}
+
+static NSString
+findApacheVersion(const char *dir)
+{
+   char path[1024];
+   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_version(path);
+
+   return v;
+}
+
 void
 configTasks(const Ldap *ldap, const char *sroot, const char *sieDN)
 {
@@ -527,6 +573,7 @@
    char apacheRoot[BIG_BUF];
    char apacheDir[BIG_BUF];
    char apacheBin[BIG_BUF];
+   char apacheVersion[BIG_BUF];
    struct stat st;
    NSString  hostip = InstUtil::getHostIpAddress(hn);
    char serverAddress[SML_BUF];
@@ -535,6 +582,7 @@
    int port;
    const char *s;
    char *ss;
+   NSString tmp;
 
    chdir(sroot);
    
@@ -577,6 +625,12 @@
       }
    }
 
+   apacheVersion[0] = '\0';
+   tmp = findApacheVersion(apacheDir);
+   if ((const char*)tmp) {
+       strcpy(apacheVersion, (const char *)tmp);
+   }
+
    s = installInfo->get(SS_USER_ID);
    if (NULL == s) {
       fatal_error("InstallInfo: Server User \"SuiteSpotUserID\" is missing.", "", "");
@@ -1209,8 +1263,12 @@
    restartarray[1] = (char *)sroot;
    restartarray[2] = NULL;
 
+   if (0 == strncmp(apacheVersion, "2.2", 3)) {
+       snprintf(src, sizeof(tstr), "%s/shared/config/template/httpd-2.2.conf.tmpl", sroot);
+   } else {
+       snprintf(src, sizeof(tstr), "%s/shared/config/template/httpd.conf.tmpl", sroot);
+   }
    snprintf(tstr, sizeof(tstr), "%s/admin-serv/config/httpd.conf", sroot);
-   snprintf(src, sizeof(tstr), "%s/shared/config/template/httpd.conf.tmpl", sroot);
    replaceTokensInFile(src, tstr, httparray);
    chmod(tstr, S_IRUSR | S_IWUSR);
    logUninstallInfo(sroot, "admin", "admin", tstr);




More information about the Fedora-directory-commits mailing list