pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/56597 (Deinstallation of compat90 destroys netbsd-9)



Hi,

would something like this diff (untested...) deal adequatly with
this part of the problem?

   Hm, seems like the +ROOT_ACTIONS script of the package, from
   ../compat_netbsd/INSTALL.ELF is responsible for managing the
   symlinks, it will not replace a file or preexisting symlink, but
   on de-install and the target was already a symlink, it will be
   summarily removed...  Perhaps the INSTALL.ELF script should as an
   added level of security verify that the symlink actually points
   to the intended target before removing it, instead of just
   testing whether it's a symlink, given the prevalent use of
   symlinks in shared library handling?

Index: compat_netbsd/INSTALL.ELF
===================================================================
RCS file: /cvsroot/pkgsrc/emulators/compat_netbsd/INSTALL.ELF,v
retrieving revision 1.2
diff -u -r1.2 INSTALL.ELF
--- compat_netbsd/INSTALL.ELF   17 Feb 2013 10:34:31 -0000      1.2
+++ compat_netbsd/INSTALL.ELF   2 Jan 2022 15:49:32 -0000
@@ -83,8 +83,15 @@
                esac

                if ${TEST} -h "$dst"; then
-                       ${ECHO} "${PKGNAME}: removing $dst"
-                       ${RM} -f "$dst"
+                       lsrc=$(readlink $dst)
+                       if [ "$lsrc" = ${PKG_PREFIX}/$src -o \
+                            "$lsrc" = $src ]
+                       then
+                               ${ECHO} "${PKGNAME}: removing $dst"
+                               ${RM} -f "$dst"
+                       else
+                               ${ECHO} "${PKGNAME}: mismatched symlink, skipping removal of $dst"
+                       fi
                fi
        done
        ${RM} -f ${ROOT_ACTIONS_COOKIE}

Regards,

- Havard


Home | Main Index | Thread Index | Old Index