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
import (
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/acme/autocert"
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/acme/autocert"
)
// 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")
if _, err := os.Stat(certDir); os.IsNotExist(err) {
err = os.MkdirAll(certDir, os.ModeDir)
err = os.MkdirAll(certDir, 0755)
if err != nil {
return nil, err
}

View File

@ -7,7 +7,6 @@ import (
"errors"
"flag"
"fmt"
"github.com/netbirdio/management-integrations/integrations"
"io"
"io/fs"
"net"
@ -18,6 +17,8 @@ import (
"strings"
"time"
"github.com/netbirdio/management-integrations/integrations"
"github.com/google/uuid"
"github.com/miekg/dns"
log "github.com/sirupsen/logrus"
@ -115,7 +116,7 @@ var (
}
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 {
return fmt.Errorf("failed creating datadir: %s: %v", config.Datadir, err)
}