#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <stdlib.h>
#include <apti18n.h>
/*}}}*/
-const char *Prog;
unsigned long TimeOut = 120;
Configuration::Item const *RshOptions = 0;
time_t RSHMethod::FailTime = 0;
// RSHConn::RSHConn - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-RSHConn::RSHConn(URI Srv) : Len(0), WriteFd(-1), ReadFd(-1),
- ServerName(Srv), Process(-1) {
+RSHConn::RSHConn(std::string const &pProg, URI Srv) : Len(0), WriteFd(-1), ReadFd(-1),
+ ServerName(Srv), Prog(pProg), Process(-1) {
Buffer[0] = '\0';
}
/*}}}*/
// Probably should do
// dup2(open("/dev/null",O_RDONLY),STDERR_FILENO);
- Args[i++] = Prog;
+ Args[i++] = Prog.c_str();
// Insert user-supplied command line options
Configuration::Item const *Opts = RshOptions;
/*}}}*/
// RSHMethod::RSHMethod - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-RSHMethod::RSHMethod(std::string const &pProg) : aptMethod(pProg.c_str(),"1.0",SendConfig), Prog(pProg)
+RSHMethod::RSHMethod(std::string &&pProg) : aptMethod(std::move(pProg),"1.0",SendConfig)
{
signal(SIGTERM,SigTerm);
signal(SIGINT,SigTerm);
// ---------------------------------------------------------------------
bool RSHMethod::Configuration(std::string Message)
{
+ // enabling privilege dropping for this method requires configuration…
+ // … which is otherwise lifted straight from root, so use it by default.
+ _config->Set(std::string("Binary::") + Binary + "::APT::Sandbox::User", "");
+
if (aptMethod::Configuration(Message) == false)
return false;
- std::string const timeconf = std::string("Acquire::") + Prog + "::Timeout";
+ std::string const timeconf = std::string("Acquire::") + Binary + "::Timeout";
TimeOut = _config->FindI(timeconf, TimeOut);
- std::string const optsconf = std::string("Acquire::") + Prog + "::Options";
+ std::string const optsconf = std::string("Acquire::") + Binary + "::Options";
RshOptions = _config->Tree(optsconf.c_str());
return true;
// Connect to the server
if (Server == 0 || Server->Comp(Get) == false) {
delete Server;
- Server = new RSHConn(Get);
+ Server = new RSHConn(Binary, Get);
}
// Could not connect is a transient error..
int main(int, const char *argv[])
{
- setlocale(LC_ALL, "");
-
- RSHMethod Mth(flNotDir(argv[0]));
- return Mth.Run();
+ return RSHMethod(flNotDir(argv[0])).Run();
}