X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/23e64f6d0facf9610c1042326ad9850e071e8349..8d1cb6da6e21302c654da3f09de3975af7e4a11f:/methods/rsh.cc diff --git a/methods/rsh.cc b/methods/rsh.cc index bcd688833..74a908ef7 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -34,7 +33,6 @@ #include /*}}}*/ -const char *Prog; unsigned long TimeOut = 120; Configuration::Item const *RshOptions = 0; time_t RSHMethod::FailTime = 0; @@ -44,8 +42,8 @@ int RSHMethod::FailFd = -1; // 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'; } /*}}}*/ @@ -128,7 +126,7 @@ bool RSHConn::Connect(std::string Host, unsigned int Port, std::string User) // 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; @@ -399,6 +397,10 @@ RSHMethod::RSHMethod(std::string const &pProg) : aptMethod(pProg.c_str(),"1.0",S // --------------------------------------------------------------------- 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::") + Prog + "::APT::Sandbox::User", ""); + if (aptMethod::Configuration(Message) == false) return false; @@ -443,7 +445,7 @@ bool RSHMethod::Fetch(FetchItem *Itm) // Connect to the server if (Server == 0 || Server->Comp(Get) == false) { delete Server; - Server = new RSHConn(Get); + Server = new RSHConn(Prog, Get); } // Could not connect is a transient error.. @@ -544,8 +546,5 @@ bool RSHMethod::Fetch(FetchItem *Itm) int main(int, const char *argv[]) { - setlocale(LC_ALL, ""); - - RSHMethod Mth(flNotDir(argv[0])); - return Mth.Run(); + return RSHMethod(flNotDir(argv[0])).Run(); }