summaryrefslogtreecommitdiff
path: root/cmdline/apt-helper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline/apt-helper.cc')
-rw-r--r--cmdline/apt-helper.cc32
1 files changed, 8 insertions, 24 deletions
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index 63f70983c..a97fc903f 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -48,9 +48,8 @@ static bool DoDownloadFile(CommandLine &CmdL)
if (CmdL.FileSize() <= 2)
return _error->Error(_("Must specify at least one pair url/filename"));
- pkgAcquire Fetcher;
- AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
- Fetcher.Setup(&Stat);
+ AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
+ pkgAcquire Fetcher(&Stat);
size_t fileind = 0;
std::vector<std::string> targetfiles;
@@ -68,6 +67,9 @@ static bool DoDownloadFile(CommandLine &CmdL)
fileind += 3;
}
+ // Disable drop-privs if "_apt" can not write to the target dir
+ CheckDropPrivsMustBeDisabled(Fetcher);
+
bool Failed = false;
if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
return _error->Error(_("Download Failed"));
@@ -81,8 +83,7 @@ static bool DoDownloadFile(CommandLine &CmdL)
static bool ShowHelp(CommandLine &)
{
- ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
- COMMON_ARCH,__DATE__,__TIME__);
+ ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
if (_config->FindB("version") == true)
return true;
@@ -117,25 +118,8 @@ int main(int argc,const char *argv[]) /*{{{*/
textdomain(PACKAGE);
// Parse the command line and initialize the package library
- CommandLine CmdL(Args.data(),_config);
- if (pkgInitConfig(*_config) == false ||
- CmdL.Parse(argc,argv) == false ||
- pkgInitSystem(*_config,_system) == false)
- {
- if (_config->FindB("version") == true)
- ShowHelp(CmdL);
- _error->DumpErrors();
- return 100;
- }
-
- // See if the help should be shown
- if (_config->FindB("help") == true ||
- _config->FindB("version") == true ||
- CmdL.FileSize() == 0)
- {
- ShowHelp(CmdL);
- return 0;
- }
+ CommandLine CmdL;
+ ParseCommandLine(CmdL, Cmds, Args.data(), &_config, &_system, argc, argv, ShowHelp);
InitOutput();