Fixed setting file modes when forcing updates

This commit is contained in:
Emmanuel BENOîT 2021-12-05 18:45:30 +01:00
parent 069b64672c
commit 256910bab2

View file

@ -152,8 +152,9 @@ func (b *tCertificateBuilder) WriteFile() error {
// Update the file's owner and group
func (b *tCertificateBuilder) UpdatePrivileges() error {
update_mode := !b.changed && b.existing.mode != b.Config.FileMode()
update_mode := b.existing != nil && b.existing.mode != b.Config.FileMode()
if update_mode {
log.WithField("mode", b.Config.FileMode).Info("Updating file mode")
err := os.Chmod(b.Config.Path, b.Config.FileMode())
if err != nil {
return err
@ -193,7 +194,9 @@ func (b *tCertificateBuilder) UpdatePrivileges() error {
return err
} else {
b.changed = b.changed || update_mode
if !update_mode {
log.Debug("No update to privileges")
}
return nil
}
}