1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package conf
- import (
- "path/filepath"
- "strings"
- "github.com/pkg/errors"
- "gogs.io/gogs/internal/osutil"
- "gogs.io/gogs/internal/process"
- )
- func cleanUpOpenSSHVersion(raw string) string {
- v := strings.TrimRight(strings.Fields(raw)[0], ",1234567890")
- v = strings.TrimSuffix(strings.TrimPrefix(v, "OpenSSH_"), "p")
- return v
- }
- func openSSHVersion() (string, error) {
-
- _, stderr, err := process.Exec("conf.openSSHVersion", "ssh", "-V")
- if err != nil {
- return "", errors.Wrap(err, stderr)
- }
- return cleanUpOpenSSHVersion(stderr), nil
- }
- func ensureAbs(path string) string {
- if filepath.IsAbs(path) {
- return path
- }
- return filepath.Join(WorkDir(), path)
- }
- func CheckRunUser(runUser string) (string, bool) {
- if IsWindowsRuntime() {
- return "", true
- }
- currentUser := osutil.CurrentUsername()
- return currentUser, runUser == currentUser
- }
|