From 079c2c59608310a73d7efafe2919500dcbe87353 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 7 Feb 2019 09:32:56 +0800 Subject: [PATCH] fix tests and add comment head --- modules/ssh/ssh.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index ae367cf700d9c..d9606488b21b1 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2017 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -210,7 +211,7 @@ func GenKeyPair(keyPath string) error { } privateKeyPEM := &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(privateKey)} - f, err := os.Create(keyPath) + f, err := os.OpenFile(keyPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } @@ -227,7 +228,7 @@ func GenKeyPair(keyPath string) error { } public := ssh.MarshalAuthorizedKey(pub) - p, err := os.Create(keyPath + ".pub") + p, err := os.OpenFile(keyPath+".pub", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err }