From 123639e3db0757fb3370516f7eaf50cbfae4d026 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 7 Sep 2026 08:12:24 +0100 Subject: delete util/libreboot-utils (unused code) this was an intense audit of nvmutil that somehow evolved into writing a new, hardened implementation of mktemp. it all works, a few memory bugs to solve on bsd, but i don't see the point in keeping it. mktemp is fine, and nvmutil already works. lbutils implemented atomic writes and integrity checking, in a manner completely overengineered for what it was actually doing (modifying a few bytes in 8KB GbE files) just delete it. i'll bring it back if i ever finish the code. i don't want to leave dead/unfinished code in the tree. Signed-off-by: Leah Rowe --- util/libreboot-utils/nvmutil.c | 134 ----------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 util/libreboot-utils/nvmutil.c (limited to 'util/libreboot-utils/nvmutil.c') diff --git a/util/libreboot-utils/nvmutil.c b/util/libreboot-utils/nvmutil.c deleted file mode 100644 index 67b01ae7..00000000 --- a/util/libreboot-utils/nvmutil.c +++ /dev/null @@ -1,134 +0,0 @@ -/* SPDX-License-Identifier: MIT ( >:3 ) - * Copyright (c) 2022-2026 Leah Rowe /| |\ - * / \ - * This tool lets you modify Intel GbE NVM (Gigabit Ethernet - * Non-Volatile Memory) images, e.g. change the MAC address. - * These images configure your Intel Gigabit Ethernet adapter. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "include/common.h" - -static void -exit_cleanup(void); - -int -main(int argc, char *argv[]) -{ -#ifndef __linux__ -#error This code is currently buggy on BSD systems. Only use on Linux. -#endif - struct xstate *x; - struct commands *cmd; - struct xfile *f; - size_t c; - - (void) lbsetprogname(argv[0]); - if (argc < 3) - usage(); - - (void) errhook(exit_cleanup); - -#ifdef __OpenBSD - /* https://man.openbsd.org/pledge.2 */ - /* https://man.openbsd.org/unveil.2 */ - if (pledge("stdio flock rpath wpath cpath unveil", NULL) == -1) - exitf("pledge"); - if (unveil("/dev/urandom", "r") == -1) - exitf("unveil"); -#endif - -#ifndef S_ISREG - exitf( - "Can't determine file types (S_ISREG undefined)"); -#endif -#if ((CHAR_BIT) != 8) - exitf("Unsupported char size"); -#endif - - if ((x = xstart(argc, argv)) == NULL) - exitf("NULL state on init"); - - /* parse user command */ -/* TODO: CHECK ACCESSES VIA xstatus() */ - set_cmd(argc, argv); - set_cmd_args(argc, argv); - - cmd = &x->cmd[x->i]; - f = &x->f; - -#ifdef __OpenBSD__ - if ((cmd->flags & O_ACCMODE) == O_RDONLY) { - if (unveil(f->fname, "r") == -1) - exitf("unveil"); - } else { - if (unveil(f->fname, "rwc") == -1) - exitf("unveil"); - } - - if (unveil(f->tname, "rwc") == -1) - exitf("unveil"); - if (unveil(NULL, NULL) == -1) - exitf("unveil"); - if (pledge("stdio flock rpath wpath cpath", NULL) == -1) - exitf("pledge"); -#endif - - if (cmd->run == NULL) - exitf("Command not set"); - - sanitize_command_list(); - open_gbe_file(); - copy_gbe(); - read_checksums(); - cmd->run(); - - for (c = 0; c < items(x->cmd); c++) - x->cmd[c].run = cmd_helper_err; - - if ((cmd->flags & O_ACCMODE) == O_RDWR) - write_to_gbe_bin(); - - exit_cleanup(); - if (f->io_err_gbe_bin) - exitf("%s: error writing final file"); - - free_and_set_null(&f->tname); - - return EXIT_SUCCESS; -} - -static void -exit_cleanup(void) -{ - struct xstate *x; - struct xfile *f; - - x = xstatus(); - if (x == NULL) - return; - - f = &x->f; - - /* close fds if still open */ - xclose(&f->tmp_fd); - xclose(&f->gbe_fd); - - /* unlink tmpfile if it exists */ - if (f->tname != NULL) { - (void) unlink(f->tname); - free_and_set_null(&f->tname); - } -} -- cgit v1.2.1