From 256910bab271b77caec1abb4b49932074c530501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 5 Dec 2021 18:45:30 +0100 Subject: [PATCH] Fixed setting file modes when forcing updates --- buildcert.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/buildcert.go b/buildcert.go index a4398e6..d352ec2 100644 --- a/buildcert.go +++ b/buildcert.go @@ -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 - log.Debug("No update to privileges") + if !update_mode { + log.Debug("No update to privileges") + } return nil } }