termux-packages/packages/apt/0012-verify-prefix.patch.txt

31 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-11-05 16:05:50 +01:00
diff -uNr apt-2.1.11/cmdline/apt.cc apt-2.1.11.mod/cmdline/apt.cc
--- apt-2.1.11/cmdline/apt.cc 2020-11-05 16:56:10.361005861 +0200
+++ apt-2.1.11.mod/cmdline/apt.cc 2020-11-05 17:03:32.752181628 +0200
@@ -106,6 +106,26 @@
return 1;
}
+ // Reversed /data/data/com.termux/files/usr. Prevents patching with 'sed'
+ // by using equal-size prefixes.
+ const char termux_prefix_obfs[] = "rsu/selif/xumret.moc/atad/atad/";
+ char termux_prefix[sizeof(termux_prefix_obfs)/sizeof(char)] = {0};
+ int termux_prefix_len = sizeof(termux_prefix_obfs)/sizeof(char) - 1;
+
+ // Decode.
+ for (int i=0; i<termux_prefix_len; i++) {
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
+ }
+
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
+ // If checks failed, then we probably running in incompatible environment.
+ // In this case warn user and exit with status 1.
+ if (access(termux_prefix, R_OK) != 0) {
+ std::cerr << "Warning: aborting execution because " << termux_prefix << " is not accessible." << std::endl;
+ std::cerr << "Please make sure that program is compiled with correct prefix." << std::endl;
+ return 1;
+ }
+
CommandLine CmdL;
auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);