Package: makejail
Version: 0.0.5-10
Severity: critical
Tags: patch
Justification: breaks unrelated software

Dear Maintainer,

when updating an existing chroot jail, then makejail fails on updating
symbolic links, e.g. for updated libraries.
makejails aborts and leaves the jail in an inconsistent stage.
Reason is that it doesn't recognize existing but broken symbol links.
As a fix I use the attached patch.

-- My error case:
   Checking Depends
        Executing : dpkg -p base-passwd
        Executing : dpkg -l libc6
      Installing the package libc6
         Copying the files from the dpkg information
            ...
            Checking path '/usr/lib/x86_64-linux-gnu/gconv/ASMO_449.so'
               File /usr/lib/x86_64-linux-gnu/gconv/ASMO_449.so is newer
than the /home/maddes/usr/lib/x86_64-linux-gnu/gconv/ASMO_449.so,
overwriting
                 Executing : file
/usr/lib/x86_64-linux-gnu/gconv/ASMO_449.so
                  shared object, checking the required libraries with ldd
                    Executing : ldd
/usr/lib/x86_64-linux-gnu/gconv/ASMO_449.so
                  Checking path '/lib/x86_64-linux-gnu/libc.so.6'
                     File /home/maddes/lib/x86_64-linux-gnu/libc.so.6
already exists
                  Checking path '/lib64/ld-linux-x86-64.so.2'
                     '/lib64/ld-linux-x86-64.so.2' is a symlink to
'/lib/x86_64-linux-gnu/ld-2.19.so'
                     Checking path '/lib/x86_64-linux-gnu/ld-2.19.so'
                        File
/home/maddes/lib/x86_64-linux-gnu/ld-2.19.so already exists
                        Creating 'lib64/ld-linux-x86-64.so.2' as a
symlink to '/lib/x86_64-linux-gnu/ld-2.19.so' (pwd=/home/maddes/lib64)
Traceback (most recent call last):
  File "/usr/sbin/makejail", line 1060, in <module>
    makeChroot()
  File "/usr/sbin/makejail", line 888, in makeChroot
    addPackageToJail(package)
  File "/usr/sbin/makejail", line 585, in addPackageToJail
    addPackageToJail(depend)
  File "/usr/sbin/makejail", line 576, in addPackageToJail
    addFileToJail(file)
  File "/usr/sbin/makejail", line 448, in addFileToJail
    checkRequirements(fileName)
  File "/usr/sbin/makejail", line 553, in checkRequirements
    addFileToJail(lib)
  File "/usr/sbin/makejail", line 395, in addFileToJail
    os.symlink(linkTarget,os.path.split(fileName)[1])
OSError: [Errno 17] File exists

-- Reason for my error case:
lib64/ld-linux-x86-64.so.2 pointed to the older installed library, which
was not existent anymore.

-- Patch:
--- /usr/sbin/makejail  2012-03-05 19:17:34.000000000 +0100
+++ /usr/sbin/makejail  2016-05-26 16:00:50.000000000 +0200
@@ -385,6 +385,9 @@
                newWorkingDir="%s/%s" % 
(config.chroot,os.path.realpath(fileDir)[1:])
                os.chdir(newWorkingDir)
                debug("   Creating '%s' as a symlink to '%s' (pwd=%s)" %
(fileName[1:],linkTarget,newWorkingDir))
+               # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=...
+               if os.path.lexists(os.path.split(fileName)[1]):
+                       os.remove(os.path.split(fileName)[1])
                os.symlink(linkTarget,os.path.split(fileName)[1])
                os.chdir("/")
                missingFiles.append(fileName)


Kind regards
Matthias


-- System Information:
Debian Release: 8.4
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-updates')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages makejail depends on:
ii  binstats  1.08-8
ii  debconf   1.5.56
ii  psmisc    22.21-2
ii  python    2.7.9-1
ii  strace    4.9-2

makejail recommends no packages.

makejail suggests no packages.

-- no debconf information

--- /usr/sbin/makejail  2012-03-05 19:17:34.000000000 +0100
+++ /usr/sbin/makejail  2016-05-26 16:00:50.000000000 +0200
@@ -385,6 +385,9 @@
                newWorkingDir="%s/%s" % 
(config.chroot,os.path.realpath(fileDir)[1:])
                os.chdir(newWorkingDir)
                debug("   Creating '%s' as a symlink to '%s' (pwd=%s)" % 
(fileName[1:],linkTarget,newWorkingDir))
+               # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=...
+               if os.path.lexists(os.path.split(fileName)[1]):
+                       os.remove(os.path.split(fileName)[1])
                os.symlink(linkTarget,os.path.split(fileName)[1])
                os.chdir("/")
                missingFiles.append(fileName)

Reply via email to