/******************************************************************************/
-/* postlicyd: a postfix policy daemon with a lot of features */
+/* pfixtools: a collection of postfix related tools */
/* ~~~~~~~~~ */
/* ________________________________________________________________________ */
/* */
#include "mem.h"
#include "buffer.h"
-#define DAEMON_NAME "srsd"
+#define DAEMON_NAME "pfix-srsd"
#define DEFAULT_ENCODER_PORT 10000
#define DEFAULT_DECODER_PORT 10001
#define __tostr(x) #x
int sock;
addr.sin_port = htons(port);
- sock = tcp_listen((const struct sockaddr *)&addr, sizeof(addr));
+ sock = tcp_listen_nonblock((const struct sockaddr *)&addr, sizeof(addr));
if (sock < 0) {
return -1;
}
int n = strlen(buf);
++lineno;
- if (buf[n - 1] != '\n') {
+ if (n == sizeof(buf) - 1 && buf[n - 1] != '\n') {
syslog(LOG_CRIT, "%s:%d: line too long", sfile, lineno);
goto error;
}
-
- srs_add_secret(srs, buf);
+ m_strrtrim(buf);
+ srs_add_secret(srs, skipspaces(buf));
}
if (!lineno) {
return EXIT_FAILURE;
}
+ if (daemon_detach() < 0) {
+ syslog(LOG_CRIT, "unable to fork");
+ return EXIT_FAILURE;
+ }
return main_loop(srs, argv[optind], port_enc, port_dec);
}