From d01ca09eaa00c66e3f513056f50fa61931ebb126 Mon Sep 17 00:00:00 2001 From: cynix Date: Mon, 22 Jun 2020 00:06:40 +1000 Subject: [PATCH] Deduplicate template fstab entries using their full paths. This allows a fstab entry that happens to be a substring of the jail path (or that of an existing entry) to be added correctly. --- usr/local/share/bastille/template.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index 9233e48..d694afe 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -243,14 +243,15 @@ for _jail in ${JAILS}; do fi ## aggregate variables into FSTAB entry - _fstab_entry="${_hostpath} ${bastille_jailsdir}/${_jail}/root/${_jailpath} ${_type} ${_perms} ${_checks}" + _jailpath="${bastille_jailsdir}/${_jail}/root/${_jailpath}" + _fstab_entry="${_hostpath} ${_jailpath} ${_type} ${_perms} ${_checks}" ## if entry doesn't exist, add; else show existing entry - if ! grep -q "${_jailpath}" "${bastille_jailsdir}/${_jail}/fstab"; then + if ! egrep -q "[[:blank:]]${_jailpath}[[:blank:]]" "${bastille_jailsdir}/${_jail}/fstab"; then echo "${_fstab_entry}" >> "${bastille_jailsdir}/${_jail}/fstab" echo "Added: ${_fstab_entry}" else - grep "${_jailpath}" "${bastille_jailsdir}/${_jail}/fstab" + egrep "[[:blank:]]${_jailpath}[[:blank:]]" "${bastille_jailsdir}/${_jail}/fstab" fi done < "${bastille_template}/FSTAB" mount -F "${bastille_jailsdir}/${_jail}/fstab" -a