Skip to content

Commit

Permalink
zed.d/all-debug.sh: simplify
Browse files Browse the repository at this point in the history
By locking the log file itself, we can omit arduous rebinding and
explicit umask setting, but, perhaps more importantly, avoid permanently
littering /var/lock/ with zed.debug.log.lock we will never delete

It is imperative that the previous commit
("zed-functions.sh: zed_lock(): don't truncate lock")
be included in any series that contains this one

Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #12042
  • Loading branch information
nabijaczleweli authored and behlendorf committed Jun 8, 2021
1 parent b828cf1 commit e20c933
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 3 additions & 0 deletions cmd/zed/zed.d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ install-data-hook:
ln -s "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \
done
chmod 0600 "$(DESTDIR)$(zedconfdir)/zed.rc"

# False positive: 1>&"${ZED_FLOCK_FD}" looks suspiciously similar to a >&filename bash extension
CHECKBASHISMS_IGNORE = -e 'should be >word 2>&1' -e '&"$${ZED_FLOCK_FD}"'
16 changes: 6 additions & 10 deletions cmd/zed/zed.d/all-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@

zed_exit_if_ignoring_this_event

lockfile="$(basename -- "${ZED_DEBUG_LOG}").lock"
zed_lock "${ZED_DEBUG_LOG}"
{
printenv | sort
echo
} 1>&"${ZED_FLOCK_FD}"
zed_unlock "${ZED_DEBUG_LOG}"

umask 077
zed_lock "${lockfile}"
exec >> "${ZED_DEBUG_LOG}"

printenv | sort
echo

exec >&-
zed_unlock "${lockfile}"
exit 0

0 comments on commit e20c933

Please sign in to comment.