Skip to content

Commit

Permalink
Place temporary key files into /run/snapd
Browse files Browse the repository at this point in the history
  • Loading branch information
vosst committed Apr 11, 2017
1 parent c4f9f0e commit 8ab6db5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dirs/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
SnapMetaDir string
SnapdSocket string
SnapSocket string
SnapRunDir string
SnapRunNsDir string

SnapSeedDir string
Expand Down Expand Up @@ -134,7 +135,8 @@ func SetRootDir(rootdir string) {
SnapMetaDir = filepath.Join(rootdir, snappyDir, "meta")
SnapBlobDir = filepath.Join(rootdir, snappyDir, "snaps")
SnapDesktopFilesDir = filepath.Join(rootdir, snappyDir, "desktop", "applications")
SnapRunNsDir = filepath.Join(rootdir, "/run/snapd/ns")
SnapRunDir = filepath.Join(rootdir, "/run/snapd")
SnapRunNsDir = filepath.Join(SnapRunDir, "/ns")

// keep in sync with the debian/snapd.socket file:
SnapdSocket = filepath.Join(rootdir, "/run/snapd.socket")
Expand Down
2 changes: 2 additions & 0 deletions overlord/devicestate/devicestate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -129,6 +130,7 @@ func (sto *fakeStore) Sections(*auth.UserState) ([]string, error) {

func (s *deviceMgrSuite) SetUpTest(c *C) {
dirs.SetRootDir(c.MkDir())
os.MkdirAll(dirs.SnapRunDir, 0755)

s.restoreOnClassic = release.MockOnClassic(false)

Expand Down
10 changes: 5 additions & 5 deletions overlord/devicestate/generate_rsa_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strconv"

"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/osutil"
)

var (
sshKeyFile = "snapd.key.tmp"
sshPublicKeyFile = sshKeyFile + ".pub"
)

func generateRSAKey(keyLength int) (*rsa.PrivateKey, error) {
sshKeyFile := filepath.Join(dirs.SnapRunDir, "snapd.key.tmp")
sshPublicKeyFile := sshKeyFile + ".pub"

defer func() {
os.Remove(sshKeyFile)
os.Remove(sshPublicKeyFile)
Expand Down

0 comments on commit 8ab6db5

Please sign in to comment.