Преглед изворни кода

merged from apt-authentication-reliability

Michael Vogt пре 18 година
родитељ
комит
e779ece477
5 измењених фајлова са 64 додато и 8 уклоњено
  1. 1 0
      apt-pkg/acquire-item.cc
  2. 3 1
      apt-pkg/deb/dpkgpm.cc
  3. 38 3
      cmdline/apt-key
  4. 11 1
      debian/changelog
  5. 11 3
      test/pre-upload-check.py

+ 1 - 0
apt-pkg/acquire-item.cc

@@ -1229,6 +1229,7 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 			   "GPG error: %s: %s\n"),
 			   "GPG error: %s: %s\n"),
 			 Desc.Description.c_str(),
 			 Desc.Description.c_str(),
 			 LookupTag(Message,"Message").c_str());
 			 LookupTag(Message,"Message").c_str());
+	 RunScripts("APT::Update::Auth-Failure");
 	 return;
 	 return;
       } else {
       } else {
 	 _error->Warning(_("GPG error: %s: %s"),
 	 _error->Warning(_("GPG error: %s: %s"),

+ 3 - 1
apt-pkg/deb/dpkgpm.cc

@@ -704,14 +704,16 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN);
       sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN);
 
 
       struct	termios tt;
       struct	termios tt;
+      struct	termios tt_out;
       struct	winsize win;
       struct	winsize win;
       int	master;
       int	master;
       int	slave;
       int	slave;
 
 
       // FIXME: setup sensible signal handling (*ick*)
       // FIXME: setup sensible signal handling (*ick*)
       tcgetattr(0, &tt);
       tcgetattr(0, &tt);
+      tcgetattr(1, &tt_out);
       ioctl(0, TIOCGWINSZ, (char *)&win);
       ioctl(0, TIOCGWINSZ, (char *)&win);
-      if (openpty(&master, &slave, NULL, &tt, &win) < 0) 
+      if (openpty(&master, &slave, NULL, &tt_out, &win) < 0) 
       {
       {
 	 const char *s = _("Can not write log, openpty() "
 	 const char *s = _("Can not write log, openpty() "
 			   "failed (/dev/pts not mounted?)\n");
 			   "failed (/dev/pts not mounted?)\n");

+ 38 - 3
cmdline/apt-key

@@ -9,9 +9,38 @@ GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-k
 GPG="$GPG_CMD --keyring /etc/apt/trusted.gpg"
 GPG="$GPG_CMD --keyring /etc/apt/trusted.gpg"
 
 
 
 
+MASTER_KEYRING=/usr/share/keyrings/ubuntu-master-keyring.gpg
 ARCHIVE_KEYRING=/usr/share/keyrings/ubuntu-archive-keyring.gpg
 ARCHIVE_KEYRING=/usr/share/keyrings/ubuntu-archive-keyring.gpg
 REMOVED_KEYS=/usr/share/keyrings/ubuntu-archive-removed-keys.gpg
 REMOVED_KEYS=/usr/share/keyrings/ubuntu-archive-removed-keys.gpg
 
 
+add_keys_with_verify_against_master_keyring() {
+    ADD_KEYRING=$1
+    MASTER=$2
+    
+    if [ ! -f "$ADD_KEYRING" ]; then
+	echo "ERROR: '$ADD_KEYRING' not found"
+	return
+    fi 
+    if [ ! -f "$MASTER" ]; then
+	echo "ERROR: '$MASTER' not found"
+	return
+    fi
+
+    # when adding new keys, make sure that the archive-master-keyring
+    # is honored. so:
+    #   all keys that are exported and have the name
+    #   "Ubuntu Archive Automatic Signing Key" must have a valid signature
+    #   from a key in the ubuntu-master-keyring
+    add_keys=`$GPG_CMD --keyring $ADD_KEYRING --with-colons --list-keys | grep ^pub | cut -d: -f5`
+    master_keys=`$GPG_CMD --keyring $MASTER --with-colons --list-keys | grep ^pub | cut -d: -f5`
+    for add_key in $add_keys; do
+	for master_key in $master_keys; do
+	    if $GPG --list-sigs --with-colons $add_key | grep ^sig | cut -d: -f5 | grep -q $master_key; then
+		$GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export $add_key | $GPG --import
+	    fi
+	done
+    done
+}
 
 
 update() {
 update() {
     if [ ! -f $ARCHIVE_KEYRING ]; then
     if [ ! -f $ARCHIVE_KEYRING ]; then
@@ -20,10 +49,15 @@ update() {
 	exit 1
 	exit 1
     fi
     fi
 
 
-    # add new keys
-    $GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import
+    # add new keys, if no MASTER_KEYRING is used, use the traditional
+    # way
+    if [ -z "$MASTER_KEYRING" ]; then
+	$GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import
+    else
+	add_keys_with_verify_against_master_keyring $ARCHIVE_KEYRING $MASTER_KEYRING
+    fi
 
 
-    # remove no-longer used keys
+    # remove no-longer supported/used keys
     keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5`
     keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5`
     for key in $keys; do
     for key in $keys; do
 	if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then
 	if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then
@@ -32,6 +66,7 @@ update() {
     done
     done
 }
 }
 
 
+
 usage() {
 usage() {
     echo "Usage: apt-key [command] [arguments]"
     echo "Usage: apt-key [command] [arguments]"
     echo
     echo

+ 11 - 1
debian/changelog

@@ -1,10 +1,20 @@
 apt (0.7.9ubuntu6) hardy; urgency=low
 apt (0.7.9ubuntu6) hardy; urgency=low
 
 
+  [ Michael Vogt ]
+  * cmdline/apt-key:
+    - add support for a master-keyring that contains signing keys
+      that can be used to sign the archive signing keys. This should
+      make key-rollover easier.
+  * apt-pkg/deb/dpkgpm.cc:
+    - merged patch from Kees Cook to fix anoying upper-case display
+      on amd64 in sbuild
+  * apt-pkg/algorithms.cc: 
+    - add APT::Update::Post-Invoke-Success script slot
   * apt-pkg/deb/dpkgpm.cc:
   * apt-pkg/deb/dpkgpm.cc:
     - add APT::Apport::MaxReports to limit the maximum number
     - add APT::Apport::MaxReports to limit the maximum number
       of reports generated in a single run (default to 3)
       of reports generated in a single run (default to 3)
 
 
- --
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Mon, 04 Feb 2008 14:28:02 +0100
 
 
 apt (0.7.9ubuntu5) hardy; urgency=low
 apt (0.7.9ubuntu5) hardy; urgency=low
 
 

+ 11 - 3
test/pre-upload-check.py

@@ -25,7 +25,8 @@ class testAptAuthenticationReliability(unittest.TestCase):
     apt = "apt-get"
     apt = "apt-get"
 
 
     def setUp(self):
     def setUp(self):
-        pass
+        if os.path.exists("/tmp/autFailure"):
+            os.unlink("/tmp/authFailure");
     def testRepositorySigFailure(self):
     def testRepositorySigFailure(self):
         """
         """
         test if a repository that used to be authenticated and fails on
         test if a repository that used to be authenticated and fails on
@@ -39,26 +40,33 @@ class testAptAuthenticationReliability(unittest.TestCase):
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
         res = call([self.apt,
         res = call([self.apt,
                     "update",
                     "update",
-                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure"
+                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure", 
+                    "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure',
                    ] + apt_args,
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
                    stdout=stdout, stderr=stderr)
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
                      "The gpg file disappeared, this should not happen")
                      "The gpg file disappeared, this should not happen")
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
                      "The Packages file disappeared, this should not happen")
                      "The Packages file disappeared, this should not happen")
+        self.assert_(os.path.exists("/tmp/authFailure"),
+                     "The APT::Update::Auth-Failure script did not run")
+        os.unlink("/tmp/authFailure");
         # the same with i-m-s hit this time
         # the same with i-m-s hit this time
         for f in glob.glob("./authReliability/lists/*"):
         for f in glob.glob("./authReliability/lists/*"):
             shutil.copy(f,"/var/lib/apt/lists")
             shutil.copy(f,"/var/lib/apt/lists")
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
         res = call([self.apt,
         res = call([self.apt,
                     "update",
                     "update",
-                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure"
+                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure",
+                    "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure',
                    ] + apt_args,
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
                    stdout=stdout, stderr=stderr)
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
                      "The gpg file disappeared, this should not happen")
                      "The gpg file disappeared, this should not happen")
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
                      "The Packages file disappeared, this should not happen")
                      "The Packages file disappeared, this should not happen")
+        self.assert_(os.path.exists("/tmp/authFailure"),
+                     "The APT::Update::Auth-Failure script did not run")
     def testRepositorySigGood(self):
     def testRepositorySigGood(self):
         """
         """
         test that a regular repository with good data stays good
         test that a regular repository with good data stays good