diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-04-13 00:12:27 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-04-13 00:12:27 +0000 |
commit | a389a24eb118f73094d2e0d27169bb1b5c4201b8 (patch) | |
tree | 88c7a4078512ab8bcc9eef26497c2431aced7162 | |
parent | 323889e4257d035beb3659e9257ff3cea92a4aa9 (diff) |
exec ssh inside a terminal if not attached to a tty
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1422 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r-- | avahi-ui/zssh.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/avahi-ui/zssh.c b/avahi-ui/zssh.c index e4cf16e..a38a9d9 100644 --- a/avahi-ui/zssh.c +++ b/avahi-ui/zssh.c @@ -55,11 +55,12 @@ int main(int argc, char*argv[]) { gtk_window_present(GTK_WINDOW(d)); if (gtk_dialog_run(GTK_DIALOG(d)) == GTK_RESPONSE_OK) { - char a[AVAHI_ADDRESS_STR_MAX], *u = NULL; + char a[AVAHI_ADDRESS_STR_MAX], *u = NULL, *n = NULL; char *h = NULL, *t = NULL; const AvahiStringList *txt; t = g_strdup(aui_service_dialog_get_service_type(AUI_SERVICE_DIALOG(d))); + n = g_strdup(aui_service_dialog_get_service_name(AUI_SERVICE_DIALOG(d))); if (avahi_nss_support()) h = g_strdup(aui_service_dialog_get_host_name(AUI_SERVICE_DIALOG(d))); @@ -77,6 +78,7 @@ int main(int argc, char*argv[]) { } else { char p[16]; + snprintf(p, sizeof(p), "%u", aui_service_dialog_get_port(AUI_SERVICE_DIALOG(d))); for (txt = aui_service_dialog_get_txt_data(AUI_SERVICE_DIALOG(d)); txt; txt = txt->next) { @@ -93,13 +95,27 @@ int main(int argc, char*argv[]) { } gtk_widget_destroy(d); - + if (u) { g_print("ssh -p %s -l %s %s\n", p, u, h); - execlp("ssh", "ssh", "-p", p, "-l", u, h, NULL); + + if (isatty(0)) + execlp("ssh", "ssh", "-p", p, "-l", u, h, NULL); + else { + execlp("x-terminal-emulator", "x-terminal-emulator", "-T", n, "-e", "ssh", "-p", p, "-l", u, h, NULL); + execlp("gnome-terminal", "gnome-terminal", "-t", n, "-x", "ssh", "-p", p, "-l", u, h, NULL); + execlp("xterm", "xterm", "-T", n, "-e", "ssh", "-p", p, "-l", u, h, NULL); + } } else { g_print("ssh -p %s %s\n", p, h); - execlp("ssh", "ssh", "-p", p, h, NULL); + + if (isatty(0)) + execlp("ssh", "ssh", "-p", p, h, NULL); + else { + execlp("x-terminal-emulator", "x-terminal-emulator", "-T", n, "-e", "ssh", "-p", p, h, NULL); + execlp("gnome-terminal", "gnome-terminal", "-t", n, "-x", "ssh", "-p", p, h, NULL); + execlp("xterm", "xterm", "-T", n, "-e", "ssh", "-p", p, h, NULL); + } } } @@ -108,6 +124,7 @@ int main(int argc, char*argv[]) { g_free(h); g_free(u); g_free(t); + g_free(n); } else { gtk_widget_destroy(d); |