File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -596,8 +596,8 @@ f_sysrc_set()
596
596
# return $FAILURE
597
597
# fi
598
598
599
- local tmpfile="$( mktemp )"
600
- [ "$tmpfile" ] || return $FAILURE
599
+ local tmpfile="$( mktemp )"
600
+ [ "$tmpfile" ] || return $FAILURE
601
601
602
602
603
603
#
@@ -606,11 +606,30 @@ f_sysrc_set()
606
606
# temporary file over the destination, the destination will inherit the
607
607
# permissions from the temporary file).
608
608
#
609
- # local mode
609
+ local mode
610
+ local owner
611
+
610
612
# f_eval_catch -dk mode $funcname stat 'stat -f "%%#Lp" "%s"' "$file" ||
611
613
# mode=0644
612
614
# f_eval_catch -d $funcname chmod 'chmod "%s" "%s"' "$mode" "$tmpfile"
613
615
616
+ case $( uname -s ) in
617
+ Linux)
618
+ mode=$( stat -c "%a" ${file} 2>/dev/null )
619
+ owner=$( stat -c "%u:%g" ${file} 2>/dev/null )
620
+ ;;
621
+ *)
622
+ mode=$( stat -f "%Lp" ${file} 2>/dev/null )
623
+ owner=$( stat -f "%u:%g" ${file} 2>/dev/null )
624
+ ;;
625
+ esac
626
+
627
+ [ -z "${mode}" ] && mode="0644"
628
+ [ -z "${owner}" ] && mode="0:0"
629
+
630
+ chmod ${mode} ${tmpfile}
631
+ chown ${owner} ${tmpfile}
632
+
614
633
#
615
634
# Fixup ownership. The destination file _is_ writable (we tested
616
635
# earlier above). However, this will fail if we don't have sufficient
You can’t perform that action at this time.
0 commit comments