The branch, master has been updated via e4371a4c3b8 release-script: Fix shellcheck errors via 233a0cd6de9 lib:fuzzing: Fix shellcheck errors in build_samba.sh via 72f16b63544 nsswitch: Fix shellcheck errors in test_rfc2307_mapping.sh via c3823ff371f examples: Fix shellcheck error in VampireDriversFunctions via fe33eaba026 examples: Remove trailing spaces in VampireDriversFunctions via 0461fa13d4a examples: Fix shellcheck error in get_next_oid via 9594778895e testprogs: Fix variable asignment in test_wintest.sh via 665db976626 s3:script: Fix variable asignment in test_dfree_command.sh via b696ae1b02b script: Add script to run shellcheck on shell scripts via 5ae4a6249f6 bootstrap: Install ShellCheck and shfmt from f92bacbe216 s3/smbd: Use after free when iterating smbd_server_connection->connections
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit e4371a4c3b891ae4e88bd91cda8eb84eb7304e04 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 23 12:19:19 2022 +0100 release-script: Fix shellcheck errors ./release-scripts/build-docs:4:7: error: Double quote array expansions to avoid re-splitting elements. [SC2068] Same error for the other scripts. Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> Autobuild-User(master): Pavel Filipensky <pfilipen...@samba.org> Autobuild-Date(master): Wed Aug 17 11:03:54 UTC 2022 on sn-devel-184 commit 233a0cd6de9d0d0aac07f1f8d753780e53dbe2b0 Author: Andreas Schneider <a...@samba.org> Date: Tue Feb 22 18:01:31 2022 +0100 lib:fuzzing: Fix shellcheck errors in build_samba.sh lib/fuzzing/oss-fuzz/build_samba.sh:24:27: error: Double quote array expansions to avoid re-splitting elements. [SC2068] Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit 72f16b635445025a9b523974ba08c753ea78ed58 Author: Andreas Schneider <a...@samba.org> Date: Tue Feb 22 17:58:47 2022 +0100 nsswitch: Fix shellcheck errors in test_rfc2307_mapping.sh nsswitch/tests/test_rfc2307_mapping.sh:65:139: error: Double quote array expansions to avoid re-splitting elements. [SC2068] Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit c3823ff371fe5c605ddaa61a3c76bc233d5f1501 Author: Andreas Schneider <a...@samba.org> Date: Tue Feb 22 17:50:34 2022 +0100 examples: Fix shellcheck error in VampireDriversFunctions examples/printing/VampireDriversFunctions:183:24: error: Double quote array expansions to avoid re-splitting elements. [SC2068] Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit fe33eaba026cab7881ab07e424e4dde94d896a1e Author: Andreas Schneider <a...@samba.org> Date: Tue Feb 22 17:51:16 2022 +0100 examples: Remove trailing spaces in VampireDriversFunctions Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit 0461fa13d4af0565ed885873cfdad18bb07ba9fd Author: Andreas Schneider <a...@samba.org> Date: Tue Feb 22 17:42:55 2022 +0100 examples: Fix shellcheck error in get_next_oid examples/LDAP/get_next_oid:6:4: error: Remove spaces around += to assign (or quote '+=' if literal). [SC2285] Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit 9594778895ee1be90c491c9b1d13c97cce16cc53 Author: Andreas Schneider <a...@samba.org> Date: Mon Feb 21 11:24:07 2022 +0100 testprogs: Fix variable asignment in test_wintest.sh Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit 665db97662664cc8f657a9d3b1af286748356e76 Author: Andreas Schneider <a...@samba.org> Date: Mon Feb 21 11:23:27 2022 +0100 s3:script: Fix variable asignment in test_dfree_command.sh Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit b696ae1b02bdcbaa58d863ba23ecb945f904d81f Author: Andreas Schneider <a...@samba.org> Date: Mon Feb 21 11:25:37 2022 +0100 script: Add script to run shellcheck on shell scripts Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> commit 5ae4a6249f6228c6c231ca79138790943673efe6 Author: Andreas Schneider <a...@samba.org> Date: Mon Feb 21 11:29:29 2022 +0100 bootstrap: Install ShellCheck and shfmt Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Pavel Filipenský <pfilipen...@samba.org> ----------------------------------------------------------------------- Summary of changes: .gitlab-ci-main.yml | 2 +- bootstrap/config.py | 8 + bootstrap/generated-dists/f36mit120/bootstrap.sh | 2 + bootstrap/generated-dists/f36mit120/packages.yml | 2 + bootstrap/generated-dists/fedora36/bootstrap.sh | 2 + bootstrap/generated-dists/fedora36/packages.yml | 2 + bootstrap/sha1sum.txt | 2 +- examples/LDAP/get_next_oid | 4 +- examples/printing/VampireDriversFunctions | 444 +++++++++++------------ lib/fuzzing/oss-fuzz/build_samba.sh | 4 +- nsswitch/tests/test_rfc2307_mapping.sh | 18 +- release-scripts/build-docs | 2 +- release-scripts/build-htmlman-git | 4 +- release-scripts/build-htmlman-nogit | 2 +- release-scripts/build-manpages-git | 2 +- release-scripts/build-manpages-nogit | 2 +- script/check-shell-scripts.sh | 20 + source3/script/tests/test_dfree_command.sh | 2 +- testprogs/blackbox/test_wintest.sh | 2 +- 19 files changed, 284 insertions(+), 242 deletions(-) create mode 100755 script/check-shell-scripts.sh Changeset truncated at 500 lines: diff --git a/.gitlab-ci-main.yml b/.gitlab-ci-main.yml index ce30e044335..a14d8e66fc7 100644 --- a/.gitlab-ci-main.yml +++ b/.gitlab-ci-main.yml @@ -47,7 +47,7 @@ variables: # Set this to the contents of bootstrap/sha1sum.txt # which is generated by bootstrap/template.py --render # - SAMBA_CI_CONTAINER_TAG: b62662cd85b10ca4767b9ead4e9b0482ad98ddb2 + SAMBA_CI_CONTAINER_TAG: 1e06877f1afbb3dbd4283e00310d63216a274333 # # We use the ubuntu1804 image as default as # it matches what we have on sn-devel-184. diff --git a/bootstrap/config.py b/bootstrap/config.py index a00b253ae77..bf2ce5207bb 100644 --- a/bootstrap/config.py +++ b/bootstrap/config.py @@ -133,6 +133,8 @@ PKGS = [ ('', 'rpcsvc-proto-devel'), # for <rpcsvc/rquota.h> header ('mawk', 'gawk'), ('', 'mold'), + ('', 'ShellCheck'), + ('', 'shfmt'), ('python3', 'python3'), ('python3-cryptography', 'python3-cryptography'), # for krb5 tests @@ -472,6 +474,8 @@ RPM_DISTS = { 'python3-setproctitle': 'python36-setproctitle', 'tracker-devel': '', # do not install 'mold': '', + 'ShellCheck': '', + 'shfmt': '', } }, 'centos8s': { @@ -487,6 +491,8 @@ RPM_DISTS = { 'perl-FindBin': '', 'liburing-devel': '', # not available yet, Add me back, once available! 'mold': '', + 'ShellCheck': '', + 'shfmt': '', } }, 'fedora36': { @@ -540,6 +546,8 @@ RPM_DISTS = { 'glusterfs-api-devel': '', 'libtasn1-tools': '', # asn1Parser is part of libtasn1 'mold': '', + 'ShellCheck': '', + 'shfmt': '', } } } diff --git a/bootstrap/generated-dists/f36mit120/bootstrap.sh b/bootstrap/generated-dists/f36mit120/bootstrap.sh index c2bbdb18908..c46dcf0d705 100755 --- a/bootstrap/generated-dists/f36mit120/bootstrap.sh +++ b/bootstrap/generated-dists/f36mit120/bootstrap.sh @@ -15,6 +15,7 @@ dnf update -y dnf install -y \ --setopt=install_weak_deps=False \ @development-tools \ + ShellCheck \ acl \ attr \ autoconf \ @@ -109,6 +110,7 @@ dnf install -y \ rpcsvc-proto-devel \ rsync \ sed \ + shfmt \ sudo \ systemd-devel \ tar \ diff --git a/bootstrap/generated-dists/f36mit120/packages.yml b/bootstrap/generated-dists/f36mit120/packages.yml index 646a282178a..d1e9af5af3d 100644 --- a/bootstrap/generated-dists/f36mit120/packages.yml +++ b/bootstrap/generated-dists/f36mit120/packages.yml @@ -1,6 +1,7 @@ --- packages: - @development-tools + - ShellCheck - acl - attr - autoconf @@ -95,6 +96,7 @@ packages: - rpcsvc-proto-devel - rsync - sed + - shfmt - sudo - systemd-devel - tar diff --git a/bootstrap/generated-dists/fedora36/bootstrap.sh b/bootstrap/generated-dists/fedora36/bootstrap.sh index 32379e34331..6cbde6f3411 100755 --- a/bootstrap/generated-dists/fedora36/bootstrap.sh +++ b/bootstrap/generated-dists/fedora36/bootstrap.sh @@ -12,6 +12,7 @@ dnf update -y dnf install -y \ --setopt=install_weak_deps=False \ @development-tools \ + ShellCheck \ acl \ attr \ autoconf \ @@ -106,6 +107,7 @@ dnf install -y \ rpcsvc-proto-devel \ rsync \ sed \ + shfmt \ sudo \ systemd-devel \ tar \ diff --git a/bootstrap/generated-dists/fedora36/packages.yml b/bootstrap/generated-dists/fedora36/packages.yml index 646a282178a..d1e9af5af3d 100644 --- a/bootstrap/generated-dists/fedora36/packages.yml +++ b/bootstrap/generated-dists/fedora36/packages.yml @@ -1,6 +1,7 @@ --- packages: - @development-tools + - ShellCheck - acl - attr - autoconf @@ -95,6 +96,7 @@ packages: - rpcsvc-proto-devel - rsync - sed + - shfmt - sudo - systemd-devel - tar diff --git a/bootstrap/sha1sum.txt b/bootstrap/sha1sum.txt index d9766fd37b9..0830eea5f84 100644 --- a/bootstrap/sha1sum.txt +++ b/bootstrap/sha1sum.txt @@ -1 +1 @@ -b62662cd85b10ca4767b9ead4e9b0482ad98ddb2 +1e06877f1afbb3dbd4283e00310d63216a274333 diff --git a/examples/LDAP/get_next_oid b/examples/LDAP/get_next_oid index f268b47b50d..bc3d6fc43c4 100755 --- a/examples/LDAP/get_next_oid +++ b/examples/LDAP/get_next_oid @@ -3,13 +3,13 @@ nextattrib=$(cat samba.schema | grep -i attributetype.*\(.*1.3.6.1.4.1.7165. | grep -v '^#' | awk '{print $3}' | cut -d. -f 10 | sort -n | tail -1) -( (nextattrib += 1)) +netattrib=$((netattrib + 1)) echo "attributetype ( 1.3.6.1.4.1.7165.2.1.$nextattrib NAME ...." nextoc=$(cat samba.schema | grep -i objectclass.*\(.*1.3.6.1.4.1.7165. | grep -v '^#' | awk '{print $3}' | cut -d. -f 10 | sort -n | tail -1) -( (nextoc += 1)) +nextoc=$((nextoc + 1)) echo "objectclass ( 1.3.6.1.4.1.7165.2.2.$nextoc NAME ...." diff --git a/examples/printing/VampireDriversFunctions b/examples/printing/VampireDriversFunctions index f245c31ed58..b06e3653214 100644 --- a/examples/printing/VampireDriversFunctions +++ b/examples/printing/VampireDriversFunctions @@ -23,7 +23,7 @@ ###################################################################### ## Here an example calling sequence -##!/bin/sh +##!/bin/sh ## set -x ## source VampireDriversFunctions @@ -48,7 +48,7 @@ ## ## fetchenumdrivers3listfromNThost # repeat, if no success at first -## createdrivernamelist +## createdrivernamelist ## createprinterlistwithUNCnames # repeat, if no success at first ## createmapofprinterstodriver ## splitenumdrivers3list @@ -71,7 +71,7 @@ function vampiredrivers_readme() { echo -e " \n\ ############################################################################ -# +# # About the \"Vampire Printer Drivers\" set of functions.... # -------------------------------------------------------- # @@ -80,7 +80,7 @@ echo -e " \n\ # # ------------------------------------------------------------ # -# Version: 0.8 (largely \"self-documented\" now, but not yet +# Version: 0.8 (largely \"self-documented\" now, but not yet # completely -- if it ever will be....) # # Thanks a lot to Fabian Franz for helping me with some important @@ -104,68 +104,68 @@ echo -e " \n\ # driver. Also, driver versions \"0\", \"2\" and \"3\" are placed in # further subdirectories. # -# -# Known problems: -# --------------- -# -# 1) I found one printer driver containing a \"slash\" which is not -# handled by this script: \"HP Color LaserJet 5/5M PS\". (There -# are more of these in the wild, of course.) -- The reason: I +# +# Known problems: +# --------------- +# +# 1) I found one printer driver containing a \"slash\" which is not +# handled by this script: \"HP Color LaserJet 5/5M PS\". (There +# are more of these in the wild, of course.) -- The reason: I # didn't find a way to create a Unix directory containing a \"slash\". # UPDATE: The script replaces the \"/\" with a \"_\" and also renames -# the drivername accordingly, when it is uploaded to the Samba +# the drivername accordingly, when it is uploaded to the Samba # [print$] share.... -# -# 2) There is an unsolved problem in case a real file name deviates -# in its case sensitive spelling from how it is displayed by the -# \"rpcclient enumdrivers\" command. I encountered cases where -# rpcclient displayed \"PS5UI.DLL\" as a file name, but \"smbclient -# mget\" retrieved \"ps5ui.dll\" from the NT printserver, and the -# driverinstallation failed because \"smbclient mput\" tried to put +# +# 2) There is an unsolved problem in case a real file name deviates +# in its case sensitive spelling from how it is displayed by the +# \"rpcclient enumdrivers\" command. I encountered cases where +# rpcclient displayed \"PS5UI.DLL\" as a file name, but \"smbclient +# mget\" retrieved \"ps5ui.dll\" from the NT printserver, and the +# driverinstallation failed because \"smbclient mput\" tried to put # \"PS5UI.DLL\" back onto the Samba server where UNIX only had # \"ps5ui.dll\" available (which of course failed). -- UPDATE: this -# is now solved. All files are renamed now to the same -# case-sensitive spelling as \"rpcclient ... enumdrivers 3\" +# is now solved. All files are renamed now to the same +# case-sensitive spelling as \"rpcclient ... enumdrivers 3\" # announces. This includes renaming into both, uppercase or # lowercase, as the case might be.... -# +# # 3) This script is probably not portable at all and relies on lots # of Bash-isms. -# +# # 4) This script runs with rpcclient from Samba-3.0.2a (or later) only # (because it uses the \"Version\" parameter for \"adddriver\"). # # The following functions use a few external variables to log -# into the 2 hosts. We suggest that you create a file which +# into the 2 hosts. We suggest that you create a file which # contains the variables and that you source that file at the -# beginning of this script... -# +# beginning of this script... +# # ################################################################# # -# ntprinteradmin=Administrator # any account on the NT host +# ntprinteradmin=Administrator # any account on the NT host # # with SePrintOperatorPrivilege privileges # ntadminpasswd=not4you # the printer admin password on # # the NT print server -# nthost=windowsntprintserverbox # the netbios name of the NT print +# nthost=windowsntprintserverbox # the netbios name of the NT print # # server -# -# smbprinteradmin=knoppix # an account on the Samba server +# +# smbprinteradmin=knoppix # an account on the Samba server # # with SePrintOperatorPrivilege privileges # smbadminpasswd=2secret4you # the printer admin password on # # the Samba server -# smbhost=knoppix # the netbios name of the Samba +# smbhost=knoppix # the netbios name of the Samba # # print server # # ################################################################# # -# -# NOTE: these functions also work for 2 NT print servers: snatch all -# drivers from the first, and upload them to the second server (which -# takes the role of the \"Samba\" server). Of course they also work -# for 2 Samba servers: snatch all drivers from the first (which takes +# +# NOTE: these functions also work for 2 NT print servers: snatch all +# drivers from the first, and upload them to the second server (which +# takes the role of the \"Samba\" server). Of course they also work +# for 2 Samba servers: snatch all drivers from the first (which takes # the role of the NT print server) and upload them to the second.... -# -# +# +# # ............PRESS \"q\" TO QUIT............" \ |less } @@ -180,7 +180,7 @@ echo -e " \n\ function helpwithvampiredrivers() { -if stringinstring help $@ ; then +if stringinstring help "$@"; then helpwithvampiredrivers ; else echo " "; @@ -210,7 +210,7 @@ fi # ----------------------------------------------------------------------------- function enumallfunctions() { -if stringinstring help $@ ; then +if stringinstring help "$@"; then helpwithvampiredrivers ; else echo " " @@ -218,23 +218,23 @@ else echo "--> Running now function enumallfunctions()..." echo "==============================================" echo -e " \n\ - - NOTE: run the listed functions in the same order as listed below. - + + NOTE: run the listed functions in the same order as listed below. + EXAMPLE: \"knoppix@ttyp6[knoppix]$ helpwithvampiredrivers\" - + HELP: the \"--help\" parameter prints usage hints regarding a function. - - EXAMPLE: \"knoppix@ttyp6[knoppix]$ fetchenumdrivers3listfromNThost --help\" - + EXAMPLE: \"knoppix@ttyp6[knoppix]$ fetchenumdrivers3listfromNThost --help\" + + function vampiredrivers_readme() - function enumallfunctions() + function enumallfunctions() function helpwithvampiredrivers() function fetchenumdrivers3listfromNThost() # repeat, if no success at first - function createdrivernamelist() + function createdrivernamelist() function createprinterlistwithUNCnames() # repeat, if no success at first - function createmapofprinterstodrivers() + function createmapofprinterstodrivers() function splitenumdrivers3list() function makesubdirsforW32X86driverlist() function splitW32X86fileintoindividualdriverfiles() @@ -251,10 +251,10 @@ fi # this is a helperfunction (Thanks to Fabian Franz!) function stringinstring() { - case "$2" in *$1*) - return 0 + case "$2" in *$1*) + return 0 ;; - esac + esac return 1 } @@ -267,17 +267,17 @@ function helpwithfetchenumdrivers3listfromNThost() { echo -e " \n\ ################################################################################ -# +# # About fetchenumdrivers3listfromNThost().... # ------------------------------------------- # -# PRECONDITIONS: 1) This function expects write access to the current directory. -# 2) This function expects to have the '\$nthosts', -# '\$ntprinteradmin' and '\$ntadminpasswd' variables set to +# PRECONDITIONS: 1) This function expects write access to the current directory. +# 2) This function expects to have the '\$nthosts', +# '\$ntprinteradmin' and '\$ntadminpasswd' variables set to # according values. # # WHAT IT DOES: This function connects to the '\$nthost' (using the credentials -# '\$ntprinteradmin' with '\$ntadminpasswd', retrieves a list of +# '\$ntprinteradmin' with '\$ntadminpasswd', retrieves a list of # drivers (with related file names) from that host, and saves the # list under the name of '\${nthost}/enumdrivers3list.txt' (ie. it # also creates the '\$nthost' subdirectory in the current one). It @@ -285,13 +285,13 @@ echo -e " \n\ # # IF IT DOESN'T WORK: It may happen that the function doesn't work at the first # time (there may be a connection problem). Just repeat a -# few times. It may work then. You will recognize if it +# few times. It may work then. You will recognize if it # does. # # HINT: The current values: 'nthost'=\"$nthost\" # 'ntprinteradmin'=\"$ntprinteradmin\" # 'ntadminpasswd'=<not shown here, check yourself!> -# +# ################################################################################" echo " " } @@ -300,7 +300,7 @@ echo " " function fetchenumdrivers3listfromNThost() { -if stringinstring help $@ ; then +if stringinstring help "$@"; then helpwithfetchenumdrivers3listfromNThost; else echo " " @@ -312,7 +312,7 @@ else | sed -e '/^.*Driver Name: \[.*\]/ y/\//_/' \ | tee \ ${nthost}/enumdrivers3list.txt; - + NUMBEROFDIFFERENTDRIVERNAMES=$( grep "Driver Name:" ${nthost}/enumdrivers3list.txt \ | sort -f \ | uniq \ @@ -340,23 +340,23 @@ function helpwithcreatedrivernamelist() { echo -e " \n\ ################################################################################ -# +# # About createdrivernamelist()... # ------------------------------- # -# PRECONDITIONS: 1) This function expects to find the subdirectory '\$nthost' +# PRECONDITIONS: 1) This function expects to find the subdirectory '\$nthost' # and the file '\${nthost}/enumdrivers3list.txt' to exist. -# 2) This function expects to have the '\$nthosts' variable set +# 2) This function expects to have the '\$nthosts' variable set # to an according value. # -# WHAT IT DOES: This function dissects the '\${nthost}/enumdrivers3list.txt' +# WHAT IT DOES: This function dissects the '\${nthost}/enumdrivers3list.txt' # and creates other textfiles from its contents: # - '\${nthost}/drvrlst.txt' # - '\${nthost}/completedriverlist.txt' # and further prints some more info to stdout. # # HINT: The current value: 'nthost'=\"$nthost\" -# +# ################################################################################" } @@ -364,7 +364,7 @@ echo -e " \n\ function createdrivernamelist() { -if stringinstring help $@ ; then +if stringinstring help "$@"; then helpwithcreatedrivernamelist; else echo " "; @@ -382,7 +382,7 @@ else | tee \ ${nthost}/drvrlst.txt; drvrlst=$(echo ${nthost}/drvrlst.txt); - + cat ${nthost}/enumdrivers3list.txt \ | grep "Driver Name:" \ | awk -F "[" '{ print $2 }' \ @@ -394,7 +394,7 @@ else | sed -e 's/^ */DRIVERNAME/' -e 's/\t/\="/' \ | tee \ ${nthost}/completedriverlist.txt; - + NUMBEROFDRIVERS=`cat ${nthost}/completedriverlist.txt| wc -l`; echo " "; echo "--> Finished in running function createdrivernamelist...."; @@ -422,12 +422,12 @@ function helpwithcreateprinterlistwithUNCnames() { echo -e " \n\ ################################################################################ -# +# # About createprinterlistwithUNCnames()... # ---------------------------------------- # -# PRECONDITIONS: 1) This function expects write access to the current directory. -# 2) This function expects to have the '\$nthost', +# PRECONDITIONS: 1) This function expects write access to the current directory. +# 2) This function expects to have the '\$nthost', # '\$ntprinteradmin' and '\$ntadminpasswd' variables set to # according values. # @@ -436,7 +436,7 @@ echo -e " \n\ # printqueues (with associated driver names) from that host (with -- Samba Shared Repository