Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2777/newinst/src
Modified Files:
ux-update.cc
Log Message:
rename scripts to x-ds-admin; fix uid change in config.c; remove obsolete snmp CGIs
Index: ux-update.cc
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/ux-update.cc,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ux-update.cc 9 May 2007 00:26:33 -0000 1.23
+++ ux-update.cc 11 May 2007 17:26:12 -0000 1.24
@@ -57,20 +57,12 @@
static int set_locate_admserv_aci(Ldap *ldap);
static int repair_group_expansion_aci(Ldap *ldap);
-static void replaceTokensInFile(const char *sourcefile, const char *destfile, const char
* const *ary);
-
-#ifdef HPUX
- #define SHLIB_EXT "sl"
-#else
- #define SHLIB_EXT "so"
-#endif
#define EPOCH_32BIT_END_TIME "20380118031417" /* <correct end time>
minus 1 day */
const char *DEFAULT_SYSUSER = DEFAULT_HTTPDUSER;
-const char *DEFAULT_DATADIR = DATADIR;
-const char *DEFAULT_TASKCONF = "admintasks.ldif"; /* relative to DATADIR */
-const char *DEFAULT_GLOBALCONF = "adminglobal.ldif"; /* relative to DATADIR */
+const char *DEFAULT_TASKCONF = "admintasks.ldif"; /* relative to LDIFDIR */
+const char *DEFAULT_GLOBALCONF = "adminglobal.ldif"; /* relative to LDIFDIR */
const char *CHOWN_CMD = "chown -R %s %s >/dev/null 2>&1";
const char *CHGRP_CMD = "chgrp -R %s %s >/dev/null 2>&1";
@@ -357,11 +349,11 @@
if (stat(pid, &fi) == 0)
{
- sprintf(startProgram, "%s/restart-admin > %s 2>&1", CMDBINDIR,
startLog);
+ sprintf(startProgram, "%s/restart-ds-admin > %s 2>&1",
CMDBINDIR, startLog);
}
else
{
- sprintf(startProgram, "%s/start-admin > %s 2>&1", CMDBINDIR,
startLog);
+ sprintf(startProgram, "%s/start-ds-admin > %s 2>&1", CMDBINDIR,
startLog);
}
ret = system(startProgram);
@@ -388,46 +380,6 @@
}
}
-/*
-void
-walk_dir_and_chown(const char *dirName, uid_t my_uid, uid_t admin_uid, uid_t tuid, gid_t
tgid)
-{
- if (chdir(dirName) == 0)
- {
- struct dirent *entry = NULL;
- DIR *dir;
- struct stat fi;
-
- dir = opendir(".");
- while ((entry = readdir(dir)) != NULL)
- {
- if (strcmp(entry->d_name, ".") && strcmp(entry->d_name,
"..") &&
- lstat(entry->d_name, &fi) == 0)
- {
- if (S_ISDIR(fi.st_mode))
- {
- walk_dir_and_chown(entry->d_name,
- my_uid, admin_uid, tuid, tgid);
- }
-
- if ((my_uid == fi.st_uid || admin_uid == fi.st_uid)
- && tuid != fi.st_uid)
- {
- lchown(entry->d_name, tuid, tgid);
- }
- }
- }
-
- closedir(dir);
-
- if (dirName[0] != '/')
- {
- chdir("..");
- }
- }
-}
-*/
-
void
admin_chown(const char *path, uid_t tuid, const char *tuser, gid_t tgid, const char
*tgrp)
{
@@ -661,8 +613,6 @@
fatal_error("Can't create directory %s (error: %s)", dir,
system_errmsg());
}
- logUninstallInfo(CONFIGDIR, "admin", "admin", dir);
-
/* make sure the config directory is owned by the ssuser */
sprintf(tstr, "%s", CONFIGDIR);
chown_file(SSuser, SSgroup, tstr);
@@ -683,7 +633,6 @@
fclose(f);
chmod(tstr, S_IRUSR | S_IWUSR);
chown_file(SSuser, SSgroup, tstr);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
hexp = make_shexp(hosts);
aexp = make_shexp(addrs);
@@ -713,6 +662,10 @@
if (installMode == Interactive)
printf("Changing ownership to admin user %s...\n", adminUser);
admin_chown(CONFIGDIR, tuid, adminUser, tgid, tgp->gr_name);
+ admin_chown(SECURITYDIR, tuid, adminUser, tgid, tgp->gr_name);
+ admin_chown(LOGDIR, tuid, adminUser, tgid, tgp->gr_name);
+ sprintf(tstr, "%s/%s", PIDDIR, PIDFILE);
+ admin_chown(tstr, tuid, adminUser, tgid, tgp->gr_name);
#ifdef HPUX
/*
@@ -953,12 +906,12 @@
* Write Tasks node
*/
- configTasks(&ldap, DATADIR, sieDN);
+ configTasks(&ldap, LDIFDIR, sieDN);
// Write global configuration paramters
char *adminDomainDN;
adminDomainDN = formAdminDomainDN(adminDomain);
- configGlobalParameters(&ldap, DATADIR, adminDomainDN);
+ configGlobalParameters(&ldap, LDIFDIR, adminDomainDN);
nsSetupFree (adminDomainDN);
/*
@@ -1003,125 +956,6 @@
admConf.write(tstr);
chmod(tstr, S_IRUSR | S_IWUSR);
chown_file(SSuser, SSgroup, tstr);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- // Mark to remove the following guys which are
- // created later on also
- sprintf(tstr, "%s/local.conf", CONFIGDIR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
- sprintf(tstr, "%s/access", LOGDIR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
- sprintf(tstr, "%s/error", LOGDIR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
- sprintf(tstr, "%s/admpw.log", LOGDIR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
- sprintf(tstr, "%s/dsconfig.log", LOGDIR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- /* PVO remember to set access permission here */
-
- char **httparray = (char **)malloc(5*sizeof(char *)); /* 2 tokens, 2 replacements,
NULL terminated */
- char **admservarray = (char **)malloc(3*sizeof(char *)); /* 1 token, 1 replacement,
NULL terminated */
- char **consolearray = (char **)malloc(11*sizeof(char *)); /* 5 tokens, 5 replacements,
NULL terminated */
- char **nssarray = (char **)malloc(3*sizeof(char *)); /* 1 token, 1 replacement, NULL
terminated */
- char **startarray = (char **)malloc(5*sizeof(char *)); /* 2 tokens, 2 replacements,
NULL terminated */
- char **stoparray = (char **)malloc(3*sizeof(char *)); /* 1 token, 1 replacement, NULL
terminated */
- char **restartarray = (char **)malloc(3*sizeof(char *)); /* 1 token, 1 replacement,
NULL terminated */
-
- char src[BIG_BUF];
-
-
- httparray[0] = "%%%sroot%%%";
- httparray[1] = (char *)CONFIGDIR;
- httparray[2] = "%%%module_dir%%%";
- httparray[3] = (char *)apacheRoot;
- httparray[4] = NULL;
-
- admservarray[0] = "%%%sroot%%%";
- admservarray[1] = (char *)CONFIGDIR;
- admservarray[2] = NULL;
-
- nssarray[0] = "%%%sroot%%%";
- nssarray[1] = (char *)CONFIGDIR;
- nssarray[2] = NULL;
-
- consolearray[0] = "%%%sroot%%%";
- consolearray[1] = (char *)CONFIGDIR;
- consolearray[2] = "%%%httpduser%%%";
- consolearray[3] = (char *)SSuser;
- consolearray[4] = "%%%httpdgroup%%%";
- consolearray[5] = (char *)SSgroup;
- consolearray[6] = "%%%httpport%%%";
- consolearray[7] = (char *)dir; /* sprint'd earlier */
- consolearray[8] = NULL;
-
- startarray[0] = "%%%sroot%%%";
- startarray[1] = (char *)CONFIGDIR;
- startarray[2] = "%%%httpd%%%";
- startarray[3] = (char *)apache;
- startarray[4] = NULL;
-
- stoparray[0] = "%%%sroot%%%";
- stoparray[1] = (char *)CONFIGDIR;
- stoparray[2] = NULL;
-
- restartarray[0] = "%%%sroot%%%";
- restartarray[1] = (char *)CONFIGDIR;
- restartarray[2] = NULL;
-
- if (0 == strncmp(apacheVersion, "2.2", 3)) {
- snprintf(src, sizeof(tstr), "%s/template/httpd-2.2.conf.tmpl",
CONFIGDIR);
- } else {
- snprintf(src, sizeof(tstr), "%s/template/httpd.conf.tmpl", CONFIGDIR);
- }
- snprintf(tstr, sizeof(tstr), "%s/httpd.conf", CONFIGDIR);
- replaceTokensInFile(src, tstr, httparray);
- chmod(tstr, S_IRUSR | S_IWUSR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- snprintf(tstr, sizeof(tstr), "%s/admserv.conf", CONFIGDIR);
- snprintf(src, sizeof(tstr), "%s/template/admserv.conf.tmpl", CONFIGDIR);
- replaceTokensInFile(src, tstr, admservarray);
- chmod(tstr, S_IRUSR | S_IWUSR);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- snprintf(tstr, sizeof(tstr), "%s/nss.conf", CONFIGDIR);
- snprintf(src, sizeof(tstr), "%s/template/nss.conf.tmpl", CONFIGDIR);
- replaceTokensInFile(src, tstr, nssarray);
- chmod(tstr, S_IRUSR | S_IWUSR);
- chown_file(SSuser, SSgroup, tstr);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- snprintf(tstr, sizeof(tstr), "%s/console.conf", CONFIGDIR);
- /*
- all of the dynamic information goes into console.conf, so we should
- not overwrite that information during an upgrade */
- if (stat(tstr, &st)) {
- snprintf(src, sizeof(tstr), "%s/template/console.conf.tmpl", CONFIGDIR);
- replaceTokensInFile(src, tstr, consolearray);
- chmod(tstr, S_IRUSR | S_IWUSR);
- chown_file(SSuser, SSgroup, tstr);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
- }
-
- snprintf(tstr, sizeof(tstr), "%s/start-admin", CONFIGDIR);
- snprintf(src, sizeof(tstr), "%s/template/start-admin.tmpl", CONFIGDIR);
- replaceTokensInFile(src, tstr, startarray);
- chmod(tstr, 0755);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- snprintf(tstr, sizeof(tstr), "%s/stop-admin", CONFIGDIR);
- snprintf(src, sizeof(tstr), "%s/template/stop-admin.tmpl", CONFIGDIR);
- replaceTokensInFile(src, tstr, stoparray);
- chmod(tstr, 0755);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
- snprintf(tstr, sizeof(tstr), "%s/restart-admin", CONFIGDIR);
- snprintf(src, sizeof(tstr), "%s/template/restart-admin.tmpl", CONFIGDIR);
- replaceTokensInFile(src, tstr, restartarray);
- chmod(tstr, 0755);
- logUninstallInfo(CONFIGDIR, "admin", "admin", tstr);
-
{
// Generating local.conf
@@ -1225,117 +1059,6 @@
return OKAY;
}
-
-/*
- Substitutes an occurance of token with replacement in the given string.
- str should point at the beginning of token e.g. use like this:
- if (str = strstr(line, token)) {
- replaceToken(str, token, replacement);
- }
-
- str is modified in place, so it should have enough room for the replacement
-*/
-static void
-replaceTokenInStr(char *str, const char *token, const char *replacement)
-{
- int offset;
- int tlen = strlen(token); /* length of the token string */
- int rlen = strlen(replacement); /* length of the replacement string */
- char *limit = str + (tlen < rlen ? tlen : rlen); /* where token or repl ends,
shortest */
- const char *rp = replacement; /* for iteration */
-
- /* up to limit, it is safe to just replace the token with the replacement */
- while (str < limit) {
- *str++ = *rp++;
- }
-
- /* at this point, we have 1 of 3 states:
- tlen == rlen - the token is exactly as long as the replacement
- we are finished
- tlen > rlen - the token is longer than the replacement - we need
- to copy back str to "fill in" the string
- tlen < rlen - the replacement is longer than the token - we need
- to copy forward str to make room for the replacement
- */
- offset = rlen - tlen;
- if (offset > 0) {
- /* first move the pointer to the end of the string */
- while (*str) {
- str++;
- }
- /* str now points to the null terminator - we need to copy that too */
- /* next, move the chars to make room for the replacement */
- while (str >= limit) {
- *(str + offset) = *str;
- str--;
- }
- /* finally, finish writing the replacement */
- while (*rp) {
- *limit++ = *rp++;
- }
- } else if (offset < 0) {
- /* move str back to fill in space */
- while (1) {
- /* offset is negative, so - a - == a + */
- *str = *(str - offset);
- if (!*str) { /* copied null - exit */
- break;
- }
- str++;
- }
- } /* else offset is 0 - done */
-
- return;
-}
-
-/*
- copy sourcefile to destfile, replacing the tokens in source file with the
- replacement values in destfile. The array ary is an array of strings of
- alternately tokens and their replacements e.g.
- %%%sroot%%%
- /opt/fedora-ds
- %%%port%%%
- 3234
- %%%httpd%%%
- /usr/sbin/httpd.worker
- NULL
-
- ary must be NULL terminated
-*/
-static void
-replaceTokensInFile(const char *sourcefile, const char *destfile, const char * const
*ary)
-{
- FILE *src, *dest;
- char line[2048];
-
- src = fopen (sourcefile, "r");
- if (src == NULL) {
- fatal_error("Cannot open %s", sourcefile, 0);
- }
-
- /* The output file */
- dest = fopen (destfile, "w");
- if (dest == NULL) {
- fatal_error("Cannot open %s for writing", destfile, 0);
- }
-
- while (fgets(line, sizeof(line), src)) {
- const char * const * argp = ary;
- for (; argp && *argp; argp += 2) {
- const char *token = *argp;
- const char *replacement = *(argp + 1);
- char *str;
- while (str = strstr(line, token)) {
- replaceTokenInStr(str, token, replacement);
- }
- }
- fputs(line, dest);
- }
-
- fclose(dest);
- fclose(src);
-
-}
/* ----------------------- main ------------------------ */