Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove device renaming and select default device #48

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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

26 changes: 10 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GNU General Public License for more details.
#include <stdint.h>
#include <sstream>
#include <string>
#include <sys/mtio.h>
#include <sys/stat.h>
#include <termios.h>
#include <time.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -248,28 +249,21 @@ 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) {
errorOut(
"'--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!");
}
Expand Down