os

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUserExist

func IsUserExist(user string) (pass string, exists bool)

func LoadGroups

func LoadGroups(groupFile string) error

func LoadUsers

func LoadUsers(userFile string) error

func RegisterCommand

func RegisterCommand(name string, cmd Command)

RegisterCommand puts the command implementation into map so it can be invoked from command line

func RegisterCommandOutput added in v0.6.0

func RegisterCommandOutput(cmd, pathToOutput string)

RegisterCommandOutput gets the file content and associate it with the command provided. So that once triggered in console the content will be displayed

func RegisterFakeCommand

func RegisterFakeCommand(cmdList []string)

RegisterFakeCommand put commands into register so that when typed in terminal they will print out SegFault

Types

type Command

type Command interface {
	GetHelp() string
	Exec(args []string, sys Sys) int
	Where() string
}

Command interface allow classes to simulate real executable that have access to standard I/O, filesystem, arguments, EnvVars, and cwd

type Group

type Group struct {
	GID      int
	Name     string
	Userlist []string
}

func GetGroupByID

func GetGroupByID(id int) Group

type Shell

type Shell struct {
	DelayFunc func()
	// contains filtered or unexported fields
}

func NewShell

func NewShell(sys *System, ipSrc string, log *log.Entry, termSignal chan<- int) *Shell

func (*Shell) ExecCmd added in v0.5.0

func (sh *Shell) ExecCmd(cmd string, tLog termlogger.StdIOErr)

func (*Shell) HandleRequest

func (sh *Shell) HandleRequest(hook termlogger.LogHook)

func (*Shell) SetSize

func (sh *Shell) SetSize(width, height int) error

type Sys

type Sys interface {
	Getcwd() string
	Chdir(path string) error
	In() io.Reader
	Out() io.Writer
	Err() io.Writer
	Environ() (env []string)
	SetEnv(key, value string) error
	FSys() afero.Fs
	Width() int
	Height() int
	CurrentUser() int
	CurrentGroup() int
	Hostname() string
}

type System

type System struct {
	// contains filtered or unexported fields
}

System provides what most of os/sys does in the honeyport

func NewSystem

func NewSystem(user, host string, fs afero.Fs, channel ssh.Channel, width, height int, log *log.Entry) *System

NewSystem initializer a system object containing current user context: ID, home directory, terminal dimensions, etc.

func (*System) Chdir

func (sys *System) Chdir(path string) error

Chdir change current working directory

func (*System) CurrentGroup

func (sys *System) CurrentGroup() int

func (*System) CurrentUser

func (sys *System) CurrentUser() int

func (*System) Environ

func (sys *System) Environ() (env []string)

func (*System) Err

func (sys *System) Err() io.Writer

func (*System) Exec

func (sys *System) Exec(path string, args []string) (int, error)

func (*System) FSys

func (sys *System) FSys() afero.Fs

func (*System) Getcwd

func (sys *System) Getcwd() string

Getcwd gets current working directory

func (*System) Height

func (sys *System) Height() int

func (*System) Hostname

func (sys *System) Hostname() string

func (*System) IOStream

func (sys *System) IOStream() io.ReadWriter

func (*System) In

func (sys *System) In() io.Reader

In returns a io.Reader that represent stdin

func (*System) Out

func (sys *System) Out() io.Writer

Out returns a io.Writer that represent stdout

func (*System) SetEnv

func (sys *System) SetEnv(key, value string) error

func (*System) Width

func (sys *System) Width() int

type User

type User struct {
	UID      int
	GID      int
	Name     string
	Password string
	Homedir  string
	Info     string
	Shell    string
}

func CreateUser

func CreateUser(name, password string) (newUser User, e error)

func GetUser

func GetUser(name string) User

func GetUserByID

func GetUserByID(id int) User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL