commit - 568a09c220a706cb717f345a4da14e935dca1672
commit + 132cae8c6f2c5866ff84058ac9461ca95d63ed8b
blob - dad0d299000bee04694d47e700b9e2b413f16c4c
blob + 0645dbb9ae6b1b14309ffc0ce2ac483f9596ca76
--- gmid.c
+++ gmid.c
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <err.h>
#include <errno.h>
-
#include <fcntl.h>
#include <limits.h>
#include <netdb.h>
wd = getcwd(NULL, 0);
if (asprintf(&r, "%s/%s", wd, path) == -1)
- err(1, "asprintf");
+ fatal("asprintf: %s", strerror(errno));
free(wd);
return r;
}
errno = 0;
lval = strtol(p, &ep, 10);
if (p[0] == '\0' || *ep != '\0')
- errx(1, "not a number: %s", p);
+ fatal("not a number: %s", p);
if (lval < 0 || lval > UINT16_MAX)
- errx(1, "port number out of range for domain %s: %ld", p, lval);
+ fatal("port number out of range for domain %s: %ld", p, lval);
return lval;
}
parse_conf(const char *path)
{
if ((yyin = fopen(path, "r")) == NULL)
- err(1, "cannot open config %s", path);
+ fatal("cannot open config %s", path);
yyparse();
fclose(yyin);
/* we need to set something, then we can add how many key we want */
if (tls_config_set_keypair_file(tlsconf, hosts->cert, hosts->key))
- errx(1, "tls_config_set_keypair_file failed");
+ fatal("tls_config_set_keypair_file failed");
for (h = hosts; h->domain != NULL; ++h) {
if (tls_config_add_keypair_file(tlsconf, h->cert, h->key) == -1)
- errx(1, "failed to load the keypair (%s, %s)",
+ fatal("failed to load the keypair (%s, %s)",
h->cert, h->key);
if ((h->dirfd = open(h->dir, O_RDONLY | O_DIRECTORY)) == -1)
- err(1, "open %s for domain %s", h->dir, h->domain);
+ fatal("open %s for domain %s", h->dir, h->domain);
}
}
struct tls_config *tlsconf;
if ((tlsconf = tls_config_new()) == NULL)
- err(1, "tls_config_new");
+ fatal("tls_config_new");
/* optionally accept client certs, but don't try to verify them */
tls_config_verify_client_optional(tlsconf);
tls_config_insecure_noverifycert(tlsconf);
if (tls_config_set_protocols(tlsconf, conf.protos) == -1)
- err(1, "tls_config_set_protocols");
+ fatal("tls_config_set_protocols");
if ((ctx = tls_server()) == NULL)
- errx(1, "tls_server failure");
+ fatal("tls_server failure");
load_vhosts(tlsconf);
if (tls_configure(ctx, tlsconf) == -1)
- errx(1, "tls_configure: %s", tls_error(ctx));
+ fatal("tls_configure: %s", tls_error(ctx));
if (!conf.foreground && daemon(0, 1) == -1)
exit(1);
case 'd':
free((char*)hosts[0].dir);
if ((hosts[0].dir = absolutify_path(optarg)) == NULL)
- err(1, "absolutify_path");
+ fatal("absolutify_path");
break;
case 'f':
if (config_path != NULL) {
if (hosts[0].cert != NULL || hosts[0].key != NULL ||
hosts[0].dir != NULL)
- errx(1, "can't specify options in conf mode");
+ fatal("can't specify options in conf mode");
parse_conf(config_path);
} else {
if (hosts[0].cert == NULL || hosts[0].key == NULL ||
hosts[0].dir == NULL)
- errx(1, "missing cert, key or root directory to serve");
+ fatal("missing cert, key or root directory to serve");
hosts[0].domain = "*";
}
- if (conftest)
- errx(0, "config OK");
+ if (conftest) {
+ puts("config OK");
+ return 0;
+ }
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
if (!conf.foreground) {
signal(SIGHUP, SIG_IGN);
if (daemon(1, 1) == -1)
- err(1, "daemon");
+ fatal("daemon: %s", strerror(errno));
}
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) == -1)
blob - bf5f767c91d0db54bb5ef0ca5975b6a7394a57e5
blob + 0ce28d7f3af78cf7a3d2b2c4589653de6e6e0975
--- server.c
+++ server.c
#include <netdb.h>
#include <assert.h>
-#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
if ((c->buf = mmap(NULL, c->len, PROT_READ, MAP_PRIVATE,
c->fd, 0)) == MAP_FAILED) {
- warn("mmap: %s", fpath);
+ LOGW(c, "mmap: %s: %s", fpath, strerror(errno));
goodbye(fds, c);
return 0;
}
err:
/* fatal("cannot talk to the executor process: %s", strerror(errno)); */
- err(1, "cannot talk to the executor process");
+ fatal("cannot talk to the executor process");
}
void
for (;;) {
if (poll(fds, MAX_USERS, INFTIM) == -1) {
if (errno == EINTR) {
- warnx("connected clients: %d",
+ fprintf(stderr, "connected clients: %d\n",
connected_clients);
continue;
}