Lines 31-36
Link Here
|
31 |
done |
31 |
done |
32 |
} |
32 |
} |
33 |
|
33 |
|
|
|
34 |
|
35 |
secure_script() |
36 |
{ |
37 |
if [ $(/usr/bin/stat -f "%u" $1) != 0 ]; then |
38 |
printf "Error: $1 must be owned by root.\n" |
39 |
exit 1 |
40 |
fi |
41 |
mode=$(ls -l $1 | awk '{ print $1 }') |
42 |
if [ $(echo $mode | cut -c 1) != '-' ]; then |
43 |
printf "Error: $1 must be a regular file.\n" |
44 |
exit 1 |
45 |
fi |
46 |
if [ $(echo $mode | cut -c 6,9) != '--' ]; then |
47 |
printf "Error: $1 cannot be group or world writable.\n" |
48 |
exit 1 |
49 |
fi |
50 |
return 0 |
51 |
} |
52 |
|
53 |
|
34 |
# Print a single map entry. |
54 |
# Print a single map entry. |
35 |
print_map_entry() { |
55 |
print_map_entry() { |
36 |
local _fstype _p |
56 |
local _fstype _p |
Lines 38-47
Link Here
|
38 |
_fstype="$1" |
58 |
_fstype="$1" |
39 |
_p="$2" |
59 |
_p="$2" |
40 |
|
60 |
|
|
|
61 |
# Perhaps some of these customizations should be handled by the mount |
62 |
# commands so they don't have to be duplicated in tools that call them |
63 |
# such as autofs? |
64 |
# |
65 |
# Check for root ownership and safe permissions |
66 |
# |
67 |
custom_script="/etc/autofs/${_fstype}-customizations.sh" |
68 |
if secure_script $custom_script; then |
69 |
_custom_flags=$($custom_script) |
70 |
fi |
71 |
|
41 |
case "${_fstype}" in |
72 |
case "${_fstype}" in |
42 |
"exfat") |
73 |
"exfat") |
43 |
if [ -f "/usr/local/sbin/mount.exfat" ]; then |
74 |
if [ -f "/usr/local/sbin/mount.exfat" ]; then |
44 |
echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid :/dev/${_p}" |
75 |
echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid,${_custom_flags} :/dev/${_p}" |
45 |
else |
76 |
else |
46 |
/usr/bin/logger -p info -t "special_media[$$]" \ |
77 |
/usr/bin/logger -p info -t "special_media[$$]" \ |
47 |
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first" |
78 |
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first" |
Lines 50-67
Link Here
|
50 |
;; |
81 |
;; |
51 |
"ntfs") |
82 |
"ntfs") |
52 |
if [ -f "/usr/local/bin/ntfs-3g" ]; then |
83 |
if [ -f "/usr/local/bin/ntfs-3g" ]; then |
53 |
echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid :/dev/${_p}" |
84 |
echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid,${_custom_flags} :/dev/${_p}" |
54 |
else |
85 |
else |
55 |
/usr/bin/logger -p info -t "special_media[$$]" \ |
86 |
/usr/bin/logger -p info -t "special_media[$$]" \ |
56 |
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first" |
87 |
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first" |
57 |
exit 1 |
88 |
exit 1 |
58 |
fi |
89 |
fi |
59 |
;; |
90 |
;; |
60 |
"ext2fs" | "msdosfs") |
91 |
"ext2fs") |
61 |
echo "-fstype=${_fstype},nosuid,async :/dev/${_p}" |
92 |
echo "-fstype=${_fstype},nosuid,async,${_custom_flags} :/dev/${_p}" |
62 |
;; |
93 |
;; |
|
|
94 |
"msdosfs") |
95 |
echo "-fstype=${_fstype},nosuid,async,${_custom_flags} :/dev/${_p}" |
96 |
;; |
63 |
*) |
97 |
*) |
64 |
echo "-fstype=${_fstype},nosuid :/dev/${_p}" |
98 |
echo "-fstype=${_fstype},nosuid,${_custom_flags} :/dev/${_p}" |
65 |
;; |
99 |
;; |
66 |
esac |
100 |
esac |
67 |
} |
101 |
} |