[java-identity-provider] branch main updated: Guard file replacement if preserved file exists.

Scott Cantor cantor.2 at osu.edu
Mon Sep 14 19:21:25 UTC 2020


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=e825d40bc5da32d77ecbf0a5a6a3c319127fc96d

The following commit(s) were added to refs/heads/main by this push:
       new  e825d40bc Guard file replacement if preserved file exists.
e825d40bc is described below

commit e825d40bc5da32d77ecbf0a5a6a3c319127fc96d
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Sep 14 15:21:18 2020 -0400

    Guard file replacement if preserved file exists.
---
 .../src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
index 5c1ddef0f..b38d80b23 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
@@ -371,8 +371,11 @@ public abstract class AbstractIdPModule implements IdPModule {
                 if (hasChanged) {
                     if (isReplace()) {
                         destPath = moduleContext.getIdPHome().resolve(destination);
-                        Files.copy(destPath, destPath.resolveSibling(destPath.getFileName() + ".idpsave"),
-                                StandardCopyOption.REPLACE_EXISTING);
+                        final Path savedPath = destPath.resolveSibling(destPath.getFileName() + ".idpsave");
+                        if (savedPath.toFile().exists()) {
+                            throw new IOException(savedPath + " exists, aborting");
+                        }
+                        Files.copy(destPath, savedPath, StandardCopyOption.REPLACE_EXISTING);
                         log.debug("Module {} preserved {}", getId(), destPath);
                         result = ResourceResult.REPLACED;
                     } else {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list