summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-09-16 23:04:22 +0200
committerChristian Grothoff <christian@grothoff.org>2021-09-16 23:04:22 +0200
commit03bfa07732db97dfaa61b103e2cb30c08805d425 (patch)
tree7fc62242644196e4871564d02d33b582cb29cc7a
parent52ed41d588082f2097473b1440fcc314a79dc4c4 (diff)
downloadsync-03bfa07732db97dfaa61b103e2cb30c08805d425.tar.gz
sync-03bfa07732db97dfaa61b103e2cb30c08805d425.tar.bz2
sync-03bfa07732db97dfaa61b103e2cb30c08805d425.zip
fix sync-httpd return values
-rw-r--r--src/include/platform.h27
-rw-r--r--src/sync/sync-httpd.c36
-rw-r--r--src/sync/sync.conf3
3 files changed, 49 insertions, 17 deletions
diff --git a/src/include/platform.h b/src/include/platform.h
index b17c64f..2fbbe24 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -51,6 +51,33 @@
/* Do not use deprecated functions from gcrypt */
#define GCRYPT_NO_DEPRECATED 1
+
+/* LSB-style exit status codes */
+#ifndef EXIT_INVALIDARGUMENT
+#define EXIT_INVALIDARGUMENT 2
+#endif
+
+#ifndef EXIT_NOTIMPLEMENTED
+#define EXIT_NOTIMPLEMENTED 3
+#endif
+
+#ifndef EXIT_NOPERMISSION
+#define EXIT_NOPERMISSION 4
+#endif
+
+#ifndef EXIT_NOTINSTALLED
+#define EXIT_NOTINSTALLED 5
+#endif
+
+#ifndef EXIT_NOTCONFIGURED
+#define EXIT_NOTCONFIGURED 6
+#endif
+
+#ifndef EXIT_NOTRUNNING
+#define EXIT_NOTRUNNING 7
+#endif
+
+
/* Ignore MHD deprecations for now as we want to be compatible
to "ancient" MHD releases. */
#define MHD_NO_DEPRECATION 1
diff --git a/src/sync/sync-httpd.c b/src/sync/sync-httpd.c
index 0ec95e7..1b02fe2 100644
--- a/src/sync/sync-httpd.c
+++ b/src/sync/sync-httpd.c
@@ -469,7 +469,7 @@ SH_trigger_curl ()
* @param daemon_handle HTTP server to prepare to run
*/
static struct GNUNET_SCHEDULER_Task *
-prepare_daemon ()
+prepare_daemon (void)
{
struct GNUNET_SCHEDULER_Task *ret;
fd_set rs;
@@ -540,7 +540,7 @@ run (void *cls,
if (SH_sync_connection_close)
go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;
TALER_MHD_setup (go);
- result = GNUNET_SYSERR;
+ result = EXIT_NOTCONFIGURED;
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
GNUNET_assert (GNUNET_OK ==
@@ -621,12 +621,10 @@ run (void *cls,
certfile,
keyfile,
keypass);
-
- // Case where APIKEY is needed.
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (config,
"sync",
- "APIKEY",
+ "API_KEY",
&apikey))
{
char *auth_header;
@@ -649,6 +647,7 @@ run (void *cls,
if (NULL ==
(db = SYNC_DB_plugin_load (config)))
{
+ result = EXIT_NOTINSTALLED;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -659,6 +658,7 @@ run (void *cls,
if ( (0 == port) &&
(-1 == fh) )
{
+ result = EXIT_NOPERMISSION;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -669,17 +669,18 @@ run (void *cls,
MHD_OPTION_LISTEN_SOCKET, fh,
MHD_OPTION_NOTIFY_COMPLETED,
&handle_mhd_completion_callback, NULL,
- MHD_OPTION_CONNECTION_TIMEOUT, (unsigned
- int) 10 /* 10s */,
+ MHD_OPTION_CONNECTION_TIMEOUT,
+ (unsigned int) 10 /* 10s */,
MHD_OPTION_END);
if (NULL == mhd)
{
+ result = EXIT_FAILURE;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to launch HTTP service, exiting.\n");
GNUNET_SCHEDULER_shutdown ();
return;
}
- result = GNUNET_OK;
+ result = EXIT_SUCCESS;
mhd_task = prepare_daemon ();
}
@@ -722,18 +723,21 @@ main (int argc,
&certtype),
GNUNET_GETOPT_OPTION_END
};
+ enum GNUNET_GenericReturnValue ret;
/* FIRST get the libtalerutil initialization out
of the way. Then throw that one away, and force
the SYNC defaults to be used! */
(void) TALER_project_data_default ();
GNUNET_OS_init (SYNC_project_data_default ());
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv,
- "sync-httpd",
- "sync HTTP interface",
- options,
- &run, NULL))
- return 3;
- return (GNUNET_OK == result) ? 0 : 1;
+ ret = GNUNET_PROGRAM_run (argc, argv,
+ "sync-httpd",
+ "sync HTTP interface",
+ options,
+ &run, NULL);
+ if (GNUNET_NO == ret)
+ return EXIT_SUCCESS;
+ if (GNUNET_SYSERR == ret)
+ return EXIT_INVALIDARGUMENT;
+ return result;
}
diff --git a/src/sync/sync.conf b/src/sync/sync.conf
index c6b7aa7..af3203f 100644
--- a/src/sync/sync.conf
+++ b/src/sync/sync.conf
@@ -40,7 +40,8 @@ FULFILLMENT_URL = taler://fulfillment-success
# Base URL of our payment backend
PAYMENT_BACKEND_URL = http://localhost:9966/
-
+# API key to pass when accessing the merchant backend.
+# API_KEY = SECRET_VALUE
# Configuration for postgres database.
[syncdb-postgres]