mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-15 21:14:35 +02:00
Add a framework for easily and securely using remote control from the main function of a custom kitten
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user