Package: irssi-plugin-xmpp
Version: 0.50+cvs20100122-1
Severity: wishlist
Tags: patch
Since my XMPP password is more valuable than my regular IRC/Nickserv
passwords, I do not store them in my .irssi/config file. Instead, I used
to manually connect to the server using /xmppconnect, but I got tired of
that and wrote a small patch that would prompt the user for its password
if it wasn't provided in the config file.
Some parts of this code were taken from the silc plugin.
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-trunk-686 (SMP w/1 CPU core)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8) (ignored: LC_ALL
set to fr_CA.UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages irssi-plugin-xmpp depends on:
ii irssi 0.8.15-1 terminal based IRC client
ii libc6 2.10.2-6 Embedded GNU C Library: Shared lib
ii libglib2.0-0 2.24.1-1 The GLib library of C routines
ii libidn11 1.18-1 GNU Libidn library, implementation
ii libloudmouth1-0 1.4.3-5 Lightweight C Jabber library
irssi-plugin-xmpp recommends no packages.
irssi-plugin-xmpp suggests no packages.
-- no debconf information
--- irssi-plugin-xmpp-0.50+cvs20100122.orig/src/core/xmpp-servers.c
+++ irssi-plugin-xmpp-0.50+cvs20100122/src/core/xmpp-servers.c
@@ -17,8 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <termios.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <string.h>
#include "module.h"
#include "network.h"
@@ -239,6 +241,93 @@
"Authenticated successfully.");
}
+
+// shameless copy-paste from irssi-silc's silc_get_input
+char *get_input(const char *prompt, unsigned char echo_off)
+{
+ int fd;
+ char input[2048];
+
+ if (echo_off) {
+ char *ret = NULL;
+//#ifdef HAVE_TERMIOS_H
+// let's assume termios.h for now
+#if 1
+ struct termios to;
+ struct termios to_old;
+
+ fd = open("/dev/tty", O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "silc: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ signal(SIGINT, SIG_IGN);
+
+ /* Get terminal info */
+ tcgetattr(fd, &to);
+ to_old = to;
+
+ /* Echo OFF, and assure we can prompt and get input */
+ to.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
+ to.c_lflag |= ICANON;
+ to.c_cc[VMIN] = 255;
+ tcsetattr(fd, TCSANOW, &to);
+
+ memset(input, 0, sizeof(input));
+
+ printf("%s", prompt);
+ fflush(stdout);
+
+ if ((read(fd, input, sizeof(input))) < 0) {
+ fprintf(stderr, "silc: %s\n", strerror(errno));
+ tcsetattr(fd, TCSANOW, &to_old);
+ return NULL;
+ }
+
+ if (strlen(input) <= 1) {
+ tcsetattr(fd, TCSANOW, &to_old);
+ return NULL;
+ }
+
+ if (strchr(input, '\n'))
+ *strchr(input, '\n') = '\0';
+
+ /* Restore old terminfo */
+ tcsetattr(fd, TCSANOW, &to_old);
+ signal(SIGINT, SIG_DFL);
+
+ ret = strndup(input, strlen(input));
+ memset(input, 0, sizeof(input));
+#endif /* HAVE_TERMIOS_H */
+ return ret;
+ } else {
+ fd = open("/dev/tty", O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "silc: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ memset(input, 0, sizeof(input));
+
+ printf("%s", prompt);
+ fflush(stdout);
+
+ if ((read(fd, input, sizeof(input))) < 0) {
+ fprintf(stderr, "silc: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ if (strlen(input) <= 1)
+ return NULL;
+
+ if (strchr(input, '\n'))
+ *strchr(input, '\n') = '\0';
+
+ return strdup(input);
+ }
+}
+
static void
lm_open_cb(LmConnection *connection, gboolean success,
gpointer user_data)
@@ -265,6 +354,11 @@
signal_emit("xmpp server status", 2, server,
"Using STARTTLS encryption.");
recoded_user = xmpp_recode_out(server->user);
+
+
+ if (server->connrec->password == '\0') {
+ server->connrec->password = get_input("xmpp password: ", 1);
+ }
recoded_password = xmpp_recode_out(server->connrec->password);
recoded_resource = xmpp_recode_out(server->resource);
lm_connection_authenticate(connection, recoded_user,