From 32f3391be100622a79c40fdce7dcec44418da34c Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 27 Jul 2021 11:26:48 +0200 Subject: secmod: fchmod socket to ug+rw --- src/util/taler-exchange-secmod-rsa.c | 79 +++++++++--------------------------- 1 file changed, 19 insertions(+), 60 deletions(-) (limited to 'src/util/taler-exchange-secmod-rsa.c') 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 #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, -- cgit v1.2.3