mirror of https://github.com/omar-polo/gmid.git
Compare commits
2 Commits
2a822b03ba
...
83a2644bfb
Author | SHA1 | Date |
---|---|---|
Omar Polo | 83a2644bfb | |
Omar Polo | 4f3b85e6d7 |
10
config.c
10
config.c
|
@ -479,9 +479,9 @@ config_crypto_recv_kp(struct conf *conf, struct imsg *imsg)
|
|||
/* XXX: check for duplicates */
|
||||
|
||||
if ((fd = imsg_get_fd(imsg)) == -1)
|
||||
fatalx("no fd for imsg %d", imsg->hdr.type);
|
||||
fatalx("%s: no fd for imsg %d", __func__, imsg_get_type(imsg));
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_CERT:
|
||||
if (pki != NULL)
|
||||
fatalx("imsg in wrong order; pki is not NULL");
|
||||
|
@ -497,8 +497,8 @@ config_crypto_recv_kp(struct conf *conf, struct imsg *imsg)
|
|||
|
||||
case IMSG_RECONF_KEY:
|
||||
if (pki == NULL)
|
||||
fatalx("got key without cert beforehand %d",
|
||||
imsg->hdr.type);
|
||||
fatalx("%s: RECONF_KEY: got key without cert",
|
||||
__func__);
|
||||
if (load_file(fd, &d, &len) == -1)
|
||||
fatalx("failed to load private key");
|
||||
if ((pki->pkey = ssl_load_pkey(d, len)) == NULL)
|
||||
|
@ -533,7 +533,7 @@ config_recv(struct conf *conf, struct imsg *imsg)
|
|||
size_t len;
|
||||
int fd;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_START:
|
||||
config_purge(conf);
|
||||
h = NULL;
|
||||
|
|
54
crypto.c
54
crypto.c
|
@ -80,7 +80,7 @@ crypto_init(struct privsep *ps, struct privsep_proc *p, void *arg)
|
|||
static int
|
||||
crypto_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
{
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_START:
|
||||
case IMSG_RECONF_CERT:
|
||||
case IMSG_RECONF_KEY:
|
||||
|
@ -117,25 +117,25 @@ crypto_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
EVP_PKEY *pkey;
|
||||
struct imsg_crypto_req req;
|
||||
struct imsg_crypto_res res;
|
||||
struct ibuf ibuf;
|
||||
struct iovec iov[2];
|
||||
const void *from;
|
||||
unsigned char *data, *to;
|
||||
size_t datalen;
|
||||
int n, ret;
|
||||
unsigned char *to;
|
||||
int n, ret, type;
|
||||
unsigned int len;
|
||||
pid_t pid;
|
||||
|
||||
data = imsg->data;
|
||||
datalen = IMSG_DATA_SIZE(imsg);
|
||||
if (imsg_get_ibuf(imsg, &ibuf) == -1)
|
||||
fatalx("%s: couldn't get an ibuf", __func__);
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
pid = imsg_get_pid(imsg);
|
||||
switch (type = imsg_get_type(imsg)) {
|
||||
case IMSG_CRYPTO_RSA_PRIVENC:
|
||||
case IMSG_CRYPTO_RSA_PRIVDEC:
|
||||
if (datalen < sizeof(req))
|
||||
fatalx("size mismatch for imsg %d", imsg->hdr.type);
|
||||
memcpy(&req, data, sizeof(req));
|
||||
if (datalen != sizeof(req) + req.flen)
|
||||
fatalx("size mismatch for imsg %d", imsg->hdr.type);
|
||||
from = data + sizeof(req);
|
||||
if (ibuf_get(&ibuf, &req, sizeof(req)) == -1 ||
|
||||
ibuf_size(&ibuf) != req.flen)
|
||||
fatalx("size mismatch for imsg %d", type);
|
||||
from = ibuf_data(&ibuf);
|
||||
|
||||
if ((pkey = get_pkey(req.hash)) == NULL ||
|
||||
(rsa = EVP_PKEY_get1_RSA(pkey)) == NULL)
|
||||
|
@ -144,7 +144,7 @@ crypto_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
if ((to = calloc(1, req.tlen)) == NULL)
|
||||
fatal("calloc");
|
||||
|
||||
if (imsg->hdr.type == IMSG_CRYPTO_RSA_PRIVENC)
|
||||
if (type == IMSG_CRYPTO_RSA_PRIVENC)
|
||||
ret = RSA_private_encrypt(req.flen, from,
|
||||
to, rsa, req.padding);
|
||||
else
|
||||
|
@ -168,12 +168,12 @@ crypto_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
n++;
|
||||
}
|
||||
|
||||
log_debug("replying to server #%d", imsg->hdr.pid);
|
||||
if (proc_composev_imsg(ps, PROC_SERVER, imsg->hdr.pid - 1,
|
||||
imsg->hdr.type, 0, -1, iov, n) == -1)
|
||||
log_debug("replying to server #%d", pid);
|
||||
if (proc_composev_imsg(ps, PROC_SERVER, pid - 1,
|
||||
type, 0, -1, iov, n) == -1)
|
||||
fatal("proc_composev_imsg");
|
||||
|
||||
if (proc_flush_imsg(ps, PROC_SERVER, imsg->hdr.pid - 1) == -1)
|
||||
if (proc_flush_imsg(ps, PROC_SERVER, pid - 1) == -1)
|
||||
fatal("proc_flush_imsg");
|
||||
|
||||
free(to);
|
||||
|
@ -181,12 +181,10 @@ crypto_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
break;
|
||||
|
||||
case IMSG_CRYPTO_ECDSA_SIGN:
|
||||
if (datalen < sizeof(req))
|
||||
fatalx("size mismatch for imsg %d", imsg->hdr.type);
|
||||
memcpy(&req, data, sizeof(req));
|
||||
if (datalen != sizeof(req) + req.flen)
|
||||
fatalx("size mismatch for imsg %d", imsg->hdr.type);
|
||||
from = data + sizeof(req);
|
||||
if (ibuf_get(&ibuf, &req, sizeof(req)) == -1 ||
|
||||
ibuf_size(&ibuf) != req.flen)
|
||||
fatalx("size mismatch for imsg %d", type);
|
||||
from = ibuf_data(&ibuf);
|
||||
|
||||
if ((pkey = get_pkey(req.hash)) == NULL ||
|
||||
(ecdsa = EVP_PKEY_get1_EC_KEY(pkey)) == NULL)
|
||||
|
@ -214,12 +212,12 @@ crypto_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
n++;
|
||||
}
|
||||
|
||||
log_debug("replying to server #%d", imsg->hdr.pid);
|
||||
if (proc_composev_imsg(ps, PROC_SERVER, imsg->hdr.pid - 1,
|
||||
imsg->hdr.type, 0, -1, iov, n) == -1)
|
||||
log_debug("replying to server #%d", pid);
|
||||
if (proc_composev_imsg(ps, PROC_SERVER, pid - 1,
|
||||
type, 0, -1, iov, n) == -1)
|
||||
fatal("proc_composev_imsg");
|
||||
|
||||
if (proc_flush_imsg(ps, PROC_SERVER, imsg->hdr.pid - 1) == -1)
|
||||
if (proc_flush_imsg(ps, PROC_SERVER, pid - 1) == -1)
|
||||
fatal("proc_flush_imsg");
|
||||
|
||||
free(to);
|
||||
|
|
6
gmid.c
6
gmid.c
|
@ -526,7 +526,7 @@ main_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
struct privsep *ps = p->p_ps;
|
||||
struct conf *conf = ps->ps_env;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_DONE:
|
||||
main_configure_done(conf);
|
||||
break;
|
||||
|
@ -543,7 +543,7 @@ main_dispatch_crypto(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
struct privsep *ps = p->p_ps;
|
||||
struct conf *conf = ps->ps_env;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_DONE:
|
||||
main_configure_done(conf);
|
||||
break;
|
||||
|
@ -560,7 +560,7 @@ main_dispatch_logger(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
struct privsep *ps = p->p_ps;
|
||||
struct conf *conf = ps->ps_env;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_DONE:
|
||||
main_configure_done(conf);
|
||||
break;
|
||||
|
|
4
logger.c
4
logger.c
|
@ -79,7 +79,7 @@ logger_shutdown(void)
|
|||
static int
|
||||
logger_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
{
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_LOG_FACILITY:
|
||||
if (imsg_get_data(imsg, &facility, sizeof(facility)) == -1)
|
||||
fatal("corrupted IMSG_LOG_SYSLOG");
|
||||
|
@ -108,7 +108,7 @@ logger_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
size_t datalen = 0;
|
||||
struct ibuf ibuf;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_LOG_REQUEST:
|
||||
if (imsg_get_ibuf(imsg, &ibuf) == -1 ||
|
||||
(datalen = ibuf_size(&ibuf)) == 0)
|
||||
|
|
2
server.c
2
server.c
|
@ -1496,7 +1496,7 @@ server_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
|||
struct privsep *ps = p->p_ps;
|
||||
struct conf *conf = ps->ps_env;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
switch (imsg_get_type(imsg)) {
|
||||
case IMSG_RECONF_START:
|
||||
case IMSG_RECONF_LOG_FMT:
|
||||
case IMSG_RECONF_MIME:
|
||||
|
|
Loading…
Reference in New Issue