Version: 1.5.2-42-git-2728e4ad (next)
https://gist.github.com/sangowen/e2820e95281da0d2045b64c1181516d3
sudo rofi -modi ssh -show
sudo rofi -modi ssh -show
All of the historical ssh entries with colon (:) are truncated starting from the first colon.
e.g.
-L 80
-L \*
Entries were not truncated in the previous versions (including 1.5.2 release or master branch).
e.g.
-L 80:192.168.0.1:80 [email protected]
-L \*:80:192.168.0.1:80 [email protected]
.Xresources:
rofi.ssh-command: {terminal} -e {ssh-client} {host}
The ~/.cache/rofi-2.sshcache is intact so when I downgrade to 1.5.2 release it works again.
I was able to use entries like "-L *:80:192.168.0.1:80 [email protected]" to port-forward.
I'm not sure if port-forwarding is part of the intended usage with ssh modi.
If not, is there a way to dynamically assign port to forward with rofi?
That is right yes.. Will fix.
Can you test this patch?
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index df17f6e9..4bf2e3f1 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -139,7 +139,7 @@ static void exec_ssh ( const SshEntry *entry )
char *path = g_build_filename ( cache_dir, SSH_CACHE_FILE, NULL );
// TODO update.
if ( entry->port > 0 ) {
- char *store = g_strdup_printf("%s:%d", entry->hostname, entry->port );
+ char *store = g_strdup_printf("%s\x1F%d", entry->hostname, entry->port );
history_set ( path, store );
g_free ( store );
} else {
@@ -205,7 +205,7 @@ static SshEntry *read_known_hosts_file ( const char *path, SshEntry * retv, unsi
if ( start[0] == '[' ) {
start++;
char *end = strchr ( start, ']');
- if ( end[1] == ':' ){
+ if ( end[1] == '\x1F' ){
*end = '\0';
port = atoi ( &(end[2]) );
}
@@ -457,7 +457,7 @@ static SshEntry * get_ssh ( SSHModePrivateData *pd, unsigned int *length )
retv = malloc ( (*length)*sizeof(SshEntry));
for ( unsigned int i = 0; i < (*length); i++ ){
int port = 0;
- char *portstr = strchr ( h[i], ':' );
+ char *portstr = strchr ( h[i], '\x1F' );
if ( portstr != NULL ) {
*portstr = '\0';
port = atoi ( &(portstr[1]) );
you might need to remove the cache first.
This patch solved the problem for me. Also it worked without removing the cache. The unpatched version seems to connect and register entries to the cache correctly.
Thank you very much.
Thanks for testing. I used : as a separator for the command in history. That was not handy if : is part of the command.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Can you test this patch?
you might need to remove the cache first.