From 8613004cbf911aef6889fd0250e8b9ab2ec9550b Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Sun, 14 Nov 2010 20:43:04 -0800 Subject: [PATCH] Remove webapp dependency on RDECK_BASE/etc. Tools are likely not working as there are numerous references to baseDir and etc. --- core/src/java/com/dtolabs/launcher/Check.java | 6 +++--- core/src/java/com/dtolabs/rundeck/core/Constants.java | 2 +- .../core/authorization/providers/SAREAuthorization.java | 1 + .../src/java/com/dtolabs/rundeck/core/common/Framework.java | 5 +++-- rundeckapp/grails-app/conf/BootStrap.groovy | 5 +++-- rundeckapp/grails-app/services/FrameworkService.groovy | 6 ++++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/src/java/com/dtolabs/launcher/Check.java b/core/src/java/com/dtolabs/launcher/Check.java index bdf3335eea8..a972dca86ef 100644 --- a/core/src/java/com/dtolabs/launcher/Check.java +++ b/core/src/java/com/dtolabs/launcher/Check.java @@ -176,7 +176,7 @@ void testBaseDir(final RequiredParams params, final Properties inputProps) throw * @param baseDir RUNDECK base directory */ void testBaseFiles(final File baseDir) { - final File etcDir = new File(baseDir, "etc"); + final File etcDir = new File(Constants.getFrameworkConfigDir(baseDir.getAbsolutePath())); reporter.beginCheckOnDirectory(etcDir); final String[] requiredFiles = new String[]{ "framework.properties", @@ -254,7 +254,7 @@ void testEtcDepotProperties(final File baseDir, final Properties inputProps) thr void testEtcLog4jProperties(final File baseDir, final Properties inputProps) throws CheckException { - final File file = new File(baseDir, "etc/log4j.properties"); + final File file = new File(new File(Constants.getFrameworkConfigDir(baseDir.getAbsolutePath())), "log4j.properties"); final Properties expectedProps = new Properties(); /* @@ -356,7 +356,7 @@ void testEtcNodeProperties(final File baseDir, final Properties inputProps) thro */ void testEtcFrameworkProperties(final File baseDir, final RequiredParams params, final Properties inputProps) throws CheckException { - final File file = new File(baseDir, "etc/framework.properties"); + final File file = new File(new File(Constants.getFrameworkConfigDir(baseDir.getAbsolutePath())), "framework.properties"); final Collection requiredExistProperties = new ArrayList(); diff --git a/core/src/java/com/dtolabs/rundeck/core/Constants.java b/core/src/java/com/dtolabs/rundeck/core/Constants.java index 456841b4ea1..b1dc5052b6d 100644 --- a/core/src/java/com/dtolabs/rundeck/core/Constants.java +++ b/core/src/java/com/dtolabs/rundeck/core/Constants.java @@ -207,7 +207,7 @@ public static final String getSystemBaseDir(){ * @param rdeck_base Ctl Base directory */ public static final String getFrameworkConfigDir(final String rdeck_base) { - return rdeck_base + FILE_SEP + "etc"; + return System.getProperty("rdeck.config", rdeck_base + FILE_SEP + "etc"); } /** diff --git a/core/src/java/com/dtolabs/rundeck/core/authorization/providers/SAREAuthorization.java b/core/src/java/com/dtolabs/rundeck/core/authorization/providers/SAREAuthorization.java index f5e8caf7a04..185908bef62 100644 --- a/core/src/java/com/dtolabs/rundeck/core/authorization/providers/SAREAuthorization.java +++ b/core/src/java/com/dtolabs/rundeck/core/authorization/providers/SAREAuthorization.java @@ -151,6 +151,7 @@ public Decision evaluate(Map resource, Subject subject, decision.explain().describe(pw); sb.append(out.toString()); + System.err.println(sb.toString()); logger.info(sb.toString()); return decision; diff --git a/core/src/java/com/dtolabs/rundeck/core/common/Framework.java b/core/src/java/com/dtolabs/rundeck/core/common/Framework.java index a4043f19060..1fbd4fcc2f5 100644 --- a/core/src/java/com/dtolabs/rundeck/core/common/Framework.java +++ b/core/src/java/com/dtolabs/rundeck/core/common/Framework.java @@ -105,9 +105,10 @@ public void initialize() { authenticationMgr = AuthenticationMgrFactory.create(lookup.getProperty(AUTHENT_CLS_PROP), this) .getAuthenticationMgr(); } + System.err.println("Using " + getConfigDir()); if(null==authorizationMgr){ authorizationMgr = AuthorizationMgrFactory.create(lookup.getProperty(AUTHORIZE_CLS_PROP), - this, new File(getBaseDir(), "etc")).getAuthorizationMgr(); + this, getConfigDir()).getAuthorizationMgr(); } if(null==centralDispatcherMgr){ try { @@ -593,7 +594,7 @@ public Collection filterNodes(final NodeSet nodeset, final String pr } public File getConfigDir() { - return new File(getBaseDir(), "etc"); + return new File(Constants.getFrameworkConfigDir(getBaseDir().getAbsolutePath())); } diff --git a/rundeckapp/grails-app/conf/BootStrap.groovy b/rundeckapp/grails-app/conf/BootStrap.groovy index 4bd8149270a..5741c17174d 100644 --- a/rundeckapp/grails-app/conf/BootStrap.groovy +++ b/rundeckapp/grails-app/conf/BootStrap.groovy @@ -1,3 +1,4 @@ +import com.dtolabs.rundeck.core.Constants; import com.dtolabs.rundeck.core.utils.ThreadBoundOutputStream import org.springframework.web.context.support.WebApplicationContextUtils import org.springframework.web.context.WebApplicationContext @@ -74,8 +75,8 @@ class BootStrap { setup.performSetup() log.info("Rundeck initialization complete.") } - - File f = new File(rdeckBase, "etc/framework.properties") + def configDir = Constants.getFrameworkConfigDir(rdeckBase) + File f = new File(configDir, "framework.properties") if (! f.exists()) { throw new RuntimeException("framework configuration file not found: " + f.getAbsolutePath()) } diff --git a/rundeckapp/grails-app/services/FrameworkService.groovy b/rundeckapp/grails-app/services/FrameworkService.groovy index 7015af961cf..3b046a4da3c 100644 --- a/rundeckapp/grails-app/services/FrameworkService.groovy +++ b/rundeckapp/grails-app/services/FrameworkService.groovy @@ -6,6 +6,8 @@ import org.springframework.beans.BeansException import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware +import com.dtolabs.rundeck.core.Constants + /** * Interfaces with the core Framework object */ @@ -94,7 +96,7 @@ class FrameworkService implements ApplicationContextAware { log.warn("rdeck.base is: ${rundeckbase}") //determine list of possible acl roles - List l = BaseAclsAuthorization.listRoles(new File(rundeckbase, "etc")) + List l = BaseAclsAuthorization.listRoles(new File(Constants.getFrameworkConfigDir(rundeckbase))) List rolelist = getUserRoleList(request,l) session.roles=rolelist @@ -112,7 +114,7 @@ class FrameworkService implements ApplicationContextAware { def Framework fw = Framework.getInstance(rundeckbase) if(null!=user && null != rolelist){ def authen = new SingleUserAuthentication(user,"") - def author = new SingleUserAclsAuthorization(fw,new File(rundeckbase, "etc"), user, rolelist.toArray(new String[0])) + def author = new SingleUserAclsAuthorization(fw,new File(Constants.getFrameworkConfigDir(rundeckbase)), user, rolelist.toArray(new String[0])) fw.setAuthenticationMgr(authen) fw.setAuthorizationMgr(author) }