|
|
|
@ -74,29 +74,33 @@ func In(b string, sl map[string]int) bool {
|
|
|
|
|
func runServ(k *cli.Context) {
|
|
|
|
|
execDir, _ := base.ExecDir()
|
|
|
|
|
newLogger(execDir)
|
|
|
|
|
log.Trace("new serv request " + log.Mode + ":" + log.Config)
|
|
|
|
|
|
|
|
|
|
base.NewConfigContext()
|
|
|
|
|
models.LoadModelsConfig()
|
|
|
|
|
|
|
|
|
|
if models.UseSQLite3 {
|
|
|
|
|
os.Chdir(execDir)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
models.SetEngine()
|
|
|
|
|
|
|
|
|
|
keys := strings.Split(os.Args[2], "-")
|
|
|
|
|
if len(keys) != 2 {
|
|
|
|
|
fmt.Println("auth file format error")
|
|
|
|
|
println("auth file format error")
|
|
|
|
|
log.Error("auth file format error")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keyId, err := strconv.ParseInt(keys[1], 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println("auth file format error")
|
|
|
|
|
println("auth file format error")
|
|
|
|
|
log.Error("auth file format error", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
user, err := models.GetUserByKeyId(keyId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println("You have no right to access")
|
|
|
|
|
log.Error("SSH visit error", err)
|
|
|
|
|
println("You have no right to access")
|
|
|
|
|
log.Error("SSH visit error: %v", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -133,13 +137,12 @@ func runServ(k *cli.Context) {
|
|
|
|
|
// access check
|
|
|
|
|
switch {
|
|
|
|
|
case isWrite:
|
|
|
|
|
has, err := models.HasAccess(user.Name, strings.ToLower(path.Join(repoUserName, repoName)), models.AU_WRITABLE)
|
|
|
|
|
has, err := models.HasAccess(user.LowerName, path.Join(repoUserName, repoName), models.AU_WRITABLE)
|
|
|
|
|
if err != nil {
|
|
|
|
|
println("Inernel error:", err)
|
|
|
|
|
log.Error(err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if !has {
|
|
|
|
|
} else if !has {
|
|
|
|
|
println("You have no right to write this repository")
|
|
|
|
|
log.Error("User %s has no right to write repository %s", user.Name, repoPath)
|
|
|
|
|
return
|
|
|
|
|