Skip to content

Commit

Permalink
Fix data dir creation permissions (netbirdio#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixmal authored Jan 29, 2024
1 parent 97d1516 commit f6ffc31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions encryption/letsencrypt.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
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.
func CreateCertManager(datadir string, letsencryptDomain string) (*autocert.Manager, error) {
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
}
Expand Down
5 changes: 3 additions & 2 deletions management/cmd/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"flag"
"fmt"
"github.com/netbirdio/management-integrations/integrations"
"io"
"io/fs"
"net"
Expand All @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit f6ffc31

Please sign in to comment.