aboutsummaryrefslogtreecommitdiff
path: root/lib
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
parentef0dd7cbe779b879f61bdbaf23a01bc1fb643243 (diff)
Temporarily remove initsock handling code
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makemodule.am3
-rw-r--r--lib/include/initsock.h65
-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
6 files changed, 0 insertions, 256 deletions
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index d8b94c8..fa8789b 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -1,9 +1,6 @@
libinit_a_SOURCES = lib/init/delsvc.c lib/init/svcmap.c lib/init/rdsvc.c
libinit_a_SOURCES += lib/init/svcscan.c lib/init/del_svc_list.c
libinit_a_SOURCES += lib/init/svc_tsort.c lib/include/service.h
-libinit_a_SOURCES += lib/init/init_socket_open.c lib/init/free_init_status.c
-libinit_a_SOURCES += lib/include/initsock.h lib/init/init_socket_send_request.c
-libinit_a_SOURCES += lib/init/init_socket_recv_status.c
libinit_a_CPPFLAGS = $(AM_CPPFLAGS)
libinit_a_CFLAGS = $(AM_CFLAGS)
diff --git a/lib/include/initsock.h b/lib/include/initsock.h
deleted file mode 100644
index ef8b9e3..0000000
--- a/lib/include/initsock.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* SPDX-License-Identifier: ISC */
-#ifndef INITSOCK_H
-#define INITSOCK_H
-
-#include <stdint.h>
-
-#include "config.h"
-#include "service.h"
-
-#define INIT_SOCK_PATH SOCKDIR "/init.sock"
-
-typedef enum {
- EIR_STATUS = 0x00,
- EIR_START = 0x01,
- EIR_STOP = 0x02,
-} E_INIT_REQUEST;
-
-typedef enum {
- ESS_NONE = 0x00,
- ESS_RUNNING = 0x01,
- ESS_ENQUEUED = 0x02,
- ESS_DONE = 0x03,
- ESS_FAILED = 0x04
-} E_SERVICE_STATE;
-
-typedef struct {
- uint8_t rq;
- uint8_t padd[3];
-
- union {
- struct {
- uint8_t filter;
- uint8_t padd[3];
- } status;
-
- struct {
- uint32_t id;
- } startstop;
- } arg;
-} init_request_t;
-
-typedef struct {
- uint8_t state;
- uint8_t exit_status;
- uint8_t padd[2];
- int32_t id;
-} init_response_status_t;
-
-typedef struct {
- E_SERVICE_STATE state;
- int exit_status;
- int id;
- char *filename;
- char *service_name;
-} init_status_t;
-
-int init_socket_open(const char *tmppath);
-
-int init_socket_send_request(int fd, E_INIT_REQUEST rq, ...);
-
-int init_socket_recv_status(int fd, init_status_t *resp);
-
-void free_init_status(init_status_t *resp);
-
-#endif /* INITSOCK_H */
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;
-}