Skip to content

Commit 079c2c5

Browse files
committed
fix tests and add comment head
1 parent f008f89 commit 079c2c5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/ssh/ssh.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2014 The Gogs Authors. All rights reserved.
2+
// Copyright 2017 The Gitea Authors. All rights reserved.
23
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
45

@@ -210,7 +211,7 @@ func GenKeyPair(keyPath string) error {
210211
}
211212

212213
privateKeyPEM := &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(privateKey)}
213-
f, err := os.Create(keyPath)
214+
f, err := os.OpenFile(keyPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
214215
if err != nil {
215216
return err
216217
}
@@ -227,7 +228,7 @@ func GenKeyPair(keyPath string) error {
227228
}
228229

229230
public := ssh.MarshalAuthorizedKey(pub)
230-
p, err := os.Create(keyPath + ".pub")
231+
p, err := os.OpenFile(keyPath+".pub", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
231232
if err != nil {
232233
return err
233234
}

0 commit comments

Comments
 (0)