projects
/
apps
/
pfixtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Working version.
[apps/pfixtools.git]
/
pfix-srsd
/
main-srsd.c
diff --git
a/pfix-srsd/main-srsd.c
b/pfix-srsd/main-srsd.c
index
a8e6ce9
..
037a458
100644
(file)
--- a/
pfix-srsd/main-srsd.c
+++ b/
pfix-srsd/main-srsd.c
@@
-44,6
+44,7
@@
#include "server.h"
#define DAEMON_NAME "pfix-srsd"
#include "server.h"
#define DAEMON_NAME "pfix-srsd"
+#define DAEMON_VERSION "0.1"
#define DEFAULT_ENCODER_PORT 10001
#define DEFAULT_DECODER_PORT 10002
#define RUNAS_USER "nobody"
#define DEFAULT_ENCODER_PORT 10001
#define DEFAULT_DECODER_PORT 10002
#define RUNAS_USER "nobody"
@@
-122,7
+123,7
@@
int process_srs(server_t *srsd, void* vconfig)
nl = strchr(srsd->ibuf.data + 4, '\n');
if (!nl) {
if (srsd->ibuf.len > BUFSIZ) {
nl = strchr(srsd->ibuf.data + 4, '\n');
if (!nl) {
if (srsd->ibuf.len > BUFSIZ) {
-
syslog(LOG_ERR,
"unreasonnable amount of data without a \\n");
+
err(
"unreasonnable amount of data without a \\n");
return -1;
}
if (srsd->obuf.len) {
return -1;
}
if (srsd->obuf.len) {
@@
-132,7
+133,7
@@
int process_srs(server_t *srsd, void* vconfig)
}
if (strncmp("get ", srsd->ibuf.data, 4)) {
}
if (strncmp("get ", srsd->ibuf.data, 4)) {
-
syslog(LOG_ERR,
"bad request, not starting with \"get \"");
+
err(
"bad request, not starting with \"get \"");
return -1;
}
return -1;
}
@@
-141,7
+142,7
@@
int process_srs(server_t *srsd, void* vconfig)
if (p == q) {
buffer_addstr(&srsd->obuf, "400 empty request ???\n");
if (p == q) {
buffer_addstr(&srsd->obuf, "400 empty request ???\n");
-
syslog(LOG_WARNING,
"empty request");
+
warn(
"empty request");
goto skip;
}
goto skip;
}
@@
-234,7
+235,7
@@
static srs_t *srs_read_secrets(const char *sfile)
++lineno;
if (n == sizeof(buf) - 1 && buf[n - 1] != '\n') {
++lineno;
if (n == sizeof(buf) - 1 && buf[n - 1] != '\n') {
-
syslog(LOG_CRIT,
"%s:%d: line too long", sfile, lineno);
+
crit(
"%s:%d: line too long", sfile, lineno);
goto error;
}
m_strrtrim(buf);
goto error;
}
m_strrtrim(buf);
@@
-242,7
+243,7
@@
static srs_t *srs_read_secrets(const char *sfile)
}
if (!lineno) {
}
if (!lineno) {
-
syslog(LOG_CRIT,
"%s: empty file, no secrets", sfile);
+
crit(
"%s: empty file, no secrets", sfile);
goto error;
}
goto error;
}
@@
-307,11
+308,17
@@
int main(int argc, char *argv[])
}
}
}
}
+ if (!daemonize) {
+ log_syslog = false;
+ }
+
if (argc - optind != 2) {
usage();
return EXIT_FAILURE;
}
if (argc - optind != 2) {
usage();
return EXIT_FAILURE;
}
+ info("starting %s v%s...", DAEMON_NAME, DAEMON_VERSION);
+
config.domain = argv[optind];
config.srs = srs_read_secrets(argv[optind + 1]);
if (!config.srs
config.domain = argv[optind];
config.srs = srs_read_secrets(argv[optind + 1]);
if (!config.srs
@@
-321,5
+328,5
@@
int main(int argc, char *argv[])
|| start_listener(port_dec, true) < 0) {
return EXIT_FAILURE;
}
|| start_listener(port_dec, true) < 0) {
return EXIT_FAILURE;
}
- return server_loop(srsd_starter, NULL, process_srs, &config);
+ return server_loop(srsd_starter, NULL, process_srs,
NULL,
&config);
}
}