summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2014-09-24 21:49:19 +0200
committerJulian Andres Klode <jak@debian.org>2014-09-24 21:49:19 +0200
commit7b18d5592fd5e0bb173e193d1e6693a66065f971 (patch)
treec7485a668a96e6b644adae4b5f46a78827878d98 /apt-pkg
parentf1e3c8f002be54617656fc4ca525c3f1e57323f3 (diff)
methods: Fail if we cannot drop privileges
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-method.cc12
-rw-r--r--apt-pkg/acquire-method.h2
2 files changed, 13 insertions, 1 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index e4a937d1d..82f2fb3ce 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -119,6 +119,18 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
std::cout << "\n" << std::flush;
}
/*}}}*/
+// AcqMethod::DropPrivsOrDie - Drop privileges or die /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqMethod::DropPrivsOrDie()
+{
+ if (!DropPrivs()) {
+ Fail(false);
+ exit(112); /* call the european emergency number */
+ }
+}
+
+ /*}}}*/
// AcqMethod::URIStart - Indicate a download is starting /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index cbf79f860..cdeecc9a7 100644
--- a/apt-pkg/acquire-method.h
+++ b/apt-pkg/acquire-method.h
@@ -105,7 +105,7 @@ class pkgAcqMethod
pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
virtual ~pkgAcqMethod() {};
-
+ void DropPrivsOrDie();
private:
APT_HIDDEN void Dequeue();
};