tech-pkg archive

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

Re: Overwriting config files that are symlinked



On Wed, 28 Mar 2012, Edgar Fuß wrote:
I regularily get bitten by security/pam-ldap overwriting my etc/ldap.conf 
because that's a symlink to openldap/ldap.conf.

What about the following patch that adds a check for an existing symlink?

Index: pkginstall/files
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/files,v
retrieving revision 1.6
diff -p -u -r1.6 files
--- pkginstall/files    25 Sep 2008 14:01:46 -0000      1.6
+++ pkginstall/files    28 Mar 2012 14:44:17 -0000
@@ -159,6 +159,8 @@ ADD)
                        
*f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes)
                                if ${TEST} -f "$file"; then
                                        ${ECHO} "${PKGNAME}: $file already 
exists"
+                               elif ${TEST} -h "$file"; then
+                                       ${ECHO} "${PKGNAME}: $file is a symlink"
                                elif ${TEST} -f "$f_eg" -o -c "$f_eg"; then
                                        ${ECHO} "${PKGNAME}: copying $f_eg to 
$file"
                                        ${CP} $f_eg $file

Sounds like a good plan to me. I keep my settings files in CVS and then have symlinks from locations in /usr/pkg/etc. Whenever I do a package update, it wipes out the symlinks.

However, as we are in a pkgsrc freeze and this is an infrastructure change, it should wait until after the branch.

--
Stephen


Home | Main Index | Thread Index | Old Index