From e0c59cc341a02d28287153f1f417530def07c3f2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 3 Jun 2021 17:05:54 -0400 Subject: [PATCH] Fixup c utilities and add start_root The diskless will use start_root to boot the 'main' OS as a container. --- confluent_osdeploy/utils/Makefile | 2 +- confluent_osdeploy/utils/autocons.c | 2 +- confluent_osdeploy/utils/clortho.c | 4 ++-- confluent_osdeploy/{diskless/initramfs => utils}/start_root.c | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename confluent_osdeploy/{diskless/initramfs => utils}/start_root.c (100%) diff --git a/confluent_osdeploy/utils/Makefile b/confluent_osdeploy/utils/Makefile index 801fffd9..dccb3bc9 100644 --- a/confluent_osdeploy/utils/Makefile +++ b/confluent_osdeploy/utils/Makefile @@ -1,6 +1,6 @@ CC := gcc CFLAGS := -Os -TARGETS := copernicus autocons +TARGETS := copernicus autocons start_root all: $(TARGETS) clortho diff --git a/confluent_osdeploy/utils/autocons.c b/confluent_osdeploy/utils/autocons.c index 6f1ce935..05cd4407 100644 --- a/confluent_osdeploy/utils/autocons.c +++ b/confluent_osdeploy/utils/autocons.c @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) { timeout.tv_usec = 500000; FD_ZERO(&set); FD_SET(ttyf, &set); - write(ttyf, "\0337\033[999;999H\033[6n\0338", 18); + if (write(ttyf, "\0337\033[999;999H\033[6n\0338", 18) < 0) {}; while (select(ttyf + 1, &set, NULL, NULL, &timeout) > 0) { if ((tmpi = read(ttyf, buff + bufflen, 127 - bufflen)) < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) { diff --git a/confluent_osdeploy/utils/clortho.c b/confluent_osdeploy/utils/clortho.c index ef58e6b8..53480ded 100644 --- a/confluent_osdeploy/utils/clortho.c +++ b/confluent_osdeploy/utils/clortho.c @@ -116,7 +116,7 @@ int main(int argc, char* argv[]) { currtype = buffer[0]; if (currtype & 0b10000000) { currlen = buffer[1] << 8; - read(sock, buffer, 1); + while (read(sock, buffer, 1) < 0) {}; currlen |= buffer[0]; } else { currlen = buffer[1]; @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) { buffer[currlen] = 0; } if (currtype == 2) { - dprintf(sock, "\x03%c", currlen); + dprintf(sock, "\x03%zu", currlen); ret = write(sock, buffer, currlen); slen = strlen(cryptedpass) & 0xff; dprintf(sock, "\x04%c%s", slen, cryptedpass); diff --git a/confluent_osdeploy/diskless/initramfs/start_root.c b/confluent_osdeploy/utils/start_root.c similarity index 100% rename from confluent_osdeploy/diskless/initramfs/start_root.c rename to confluent_osdeploy/utils/start_root.c