Remove device renaming and select default device (#48)
This commit is contained in:
17
configure.ac
17
configure.ac
@@ -88,26 +88,9 @@ AC_ARG_WITH([static-libgcc],
|
|||||||
],
|
],
|
||||||
[AC_MSG_RESULT(no)])
|
[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])
|
AC_CHECK_PROG(PANDOC, [pandoc], [yes])
|
||||||
AM_CONDITIONAL([FOUND_PANDOC], [test "x$PANDOC" = xyes])
|
AM_CONDITIONAL([FOUND_PANDOC], [test "x$PANDOC" = xyes])
|
||||||
AM_COND_IF([FOUND_PANDOC],,[AC_MSG_ERROR([required program 'pandoc' not found.])])
|
AM_COND_IF([FOUND_PANDOC],,[AC_MSG_ERROR([required program 'pandoc' not found.])])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile tests/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile tests/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
|
|||||||
26
src/main.cpp
26
src/main.cpp
@@ -28,6 +28,7 @@ GNU General Public License for more details.
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sys/mtio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -132,7 +133,7 @@ int main(int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tapeDrive = "";
|
std::string tapeDrive;
|
||||||
int action = 0; // 0 = status, 1 =setting param, 2 = generating key
|
int action = 0; // 0 = status, 1 =setting param, 2 = generating key
|
||||||
std::string keyFile, keyDesc;
|
std::string keyFile, keyDesc;
|
||||||
int keyLength = 0;
|
int keyLength = 0;
|
||||||
@@ -248,9 +249,14 @@ int main(int argc, char **argv) {
|
|||||||
std::cout << "Permissions of keyfile set to 600\n";
|
std::cout << "Permissions of keyfile set to 600\n";
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
// validate the tape device
|
// select device from env variable or system default if not given with -f
|
||||||
if (tapeDrive == "") {
|
if (tapeDrive.empty()) {
|
||||||
errorOut("Tape drive device must be specified with the -f option");
|
const char *env_tape = getenv("TAPE");
|
||||||
|
if (env_tape != nullptr) {
|
||||||
|
tapeDrive = env_tape;
|
||||||
|
} else {
|
||||||
|
tapeDrive = DEFTAPE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (drvOptions.cryptMode == CRYPTMODE_RAWREAD &&
|
if (drvOptions.cryptMode == CRYPTMODE_RAWREAD &&
|
||||||
drvOptions.rdmc == RDMC_PROTECT) {
|
drvOptions.rdmc == RDMC_PROTECT) {
|
||||||
@@ -258,18 +264,6 @@ int main(int argc, char **argv) {
|
|||||||
"'--protect' is not valid when setting encryption mode to 'rawread'");
|
"'--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) {
|
if (getuid() != 0) {
|
||||||
errorOut("You must be root to read or set encryption options on a drive!");
|
errorOut("You must be root to read or set encryption options on a drive!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user