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

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Mon May 21 15:52:29 UTC 2007


Author: rmeggins

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

Modified Files:
	ux-update.cc 
Log Message:
Resolves: bug 239502
Description: adminserver: autotools, FHS, and many bug fixes
Fix Description: 1) Fixes for RHEL5 and Apache 2.2 - the existing code for handling Apache 2.2 did not work, including cgisock code in httpd.conf
2) better support for mod_nss detection - look in several places for pcache and module
3) admin server post install will mkdirs that it uses if they do not already exist, and set permissions appropriately
4) use --variable=libdir with nss pkg-config to get the libdir - --libs-only-L returns nothing if the library is already in the system libdir - we need the actual libdir in every case because we have to use it in the ld_preload in the startup script



Index: ux-update.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-update.cc,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- ux-update.cc	15 May 2007 22:59:13 -0000	1.27
+++ ux-update.cc	21 May 2007 15:52:26 -0000	1.28
@@ -70,6 +70,7 @@
 
 const char *CHOWN_CMD = "chown -R %s %s >/dev/null 2>&1";
 const char *CHGRP_CMD = "chgrp -R %s %s >/dev/null 2>&1";
+const char *MKDIR_CMD = "mkdir -p %s > /dev/null 2>&1";
 
 const char *DEFAULT_ADMIN_CONFIG_ACI = "(targetattr=*)(version 3.0; acl \"Enable delegated admin to access configuration\"; allow (read,search) groupdn=\"ldap:///%s\";)";
 
@@ -274,7 +275,7 @@
 
    if (ret)
    {
-      printf("Can't start Admin server [%s] (error: %s)", startProgram, system_errmsg());
+      printf("Can't start Admin server [%s] (error: %s)\n", startProgram, system_errmsg());
       installLog->logMessage(WARN, "Admin", "Can't start Admin server [%s] (error: %s)", startProgram, system_errmsg());
    }
    else
@@ -294,6 +295,42 @@
    }
 }
 
+/* like mkdir -p and chmod */
+void
+admin_mkdir(const char *path, int mode)
+{
+   struct stat fi;
+   int rc = stat(path, &fi);
+   int err = errno;
+   char tmp[BIG_BUF];
+
+   if (!rc && S_ISDIR(fi.st_mode)) {
+       /* already exists */
+       return;
+   }
+   if (!rc && !S_ISDIR(fi.st_mode)) {
+       installLog->logMessage(FATAL, "Admin", "Can't create directory [%s]: that path already exists but is not a directory",
+                              path);
+       exit(1);
+   }
+   if (rc && (err != ENOENT)) {
+       installLog->logMessage(FATAL, "Admin", "Can't create directory [%s]: [%d:%s]",
+                              path, err, system_errmsg());
+       exit(1);
+   }
+
+   sprintf(tmp, MKDIR_CMD, path);
+   if (system(tmp)) {
+       err = errno;
+       installLog->logMessage(FATAL, "Admin", "Can't create directory [%s]: [%d:%s]",
+                              path, err, system_errmsg());
+       exit(1);
+   }
+   chmod(path, mode);
+
+   return;
+}
+
 void
 admin_chown(const char *path, uid_t tuid, const char *tuser, gid_t tgid, const char *tgrp)
 {
@@ -523,11 +560,6 @@
       installLog->logMessage(INFO, "Admin", "Writing configuration data to %s", configdir);
    }
 
-   if ((mkdir(dir, 0700) == -1) && (errno != EEXIST))
-   {
-      fatal_error("Can't create directory %s (error: %s)", dir, system_errmsg());
-   }
-
    /*
     * Write new admpw.
     */
@@ -547,6 +579,9 @@
    hexp = make_shexp(hosts);
    aexp = make_shexp(addrs);
 
+   admin_mkdir(configdir, S_IRUSR | S_IWUSR | S_IXUSR);
+   admin_mkdir(securitydir, S_IRUSR | S_IWUSR | S_IXUSR);
+   admin_mkdir(logdir, S_IRUSR | S_IWUSR | S_IXUSR);
    if (!geteuid())
    {
       /* Current pw ent, target pw ent */




More information about the Fedora-directory-commits mailing list