[type/{__file/__directory}] Support setuid,setguid,sticky bits
This commit is contained in:
parent
7074f9c395
commit
3860f1feea
4 changed files with 20 additions and 19 deletions
|
@ -33,7 +33,7 @@ fallback() {
|
|||
group=$(awk -F: -v uid="$uid" '$3 == uid { print $1; f=1 } END { if (!f) print "UNKNOWN" }' /etc/group)
|
||||
|
||||
mode_text=$(echo "$ls_line" | awk '{ print $1 }')
|
||||
mode=$(echo "$mode_text" | awk '{ k=0; for (i=0; i<=8; i++) k += ((substr($1, i+2, 1) ~ /[rwx]/) * 2^(8-i)); printf("%0o", k) }')
|
||||
mode=$(echo "$mode_text" | awk '{for(i=8;i>=0;--i){c=substr($1,10-i,1);k+=((c~/[rwxst]/)*2^i);if(!(i%3))k+=(tolower(c)~/[st]/)*2^(9+i/3)}printf("%04o",k)}')
|
||||
|
||||
printf 'type: %s\nowner: %d %s\ngroup: %d %s\nmode: %s %s\n' \
|
||||
"$("$__type_explorer/type")" \
|
||||
|
@ -51,13 +51,14 @@ then
|
|||
exit
|
||||
fi
|
||||
|
||||
case $("$__explorer/os") in
|
||||
"freebsd"|"netbsd"|"openbsd"|"macosx")
|
||||
stat -f "type: %HT
|
||||
case $("$__explorer/os")
|
||||
in
|
||||
freebsd|netbsd|openbsd|macosx)
|
||||
stat -f 'type: %HT
|
||||
owner: %Du %Su
|
||||
group: %Dg %Sg
|
||||
mode: %Lp %Sp
|
||||
" "$destination" | awk '/^type/ { print tolower($0); next } { print }'
|
||||
mode: %Mp%03Lp %Sp
|
||||
' "$destination" | awk '/^type/ { print tolower($0); next } { print }'
|
||||
;;
|
||||
solaris)
|
||||
ls1="$( ls -ld "$destination" )"
|
||||
|
@ -92,9 +93,9 @@ mode: %Lp %Sp
|
|||
# NOTE: Do not use --printf here as it is not supported by BusyBox stat.
|
||||
# NOTE: BusyBox's stat might not support the "-c" option, in which case
|
||||
# we fall through to the shell fallback.
|
||||
stat -c "type: %F
|
||||
stat -c 'type: %F
|
||||
owner: %u %U
|
||||
group: %g %G
|
||||
mode: %a %A" "$destination" 2>/dev/null || fallback
|
||||
mode: %04a %A' "$destination" 2>/dev/null || fallback
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -97,9 +97,9 @@ case "$state_should" in
|
|||
value_should="$(cat "$__object/parameter/$attribute")"
|
||||
value_is="$(get_current_value "$attribute" "$value_should")"
|
||||
|
||||
# change 0xxx format to xxx format => same as stat returns
|
||||
# format mode in four digits => same as stat returns
|
||||
if [ "$attribute" = mode ]; then
|
||||
value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')"
|
||||
value_should=$(printf '%04u' "${value_should}")
|
||||
fi
|
||||
|
||||
if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then
|
||||
|
|
|
@ -34,7 +34,7 @@ fallback() {
|
|||
group=$(awk -F: -v uid="$uid" '$3 == uid { print $1; f=1 } END { if (!f) print "UNKNOWN" }' /etc/group)
|
||||
|
||||
mode_text=$(echo "$ls_line" | awk '{ print $1 }')
|
||||
mode=$(echo "$mode_text" | awk '{ k=0; for (i=0; i<=8; i++) k += ((substr($1, i+2, 1) ~ /[rwx]/) * 2^(8-i)); printf("%0o", k) }')
|
||||
mode=$(echo "$mode_text" | awk '{for(i=8;i>=0;--i){c=substr($1,10-i,1);k+=((c~/[rwxst]/)*2^i);if(!(i%3))k+=(tolower(c)~/[st]/)*2^(9+i/3)}printf("%04o",k)}')
|
||||
|
||||
size=$(echo "$ls_line" | awk '{ print $5 }')
|
||||
links=$(echo "$ls_line" | awk '{ print $2 }')
|
||||
|
@ -63,13 +63,13 @@ fi
|
|||
case $("$__explorer/os")
|
||||
in
|
||||
freebsd|netbsd|openbsd|macosx)
|
||||
stat -f "type: %HT
|
||||
stat -f 'type: %HT
|
||||
owner: %Du %Su
|
||||
group: %Dg %Sg
|
||||
mode: %Lp %Sp
|
||||
mode: %Mp%03Lp %Sp
|
||||
size: %Dz
|
||||
links: %Dl
|
||||
" "$destination" | awk '/^type/ { print tolower($0); next } { print }'
|
||||
' "$destination" | awk '/^type/ { print tolower($0); next } { print }'
|
||||
;;
|
||||
solaris)
|
||||
ls1="$( ls -ld "$destination" )"
|
||||
|
@ -106,11 +106,11 @@ links: %Dl
|
|||
# NOTE: Do not use --printf here as it is not supported by BusyBox stat.
|
||||
# NOTE: BusyBox's stat might not support the "-c" option, in which case
|
||||
# we fall through to the shell fallback.
|
||||
stat -c "type: %F
|
||||
stat -c 'type: %F
|
||||
owner: %u %U
|
||||
group: %g %G
|
||||
mode: %a %A
|
||||
mode: %04a %A
|
||||
size: %s
|
||||
links: %h" "$destination" 2>/dev/null || fallback
|
||||
links: %h' "$destination" 2>/dev/null || fallback
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -68,9 +68,9 @@ case "$state_should" in
|
|||
if [ -f "$__object/parameter/$attribute" ]; then
|
||||
value_should="$(cat "$__object/parameter/$attribute")"
|
||||
|
||||
# change 0xxx format to xxx format => same as stat returns
|
||||
# format mode in four digits => same as stat returns
|
||||
if [ "$attribute" = mode ]; then
|
||||
value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')"
|
||||
value_should=$(printf '%04u' "${value_should}")
|
||||
fi
|
||||
|
||||
value_is="$(get_current_value "$attribute" "$value_should")"
|
||||
|
|
Loading…
Reference in a new issue