use fatal() in code used in the daemon

This commit is contained in:
Omar Polo 2023-06-06 11:52:43 +00:00
parent bc525c73db
commit 2dd5994ae1
4 changed files with 12 additions and 12 deletions

4
fcgi.c
View File

@ -244,14 +244,14 @@ fcgi_read(struct bufferevent *bev, void *d)
struct sockaddr_un addr;
if ((debug_socket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
err(1, "socket");
fatal("socket");
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strlcpy(addr.sun_path, "./debug.sock", sizeof(addr.sun_path));
if (connect(debug_socket, (struct sockaddr*)&addr, sizeof(addr))
== -1)
err(1, "connect");
fatal("connect");
}
#endif

14
ge.c
View File

@ -56,9 +56,9 @@ load_local_cert(struct vhost *h, const char *hostname, const char *dir)
char *cert, *key;
if (asprintf(&cert, "%s/%s.cert.pem", dir, hostname) == -1)
errx(1, "asprintf");
fatal("asprintf");
if (asprintf(&key, "%s/%s.key.pem", dir, hostname) == -1)
errx(1, "asprintf");
fatal("asprintf");
if (access(cert, R_OK) == -1 || access(key, R_OK) == -1)
gen_certificate(hostname, cert, key);
@ -102,12 +102,12 @@ data_dir(void)
if ((xdg = getenv("XDG_DATA_HOME")) == NULL) {
if ((home = getenv("HOME")) == NULL)
errx(1, "XDG_DATA_HOME and HOME both empty");
fatalx("XDG_DATA_HOME and HOME both empty");
if (asprintf(&t, "%s/.local/share/gmid", home) == -1)
err(1, "asprintf");
fatalx("asprintf");
} else {
if (asprintf(&t, "%s/gmid", xdg) == -1)
err(1, "asprintf");
fatal("asprintf");
}
mkdirs(t, 0755);
@ -120,11 +120,11 @@ logger_init(void)
int p[2];
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) == -1)
err(1, "socketpair");
fatal("socketpair");
switch (fork()) {
case -1:
err(1, "fork");
fatal("fork");
case 0:
close(p[0]);
setproctitle("logger");

View File

@ -675,7 +675,7 @@ lungetc(int c)
if (file->ungetpos >= file->ungetsize) {
void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
if (p == NULL)
err(1, "lungetc");
fatal("lungetc");
file->ungetbuf = p;
file->ungetsize *= 2;
}
@ -809,7 +809,7 @@ top:
}
yylval.v.string = strdup(buf);
if (yylval.v.string == NULL)
err(1, "yylex: strdup");
fatal("yylex: strdup");
return STRING;
}

View File

@ -47,7 +47,7 @@ void
sandbox_logger_process(void)
{
if (pledge("stdio recvfd", NULL) == -1)
err(1, "pledge");
fatal("pledge");
}
#else