diff --git a/Makefile.am b/Makefile.am index 4fd3f9b3d62e..8e4fffc5d793 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,255 +1,230 @@ include $(top_srcdir)/config/Shellcheck.am ACLOCAL_AMFLAGS = -I config SUBDIRS = include if BUILD_LINUX SUBDIRS += rpm endif if CONFIG_USER SUBDIRS += man scripts lib tests cmd etc contrib if BUILD_LINUX SUBDIRS += udev endif endif if CONFIG_KERNEL SUBDIRS += module extradir = $(prefix)/src/zfs-$(VERSION) extra_HEADERS = zfs.release.in zfs_config.h.in if BUILD_LINUX kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS) endif endif AUTOMAKE_OPTIONS = foreign EXTRA_DIST = autogen.sh copy-builtin EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am EXTRA_DIST += AUTHORS CODE_OF_CONDUCT.md COPYRIGHT LICENSE META NEWS NOTICE EXTRA_DIST += README.md RELEASES.md EXTRA_DIST += module/lua/README.zfs module/os/linux/spl/README.md # Include all the extra licensing information for modules EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE.descrip EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams.descrip EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl.descrip EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2 EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2.descrip EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip @CODE_COVERAGE_RULES@ GITREV = include/zfs_gitrev.h PHONY = gitrev gitrev: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh $(GITREV) all: gitrev # Double-colon rules are allowed; there are multiple independent definitions. maintainer-clean-local:: -$(RM) $(GITREV) distclean-local:: -$(RM) -R autom4te*.cache build -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ -o -name .pc -o -name .hg -o -name .git \) -prune -o \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' -o -size 0 -o -name '*%' -o -name '.*.cmd' \ -o -name 'core' -o -name 'Makefile' -o -name 'Module.symvers' \ -o -name '*.order' -o -name '*.markers' -o -name '*.gcda' \ -o -name '*.gcno' \) \ -type f -print | xargs $(RM) all-local: -[ -x ${top_builddir}/scripts/zfs-tests.sh ] && \ ${top_builddir}/scripts/zfs-tests.sh -c dist-hook: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) $(SED) ${ac_inplace} -e 's/Release:[[:print:]]*/Release: $(RELEASE)/' \ $(distdir)/META if BUILD_LINUX # For compatibility, create a matching spl-x.y.z directly which contains # symlinks to the updated header and object file locations. These # compatibility links will be removed in the next major release. if CONFIG_KERNEL install-data-hook: rm -rf $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ mkdir $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ cd $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ ln -s ../zfs-$(VERSION)/include/spl include && \ ln -s ../zfs-$(VERSION)/$(LINUX_VERSION) $(LINUX_VERSION) && \ ln -s ../zfs-$(VERSION)/zfs_config.h.in spl_config.h.in && \ ln -s ../zfs-$(VERSION)/zfs.release.in spl.release.in && \ cd $(DESTDIR)$(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) && \ ln -fs zfs_config.h spl_config.h && \ ln -fs zfs.release spl.release endif endif PHONY += codecheck codecheck: cstyle shellcheck checkbashisms flake8 mancheck testscheck vcscheck PHONY += checkstyle checkstyle: codecheck commitcheck PHONY += commitcheck commitcheck: @if git rev-parse --git-dir > /dev/null 2>&1; then \ ${top_srcdir}/scripts/commitcheck.sh; \ fi PHONY += cstyle cstyle: @find ${top_srcdir} -name build -prune \ -o -type f -name '*.[hc]' \ ! -name 'zfs_config.*' ! -name '*.mod.c' \ ! -name 'opt_global.h' ! -name '*_if*.h' \ ! -path './module/zstd/lib/*' \ -exec ${top_srcdir}/scripts/cstyle.pl -cpP {} \+ filter_executable = -exec test -x '{}' \; -print SHELLCHECKDIRS = cmd contrib etc scripts tests SHELLCHECKSCRIPTS = autogen.sh PHONY += checkabi storeabi checkabi: lib $(MAKE) -C lib checkabi storeabi: lib $(MAKE) -C lib storeabi -PHONY += checkbashisms -checkbashisms: - @if type checkbashisms > /dev/null 2>&1; then \ - checkbashisms -n -p -x \ - $$(find ${top_srcdir} \ - -name '.git' -prune \ - -o -name 'build' -prune \ - -o -name 'tests' -prune \ - -o -name 'config' -prune \ - -o -name 'zed-functions.sh*' -prune \ - -o -name 'zfs-import*' -prune \ - -o -name 'zfs-mount*' -prune \ - -o -name 'zfs-zed*' -prune \ - -o -name 'smart' -prune \ - -o -name 'paxcheck.sh' -prune \ - -o -name 'make_gitrev.sh' -prune \ - -o -name '90zfs' -prune \ - -o -path '*initramfs/hooks' -prune \ - -o -type f ! -name 'config*' \ - ! -name 'libtool' \ - -exec awk 'FNR==1 && /^#!.*bin\/sh/ {print FILENAME}' {} \+); \ - else \ - echo "skipping checkbashisms because checkbashisms is not installed"; \ - fi - PHONY += mancheck mancheck: @if type mandoc > /dev/null 2>&1; then \ find ${top_srcdir}/man ${top_srcdir}/tests/test-runner/man -type f -name '*[1-9]*' \ -exec mandoc -Tlint -Werror {} \+; \ else \ echo "skipping mancheck because mandoc is not installed"; \ fi if BUILD_LINUX stat_fmt = -c '%A %n' else stat_fmt = -f '%Sp %N' endif PHONY += testscheck testscheck: @find ${top_srcdir}/tests/zfs-tests -type f \ \( -name '*.ksh' -not ${filter_executable} \) -o \ \( -name '*.kshlib' ${filter_executable} \) -o \ \( -name '*.shlib' ${filter_executable} \) -o \ \( -name '*.cfg' ${filter_executable} \) | \ xargs -r stat ${stat_fmt} | \ awk '{c++; print} END {if(c>0) exit 1}' PHONY += vcscheck vcscheck: @if git rev-parse --git-dir > /dev/null 2>&1; then \ git ls-files . --exclude-standard --others | \ awk '{c++; print} END {if(c>0) exit 1}' ; \ fi PHONY += lint lint: cppcheck paxcheck CPPCHECKDIRS = cmd lib module PHONY += cppcheck cppcheck: $(CPPCHECKDIRS) @if test -n "$(CPPCHECK)"; then \ set -e ; for dir in $(CPPCHECKDIRS) ; do \ $(MAKE) -C $$dir cppcheck ; \ done \ else \ echo "skipping cppcheck because cppcheck is not installed"; \ fi PHONY += paxcheck paxcheck: @if type scanelf > /dev/null 2>&1; then \ ${top_srcdir}/scripts/paxcheck.sh ${top_builddir}; \ else \ echo "skipping paxcheck because scanelf is not installed"; \ fi PHONY += flake8 flake8: @if type flake8 > /dev/null 2>&1; then \ flake8 ${top_srcdir}; \ else \ echo "skipping flake8 because flake8 is not installed"; \ fi PHONY += ctags ctags: $(RM) tags find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hcS]' -print | xargs ctags -a PHONY += etags etags: $(RM) TAGS find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hcS]' -print | xargs etags -a PHONY += cscopelist cscopelist: find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hc]' -print >cscope.files PHONY += tags tags: ctags etags PHONY += pkg pkg-dkms pkg-kmod pkg-utils pkg: @DEFAULT_PACKAGE@ pkg-dkms: @DEFAULT_PACKAGE@-dkms pkg-kmod: @DEFAULT_PACKAGE@-kmod pkg-utils: @DEFAULT_PACKAGE@-utils include config/rpm.am include config/deb.am include config/tgz.am .PHONY: $(PHONY) diff --git a/cmd/zpool/zpool.d/smart b/cmd/zpool/zpool.d/smart index b71591abbc61..b95256d75648 100755 --- a/cmd/zpool/zpool.d/smart +++ b/cmd/zpool/zpool.d/smart @@ -1,243 +1,240 @@ #!/bin/sh # # Show SMART stats # helpstr=" smart: Show SMART temperature and error stats (specific to drive type) smartx: Show SMART extended drive stats (specific to drive type). temp: Show SMART drive temperature in celsius (all drives). health: Show reported SMART status (all drives). r_proc: Show SMART read GBytes processed over drive lifetime (SAS). w_proc: Show SMART write GBytes processed over drive lifetime (SAS). r_ucor: Show SMART read uncorrectable errors (SAS). w_ucor: Show SMART write uncorrectable errors (SAS). nonmed: Show SMART non-medium errors (SAS). defect: Show SMART grown defect list (SAS). hours_on: Show number of hours drive powered on (all drives). realloc: Show SMART reallocated sectors count (ATA). rep_ucor: Show SMART reported uncorrectable count (ATA). cmd_to: Show SMART command timeout count (ATA). pend_sec: Show SMART current pending sector count (ATA). off_ucor: Show SMART offline uncorrectable errors (ATA). ata_err: Show SMART ATA errors (ATA). pwr_cyc: Show SMART power cycle count (ATA). serial: Show disk serial number. nvme_err: Show SMART NVMe errors (NVMe). smart_test: Show SMART self-test results summary. test_type: Show SMART self-test type (short, long... ). test_status: Show SMART self-test status. test_progress: Show SMART self-test percentage done. test_ended: Show when the last SMART self-test ended (if supported). " # Hack for developer testing # # If you set $samples to a directory containing smartctl output text files, # we will use them instead of running smartctl on the vdevs. This can be # useful if you want to test a bunch of different smartctl outputs. Also, if # $samples is set, and additional 'file' column is added to the zpool output # showing the filename. samples= # get_filename_from_dir DIR # # Look in directory DIR and return a filename from it. The filename returned # is chosen quasi-sequentially (based off our PID). This allows us to return # a different filename every time this script is invoked (which we do for each # vdev), without having to maintain state. get_filename_from_dir() { dir=$1 pid="$$" num_files=$(find "$dir" -maxdepth 1 -type f | wc -l) mod=$((pid % num_files)) i=0 find "$dir" -type f -printf '%f\n' | while read -r file ; do if [ "$mod" = "$i" ] ; then echo "$file" break fi i=$((i+1)) done } -script=$(basename "$0") +script="${0##*/}" if [ "$1" = "-h" ] ; then echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2- exit fi -smartctl_path=$(command -v smartctl) - -# shellcheck disable=SC2015 -if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ] || [ -n "$samples" ] ; then +if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then if [ -n "$samples" ] ; then # cat a smartctl output text file instead of running smartctl # on a vdev (only used for developer testing). file=$(get_filename_from_dir "$samples") echo "file=$file" raw_out=$(cat "$samples/$file") else - raw_out=$(eval "sudo $smartctl_path -a $VDEV_UPATH") + raw_out=$(sudo smartctl -a "$VDEV_UPATH") fi # What kind of drive are we? Look for the right line in smartctl: # # SAS: # Transport protocol: SAS # # SATA: # ATA Version is: 8 # # NVMe: # SMART/Health Information (NVMe Log 0xnn, NSID 0xnn) # out=$(echo "$raw_out" | awk ' # SAS specific /read:/{print "rrd="$4"\nr_cor="$5"\nr_proc="$7"\nr_ucor="$8} /write:/{print "rwr="$4"\nw_cor="$5"\nw_proc="$7"\nw_ucor="$8} /Non-medium error count/{print "nonmed="$4} /Elements in grown defect list/{print "defect="$6} # SAS common /SAS/{type="sas"} /Drive Temperature:/{print "temp="$4} # Status can be a long string, substitute spaces for '_' /SMART Health Status:/{printf "health="; for(i=4;i<=NF-1;i++){printf "%s_", $i}; printf "%s\n", $i} /number of hours powered up/{print "hours_on="$7; hours_on=int($7)} /Serial number:/{print "serial="$3} # SATA specific /Reallocated_Sector_Ct/{print "realloc="$10} /Reported_Uncorrect/{print "rep_ucor="$10} /Command_Timeout/{print "cmd_to="$10} /Current_Pending_Sector/{print "pend_sec="$10} /Offline_Uncorrectable/{print "off_ucor="$10} /ATA Error Count:/{print "ata_err="$4} /Power_Cycle_Count/{print "pwr_cyc="$10} # SATA common /SATA/{type="sata"} /Temperature_Celsius/{print "temp="$10} /Airflow_Temperature_Cel/{print "temp="$10} /Current Temperature:/{print "temp="$3} /SMART overall-health self-assessment test result:/{print "health="$6} /Power_On_Hours/{print "hours_on="$10; hours_on=int($10)} /Serial Number:/{print "serial="$3} # NVMe common /NVMe/{type="nvme"} /Temperature:/{print "temp="$2} /SMART overall-health self-assessment test result:/{print "health="$6} /Power On Hours:/{gsub("[^0-9]","",$4); print "hours_on="$4} /Serial Number:/{print "serial="$3} /Power Cycles:/{print "pwr_cyc="$3} # NVMe specific /Media and Data Integrity Errors:/{print "nvme_err="$6} # SMART self-test info /Self-test execution status:/{progress=tolower($4)} # SAS /SMART Self-test log/{test_seen=1} # SAS /SMART Extended Self-test Log/{test_seen=1} # SATA /# 1/{ test_type=tolower($3"_"$4); # Status could be one word ("Completed") or multiple ("Completed: read # failure"). Look for the ":" to see if we need to grab more words. if ($5 ~ ":") status=tolower($5""$6"_"$7) else status=tolower($5) if (status=="self") status="running"; if (type == "sas") { hours=int($(NF-4)) } else { hours=int($(NF-1)) # SATA reports percent remaining, rather than percent done # Convert it to percent done. progress=(100-int($(NF-2)))"%" } # When we int()-ify "hours", it converts stuff like "NOW" and "-" into # 0. In those cases, set it to hours_on, so they will cancel out in # the "hours_ago" calculation later on. if (hours == 0) hours=hours_on if (test_seen) { print "test="hours_on print "test_type="test_type print "test_status="status print "test_progress="progress } # Not all drives report hours_on if (hours_on && hours) { total_hours_ago=(hours_on-hours) days_ago=int(total_hours_ago/24) hours_ago=(total_hours_ago % 24) if (days_ago != 0) ago_str=days_ago"d" if (hours_ago !=0) ago_str=ago_str""hours_ago"h" print "test_ended="ago_str } } END {print "type="type; ORS="\n"; print ""} '); fi type=$(echo "$out" | grep '^type=' | cut -d '=' -f 2) # If type is not set by now, either we don't have a block device # or smartctl failed. Either way, default to ATA and set $out to # nothing. if [ -z "$type" ]; then type="sata" out= fi case $script in smart) # Print temperature plus common predictors of drive failure if [ "$type" = "sas" ] ; then scripts="temp|health|r_ucor|w_ucor" elif [ "$type" = "sata" ] ; then scripts="temp|health|ata_err|realloc|rep_ucor|cmd_to|pend_sec|off_ucor" elif [ "$type" = "nvme" ] ; then scripts="temp|health|nvme_err" fi ;; smartx) # Print some other interesting stats if [ "$type" = "sas" ] ; then scripts="hours_on|defect|nonmed|r_proc|w_proc" elif [ "$type" = "sata" ] ; then scripts="hours_on|pwr_cyc" elif [ "$type" = "nvme" ] ; then scripts="hours_on|pwr_cyc" fi ;; smart_test) scripts="test_type|test_status|test_progress|test_ended" ;; *) scripts="$script" esac with_vals=$(echo "$out" | grep -E "$scripts") if [ -n "$with_vals" ]; then echo "$with_vals" without_vals=$(echo "$scripts" | tr '|' '\n' | grep -v -E "$(echo "$with_vals" | awk -F "=" '{print $1}')" | awk '{print $0"="}') else without_vals=$(echo "$scripts" | tr '|' '\n' | awk '{print $0"="}') fi if [ -n "$without_vals" ]; then echo "$without_vals" fi diff --git a/config/Shellcheck.am b/config/Shellcheck.am index a22333ac45e7..6b805b797d12 100644 --- a/config/Shellcheck.am +++ b/config/Shellcheck.am @@ -1,8 +1,22 @@ .PHONY: shellcheck shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS) if HAVE_SHELLCHECK [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; shellcheck $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") --exclude=SC1090,SC1091$(SHELLCHECK_IGNORE) --format=gcc $(SCRIPTS) $(SHELLCHECKSCRIPTS) else @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed" endif @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done + + +# command -v *is* specified by POSIX and every shell in existence supports it +.PHONY: checkbashisms +checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS) +if HAVE_CHECKBASHISMS + [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \ + checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \ + for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \ + fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2 +else + @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed" +endif + @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done diff --git a/config/always-shellcheck.m4 b/config/always-shellcheck.m4 index 1e154e1c5552..2a9a099746f4 100644 --- a/config/always-shellcheck.m4 +++ b/config/always-shellcheck.m4 @@ -1,7 +1,10 @@ dnl # -dnl # Check if shellcheck is available. +dnl # Check if shellcheck and/or checkbashisms are available. dnl # AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SHELLCHECK], [ AC_CHECK_PROG([SHELLCHECK], [shellcheck], [yes]) + AC_CHECK_PROG([CHECKBASHISMS], [checkbashisms], [yes]) + AM_CONDITIONAL([HAVE_SHELLCHECK], [test "x$SHELLCHECK" = "xyes"]) + AM_CONDITIONAL([HAVE_CHECKBASHISMS], [test "x$CHECKBASHISMS" = "xyes"]) ]) diff --git a/contrib/dracut/90zfs/Makefile.am b/contrib/dracut/90zfs/Makefile.am index 19b206ddd7c9..ff3a2b27f24e 100644 --- a/contrib/dracut/90zfs/Makefile.am +++ b/contrib/dracut/90zfs/Makefile.am @@ -1,20 +1,23 @@ include $(top_srcdir)/config/Substfiles.am include $(top_srcdir)/config/Shellcheck.am pkgdracutdir = $(dracutdir)/modules.d/90zfs pkgdracut_SCRIPTS = \ export-zfs.sh \ module-setup.sh \ mount-zfs.sh \ parse-zfs.sh \ zfs-generator.sh \ zfs-load-key.sh \ zfs-needshutdown.sh \ zfs-lib.sh pkgdracut_DATA = \ zfs-env-bootfs.service \ zfs-snapshot-bootfs.service \ zfs-rollback-bootfs.service SUBSTFILES += $(pkgdracut_SCRIPTS) $(pkgdracut_DATA) + +# Provided by /bin/sleep, and, again, every implementation of that supports this +CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.' diff --git a/scripts/make_gitrev.sh b/scripts/make_gitrev.sh index f5c743b13799..da21455332ab 100755 --- a/scripts/make_gitrev.sh +++ b/scripts/make_gitrev.sh @@ -1,78 +1,78 @@ #!/bin/sh # # CDDL HEADER START # # This file and its contents are supplied under the terms of the # Common Development and Distribution License ("CDDL"), version 1.0. # You may only use this file in accordance with the terms of version # 1.0 of the CDDL. # # A full copy of the text of the CDDL should have accompanied this # source. A copy of the CDDL is also available via the Internet at # http://www.illumos.org/license/CDDL. # # CDDL HEADER END # # Copyright (c) 2018 by Delphix. All rights reserved. # Copyright (c) 2018 by Matthew Thode. All rights reserved. # # Generate zfs_gitrev.h. Note that we need to do this for every # invocation of `make`, including for incremental builds. Therefore we # can't use a zfs_gitrev.h.in file which would be processed only when # `configure` is run. # set -e -u dist=no distdir=. while getopts D: flag do case $flag in \?) echo "Usage: $0 [-D distdir] [file]" >&2; exit 1;; D) dist=yes; distdir=${OPTARG};; esac done shift $((OPTIND - 1)) top_srcdir="$(dirname "$0")/.." GITREV="${1:-include/zfs_gitrev.h}" # GITREV should be a relative path (relative to top_builddir or distdir) case "${GITREV}" in /*) echo "Error: ${GITREV} should be a relative path" >&2 exit 1;; esac ZFS_GITREV=$({ cd "${top_srcdir}" && git describe --always --long --dirty 2>/dev/null; } || :) if [ "x${ZFS_GITREV}" = x ] then # If the source directory is not a git repository, check if the file # already exists (in the source) if [ -f "${top_srcdir}/${GITREV}" ] then - ZFS_GITREV="$(sed -n \ + ZFS_GITREV=$(sed -n \ '1s/^#define[[:blank:]]ZFS_META_GITREV "\([^"]*\)"$/\1/p' \ - "${top_srcdir}/${GITREV}")" + "${top_srcdir}/${GITREV}") fi elif [ ${dist} = yes ] then # Append -dist when creating distributed sources from a git repository ZFS_GITREV="${ZFS_GITREV}-dist" fi ZFS_GITREV=${ZFS_GITREV:-unknown} GITREVTMP="${GITREV}~" printf '#define\tZFS_META_GITREV "%s"\n' "${ZFS_GITREV}" >"${GITREVTMP}" GITREV="${distdir}/${GITREV}" if cmp -s "${GITREV}" "${GITREVTMP}" then rm -f "${GITREVTMP}" else mv -f "${GITREVTMP}" "${GITREV}" fi diff --git a/scripts/paxcheck.sh b/scripts/paxcheck.sh index 87e817500b1b..27acc95364aa 100755 --- a/scripts/paxcheck.sh +++ b/scripts/paxcheck.sh @@ -1,44 +1,43 @@ #!/bin/sh -# shellcheck disable=SC2039 -if ! type scanelf > /dev/null 2>&1; then +if ! command -v scanelf > /dev/null; then echo "scanelf (from pax-utils) is required for these checks." >&2 exit 3 fi RET=0 # check for exec stacks OUT=$(scanelf -qyRAF '%e %p' "$1") if [ x"${OUT}" != x ]; then RET=2 echo "The following files contain writable and executable sections" echo " Files with such sections will not work properly (or at all!) on some" echo " architectures/operating systems." echo " For more information, see:" echo " https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart" echo echo "${OUT}" echo fi # check for TEXTRELS OUT=$(scanelf -qyRAF '%T %p' "$1") if [ x"${OUT}" != x ]; then RET=2 echo "The following files contain runtime text relocations" echo " Text relocations force the dynamic linker to perform extra" echo " work at startup, waste system resources, and may pose a security" echo " risk. On some architectures, the code may not even function" echo " properly, if at all." echo " For more information, see:" echo " https://wiki.gentoo.org/wiki/Hardened/HOWTO_locate_and_fix_textrels" echo echo "${OUT}" echo fi exit $RET