#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
static char * server = "vespa.holoscopio.com";
static char * username = "pubsub";
-static char * password = "pubsub";
+static char * password = NULL;
static char * pbservice = "pubsub@vespa.holoscopio.com";
static char * authed_jid = "vespa";
static int
xmpp_sasl_hook (iksparser *parser, iks* node)
{
+ if (password == NULL)
+ return -1;
iks_start_sasl (parser, IKS_SASL_DIGEST_MD5, username, password);
return 0;
}
xmpp_bind_hook (iksparser *parser, iks *node)
{
iks *iq;
+ if (password)
+ {
+ memset (password, 0, sysconf (_SC_PASS_MAX));
+ free (password);
+ password = NULL;
+ }
iq = iks_new ("iq");
iks_insert_attrib (iq, "type", "set");
iks_insert_attrib (iq, "id", "bind1");
{
iksparser *parser;
int c;
- while ((c = getopt (argc, argv, "s:u:p:i:a:")) != -1)
+ int askpasswd = 0;
+ char *passwd = strdup ("pubsub");
+ while ((c = getopt (argc, argv, "s:u:p:i:a:w")) != -1)
{
switch (c)
{
username = optarg;
break;
case 'p':
- password = optarg;
+ free (passwd);
+ passwd = strdup (optarg);
break;
case 'i':
pbservice = optarg;
case 'a':
authed_jid = optarg;
break;
+ case 'w':
+ askpasswd = 1;
+ break;
}
}
+ if (askpasswd)
+ passwd = getpass ("Type password: ");
+ password = malloc (sysconf (_SC_PASS_MAX));
+ strcpy (password, passwd);
+ memset (passwd, 0, strlen (passwd));
+ if (!askpasswd)
+ {
+ free (passwd);
+ passwd = NULL;
+ }
parser = iks_stream_new ("jabber:client", &parser, hook);
iks_connect_tcp (parser, server, 5222);
loop (parser);