#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
-#include "gnunet_directories.h"
+#include "gnunet_constants.h"
#include "gnunet_resolver_service.h"
+#include "speedup.h"
#if HAVE_MALLINFO
#include <malloc.h>
/* ******************* access control ******************** */
-/**
- * Start task that may speed up our system clock artificially
- *
- * @param cfg configuration to use
- * @return GNUNET_OK on success, GNUNET_SYSERR if the speedup was not configured
- */
-int
-GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-/**
- * Stop tasks that modify clock behavior.
- */
-void
-GNUNET_SPEEDUP_stop_ (void);
-
-
/**
* Check if the given IP address is in the list of IP addresses.
*
* @param saddrs array to update
* @param saddrlens where to store the address length
* @param unixpath path to add
+ * @param abstract GNUNET_YES to add an abstract UNIX domain socket. This
+ * parameter is ignore on systems other than LINUX
*/
static void
add_unixpath (struct sockaddr **saddrs, socklen_t * saddrlens,
- const char *unixpath)
+ const char *unixpath,
+ int abstract)
{
#ifdef AF_UNIX
struct sockaddr_un *un;
un = GNUNET_new (struct sockaddr_un);
un->sun_family = AF_UNIX;
strncpy (un->sun_path, unixpath, sizeof (un->sun_path) - 1);
+#ifdef LINUX
+ if (GNUNET_YES == abstract)
+ un->sun_path[0] = '\0';
+#endif
#if HAVE_SOCKADDR_IN_SIN_LEN
un->sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
unsigned int i;
int resi;
int ret;
+ int abstract;
struct sockaddr **saddrs;
socklen_t *saddrlens;
char *hostname;
hostname = NULL;
unixpath = NULL;
+ abstract = GNUNET_NO;
#ifdef AF_UNIX
if ((GNUNET_YES ==
GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
LOG (GNUNET_ERROR_TYPE_INFO,
_("Using `%s' instead\n"), unixpath);
}
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (unixpath))
+#ifdef LINUX
+ abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "TESTING",
+ "USE_ABSTRACT_SOCKETS");
+ if (GNUNET_SYSERR == abstract)
+ abstract = GNUNET_NO;
+#endif
+ if ((GNUNET_YES != abstract)
+ && (GNUNET_OK !=
+ GNUNET_DISK_directory_create_for_file (unixpath)))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"mkdir",
unixpath);
{
saddrs = GNUNET_malloc (2 * sizeof (struct sockaddr *));
saddrlens = GNUNET_malloc (2 * sizeof (socklen_t));
- add_unixpath (saddrs, saddrlens, unixpath);
+ add_unixpath (saddrs, saddrlens, unixpath, abstract);
GNUNET_free_non_null (unixpath);
GNUNET_free_non_null (hostname);
*addrs = saddrs;
i = 0;
if (NULL != unixpath)
{
- add_unixpath (saddrs, saddrlens, unixpath);
+ add_unixpath (saddrs, saddrlens, unixpath, abstract);
i++;
}
next = res;
saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t));
if (NULL != unixpath)
{
- add_unixpath (saddrs, saddrlens, unixpath);
+ add_unixpath (saddrs, saddrlens, unixpath, abstract);
i++;
}
saddrlens[i] = sizeof (struct sockaddr_in);
i = 0;
if (NULL != unixpath)
{
- add_unixpath (saddrs, saddrlens, unixpath);
+ add_unixpath (saddrs, saddrlens, unixpath, abstract);
i++;
}
saddrlens[i] = sizeof (struct sockaddr_in6);
#ifndef WINDOWS
if (NULL != sctx->addrs)
for (i = 0; NULL != sctx->addrs[i]; i++)
- if (AF_UNIX == sctx->addrs[i]->sa_family)
+ if ((AF_UNIX == sctx->addrs[i]->sa_family)
+ && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0]))
GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path,
sctx->match_uid,
sctx->match_gid);
HANDLE_ERROR;
if (NULL == opt_cfg_fn)
opt_cfg_fn = GNUNET_strdup (cfg_fn);
- if (GNUNET_YES ==
- GNUNET_DISK_file_test (opt_cfg_fn))
- (void) GNUNET_CONFIGURATION_load (cfg, opt_cfg_fn);
+ if (GNUNET_YES == GNUNET_DISK_file_test (opt_cfg_fn))
+ {
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, opt_cfg_fn))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Malformed configuration file `%s', exit ...\n"),
+ opt_cfg_fn);
+ goto shutdown;
+ }
+ }
else
{
- (void) GNUNET_CONFIGURATION_load (cfg, NULL);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Malformed configuration, exit ...\n"));
+ goto shutdown;
+ }
if (0 != strcmp (opt_cfg_fn, cfg_fn))
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not access configuration file `%s'\n"),
GNUNET_free_non_null (logfile);
GNUNET_free_non_null (loglev);
GNUNET_free (cfg_fn);
- GNUNET_free (opt_cfg_fn);
+ GNUNET_free_non_null (opt_cfg_fn);
GNUNET_free_non_null (sctx.v4_denied);
GNUNET_free_non_null (sctx.v6_denied);
GNUNET_free_non_null (sctx.v4_allowed);
#ifndef WINDOWS
if (NULL != sctx->addrs)
for (i = 0; NULL != sctx->addrs[i]; i++)
- if (AF_UNIX == sctx->addrs[i]->sa_family)
+ if ((AF_UNIX == sctx->addrs[i]->sa_family)
+ && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0]))
GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path,
sctx->match_uid,
sctx->match_gid);