From aa9e12e21be7146b317112a12f8186756c4969df Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 22 Jun 2009 12:05:11 +0000
Subject: [PATCH] Do a best effort and try to retrieve the canonical path of the instance and install paths when they are calculated. This is harmless and avoids having relative paths ('../.' and '/.') in the data in cn=monitor.
---
opends/src/server/org/opends/server/extensions/ConfigFileHandler.java | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
index 711145c..2a200a3 100644
--- a/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.extensions;
@@ -690,7 +690,19 @@
if ((configDirFile != null) &&
configDirFile.getName().equals(CONFIG_DIR_NAME))
{
- serverRoot = configDirFile.getParentFile().getAbsolutePath();
+ /*
+ * Do a best effort to avoid having a relative representation (for
+ * instance to avoid having ../../../).
+ */
+ try
+ {
+ serverRoot = configDirFile.getParentFile().getCanonicalPath();
+ }
+ catch (IOException ioe)
+ {
+ // Best effort
+ serverRoot = configDirFile.getParentFile().getAbsolutePath();
+ }
}
if (serverRoot == null)
@@ -739,7 +751,19 @@
}
else
{
- instanceRoot = instanceFile.getAbsolutePath();
+ /*
+ * Do a best effort to avoid having a relative representation (for
+ * instance to avoid having ../../../).
+ */
+ try
+ {
+ instanceRoot = instanceFile.getCanonicalPath();
+ }
+ catch (IOException ioe)
+ {
+ // Best effort
+ instanceRoot = instanceFile.getAbsolutePath();
+ }
}
--
Gitblit v1.10.0