mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-11 16:32:50 +00:00
Add a framework for easily and securely using remote control from the main function of a custom kitten
This commit is contained in:
parent
4bb0d3dbfb
commit
af83d855de
10 changed files with 219 additions and 29 deletions
|
|
@ -326,6 +326,17 @@ func get_password(password string, password_file string, password_env string, us
|
|||
ttyf.Close()
|
||||
}
|
||||
}
|
||||
} else if strings.HasPrefix(password_file, "fd:") {
|
||||
var fd int
|
||||
if fd, err = strconv.Atoi(password_file[3:]); err == nil {
|
||||
f := os.NewFile(uintptr(fd), password_file)
|
||||
var q []byte
|
||||
if q, err = io.ReadAll(f); err == nil {
|
||||
ans.is_set = true
|
||||
ans.val = string(q)
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
} else {
|
||||
var q []byte
|
||||
q, err = os.ReadFile(password_file)
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ func do_socket_io(io_data *rc_io_data) (serialized_response []byte, err error) {
|
|||
f := os.NewFile(uintptr(fd), "fd:"+global_options.to_address)
|
||||
conn, err = net.FileConn(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Failed to open a socket for the remote control file descriptor: %d with error: %w", fd, err)
|
||||
}
|
||||
defer f.Close()
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue