Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fjail @ 162:9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 20 Nov 2019 12:55:52 +0100 |
| parents | 57b9b899bf77 |
| children | 9aef3f0e4d1c |
comparison
equal
deleted
inserted
replaced
| 161:57b9b899bf77 | 162:9bd38c55a75c |
|---|---|
| 270 # | 270 # |
| 271 # To be used when all ZFS datasets are mounted. | 271 # To be used when all ZFS datasets are mounted. |
| 272 # | 272 # |
| 273 command_privs() { | 273 command_privs() { |
| 274 # mountpoint | 274 # mountpoint |
| 275 local _mp _d | 275 local _mp _d _veds _get _vestatus |
| 276 | 276 |
| 277 _mp="$1" | 277 _mp="$1" |
| 278 if [ -z "${_mp}" ]; then | 278 if [ -z "${_mp}" ]; then |
| 279 echo "ERROR: no mountpoint given" >&2 | 279 echo "ERROR: no mountpoint given" >&2 |
| 280 return 2 | 280 return 2 |
| 286 for _d in tmp var/tmp ; do | 286 for _d in tmp var/tmp ; do |
| 287 chmod 01777 "${_mp}/${_d}" | 287 chmod 01777 "${_mp}/${_d}" |
| 288 done | 288 done |
| 289 chown root:mail "${_mp}/var/mail" | 289 chown root:mail "${_mp}/var/mail" |
| 290 chmod 0775 "${_mp}/var/mail" | 290 chmod 0775 "${_mp}/var/mail" |
| 291 | |
| 292 # | |
| 293 # Handle <mountpoint>/var/empty specially: | |
| 294 # make it writeable temporarily if it is mounted read-only: | |
| 295 # | |
| 296 _vestatus="" | |
| 297 _veds=$(_get_dataset_for_varempty "${_mp}") | |
| 298 if [ $? -eq 0 ]; then | |
| 299 _get=$(zfs get -H readonly ${_veds} 2>/dev/null) || { echo "ERROR: cannot determine readonly status of ${_mp}/var/empty" >&2; return 1; } | |
| 300 IFS=$'\t' read _dummy _dummy _vestatus _dummy <<EOF | |
| 301 ${_get} | |
| 302 EOF | |
| 303 if [ "${_vestatus}" = "on" ]; then | |
| 304 zfs set readonly=off ${_veds} >/dev/null 2>/dev/null || { echo "ERROR: cannot reset readonly-status of ${_mp}/var/empty" >&2; return 1; } | |
| 305 fi | |
| 306 fi | |
| 307 # Set the access rights and the file flags as given in mtree | |
| 308 chmod 0555 "${_mp}/var/empty" | |
| 309 chflags schg "${_mp}/var/empty" | |
| 310 # Reset the read-only status of the mountpoint as it was before | |
| 311 if [ "${_vestatus}" = "on" ]; then | |
| 312 zfs set readonly=on ${_veds} >/dev/null 2>/dev/null || { echo "ERROR: cannot reactivate readonly-status of ${_mp}/var/empty" >&2; return 1; } | |
| 313 fi | |
| 291 } | 314 } |
| 292 | 315 |
| 293 | 316 |
| 294 # | 317 # |
| 295 # Global option handling | 318 # Global option handling |
