Fix data dir creation permissions (#1503)

This commit is contained in:
Viktor Liu 2024-01-29 14:21:45 +01:00 committed by GitHub
parent c41504b571
commit 25b3641be8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -1,10 +1,11 @@
package encryption package encryption
import ( import (
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/acme/autocert"
"os" "os"
"path/filepath" "path/filepath"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/acme/autocert"
) )
// CreateCertManager wraps common logic of generating Let's encrypt certificate. // CreateCertManager wraps common logic of generating Let's encrypt certificate.
@ -12,7 +13,7 @@ func CreateCertManager(datadir string, letsencryptDomain string) (*autocert.Mana
certDir := filepath.Join(datadir, "letsencrypt") certDir := filepath.Join(datadir, "letsencrypt")
if _, err := os.Stat(certDir); os.IsNotExist(err) { if _, err := os.Stat(certDir); os.IsNotExist(err) {
err = os.MkdirAll(certDir, os.ModeDir) err = os.MkdirAll(certDir, 0755)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"github.com/netbirdio/management-integrations/integrations"
"io" "io"
"io/fs" "io/fs"
"net" "net"
@ -18,6 +17,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/netbirdio/management-integrations/integrations"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/miekg/dns" "github.com/miekg/dns"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -115,7 +116,7 @@ var (
} }
if _, err = os.Stat(config.Datadir); os.IsNotExist(err) { if _, err = os.Stat(config.Datadir); os.IsNotExist(err) {
err = os.MkdirAll(config.Datadir, os.ModeDir) err = os.MkdirAll(config.Datadir, 0755)
if err != nil { if err != nil {
return fmt.Errorf("failed creating datadir: %s: %v", config.Datadir, err) return fmt.Errorf("failed creating datadir: %s: %v", config.Datadir, err)
} }