Re: bug in apkg -u merge

Erich Titl <[email protected]> Wed, 22 Nov 2017 23:00:10 +0100
Newsgroups gmane.linux.leaf.devel
Message-ID <[email protected]>
Hi KP

Am 22.11.2017 um 18:32 schrieb KP Kirchdoerfer via leaf-devel:
> HI all;
> 
> when I update a package with apkg -u [packagename] and choose M 
> "M ) Edit a merged version of the files"
> 
> the file permissions are not saved to the original ones.
> 
> I've tried with (yet unreleased package) lighthttpd where the
> permissions for 
> /etc/init.d/lighttpd
> 
> are set to 755 (-rwxr-xr-x) in the package. After running update and
> edit with M(erge) the permissions are  set to 644 (-rw-r--r--).
> 
> The M(erge) command shouldn't change the permissions.

It does not :-( it creates a new file with the user's file creation mask
settings, see man umask.

m|M)
        tmp=$TMP/$SESSIONID.tmp
        apkg.mergefile $1/$3 $2/$3 > $tmp
        sha1=$(sha1sum $tmp)
        $EDITOR $tmp
        if echo "$sha1" | sha1sum -c >/dev/null 2>&1; then
                rm $tmp
        else
                mv $tmp $2/$3
                break
        fi
        ;;


So the culprit is in apkg.merge which just pipes the output of
apkg.mergefile into a temporary file.

You could temporarily change umask to get the right permissions or use a
more sophisticated aproach to file creation by reading first the
attributes of the files to be merged. But then what will you do if they
differ?

For example:

mega@leafbuilder64:/tmp$ umask
0002
mega@leafbuilder64:/tmp$ > foo
mega@leafbuilder64:/tmp$ umask 0004
mega@leafbuilder64:/tmp$ > bar
mega@leafbuilder64:/tmp$ ls -l foo bar
-rw-rw--w- 1 mega mega 0 Nov 22 22:44 bar
-rw-rw-r-- 1 mega mega 0 Nov 22 22:44 foo

mega@leafbuilder64:/tmp$ stat --format %a  foo bar
664
662

The easiest and crudest way would be to just force the output file.

mega@leafbuilder64:/tmp$ chmod 755 foo
mega@leafbuilder64:/tmp$ stat --format %a foo
755

cheers

ET

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


_______________________________________________
leaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-devel
smime.p7s (application/pkcs7-signature, 1.9 KB) - not displayed