Mercurial > hg
diff mcabber/src/main.c @ 1530:29c505d43b3e
Use random resource suffix by default
By default a random suffix is appended to the resource name,
as recommended in rfc3920bis ("For the sake of proper security, a resource
identifier SHOULD be random").
This behaviour can be altered with the new option "disable_random_resource".
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 04 Oct 2008 14:13:49 +0200 |
parents | 0803c0bd8b76 |
children | 31472d421267 |
line wrap: on
line diff
--- a/mcabber/src/main.c Sat Oct 04 13:07:18 2008 +0200 +++ b/mcabber/src/main.c Sat Oct 04 14:13:49 2008 +0200 @@ -70,6 +70,7 @@ { const char *username, *password, *resource, *servername; const char *proxy_host; + const char *resource_prefix = PACKAGE_NAME; char *dynresource = NULL; char *fjid; int ssl; @@ -138,16 +139,18 @@ // We can't free the ca*_xp variables now, because they're not duplicated // in cw_set_ssl_options(). - if (!resource) { + if (!resource) + resource = resource_prefix; + + if (!settings_opt_get("disable_random_resource")) { #if HAVE_ARC4RANDOM - dynresource = g_strdup_printf("%s.%08x", PACKAGE_NAME, arc4random()); + dynresource = g_strdup_printf("%s.%08x", resource, arc4random()); #else unsigned int tab[2]; srand(time(NULL)); tab[0] = (unsigned int) (0xffff * (rand() / (RAND_MAX + 1.0))); tab[1] = (unsigned int) (0xffff * (rand() / (RAND_MAX + 1.0))); - dynresource = g_strdup_printf("%s.%04x%04x", PACKAGE_NAME, - tab[0], tab[1]); + dynresource = g_strdup_printf("%s.%04x%04x", resource, tab[0], tab[1]); #endif resource = dynresource; }