1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shaoying 2019-07-27 09:26:38 +08:00
parent 28493d4ba5
commit c0c9f26fe2
5 changed files with 502 additions and 598 deletions

View File

@ -9,6 +9,8 @@ ctx_bin=${ctx_app} && [ -f bin/${ctx_app} ] && ctx_bin=$(pwd)/bin/${ctx_app}
ctx_dev=${ctx_dev:="https://shylinux.com"} ctx_dev=${ctx_dev:="https://shylinux.com"}
ctx_root=${ctx_root:=/usr/local/context} ctx_root=${ctx_root:=/usr/local/context}
ctx_home=${ctx_home:=~/context} ctx_home=${ctx_home:=~/context}
# node_cert=
# node_key=
# web_port= # web_port=
# ssh_port= # ssh_port=
# HOSTNAME= # HOSTNAME=

File diff suppressed because it is too large Load Diff

View File

@ -4,5 +4,5 @@ var version = struct {
host string host string
self int self int
}{ }{
"2019-07-27 05:58:32", "com", 218, "2019-07-27 06:00:22", "mac", 219,
} }

View File

@ -1070,22 +1070,21 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
return return
}}, }},
"_exec": &ctx.Command{Name: "_exec", Help: "命令", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { "_exec": &ctx.Command{Name: "_exec", Help: "命令", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
access := kit.Hashs( access := m.Option("access", kit.Hashs(
m.Option("node.route"), m.Option("node.route"),
m.Option("user.route"), m.Option("user.route"),
m.Option("work.route"), m.Option("work.route"),
m.Option("work.name"), m.Option("work.name"),
m.Option("user.name"), m.Option("user.name"),
m.Option("text.username"), m.Option("text.username"),
) ))
if m.Option("sessid", m.Cmd("aaa.auth", "access", access, "session").Append("key")); m.Option("username", m.Cmd("aaa.sess", "user").Append("meta")) != "" { // 历史会话 if m.Option("sessid", m.Cmd("aaa.auth", "access", access, "session").Append("key")) != "" &&
m.Option("username", m.Cmd("aaa.sess", "user").Append("meta")) != "" { // 历史会话
m.Log("warn", "access: %s", access) m.Log("warn", "access: %s", access)
m.Log("info", "sessid: %s", m.Option("sessid")) m.Log("info", "sessid: %s", m.Option("sessid"))
m.Option("trust", m.Cmdx("aaa.auth", "access", access, "data", "trust")) m.Option("trust", m.Cmdx("aaa.auth", "access", access, "data", "trust"))
if m.Option("userrole", m.Cmdx("aaa.auth", "access", access, "data", "userrole")); !m.Options("userrole") { m.Option("userrole", m.Cmdx("aaa.auth", "access", access, "data", "userrole"))
m.Option("userrole", m.Cmd("aaa.user", "role").Append("meta"))
}
} else if m.Option("username", m.Option("text.username")); !m.Confs("runtime", "user.route") && m.Confs("trust", "fresh") { // 免签节点 } else if m.Option("username", m.Option("text.username")); !m.Confs("runtime", "user.route") && m.Confs("trust", "fresh") { // 免签节点
m.Log("warn", "trust fresh %s", m.Option("node.route")) m.Log("warn", "trust fresh %s", m.Option("node.route"))
@ -1116,7 +1115,10 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
return return
} }
m.Log("info", "username: %s", m.Option("username")) // 用户角色
if m.Log("info", "username: %s", m.Option("username")); !m.Options("userrole") {
m.Option("userrole", kit.Select("void", m.Cmd("aaa.user", "role").Append("meta")))
}
m.Log("info", "userrole: %s", m.Option("userrole")) m.Log("info", "userrole: %s", m.Option("userrole"))
// 创建会话 // 创建会话
@ -1127,13 +1129,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
} }
// 权限检查 // 权限检查
if arg[0] != "tool" { if !m.Cmds("aaa.role", m.Option("userrole"), "check", "remote", arg[0]) {
// 创建空间 m.Echo("no right %s %s", "remote", arg[0])
m.Option("bench", m.Cmdx("aaa.sess", "bench", "select")) return
if !m.Cmds("aaa.work", "right", "remote", arg[0]) {
m.Echo("no right %s %s", "remote", arg[0])
return
}
} }
// 执行命令 // 执行命令

View File

@ -4,7 +4,6 @@ import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io"
"math/rand" "math/rand"
"os" "os"
"path" "path"
@ -79,16 +78,6 @@ func Hash(arg ...interface{}) (string, []string) {
args = append(args, Format(time.Now())) args = append(args, Format(time.Now()))
args = append(args, Format(rand.Int())) args = append(args, Format(rand.Int()))
default: default:
if s, e := os.Stat(v); e == nil && !s.IsDir() {
if f, e := os.Open(v); e == nil {
defer f.Close()
m := md5.New()
io.Copy(m, f)
h := m.Sum(nil)
args = append(args, hex.EncodeToString(h[:]))
return hex.EncodeToString(h[:]), args
}
}
args = append(args, v) args = append(args, v)
} }
} }