openwrt/package
Tony Ambardar 484117b478 base-files: fix postinstall uci-defaults removal
Commit 7f694582 introduced a bug where default_postinst() often fails to
remove a uci-defaults script after application, leaving it to run again
after a reboot.
(Note: commit 7f694582 also introduced FS#1021, now fixed by 73c745f6)

The subtle problem arises from the shell logical chain:
[ -f "$i" ] && . "$i" && rm -f "$i"

Most uci-defaults scripts contain a terminal 'exit 0' statement which,
when sourced, results in the logic chain exiting before executing 'rm -f'.
This was observed while testing upgrades of 'luci-app-sqm'.

The solution is to wrap the shell sourcing in a subshell relative to the
command 'rm -f':
( [ -f "$i" ] && . "$i" ) && rm -f "$i"

Revert to using 'grep' to prefilter the list of entries from the control
file, which yields the full path of uci-defaults scripts. This allows
keeping the existence check, directory change and script sourcing inside
the subshell, with the script removal correctly outside.

This approach avoids adding a second subshell only around the "." (source)
command. The change also preserves the fix FS#1021, since the full path is
used to source the script, which is POSIX-portable irrespective of PATH
variable or reference to the CWD.

Run Tested on: LEDE 17.01.4 running ar71xx, while tracing installation of
package luci-app-sqm with its associated /etc/uci-defaults/luci-sqm file.

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
(backported from 4097ab6a97)
2019-01-22 07:22:59 +01:00
..
base-files base-files: fix postinstall uci-defaults removal 2019-01-22 07:22:59 +01:00
boot grub2: rebase patches 2018-08-30 14:10:54 +02:00
devel perf: restrict libunwind dependency to archs that actually support libunwind 2018-02-25 17:07:32 +01:00
firmware firmware: amd64-microcode: update to 20180524 2018-08-09 01:04:18 +02:00
kernel mac80211: brcmfmac: fix use-after-free & possible NULL pointer dereference 2019-01-08 11:46:24 +01:00
libs uclient: update to latest Git head 2018-11-24 20:16:06 +01:00
network uhttpd: update to latest Git head 2018-11-28 14:51:58 +01:00
system rpcd: update to latest Git head 2018-12-12 16:53:18 +01:00
utils bzip2: Fix CVE-2016-3189 2018-08-30 13:15:06 +02:00
Makefile build: fix triggering opkg/host compilation 2017-04-09 15:42:20 +02:00