Merge pull request #7844 from dokku/7308-ignore-symlinks

Do not change permissions on config directory symlinks
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2025-08-12 16:36:59 -04:00
commit 64f4314df3
2 files changed
+22 -6

No files matched your search

+11
View File
@@ -108,6 +108,17 @@ func IsAbsPath(path string) bool {
return strings.HasPrefix(path, "/") return strings.HasPrefix(path, "/")
} }
// IsSymlink returns true if the path is a symlink
// if lstat fails, it returns false
func IsSymlink(path string) bool {
info, err := os.Lstat(path)
if err != nil {
return false
}
return info.Mode()&os.ModeSymlink == os.ModeSymlink
}
// ListFilesWithPrefix lists files within a given path that have a given prefix // ListFilesWithPrefix lists files within a given path that have a given prefix
func ListFilesWithPrefix(path string, prefix string) []string { func ListFilesWithPrefix(path string, prefix string) []string {
names, err := os.ReadDir(path) names, err := os.ReadDir(path)
+11 -6
View File
@@ -516,19 +516,24 @@ func PropertyWrite(pluginName string, appName string, property string, value str
// PropertySetup creates the plugin config root // PropertySetup creates the plugin config root
func PropertySetup(pluginName string) error { func PropertySetup(pluginName string) error {
configRoot := filepath.Join(MustGetEnv("DOKKU_LIB_ROOT"), "config")
pluginConfigRoot := getPluginConfigPath(pluginName) pluginConfigRoot := getPluginConfigPath(pluginName)
if err := os.MkdirAll(pluginConfigRoot, 0755); err != nil { if err := os.MkdirAll(pluginConfigRoot, 0755); err != nil {
return err return err
} }
input := SetPermissionInput{ // check if configRoot is a symlink
Filename: filepath.Join(MustGetEnv("DOKKU_LIB_ROOT"), "config"), if !IsSymlink(configRoot) {
Mode: os.FileMode(0755), input := SetPermissionInput{
Filename: configRoot,
Mode: os.FileMode(0755),
}
if err := SetPermissions(input); err != nil {
return err
}
} }
if err := SetPermissions(input); err != nil {
return err
}
return SetPermissions(SetPermissionInput{ return SetPermissions(SetPermissionInput{
Filename: pluginConfigRoot, Filename: pluginConfigRoot,
Mode: os.FileMode(0755), Mode: os.FileMode(0755),