[java-identity-provider] branch main updated: IDP-2144 - Upgrade to 5.0 snapshot failing

Scott Cantor cantor.2 at osu.edu
Thu Jul 20 12:39:58 UTC 2023


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=7a38e3ea3a77f0e16e98465ad9e42474e3299297

The following commit(s) were added to refs/heads/main by this push:
     new 7a38e3ea3 IDP-2144 - Upgrade to 5.0 snapshot failing
7a38e3ea3 is described below

commit 7a38e3ea3a77f0e16e98465ad9e42474e3299297
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jul 20 08:39:21 2023 -0400

    IDP-2144 - Upgrade to 5.0 snapshot failing
    
    https://shibboleth.atlassian.net/browse/IDP-2144
    
    Protect against symlinks when auto-creating folders.
---
 .../net/shibboleth/idp/module/core/impl/Core.java  | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/idp-conf-impl/src/main/java/net/shibboleth/idp/module/core/impl/Core.java b/idp-conf-impl/src/main/java/net/shibboleth/idp/module/core/impl/Core.java
index a3abad571..b9074e996 100644
--- a/idp-conf-impl/src/main/java/net/shibboleth/idp/module/core/impl/Core.java
+++ b/idp-conf-impl/src/main/java/net/shibboleth/idp/module/core/impl/Core.java
@@ -17,7 +17,6 @@
 
 package net.shibboleth.idp.module.core.impl;
 
-import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -36,10 +35,14 @@ import net.shibboleth.profile.module.ModuleException;
  * {@link IdPModule} implementation.
  * 
  * <p>This is a somewhat special module as it represents the "core" software
- * being installed or upgraded so has some different characteristics and methods.
+ * being installed or upgraded so has some different characteristics and methods.</p>
  */
 public final class Core extends CoreIdPModule {
 
+    /** Auto-created folders. */
+    @Nonnull private static final String[] AUTO_CREATED =
+        { "conf", "credentials", "metadata", "flows", "messages", "views" }; 
+    
     /**
      * Constructor.
      *  
@@ -65,12 +68,17 @@ public final class Core extends CoreIdPModule {
         try {
             if (!moduleContext.getInstallLocation().startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
                 final Path home = Path.of(moduleContext.getInstallLocation());
-                Files.createDirectories(home.resolve("conf"));
-                Files.createDirectories(home.resolve("credentials"));
-                Files.createDirectories(home.resolve("metadata"));
-                Files.createDirectories(home.resolve("flows"));
-                Files.createDirectories(home.resolve("messages"));
-                Files.createDirectories(home.resolve("views"));
+                
+                // This should follow symlinks before trying to create the folders. 
+                for (final String folder : AUTO_CREATED) {
+                    final Path resolved = home.resolve(folder);
+                    if (!Files.exists(resolved)) {
+                        Files.createDirectories(resolved);
+                    } else if (!Files.isDirectory(resolved)) {
+                        throw new IOException("Folder '" + folder + "' exists, but is not a directory.");
+                    }
+                }
+                
                 // Tidy up files we no longer need in V5
                 Path antFile = home.resolve("bin").resolve("build.xml");
                 if (Files.exists(antFile)) {
@@ -99,5 +107,4 @@ public final class Core extends CoreIdPModule {
         throw new ModuleException("This module cannot be disabled.");
     }
 
-    
 }
\ No newline at end of file

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


More information about the commits mailing list