guard-xmpp-password.diff
changeset 87 78238d26911a
parent 52 887f44e99aa1
child 88 0a87df8ad9c1
equal deleted inserted replaced
86:ac5fed257211 87:78238d26911a
     2 
     2 
     3   * instead of filtering access to stored in public place
     3   * instead of filtering access to stored in public place
     4     restricted data, better store restricted data somewhere else
     4     restricted data, better store restricted data somewhere else
     5   * add xmpp_init() and xmpp_have_password (non-api)
     5   * add xmpp_init() and xmpp_have_password (non-api)
     6 
     6 
     7 diff -r ce54b748207b mcabber/mcabber/commands.c
     7 diff -r d5d7361a99c0 mcabber/mcabber/commands.c
     8 --- a/mcabber/mcabber/commands.c	Thu Oct 18 13:43:12 2012 +0300
     8 --- a/mcabber/mcabber/commands.c	Tue Nov 11 21:10:14 2014 +0200
     9 +++ b/mcabber/mcabber/commands.c	Thu Oct 18 13:43:18 2012 +0300
     9 +++ b/mcabber/mcabber/commands.c	Tue Nov 11 21:12:47 2014 +0200
    10 @@ -2274,10 +2274,8 @@
    10 @@ -2286,10 +2286,8 @@
    11  
    11  
    12  static void list_option_cb(char *k, char *v, void *f)
    12  static void list_option_cb(char *k, char *v, void *f)
    13  {
    13  {
    14 -  if (strcmp(k, "password")) {
    14 -  if (strcmp(k, "password")) {
    15 -    GSList **list = f;
    15 -    GSList **list = f;
    18 +  GSList **list = f;
    18 +  GSList **list = f;
    19 +  *list = g_slist_insert_sorted(*list, k, (GCompareFunc)strcmp);
    19 +  *list = g_slist_insert_sorted(*list, k, (GCompareFunc)strcmp);
    20  }
    20  }
    21  
    21  
    22  static void do_set(char *arg)
    22  static void do_set(char *arg)
    23 diff -r ce54b748207b mcabber/mcabber/main.c
    23 diff -r d5d7361a99c0 mcabber/mcabber/main.c
    24 --- a/mcabber/mcabber/main.c	Thu Oct 18 13:43:12 2012 +0300
    24 --- a/mcabber/mcabber/main.c	Tue Nov 11 21:10:14 2014 +0200
    25 +++ b/mcabber/mcabber/main.c	Thu Oct 18 13:43:18 2012 +0300
    25 +++ b/mcabber/mcabber/main.c	Tue Nov 11 21:12:47 2014 +0200
    26 @@ -381,6 +381,7 @@
    26 @@ -389,6 +389,7 @@
    27    scr_init_locale_charset();
    27    scr_init_locale_charset();
    28    ut_init_debug();
    28    ut_init_debug();
    29    help_init();
    29    help_init();
    30 +  xmpp_init();
    30 +  xmpp_init();
    31  
    31  
    32    /* Parsing config file... */
    32    /* Parsing config file... */
    33    ret = cfg_read_file(configFile, TRUE);
    33    ret = cfg_read_file(configFile, TRUE);
    34 @@ -417,8 +418,9 @@
    34 @@ -410,8 +411,9 @@
    35  
    35  
    36    /* If no password is stored, we ask for it before entering
    36    /* If no password is stored, we ask for it before entering
    37       ncurses mode -- unless the username is unknown. */
    37       ncurses mode -- unless the username is unknown. */
    38 -  if (settings_opt_get("jid") && !settings_opt_get("password")) {
    38 -  if (settings_opt_get("jid") && !settings_opt_get("password")) {
    39 +  if (settings_opt_get("jid") && !xmpp_have_password) {
    39 +  if (settings_opt_get("jid") && !xmpp_have_password) {
    40      char *pwd = ask_password("your Jabber password");
    40      char *pwd = ask_password("your Jabber password");
    41 +    /* Will be intercepted by guard */
    41 +    /* Will be intercepted by guard */
    42      settings_set(SETTINGS_TYPE_OPTION, "password", pwd);
    42      settings_set(SETTINGS_TYPE_OPTION, "password", pwd);
    43      g_free(pwd);
    43      g_free(pwd);
    44    }
    44    }
    45 diff -r ce54b748207b mcabber/mcabber/xmpp.c
    45 diff -r d5d7361a99c0 mcabber/mcabber/xmpp.c
    46 --- a/mcabber/mcabber/xmpp.c	Thu Oct 18 13:43:12 2012 +0300
    46 --- a/mcabber/mcabber/xmpp.c	Tue Nov 11 21:10:14 2014 +0200
    47 +++ b/mcabber/mcabber/xmpp.c	Thu Oct 18 13:43:18 2012 +0300
    47 +++ b/mcabber/mcabber/xmpp.c	Tue Nov 11 21:12:47 2014 +0200
    48 @@ -23,6 +23,8 @@
    48 @@ -23,6 +23,8 @@
    49   */
    49   */
    50  #include <stdlib.h>
    50  #include <stdlib.h>
    51  #include <string.h>
    51  #include <string.h>
    52 +#include <sys/mman.h>
    52 +#include <sys/mman.h>
    53 +#include <errno.h>
    53 +#include <errno.h>
    54  
    54  
    55  #include "xmpp.h"
    55  #include "xmpp.h"
    56  #include "xmpp_helper.h"
    56  #include "xmpp_helper.h"
    57 @@ -53,6 +55,9 @@
    57 @@ -54,6 +56,9 @@
    58  static enum imstatus mywantedstatus = available;
    58  static enum imstatus mywantedstatus = available;
    59  gchar *mystatusmsg;
    59  gchar *mystatusmsg;
    60  
    60  
    61 +static char *xmpp_password = NULL;
    61 +static char *xmpp_password = NULL;
    62 +gboolean xmpp_have_password = FALSE;
    62 +gboolean xmpp_have_password = FALSE;
    63 +
    63 +
    64  char imstatus2char[imstatus_size+1] = {
    64  char imstatus2char[imstatus_size+1] = {
    65      '_', 'o', 'f', 'd', 'n', 'a', 'i', '\0'
    65      '_', 'o', 'f', 'd', 'n', 'a', 'i', '\0'
    66  };
    66  };
    67 @@ -891,16 +896,15 @@
    67 @@ -778,16 +783,15 @@
    68    GError *error = NULL;
    68    GError *error = NULL;
    69  
    69  
    70    if (success) {
    70    if (success) {
    71 -    const char *password, *resource;
    71 -    const char *password, *resource;
    72 +    const char *resource;
    72 +    const char *resource;
    81 -    if (!lm_connection_authenticate(lconnection, username, password, resource,
    81 -    if (!lm_connection_authenticate(lconnection, username, password, resource,
    82 +    if (!lm_connection_authenticate(lconnection, username, xmpp_password, resource,
    82 +    if (!lm_connection_authenticate(lconnection, username, xmpp_password, resource,
    83                                      connection_auth_cb, NULL, FALSE, &error)) {
    83                                      connection_auth_cb, NULL, FALSE, &error)) {
    84        scr_LogPrint(LPRINT_LOGNORM, "Failed to authenticate: %s",
    84        scr_LogPrint(LPRINT_LOGNORM, "Failed to authenticate: %s",
    85                     error->message);
    85                     error->message);
    86 @@ -1783,13 +1787,37 @@
    86 @@ -1687,13 +1691,37 @@
    87    }
    87    }
    88  }
    88  }
    89  
    89  
    90 +static gchar *xmpp_password_guard(const gchar *key, const gchar *new_value)
    90 +static gchar *xmpp_password_guard(const gchar *key, const gchar *new_value)
    91 +{
    91 +{
   120 -  const char *userjid, *password, *resource, *servername, *ssl_fpr;
   120 -  const char *userjid, *password, *resource, *servername, *ssl_fpr;
   121 +  const char *userjid, *resource, *servername, *ssl_fpr;
   121 +  const char *userjid, *resource, *servername, *ssl_fpr;
   122    char *dynresource = NULL;
   122    char *dynresource = NULL;
   123    char fpr[16];
   123    char fpr[16];
   124    const char *proxy_host;
   124    const char *proxy_host;
   125 @@ -1806,7 +1834,6 @@
   125 @@ -1710,7 +1738,6 @@
   126  
   126  
   127    servername = settings_opt_get("server");
   127    servername  = settings_opt_get("server");
   128    userjid    = settings_opt_get("jid");
   128    userjid     = settings_opt_get("jid");
   129 -  password   = settings_opt_get("password");
   129 -  password    = settings_opt_get("password");
   130    resource   = settings_opt_get("resource");
   130    resource    = settings_opt_get("resource");
   131    proxy_host = settings_opt_get("proxy_host");
   131    proxy_host  = settings_opt_get("proxy_host");
   132    ssl_fpr    = settings_opt_get("ssl_fingerprint");
   132    ssl_fpr     = settings_opt_get("ssl_fingerprint");
   133 @@ -1815,7 +1842,7 @@
   133 @@ -1719,7 +1746,7 @@
   134      scr_LogPrint(LPRINT_LOGNORM, "Your JID has not been specified!");
   134      scr_LogPrint(LPRINT_LOGNORM, "Your JID has not been specified!");
   135      return -1;
   135      return -1;
   136    }
   136    }
   137 -  if (!password) {
   137 -  if (!password) {
   138 +  if (!xmpp_password) {
   138 +  if (!xmpp_password) {
   139      scr_LogPrint(LPRINT_LOGNORM, "Your password has not been specified!");
   139      scr_LogPrint(LPRINT_LOGNORM, "Your password has not been specified!");
   140      return -1;
   140      return -1;
   141    }
   141    }
   142 diff -r ce54b748207b mcabber/mcabber/xmpp.h
   142 diff -r d5d7361a99c0 mcabber/mcabber/xmpp.h
   143 --- a/mcabber/mcabber/xmpp.h	Thu Oct 18 13:43:12 2012 +0300
   143 --- a/mcabber/mcabber/xmpp.h	Tue Nov 11 21:10:14 2014 +0200
   144 +++ b/mcabber/mcabber/xmpp.h	Thu Oct 18 13:43:18 2012 +0300
   144 +++ b/mcabber/mcabber/xmpp.h	Tue Nov 11 21:12:47 2014 +0200
   145 @@ -33,7 +33,9 @@
   145 @@ -34,7 +34,9 @@
   146  
   146  
   147  extern LmConnection* lconnection;
   147  extern LmConnection* lconnection;
   148  extern LmSSL* lssl;
   148  extern LmSSL* lssl;
   149 +extern gboolean xmpp_have_password; /* private */
   149 +extern gboolean xmpp_have_password; /* private */
   150  
   150