aboutsummaryrefslogtreecommitdiff
path: root/lib/init
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2020-05-07 22:04:42 +0200
committerDavid Oberhollenzer <goliath@infraroot.at>2020-05-07 22:08:37 +0200
commit13aa3840cc94ce37ef1e63c093c0f71ac84e90fd (patch)
treedb60e6ff38fd7477f5b76cdabcd9277357184b6b /lib/init
parentef0dd7cbe779b879f61bdbaf23a01bc1fb643243 (diff)
Temporarily remove initsock handling code
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'lib/init')
-rw-r--r--lib/init/free_init_status.c10
-rw-r--r--lib/init/init_socket_open.c46
-rw-r--r--lib/init/init_socket_recv_status.c87
-rw-r--r--lib/init/init_socket_send_request.c45
4 files changed, 0 insertions, 188 deletions
diff --git a/lib/init/free_init_status.c b/lib/init/free_init_status.c
deleted file mode 100644
index 945d407..0000000
--- a/lib/init/free_init_status.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: ISC */
-#include <stdlib.h>
-
-#include "initsock.h"
-
-void free_init_status(init_status_t *resp)
-{
- free(resp->filename);
- free(resp->service_name);
-}
diff --git a/lib/init/init_socket_open.c b/lib/init/init_socket_open.c
deleted file mode 100644
index d0cf168..0000000
--- a/lib/init/init_socket_open.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: ISC */
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include "initsock.h"
-
-int init_socket_open(const char *tmppath)
-{
- struct sockaddr_un un;
- int fd;
-
- fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
- if (fd < 0) {
- perror("socket");
- return -1;
- }
-
- memset(&un, 0, sizeof(un));
- un.sun_family = AF_UNIX;
-
- strcpy(un.sun_path, tmppath);
-
- if (bind(fd, (struct sockaddr *)&un, sizeof(un))) {
- fprintf(stderr, "bind: %s: %s", tmppath, strerror(errno));
- close(fd);
- unlink(tmppath);
- return -1;
- }
-
- memset(&un, 0, sizeof(un));
- un.sun_family = AF_UNIX;
-
- strcpy(un.sun_path, INIT_SOCK_PATH);
-
- if (connect(fd, (struct sockaddr *)&un, sizeof(un))) {
- perror("connect: " INIT_SOCK_PATH);
- close(fd);
- return -1;
- }
-
- return fd;
-}
diff --git a/lib/init/init_socket_recv_status.c b/lib/init/init_socket_recv_status.c
deleted file mode 100644
index 996f8de..0000000
--- a/lib/init/init_socket_recv_status.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* SPDX-License-Identifier: ISC */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "initsock.h"
-
-static int read_retry(int fd, void *buffer, size_t size)
-{
- ssize_t ret;
-retry:
- ret = read(fd, buffer, size);
-
- if (ret < 0) {
- if (errno == EINTR)
- goto retry;
- return -1;
- }
-
- if ((size_t)ret < size) {
- errno = EPROTO;
- return 0;
- }
-
- return 1;
-}
-
-static char *read_string(int fd)
-{
- uint16_t len;
- char *buffer;
- int ret;
-
- ret = read_retry(fd, &len, sizeof(len));
- if (ret <= 0)
- return NULL;
-
- len = be16toh(len);
-
- buffer = calloc(1, len + 1);
- if (buffer == NULL)
- return NULL;
-
- if (len > 0) {
- ret = read_retry(fd, buffer, len);
-
- if (ret <= 0) {
- ret = errno;
- free(buffer);
- errno = ret;
- return NULL;
- }
- }
-
- return buffer;
-}
-
-int init_socket_recv_status(int fd, init_status_t *resp)
-{
- init_response_status_t info;
-
- memset(resp, 0, sizeof(*resp));
-
- if (read_retry(fd, &info, sizeof(info)) <= 0)
- return -1;
-
- resp->state = info.state;
- resp->exit_status = info.exit_status;
- resp->id = be32toh(info.id);
-
- if (resp->state == ESS_NONE)
- return 0;
-
- resp->filename = read_string(fd);
- if (resp->filename == NULL)
- return -1;
-
- resp->service_name = read_string(fd);
- if (resp->service_name == NULL)
- return -1;
-
- return 0;
-}
diff --git a/lib/init/init_socket_send_request.c b/lib/init/init_socket_send_request.c
deleted file mode 100644
index 53b31f6..0000000
--- a/lib/init/init_socket_send_request.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: ISC */
-#include <unistd.h>
-#include <string.h>
-#include <stdarg.h>
-#include <endian.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include "initsock.h"
-
-int init_socket_send_request(int fd, E_INIT_REQUEST rq, ...)
-{
- init_request_t request;
- ssize_t ret;
- va_list ap;
-
- memset(&request, 0, sizeof(request));
- request.rq = rq;
-
- va_start(ap, rq);
- switch (rq) {
- case EIR_STATUS:
- request.arg.status.filter = va_arg(ap, E_SERVICE_STATE);
- break;
- case EIR_START:
- case EIR_STOP:
- request.arg.startstop.id = htobe32(va_arg(ap, int));
- break;
- default:
- break;
- }
- va_end(ap);
-
-retry:
- ret = write(fd, &request, sizeof(request));
-
- if (ret < 0) {
- if (errno == EINTR)
- goto retry;
- perror(INIT_SOCK_PATH);
- return -1;
- }
-
- return 0;
-}