[Fedora-directory-commits] adminserver/admserv/newinst/src ux-config.cc, 1.11, 1.12 ux-dialog.cc, 1.11, 1.12 ux-dialog.h, 1.5, 1.6 ux-remove.cc, 1.7, 1.8 ux-update.cc, 1.25, 1.26

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Tue May 15 22:57:55 UTC 2007


Author: rmeggins

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

Modified Files:
	ux-config.cc ux-dialog.cc ux-dialog.h ux-remove.cc 
	ux-update.cc 
Log Message:
Resolves: bug 239502
Description: adminserver: autotools, FHS, and many bug fixes
Fix Description: 1) Change the pre configuration program to use the standard adminutil pset and admldapInfo interfaces to get the default configuration information.  No sense having code duplicated all over the place.
2) Change pre-config to allow passed in config, security, log, and pid directories, or get from env. vars., as the post-config (update) program does.
3) Removed the Apache stuff.  This will be set during the build process.



Index: ux-config.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-config.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ux-config.cc	9 May 2007 00:26:33 -0000	1.11
+++ ux-config.cc	15 May 2007 22:57:53 -0000	1.12
@@ -44,10 +44,20 @@
 #include "ux-config.h"
 #include "ux-dialog.h"
 
+#include "libadminutil/admutil.h"
+#include "libadminutil/distadm.h"
+#include "libadmsslutil/admsslutil.h"
+#include "libadmsslutil/psetcssl.h"
+
 #include "config.h"
 
 extern const char *DEFAULT_SYSUSER;
 
+static char configdir[BIG_BUF];
+static char securitydir[BIG_BUF];
+static char logdir[BIG_BUF];
+static char piddir[BIG_BUF];
+
 /*********************************************************************
 **
 ** METHOD:
@@ -174,12 +184,6 @@
       }
       else 
       {
-         if (_logFile == (char *) NULL)
-         {
-	    NSString logdir(LOGDIR);
-            _logFile = logdir + "/" + INSTALL_LOG;
-         }
-         _installLog = new InstallLog (_logFile);
       }
    }
 
@@ -221,6 +225,53 @@
          _adminInfo = _installInfo->createSection("admin");
       }
 
+      // if we have been given a .inf file, see if the user specified custom
+      // config and log dirs, or specified env vars, or just use the defaults
+      const char *s = _adminInfo->get("config_dir");
+      if (NULL == s) {
+         s = getenv("ADMSERV_CONF_DIR");
+      }
+      if (NULL == s) {
+         s = CONFIGDIR;
+      }
+      strcpy(configdir, s);
+
+      s = _adminInfo->get("security_dir");
+      if (NULL == s) {
+         s = getenv("ADMSERV_CONF_DIR");
+      }
+      if (NULL == s) {
+         s = SECURITYDIR;
+      }
+      strcpy(securitydir, s);
+
+      s = _adminInfo->get("log_dir");
+      if (NULL == s) {
+         s = getenv("ADMSERV_LOG_DIR");
+      }
+      if (NULL == s) {
+         s = LOGDIR;
+      }
+      strcpy(logdir, s);
+
+      s = _adminInfo->get("run_dir");
+      if (NULL == s) {
+         s = getenv("ADMSERV_PID_DIR");
+      }
+      if (NULL == s) {
+         s = PIDDIR;
+      }
+      strcpy(piddir, s);
+
+      if (installMode() != Interactive) {
+         if (_logFile == (char *) NULL)
+         {
+	    NSString mylogdir(logdir);
+            _logFile = mylogdir + "/" + INSTALL_LOG;
+         }
+         _installLog = new InstallLog (_logFile);
+      }          
+
       initDefaultConfig();
 
       setDefaultScript(_adminInfo);
@@ -248,68 +299,41 @@
 void
 AdminPreInstall::initDefaultConfig()
 {
-   char tmp[BIG_BUF];
-   NVPair admConf;
-   LdapError ldapError;
    char *ldapURL = NULL;
-   NSString siePwd = NULL;
-   NSString siePort = NULL;
    NSString hostName = InstUtil::guessHostname();
+   PsetHndl pset = NULL;
+   AdmldapInfo admConf;
 
    /* First, determine whether Admin is already configured */
-   snprintf(tmp, sizeof(tmp), "%s/local.conf", CONFIGDIR);
-   tmp[sizeof(tmp)-1] = 0;
-
-   admConf.setFormat(2);
-   admConf.read(tmp);
-
-   getDefaultLdapInfo(CONFIGDIR, &ldapURL, NULL, NULL );
-
-   if (admConf.isEmpty() == False)
-   {
-      NSString sieDN;
-
-      /* Use admin id and admin pwd to access DS */
-      sieDN = _installInfo->get(MC_ADMIN_ID); 
-      siePwd = _installInfo->get(MC_ADMIN_PWD);
-      siePort = admConf.get("nsServerPort");
-
-      if (sieDN != (char *) NULL && siePwd != (char *) NULL && ldapURL != NULL)
-      {
-         _configured = True;
-
-         Ldap ldap (ldapError, ldapURL, sieDN, siePwd, sieDN, siePwd);
-
-         if (ldapError == OKAY)
-         {
-            NSString configDN = NSString("cn=configuration") + LDAP_PATHSEP + sieDN;
-            LdapEntry *configEntry = new LdapEntry(&ldap);
-
-            if (configEntry->retrieve(configDN) == OKAY)
-            {
-               _adminInfo->set("Port", configEntry->getAttribute("nsServerPort"));
-               _adminInfo->set("SysUser", configEntry->getAttribute("nsSuiteSpotUser"));
-	       _adminInfo->set("ServerIpAddress", configEntry->getAttribute("nsServerAddress"));
-            }
-         }
+   int rv = ADMUTIL_Init();
+   if (!rv) {
+      admConf = admldapBuildInfoOnly(configdir, &rv);
+      rv = ADMSSL_InitSimple(configdir, securitydir, 0);
+      if (!rv) {
+         pset = psetCreateSSL("admin-serv", configdir,
+                              (char *)_installInfo->get(MC_ADMIN_ID),
+                              (char *)_installInfo->get(MC_ADMIN_PWD),
+                              &rv);
       }
    }
 
-   snprintf(tmp, sizeof(tmp), "%s/admpw", CONFIGDIR);
-   tmp[sizeof(tmp)-1] = 0;
-
-   admConf.read(tmp);
-
-   if (admConf.isEmpty())
+   if (pset && admConf)
    {
-      _configured = False;
+      _configured = True;
    }
-   else
+
+   if (pset)
    {
-      _adminInfo->set("ServerAdminID", admConf.name(0));
+      _adminInfo->set("Port", psetGetAttrSingleValue(pset, "configuration.nsServerPort", &rv));
+      _adminInfo->set("SysUser", psetGetAttrSingleValue(pset, "configuration.nsSuiteSpotUser", &rv));
+      _adminInfo->set("ServerIpAddress", psetGetAttrSingleValue(pset, "configuration.nsServerAddress", &rv));
    }
 
-   _adminInfo->set("ServerAdminPwd", siePwd);
+   if (admConf)
+   {
+      _adminInfo->set("ServerAdminID", admldapGetLocalAdminName(admConf));
+      ldapURL = admldapGetDirectoryURL(admConf);
+   }
 
    if (_adminInfo->get("SysUser") == NULL)
    {
@@ -318,12 +342,7 @@
 
    if (_adminInfo->get("Port") == NULL)
    {
-      if (siePort != (char*)NULL) {
-           _adminInfo->set("Port", siePort);
-      }
-      else {
-          _adminInfo->set("Port", (unsigned long)InstUtil::guessPort());
-      }
+      _adminInfo->set("Port", (unsigned long)InstUtil::guessPort());
    }
 
    if (_adminInfo->get("ServerIpAddress") == NULL)
@@ -359,8 +378,8 @@
          ldapURL = (char *) _installInfo->get(CONFIG_LDAP_URL);
       }
 
-      _installInfo->set(SS_USER_ID, InstUtil::getDefaultUser(CONFIGDIR));
-      _installInfo->set(SS_GROUP, InstUtil::getDefaultGroup(CONFIGDIR));
+//      _installInfo->set(SS_USER_ID, InstUtil::getDefaultUser(configdir));
+//      _installInfo->set(SS_GROUP, InstUtil::getDefaultGroup(configdir));
    }
 }
 
@@ -540,14 +559,6 @@
 
 SS7:
 
-  if (installType() == Express)
-  {
-     NSString httpd = HTTPD;
-     _adminInfo->set("Apache", httpd);
-     goto SS8;
-  }
-  askApache.registerDialogNext(this);
-  action = askApache.execute();
   if (action == DIALOG_PREV)
   {
      goto SS6;
@@ -736,7 +747,7 @@
    NSString errMsg;
    NSString sysUser;
 
-   snprintf(tmp, sizeof(tmp), "%s/local.conf", CONFIGDIR);
+   snprintf(tmp, sizeof(tmp), "%s/local.conf", configdir);
    tmp[sizeof(tmp)-1] = 0;
 
    if (stat(tmp, &fi) == 0)
@@ -769,12 +780,12 @@
    char stopProgram[BIG_BUF];
    struct stat fi;
 
-   snprintf(pid, sizeof(pid), "%s/%s", PIDDIR, PIDFILE);
+   snprintf(pid, sizeof(pid), "%s/%s", piddir, PIDFILE);
    pid[sizeof(pid)-1] = 0;
 
    if (stat(pid, &fi) == 0)
    {
-       snprintf(stopProgram, sizeof(stopProgram), "%s/stop-admin", CMDBINDIR);
+       snprintf(stopProgram, sizeof(stopProgram), "%s/stop-ds-admin", CMDBINDIR);
        stopProgram[sizeof(stopProgram)-1] = 0;
       if (stat (stopProgram, &fi) != 0)
       {
@@ -793,7 +804,7 @@
 
    disableWinMode();
 
-   snprintf(tmp, sizeof(tmp), "%s/ns-update -f %s", CMDBINDIR, _infoFile.data());
+   snprintf(tmp, sizeof(tmp), "%s/ds-admin-update -f %s", CMDBINDIR, _infoFile.data());
    tmp[sizeof(tmp)-1] = 0;
 
    err = system(tmp);
@@ -825,86 +836,3 @@
       ldap_value_free(dn);
    }
 }
-
-static char *get_value(const char * file, const char * attr) {
-   char cmd[1024];
-   char buf[1024];
-   FILE *fp;
-
-   snprintf(cmd, sizeof(cmd), "%s -V", file);
-   cmd[sizeof(cmd)-1] = 0;
-   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;
-}
-
-NSString
-AdminPreInstall::verifyApache(const char *path) const
-{
-   char errMsg[SML_BUF];
-   NSString apacheRoot;
-   struct stat st;
-   char *v;
-
-   if (stat(path, &st) != 0) {
-      snprintf(errMsg, sizeof(errMsg), "Unable to locate Apache binary %s\n.", path);
-      errMsg[sizeof(errMsg)-1] = 0;
-      return errMsg;
-   }
-
-   v = get_value(path, "APACHE_MPM_DIR");
-   if (!v || strcmp(v, "server/mpm/worker")) {
-      snprintf(errMsg, sizeof(errMsg),
-	       "The Admininistration Server requires an Apache web "
-	       "server that provides the worker (multi-threaded) model.\n%s was not "
-	       "built with this option.  See '%s -V' for more details", path, path);
-      errMsg[sizeof(errMsg)-1] = 0;
-      return errMsg;
-   }
-
-   apacheRoot = getApacheRoot(path);
-   if (!apacheRoot.data() || !apacheRoot.length()) {
-      snprintf(errMsg, sizeof(errMsg), "Unable to locate Apache modules for %s\n.", path);
-      errMsg[sizeof(errMsg)-1] = 0;
-      return errMsg;
-   }
-
-   errMsg[0] = 0;
-
-   return errMsg;
-}
-
-NSString
-AdminPreInstall::getApacheRoot(const char *path) const
-{
-   char mypath[1024];
-   char errMsg[SML_BUF];
-   struct stat st;
-   char *v;
-
-   v = get_value(path, "HTTPD_ROOT");
-   snprintf(mypath, sizeof(mypath), "%s/modules", v);
-   mypath[sizeof(mypath)-1] = 0;
-   if (stat(mypath, &st) != 0) {
-      return NULL;
-   }
-
-   return v;
-}


Index: ux-dialog.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-dialog.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ux-dialog.cc	9 May 2007 00:26:33 -0000	1.11
+++ ux-dialog.cc	15 May 2007 22:57:53 -0000	1.12
@@ -54,8 +54,6 @@
 DialogAction askLdapUserSetup(Dialog *me);
 DialogAction askHostIpAddressSetup (Dialog *me);
 DialogAction askHostIpAddressNext (Dialog *me);
-DialogAction askApacheSetup (Dialog *me);
-DialogAction askApacheNext (Dialog *me);
 
 DialogAction
 yesNoDefaultNo(const char *answer)
@@ -560,55 +558,3 @@
 
    return DIALOG_NEXT;
 }
-
-DialogInput askApache(
-"The Administration Server runs on the Apache web server. Please provide the\n"
-"absolute path and filename of the Apache binary. The Administration \n"
-"Server needs an Apache compiled with the worker (multi-threaded) model.\n",
-
-"Apache",
-
-HTTPD,
-askApacheSetup,
-askApacheNext
-);
-
-DialogAction
-askApacheSetup(Dialog *me)
-{
-   dialogSetup(me, "Apache", ((AdminPreInstall *) me->manager()->parent())->getDefaultScript());
-   return DIALOG_SAME;
-}
-
-DialogAction
-askApacheNext(Dialog *me)
-{
-   const char *buf = me->input();
-   const char *Apache;
-   NSString errMsg;
-   AdminPreInstall *installer = (AdminPreInstall *) me->manager()->parent();
-
-   if (buf[0] == 0)
-   {
-      Apache = me->defaultAns();
-   }
-   else
-   {
-      Apache = buf;
-   }
-
-   errMsg = installer->verifyApache(Apache);
-
-   if (errMsg != (char *) NULL)
-   {
-      DialogAlert alert(errMsg);
-      alert.execute();
-      return DIALOG_SAME;
-   }
-
-   me->manager()->getDefaultScript()->set("Apache", Apache);
-   me->manager()->getDefaultScript()->set("ApacheRoot", installer->getApacheRoot(Apache));
-
-   return DIALOG_NEXT;
-}
-


Index: ux-dialog.h
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-dialog.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ux-dialog.h	9 May 2007 00:26:33 -0000	1.5
+++ ux-dialog.h	15 May 2007 22:57:53 -0000	1.6
@@ -26,5 +26,4 @@
 extern DialogInput askHostIpAddress;
 extern DialogInput askLdapInfo;
 extern DialogInput askLdapUser;
-extern DialogInput askApache;
 


Index: ux-remove.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-remove.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ux-remove.cc	9 May 2007 00:26:33 -0000	1.7
+++ ux-remove.cc	15 May 2007 22:57:53 -0000	1.8
@@ -131,11 +131,11 @@
    FILE *fhdl = NULL;
 
    /* Stop the Admin Server */
-   snprintf(pidFile, sizeof(pidFile), "%s/admin-serv/logs/pid", serverRoot.data());
+   snprintf(pidFile, sizeof(pidFile), "%s/%s", PIDDIR, PIDFILE);
    pidFile[sizeof(pidFile)-1] = 0;
    if (stat(pidFile, &fi) == 0)
    {
-      snprintf(stopProgram, sizeof(stopProgram), "%s/stop-admin", serverRoot.data());
+      snprintf(stopProgram, sizeof(stopProgram), "%s/stop-ds-admin", CMDBINDIR);
       stopProgram[sizeof(stopProgram)-1] = 0;
       if (stat (stopProgram, &fi) != 0)
       {
@@ -145,17 +145,6 @@
       system(stopProgram);
    }
 
-   /* Stop SNMP Master Agent if running */
-   snprintf(pidFile, sizeof(pidFile), "%s/admin-serv/logs/pid_masteragt", serverRoot.data());
-   pidFile[sizeof(pidFile)-1] = 0;
-   if ((fhdl = fopen(pidFile, "r")) != NULL)
-   {
-      fscanf(fhdl, "%d\n", &pid);
-      fclose(fhdl);
-      kill(pid, SIGKILL);
-      unlink(pidFile);
-   }
-   
    char szCmdBuf[BIG_BUF];
    char *szHomeDir;
 


Index: ux-update.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-update.cc,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ux-update.cc	15 May 2007 00:30:49 -0000	1.25
+++ ux-update.cc	15 May 2007 22:57:53 -0000	1.26
@@ -397,7 +397,7 @@
 
    s = adminInstallInfo->get("security_dir");
    if (NULL == s) {
-       s = getenv("ADMSERV_CONF_DIR");;
+       s = getenv("ADMSERV_CONF_DIR");
    }
    if (NULL == s) {
        s = SECURITYDIR;
@@ -406,7 +406,7 @@
 
    s = adminInstallInfo->get("log_dir");
    if (NULL == s) {
-       s = getenv("ADMSERV_LOG_DIR");;
+       s = getenv("ADMSERV_LOG_DIR");
    }
    if (NULL == s) {
        s = LOGDIR;




More information about the Fedora-directory-commits mailing list