diff options
author | Florian Dold <florian@dold.me> | 2021-07-27 11:26:48 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-07-27 11:26:48 +0200 |
commit | 32f3391be100622a79c40fdce7dcec44418da34c (patch) | |
tree | b15af29e6df4667b2328a4698f80bc7e18b41a5e /src/util/taler-exchange-secmod-rsa.c | |
parent | 065ebbf57e673927034357bd85fb8c6519639894 (diff) | |
download | exchange-32f3391be100622a79c40fdce7dcec44418da34c.tar.xz |
secmod: fchmod socket to ug+rw
Diffstat (limited to 'src/util/taler-exchange-secmod-rsa.c')
-rw-r--r-- | src/util/taler-exchange-secmod-rsa.c | 79 |
1 files changed, 19 insertions, 60 deletions
diff --git a/src/util/taler-exchange-secmod-rsa.c b/src/util/taler-exchange-secmod-rsa.c index 0b2da99d7..b6729b66b 100644 --- a/src/util/taler-exchange-secmod-rsa.c +++ b/src/util/taler-exchange-secmod-rsa.c @@ -40,6 +40,7 @@ #include <sys/eventfd.h> #include "taler_error_codes.h" #include "taler_signatures.h" +#include "secmod_common.h" /** @@ -1895,69 +1896,27 @@ run (void *cls, return; } - /* open socket */ + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "taler-exchange-secmod-rsa", + "UNIXPATH", + &unixpath)) { - int sock; + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "taler-exchange-secmod-rsa", + "UNIXPATH"); + global_ret = 3; + return; + } - sock = socket (PF_UNIX, - SOCK_DGRAM, - 0); - if (-1 == sock) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "socket"); - global_ret = 2; - return; - } - { - struct sockaddr_un un; + GNUNET_assert (NULL != unixpath); + unix_sock = TES_open_socket (unixpath); - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (kcfg, - "taler-exchange-secmod-rsa", - "UNIXPATH", - &unixpath)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "taler-exchange-secmod-rsa", - "UNIXPATH"); - global_ret = 3; - return; - } - if (GNUNET_OK != - GNUNET_DISK_directory_create_for_file (unixpath)) - { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "mkdir(dirname)", - unixpath); - } - if (0 != unlink (unixpath)) - { - if (ENOENT != errno) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", - unixpath); - } - memset (&un, - 0, - sizeof (un)); - un.sun_family = AF_UNIX; - strncpy (un.sun_path, - unixpath, - sizeof (un.sun_path) - 1); - if (0 != bind (sock, - (const struct sockaddr *) &un, - sizeof (un))) - { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "bind", - unixpath); - global_ret = 3; - GNUNET_break (0 == close (sock)); - return; - } - } - unix_sock = GNUNET_NETWORK_socket_box_native (sock); + if (NULL == unix_sock) + { + GNUNET_free (unixpath); + global_ret = 2; + return; } GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |