Ticket #13574: 0001-Config.xml-Change-owner-and-permissions-on-the-final.patch

File 0001-Config.xml-Change-owner-and-permissions-on-the-final.patch, 1.7 KB (added by rcrdnalor, 6 months ago)

Config.xml: Change owner and permissions on the final file, only

  • deb/debian/mythtv-common.postinst

    From 06cac6446d1675164b8113c32f6f9664baf19dd8 Mon Sep 17 00:00:00 2001
    From: Roland Ernst <rcrernst@gmail.com>
    Date: Wed, 5 Feb 2020 21:00:54 +0100
    Subject: [PATCH] Config.xml: Change owner and permissions on the final file,
     only
    
    Newer kernels 'allow restricted O_CREAT of FIFOs and regular files' (*),
    which prevents edtitng files in directories with sticky bit set, if
    the user/group of the file is different to the owner of the directory
    itself.
    
    (*) https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=30aba6656
    ---
     deb/debian/mythtv-common.postinst | 12 ++++++++----
     1 file changed, 8 insertions(+), 4 deletions(-)
    
    diff --git a/deb/debian/mythtv-common.postinst b/deb/debian/mythtv-common.postinst
    index a60c80a..1d0ecd9 100644
    a b case "$1" in 
    4343    NEW=$(mktemp -t config.xml-XXXXXX)
    4444    if [ -s /etc/mythtv/config.xml ]; then
    4545        INPUT=/etc/mythtv/config.xml
    46         chown --reference="$INPUT" "$NEW"
    47         chmod --reference="$INPUT" "$NEW"
     46        CXMLOWN=$(stat -c %U:%G "$INPUT")
     47        CXMLMOD=$(stat -c %a "$INPUT")
    4848    else
    4949        INPUT=/usr/share/mythtv/config.xml
    50         chown mythtv:mythtv "$NEW"
    51         chmod 660 "$NEW"
     50        CXMLOWN="mythtv:mythtv"
     51        CXMLMOD="660"
    5252    fi
    5353
    5454    cat $INPUT > $NEW
    case "$1" in 
    6161
    6262    mv $NEW /etc/mythtv/config.xml
    6363
     64    # change mode and permissions on the final file only
     65    chmod $CXMLMOD /etc/mythtv/config.xml
     66    chown $CXMLOWN /etc/mythtv/config.xml
     67
    6468    mkdir -p /root/.mythtv || true
    6569    mkdir -p $HOMEDIR/.mythtv || true
    6670    chown mythtv:mythtv $HOMEDIR/.mythtv || true