From 7dd4d665b2700de297a916cc80f392e265f48ed7 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Sun, 8 May 2022 15:41:30 -0700 Subject: [PATCH] Remove device renaming and select default device --- configure.ac | 17 ----------------- src/main.cpp | 26 ++++++++++---------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index b63a91f..d971996 100644 --- a/configure.ac +++ b/configure.ac @@ -88,26 +88,9 @@ AC_ARG_WITH([static-libgcc], ], [AC_MSG_RESULT(no)]) - -AC_MSG_CHECKING(whether to convert rewinding device names to non-rewinding device names) -AC_ARG_ENABLE([device-name-conversion], - [AS_HELP_STRING([--enable-device-name-conversion],[converts /dev/st* to /dev/st*.1 and /dev/rmt* to /dev/rmt*.1 to prevent rewinds. Enabled by default.])], - [enable_dnc=$enableval], - [enable_dnc="yes"] - ) - -if test "$enable_dnc" = "yes"; then - AC_MSG_RESULT(yes) -else - AC_DEFINE(DISABLE_DEVICE_NAME_CONVERSION,1,"") - AC_MSG_RESULT(no) -fi - - AC_CHECK_PROG(PANDOC, [pandoc], [yes]) AM_CONDITIONAL([FOUND_PANDOC], [test "x$PANDOC" = xyes]) AM_COND_IF([FOUND_PANDOC],,[AC_MSG_ERROR([required program 'pandoc' not found.])]) AC_CONFIG_FILES([Makefile src/Makefile man/Makefile tests/Makefile]) AC_OUTPUT - diff --git a/src/main.cpp b/src/main.cpp index 8121439..560bcb9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,7 @@ GNU General Public License for more details. #include #include #include +#include #include #include #include @@ -132,7 +133,7 @@ int main(int argc, char **argv) { break; } - std::string tapeDrive = ""; + std::string tapeDrive; int action = 0; // 0 = status, 1 =setting param, 2 = generating key std::string keyFile, keyDesc; int keyLength = 0; @@ -248,9 +249,14 @@ int main(int argc, char **argv) { std::cout << "Permissions of keyfile set to 600\n"; exit(EXIT_SUCCESS); } - // validate the tape device - if (tapeDrive == "") { - errorOut("Tape drive device must be specified with the -f option"); + // select device from env variable or system default if not given with -f + if (tapeDrive.empty()) { + const char *env_tape = getenv("TAPE"); + if (env_tape != nullptr) { + tapeDrive = env_tape; + } else { + tapeDrive = DEFTAPE; + } } if (drvOptions.cryptMode == CRYPTMODE_RAWREAD && drvOptions.rdmc == RDMC_PROTECT) { @@ -258,18 +264,6 @@ int main(int argc, char **argv) { "'--protect' is not valid when setting encryption mode to 'rawread'"); } -#ifndef DISABLE_DEVICE_NAME_CONVERSION - if (tapeDrive.find(".") == std::string::npos) { - if (tapeDrive.substr(0, 7) == "/dev/st") { - tapeDrive = "/dev/nst" + tapeDrive.substr(7, tapeDrive.size() - 6); - } - - if (tapeDrive.substr(0, 8) == "/dev/rmt" && - tapeDrive.substr(tapeDrive.size() - 2, 2) != ".1") { - tapeDrive = "/dev/rmt" + tapeDrive.substr(8, tapeDrive.size() - 7) + ".1"; - } - } -#endif if (getuid() != 0) { errorOut("You must be root to read or set encryption options on a drive!"); }