summaryrefslogtreecommitdiffstats
path: root/pki/base/java-tools
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/java-tools')
-rw-r--r--pki/base/java-tools/build.xml6
-rw-r--r--pki/base/java-tools/src/com/netscape/cmstools/PasswordCache.java49
2 files changed, 43 insertions, 12 deletions
diff --git a/pki/base/java-tools/build.xml b/pki/base/java-tools/build.xml
index 79dba975c..cb2ac2d21 100644
--- a/pki/base/java-tools/build.xml
+++ b/pki/base/java-tools/build.xml
@@ -38,6 +38,10 @@
<pathelement location="${cms.jar}"/>
<pathelement location="${certsrv.jar}"/>
</path>
+ <path id="javadoc_classpath">
+ <path refid="classpath"/>
+ <pathelement location="./build/classes"/>
+ </path>
<target name="clean"
@@ -149,7 +153,7 @@
version="true"
use="true"
windowtitle="${ant.project.name}"
- classpathref="classpath"
+ classpathref="javadoc_classpath"
verbose="false">
<doctitle>
<![CDATA[<h1>${ant.project.name}</h1>]]>
diff --git a/pki/base/java-tools/src/com/netscape/cmstools/PasswordCache.java b/pki/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
index 388fedcd8..2031337de 100644
--- a/pki/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
+++ b/pki/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
@@ -612,28 +612,55 @@ class PWsdrCache {
if (tmpPWcache.exists()) {
// it wasn't removed?
tmpPWcache.delete();
- tmpPWcache = new File(mPWcachedb + ".tmp");
}
FileOutputStream outstream = new FileOutputStream(mPWcachedb + ".tmp");
outstream.write(writebuf);
outstream.close();
+ // Make certain that this temporary file has
+ // the correct permissions.
+ if( !isNT() ) {
+ exec( "chmod 00660 " + tmpPWcache.getAbsolutePath() );
+ }
+
File origFile = new File(mPWcachedb);
try {
- if (tmpPWcache.renameTo(origFile) == true) {
- debug("operation completed for " + mPWcachedb);
+ // Always remove any pre-existing target file
+ if( origFile.exists() ) {
+ origFile.delete();
+ }
+
+ if (isNT()) {
+ // NT is very picky on the path
+ exec("copy " +
+ tmpPWcache.getAbsolutePath().replace('/', '\\') + " " +
+ origFile.getAbsolutePath().replace('/', '\\'));
} else {
- if (isNT()) {
- // NT is very picky on the path
- exec("copy " +
- tmpPWcache.getAbsolutePath().replace('/', '\\') + " " +
- origFile.getAbsolutePath().replace('/', '\\'));
- } else {
- exec("cp " + tmpPWcache.getAbsolutePath() + " " +
- origFile.getAbsolutePath());
+ // Create a copy of the temporary file which
+ // preserves the temporary file's permissions.
+ exec("cp -p " + tmpPWcache.getAbsolutePath() + " " +
+ origFile.getAbsolutePath());
+ }
+
+ // Remove the temporary file if and only if
+ // the "rename" was successful.
+ if( origFile.exists() ) {
+ tmpPWcache.delete();
+
+ // Make certain that the final file has
+ // the correct permissions.
+ if( !isNT() ) {
+ exec( "chmod 00660 " + origFile.getAbsolutePath() );
}
+
+ // report success
+ debug( "Renaming operation completed for " + mPWcachedb );
+ } else {
+ // report failure and exit
+ debug( "Renaming operation failed for " + mPWcachedb );
+ System.exit(1);
}
} catch (IOException exx) {
System.out.println("sdrPWcache: Error " + exx.toString());