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 |
43 | 43 | NEW=$(mktemp -t config.xml-XXXXXX) |
44 | 44 | if [ -s /etc/mythtv/config.xml ]; then |
45 | 45 | 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") |
48 | 48 | else |
49 | 49 | INPUT=/usr/share/mythtv/config.xml |
50 | | chown mythtv:mythtv "$NEW" |
51 | | chmod 660 "$NEW" |
| 50 | CXMLOWN="mythtv:mythtv" |
| 51 | CXMLMOD="660" |
52 | 52 | fi |
53 | 53 | |
54 | 54 | cat $INPUT > $NEW |
… |
… |
case "$1" in |
61 | 61 | |
62 | 62 | mv $NEW /etc/mythtv/config.xml |
63 | 63 | |
| 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 | |
64 | 68 | mkdir -p /root/.mythtv || true |
65 | 69 | mkdir -p $HOMEDIR/.mythtv || true |
66 | 70 | chown mythtv:mythtv $HOMEDIR/.mythtv || true |