Skip to content

Commit

Permalink
fix: when settings files not set, don't chmod, for ddev#5675
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Feb 2, 2024
1 parent c9d8f54 commit 2d498a4
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions pkg/ddevapp/apptypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,27 +253,29 @@ func (app *DdevApp) CreateSettingsFile() (string, error) {
// Drupal and WordPress love to change settings files to be unwriteable.
// Chmod them to something we can work with in the event that they already
// exist.
chmodTargets := []string{filepath.Dir(app.SiteSettingsPath), app.SiteDdevSettingsFile}
for _, fp := range chmodTargets {
fileInfo, err := os.Stat(fp)
if err != nil {
// We're not doing anything about this error other than warning,
// and will have to deal with the same check in settingsCreator.
if !os.IsNotExist(err) {
util.Warning("Unable to ensure write permissions: %v", err)
if app.SiteSettingsPath != "" {
chmodTargets := []string{filepath.Dir(app.SiteSettingsPath), app.SiteDdevSettingsFile}
for _, fp := range chmodTargets {
fileInfo, err := os.Stat(fp)
if err != nil {
// We're not doing anything about this error other than warning,
// and will have to deal with the same check in settingsCreator.
if !os.IsNotExist(err) {
util.Warning("Unable to ensure write permissions: %v", err)
}

continue
}

continue
}

perms := 0644
if fileInfo.IsDir() {
perms = 0755
}
perms := 0644
if fileInfo.IsDir() {
perms = 0755
}

err = os.Chmod(fp, os.FileMode(perms))
if err != nil {
return "", fmt.Errorf("could not change permissions on file %s to make it writeable: %v", fp, err)
err = os.Chmod(fp, os.FileMode(perms))
if err != nil {
return "", fmt.Errorf("could not change permissions on file %s to make it writeable: %v", fp, err)
}
}
}

Expand Down

0 comments on commit 2d498a4

Please sign in to comment.