mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
CORDA-2914: Allow certificate directory to be a symlink (#5102)
This commit is contained in:
parent
88894bc592
commit
44835bd17c
@ -194,3 +194,12 @@ inline fun <reified T : Any> Path.readObject(): T = readAll().deserialize()
|
||||
|
||||
/** Calculate the hash of the contents of this file. */
|
||||
inline val Path.hash: SecureHash get() = read { it.hash() }
|
||||
|
||||
/* Check if the Path is symbolic link */
|
||||
fun Path.safeSymbolicRead(): Path {
|
||||
if (Files.isSymbolicLink(this)) {
|
||||
return (Files.readSymbolicLink(this))
|
||||
} else {
|
||||
return (this)
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,11 @@ import net.corda.core.internal.createDirectories
|
||||
import net.corda.core.internal.exists
|
||||
import net.corda.core.internal.read
|
||||
import net.corda.core.internal.write
|
||||
import net.corda.core.internal.safeSymbolicRead
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Files
|
||||
import java.security.*
|
||||
import java.security.cert.Certificate
|
||||
import java.security.cert.X509Certificate
|
||||
@ -30,7 +32,7 @@ fun loadOrCreateKeyStore(keyStoreFilePath: Path, storePassword: String): KeyStor
|
||||
keyStoreFilePath.read { keyStore.load(it, pass) }
|
||||
} else {
|
||||
keyStore.load(null, pass)
|
||||
keyStoreFilePath.toAbsolutePath().parent?.createDirectories()
|
||||
keyStoreFilePath.toAbsolutePath().parent?.safeSymbolicRead()?.createDirectories()
|
||||
keyStoreFilePath.write { keyStore.store(it, pass) }
|
||||
}
|
||||
return keyStore
|
||||
|
@ -12,6 +12,7 @@ import net.corda.core.internal.*
|
||||
import net.corda.core.internal.concurrent.thenMatch
|
||||
import net.corda.core.internal.cordapp.CordappImpl
|
||||
import net.corda.core.internal.errors.AddressBindingException
|
||||
import net.corda.core.internal.safeSymbolicRead
|
||||
import net.corda.core.utilities.Try
|
||||
import net.corda.core.utilities.contextLogger
|
||||
import net.corda.core.utilities.loggerFor
|
||||
@ -487,11 +488,7 @@ fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean {
|
||||
//Test for access to the logging path and shutdown if we are unable to reach it.
|
||||
val logPath = baseDirectory / NodeCliCommand.LOGS_DIRECTORY_NAME
|
||||
try {
|
||||
if (Files.isSymbolicLink(logPath)){
|
||||
Files.readSymbolicLink(logPath).createDirectories()
|
||||
} else {
|
||||
logPath.createDirectories()
|
||||
}
|
||||
logPath.safeSymbolicRead()?.createDirectories()
|
||||
} catch (e: IOException) {
|
||||
printError("Unable to create logging directory ${logPath.toString()}. Node will now shutdown.")
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user