feat: terminal as a chosen OS user, create users from the panel (0.0.2)

- agent reports the OS user it runs as (enroll + poll header)
- per-machine terminal user on the edit page; defaults to the agent's own user (root on Linux)
- create a new user from the panel: name, password, optional sudo group
- show the reason in the terminal when a shell fails to start
- bump version to 0.0.2
This commit is contained in:
redtea committed 2026-10-13 01:28:57 +03:00
1 parent be7fbabd9e
commit 3dde07f403
18 files changed
+530 -45

No files matched your search

+19 -1
View File
@@ -27,6 +27,7 @@ type EnrollRequest struct {
OS string `json:"os"`
Arch string `json:"arch"`
Version string `json:"version"`
User string `json:"user,omitempty"` // OS user the agent runs as
}
// EnrollResponse carries the identity the agent persists and uses from then on.
@@ -41,6 +42,7 @@ type ControlMessage struct {
SessionID string `json:"session_id,omitempty"`
Port int `json:"port,omitempty"` // CtrlOpenForward: client-side port to dial
TaskID string `json:"task_id,omitempty"` // CtrlTask
User string `json:"user,omitempty"` // CtrlOpenTerminal: OS user for the shell ("" = the agent's own)
}
// Terminal / stream frame types on the session "in" channel (server -> agent).
@@ -84,7 +86,9 @@ const (
TaskFSMove = "fs.move" // move/rename
TaskFSDownload = "fs.download" // read a whole file (larger cap) for browser download
TaskSysUpdate = "sys.update" // download the latest agent binary and restart
TaskSysUpdate = "sys.update" // download the latest agent binary and restart
TaskSysUsers = "sys.users" // report the agent's user and the login-capable users
TaskSysUserAdd = "sys.useradd" // create a new OS user
)
// TaskEnvelope is what the agent fetches for a task id.
@@ -144,3 +148,17 @@ type FSReadResult struct {
Truncated bool `json:"truncated"`
Binary bool `json:"binary"`
}
// SysUsersResult is returned for TaskSysUsers.
type SysUsersResult struct {
Current string `json:"current"` // user the agent runs as
CanSwitch bool `json:"can_switch"` // agent is root, so it can open shells as (and create) other users
Users []string `json:"users"`
}
// SysUserAddArgs are the arguments of TaskSysUserAdd.
type SysUserAddArgs struct {
Name string `json:"name"`
Password string `json:"password,omitempty"` // empty leaves the account without a password
Sudo bool `json:"sudo"` // add to the sudo/wheel group
}