Set Setpgid on child git processes (#19865) (#19881)

This commit is contained in:
zeripath 2022-06-04 04:39:15 +01:00 committed by GitHub
parent daf14b275a
commit 736b7b25a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 4 deletions

View file

@ -24,6 +24,7 @@ import (
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
@ -100,6 +101,8 @@ func sessionHandler(session ssh.Session) {
}
defer stdin.Close()
process.SetSysProcAttribute(cmd)
wg := &sync.WaitGroup{}
wg.Add(2)
@ -330,7 +333,7 @@ func GenKeyPair(keyPath string) error {
}
privateKeyPEM := &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(privateKey)}
f, err := os.OpenFile(keyPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
f, err := os.OpenFile(keyPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil {
return err
}
@ -351,7 +354,7 @@ func GenKeyPair(keyPath string) error {
}
public := gossh.MarshalAuthorizedKey(pub)
p, err := os.OpenFile(keyPath+".pub", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
p, err := os.OpenFile(keyPath+".pub", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil {
return err
}