Update plibc header
[oweals/gnunet.git] / src / util / service.c
index 836501d3891fffe383549a03b809573a824c5ccb..d8ca5eba6cee817b8e97f21fdad80fdc1e4d8485 100644 (file)
  * @author Christian Grothoff
  */
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_configuration_lib.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_directories.h"
-#include "gnunet_disk_lib.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_os_lib.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
+#include "gnunet_directories.h"
 #include "gnunet_resolver_service.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_service_lib.h"
 
 #if HAVE_MALLINFO
 #include <malloc.h>
@@ -108,7 +101,7 @@ GNUNET_SPEEDUP_stop_ (void);
  * with a semicolon). The network must be given in dotted-decimal
  * notation. The netmask can be given in CIDR notation (/16) or
  * in dotted-decimal (/255.255.0.0).
- * 
+ *
  * @param routeList a string specifying the forbidden networks
  * @return the converted list, NULL if the synatx is flawed
  */
@@ -261,7 +254,7 @@ parse_ipv4_specification (const char *routeList)
  * with a semicolon). The network must be given in colon-hex
  * notation.  The netmask must be given in CIDR notation (/16) or
  * can be omitted to specify a single host.
- * 
+ *
  * @param routeListX a string specifying the forbidden networks
  * @return the converted list, NULL if the synatx is flawed
  */
@@ -666,18 +659,18 @@ check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
 #ifndef WINDOWS
   case AF_UNIX:
     ret = GNUNET_OK;            /* always OK for now */
-    if (GNUNET_YES == sctx->match_uid) 
+    if (GNUNET_YES == sctx->match_uid)
     {
       /* UID match required */
       ret = (NULL != uc) && ( (0 == uc->uid) || (uc->uid == geteuid ()) );
     }
     else if ( (GNUNET_YES == sctx->match_gid) &&
-             ( (NULL == uc) || 
+             ( (NULL == uc) ||
                ( (0 != uc->uid) &&
                  (uc->uid != geteuid ()) ) ) )
     {
       /* group match required and UID does not match */
-      if (NULL == uc) 
+      if (NULL == uc)
       {
        /* no credentials, group match not possible */
        ret = GNUNET_NO;
@@ -725,7 +718,7 @@ check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
   if (GNUNET_OK != ret)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Access from `%s' denied to service `%s'\n"), 
+         _("Access from `%s' denied to service `%s'\n"),
         GNUNET_a2s (addr, addrlen),
          sctx->service_name);
   }
@@ -757,9 +750,9 @@ get_pid_file_name (struct GNUNET_SERVICE_Context *sctx)
  * Parse an IPv4 access control list.
  *
  * @param ret location where to write the ACL (set)
- * @param sctx service context to use to get the configuration 
+ * @param sctx service context to use to get the configuration
  * @param option name of the ACL option to parse
- * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including 
+ * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including
  *         no ACL configured)
  */
 static int
@@ -770,7 +763,7 @@ process_acl4 (struct IPv4NetworkSet **ret, struct GNUNET_SERVICE_Context *sctx,
 
   if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
   {
-    *ret = NULL;    
+    *ret = NULL;
     return GNUNET_OK;
   }
   GNUNET_break (GNUNET_OK ==
@@ -794,9 +787,9 @@ process_acl4 (struct IPv4NetworkSet **ret, struct GNUNET_SERVICE_Context *sctx,
  * Parse an IPv6 access control list.
  *
  * @param ret location where to write the ACL (set)
- * @param sctx service context to use to get the configuration 
+ * @param sctx service context to use to get the configuration
  * @param option name of the ACL option to parse
- * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including 
+ * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including
  *         no ACL configured)
  */
 static int
@@ -995,7 +988,6 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name,
       unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
       LOG (GNUNET_ERROR_TYPE_INFO,
           _("Using `%s' instead\n"), unixpath);
-
     }
   }
   if (NULL != unixpath)
@@ -1301,8 +1293,6 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
   int tolerant;
 
 #ifndef MINGW
-  const char *lpid;
-  unsigned int pid;
   const char *nfds;
   unsigned int cnt;
   int flags;
@@ -1343,9 +1333,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
 
 #ifndef MINGW
   errno = 0;
-  if ((NULL != (lpid = getenv ("LISTEN_PID"))) &&
-      (1 == SSCANF (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) &&
-      (NULL != (nfds = getenv ("LISTEN_FDS"))) &&
+  if ((NULL != (nfds = getenv ("LISTEN_FDS"))) &&
       (1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
       (cnt + 4 < FD_SETSIZE))
   {
@@ -1370,7 +1358,6 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
         break;
       }
     }
-    unsetenv ("LISTEN_PID");
     unsetenv ("LISTEN_FDS");
   }
 #else
@@ -1578,7 +1565,7 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Detach from terminal.
  *
  * @param sctx service context
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 static int
 detach_terminal (struct GNUNET_SERVICE_Context *sctx)
@@ -1838,7 +1825,7 @@ shutdown:
 #if HAVE_MALLINFO
   {
     char *counter;
-    
+
     if ( (GNUNET_YES ==
          GNUNET_CONFIGURATION_have_value (sctx.cfg, service_name,
                                           "GAUGER_HEAP")) &&
@@ -1848,11 +1835,11 @@ shutdown:
                                                 &counter)) )
     {
       struct mallinfo mi;
-      
+
       mi = mallinfo ();
       GAUGER (service_name, counter, mi.usmblks, "blocks");
       GNUNET_free (counter);
-    }     
+    }
   }
 #endif
   GNUNET_SPEEDUP_stop_ ();
@@ -1957,7 +1944,7 @@ GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx)
 #if HAVE_MALLINFO
   {
     char *counter;
-    
+
     if ( (GNUNET_YES ==
          GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name,
                                           "GAUGER_HEAP")) &&
@@ -1967,11 +1954,11 @@ GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx)
                                                 &counter)) )
     {
       struct mallinfo mi;
-      
+
       mi = mallinfo ();
       GAUGER (sctx->service_name, counter, mi.usmblks, "blocks");
       GNUNET_free (counter);
-    }     
+    }
   }
 #endif
   if (GNUNET_SCHEDULER_NO_TASK != sctx->shutdown_task)