modify call of stat to use NUL delimiter

for more robust string parsing
This commit is contained in:
Patrick Schleizer 2024-07-24 11:10:56 -04:00
parent d536683511
commit 00911df5c1
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -72,7 +72,7 @@ add_nosuid_statoverride_entry() {
while IFS="" read -r -d "" line; do while IFS="" read -r -d "" line; do
counter_actual="$((counter_actual + 1))" counter_actual="$((counter_actual + 1))"
local arr file_name existing_mode existing_owner existing_group stat_output local arr file_name file_name_from_stat existing_mode existing_owner existing_group stat_output
file_name="${line}" file_name="${line}"
@ -88,7 +88,7 @@ add_nosuid_statoverride_entry() {
readarray -d '\0' -t arr <<< "${stat_output}" readarray -d '\0' -t arr <<< "${stat_output}"
if test "${#arr[@]}" = 0; then if test "${#arr[@]}" = 0; then
log error "Line is empty: '${line}'" >&2 log error "Line is empty. Stat output: '${stat_output}', line: '${line}'" >&2
continue continue
fi fi
@ -387,12 +387,19 @@ set_file_perms() {
continue continue
fi fi
local arr file_name existing_mode existing_owner existing_group local arr file_name file_name_from_stat existing_mode existing_owner existing_group
read -r -a arr <<< "${stat_output}" readarray -d '\0' -t arr <<< "${stat_output}"
file_name="${fso_without_trailing_slash}" file_name="${fso_without_trailing_slash}"
existing_mode="${arr[0]}"
existing_owner="${arr[1]}" if test "${#arr[@]}" = 0; then
existing_group="${arr[2]}" log error "Line is empty: '${line}'" >&2
continue
fi
file_name_from_stat="${arr[0]}"
existing_mode="${arr[1]}"
existing_owner="${arr[2]}"
existing_group="${arr[3]}"
if test "${#arr[@]}" = 0; then if test "${#arr[@]}" = 0; then
log error "Line is empty. Stat output: '${stat_output}', line: '${line}'" >&2 log error "Line is empty. Stat output: '${stat_output}', line: '${line}'" >&2