rofi  1.5.1
Collaboration diagram for SSH:

Variables

Mode ssh_mode
 
Mode ssh_mode
 
#define G_LOG_DOMAIN   "Dialogs.Ssh"
 
#define SSH_CACHE_FILE   "rofi-2.sshcache"
 
#define SSH_TOKEN_DELIM   "= \t\r\n"
 
static int execshssh (const char *host)
 
static void exec_ssh (const char *host)
 
static void delete_ssh (const char *host)
 
static char ** read_known_hosts_file (char **retv, unsigned int *length)
 
static char ** read_hosts_file (char **retv, unsigned int *length)
 
static void parse_ssh_config_file (const char *filename, char ***retv, unsigned int *length, unsigned int num_favorites)
 
static char ** get_ssh (unsigned int *length)
 
static int ssh_mode_init (Mode *sw)
 
static unsigned int ssh_mode_get_num_entries (const Mode *sw)
 
static void ssh_mode_destroy (Mode *sw)
 
static ModeMode ssh_mode_result (Mode *sw, int mretv, char **input, unsigned int selected_line)
 
static char * _get_display_value (const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **attr_list, int get_entry)
 
static int ssh_token_match (const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
 

Detailed Description

SSH Mode, returns a list of known SSH hosts the user can log into. It does this by parsing the SSH config file and optional the known host and host list It also keeps history of the last chosen hosts.

This mode uses the following options from the config object:

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "Dialogs.Ssh"

Log domain for the ssh modi.

Definition at line 36 of file ssh.c.

◆ SSH_CACHE_FILE

#define SSH_CACHE_FILE   "rofi-2.sshcache"

Name of the history file where previously chosen hosts are stored.

Definition at line 62 of file ssh.c.

Referenced by delete_ssh(), exec_ssh(), and get_ssh().

◆ SSH_TOKEN_DELIM

#define SSH_TOKEN_DELIM   "= \t\r\n"

Used in get_ssh() when splitting lines from the user's SSH config file into tokens.

Definition at line 68 of file ssh.c.

Referenced by parse_ssh_config_file().

Function Documentation

◆ _get_display_value()

static char* _get_display_value ( const Mode sw,
unsigned int  selected_line,
G_GNUC_UNUSED int *  state,
G_GNUC_UNUSED GList **  attr_list,
int  get_entry 
)
static
Parameters
swObject handle to the SSH Mode object
selected_lineThe line to view
stateThe state of the entry [out]
attr_listList of extra rendering attributes to set [out]
get_entryGets the string as it should be displayed and the display state. If get_entry is FALSE only the state is set.
Returns
the string as it should be displayed and the display state.

Definition at line 503 of file ssh.c.

References SSHModePrivateData::hosts_list, and mode_get_private_data().

Here is the call graph for this function:

◆ delete_ssh()

static void delete_ssh ( const char *  host)
static
Parameters
hostThe host to remove from history

Remove host from history.

Definition at line 124 of file ssh.c.

References cache_dir, history_remove(), and SSH_CACHE_FILE.

Referenced by ssh_mode_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exec_ssh()

static void exec_ssh ( const char *  host)
static
Parameters
hostThe host to connect too

SSH into the selected host, if successful update history.

Definition at line 102 of file ssh.c.

References cache_dir, execshssh(), history_set(), and SSH_CACHE_FILE.

Referenced by ssh_mode_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execshssh()

static int execshssh ( const char *  host)
static
Parameters
hostThe host to connect too

SSH into the selected host.

Returns
FALSE On failure, TRUE on success

Definition at line 77 of file ssh.c.

References config, helper_execute(), helper_parse_setup(), RofiHelperExecuteContext::name, and Settings::ssh_command.

Referenced by exec_ssh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ssh()

static char** get_ssh ( unsigned int *  length)
static
Parameters
lengthThe number of found ssh hosts [out]

Gets the list available SSH hosts.

Returns
an array of strings containing all the hosts.

Definition at line 366 of file ssh.c.

References cache_dir, config, history_get_list(), Settings::parse_hosts, Settings::parse_known_hosts, parse_ssh_config_file(), read_hosts_file(), read_known_hosts_file(), and SSH_CACHE_FILE.

Referenced by ssh_mode_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_ssh_config_file()

static void parse_ssh_config_file ( const char *  filename,
char ***  retv,
unsigned int *  length,
unsigned int  num_favorites 
)
static

Definition at line 260 of file ssh.c.

References rofi_expand_path(), and SSH_TOKEN_DELIM.

Referenced by get_ssh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_hosts_file()

static char** read_hosts_file ( char **  retv,
unsigned int *  length 
)
static
Parameters
retvThe list of hosts to update.
lengthThe length of the list retv [in][out]

Read /etc/hosts and appends them to the list retv

Returns
an updated list with the added hosts.

Definition at line 194 of file ssh.c.

Referenced by get_ssh().

Here is the caller graph for this function:

◆ read_known_hosts_file()

static char** read_known_hosts_file ( char **  retv,
unsigned int *  length 
)
static
Parameters
retvlist of hosts
lengthpointer to length of list [in][out]

Read 'known_hosts' file when entries are not hashsed.

Returns
updated list of hosts.

Definition at line 142 of file ssh.c.

Referenced by get_ssh().

Here is the caller graph for this function:

◆ ssh_mode_destroy()

static void ssh_mode_destroy ( Mode sw)
static
Parameters
swObject handle to the SSH Mode object

Cleanup the SSH Mode. Free all allocated memory and NULL the private data pointer.

Definition at line 441 of file ssh.c.

References SSHModePrivateData::hosts_list, mode_get_private_data(), and mode_set_private_data().

Referenced by ssh_mode_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ssh_mode_get_num_entries()

static unsigned int ssh_mode_get_num_entries ( const Mode sw)
static
Parameters
swObject handle to the SSH Mode object

Get the number of SSH entries.

Returns
the number of ssh entries.

Definition at line 431 of file ssh.c.

References SSHModePrivateData::hosts_list_length, and mode_get_private_data().

Here is the call graph for this function:

◆ ssh_mode_init()

static int ssh_mode_init ( Mode sw)
static
Parameters
swObject handle to the SSH Mode object

Initializes the SSH Mode private data object and loads the relevant ssh information.

Definition at line 414 of file ssh.c.

References get_ssh(), mode_get_private_data(), and mode_set_private_data().

Referenced by ssh_mode_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ssh_mode_result()

static ModeMode ssh_mode_result ( Mode sw,
int  mretv,
char **  input,
unsigned int  selected_line 
)
static
Parameters
swObject handle to the SSH Mode object
mretvThe menu return value.
inputPointer to the user input string.
selected_linethe line selected by the user.

Acts on the user interaction.

Returns
the next ModeMode.

Definition at line 461 of file ssh.c.

References delete_ssh(), exec_ssh(), SSHModePrivateData::hosts_list, MENU_CUSTOM_INPUT, MENU_ENTRY_DELETE, MENU_LOWER_MASK, MENU_NEXT, MENU_OK, MENU_PREVIOUS, MENU_QUICK_SWITCH, MODE_EXIT, mode_get_private_data(), NEXT_DIALOG, PREVIOUS_DIALOG, RELOAD_DIALOG, ssh_mode_destroy(), and ssh_mode_init().

Here is the call graph for this function:

◆ ssh_token_match()

static int ssh_token_match ( const Mode sw,
rofi_int_matcher **  tokens,
unsigned int  index 
)
static
Parameters
swObject handle to the SSH Mode object
tokensThe set of tokens to match against
indexThe index of the entry to match

Match entry against the set of tokens.

Returns
TRUE if matches

Definition at line 518 of file ssh.c.

References helper_token_match(), SSHModePrivateData::hosts_list, and mode_get_private_data().

Here is the call graph for this function:

Variable Documentation

◆ ssh_mode [1/2]

Mode ssh_mode

Mode object representing the ssh dialog.

Definition at line 524 of file ssh.c.

Referenced by rofi_collect_modi().

◆ ssh_mode [2/2]

Mode ssh_mode
Initial value:
=
{
.name = "ssh",
.cfg_name_key = "display-ssh",
._init = ssh_mode_init,
._get_num_entries = ssh_mode_get_num_entries,
._result = ssh_mode_result,
._destroy = ssh_mode_destroy,
._token_match = ssh_token_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
._preprocess_input = NULL,
.private_data = NULL,
.free = NULL
}
static char * _get_display_value(const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **attr_list, int get_entry)
Definition: ssh.c:503
static unsigned int ssh_mode_get_num_entries(const Mode *sw)
Definition: ssh.c:431
static void ssh_mode_destroy(Mode *sw)
Definition: ssh.c:441
static int ssh_token_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
Definition: ssh.c:518
static ModeMode ssh_mode_result(Mode *sw, int mretv, char **input, unsigned int selected_line)
Definition: ssh.c:461
static int ssh_mode_init(Mode *sw)
Definition: ssh.c:414

Mode object representing the ssh dialog.

Definition at line 524 of file ssh.c.

Referenced by rofi_collect_modi().