]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Makefile: bail out on error in for-loops 205/head
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 19 Dec 2019 17:54:30 +0000 (18:54 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 19 Dec 2019 17:54:30 +0000 (18:54 +0100)
`make` runs each line in a shell and bails out on error,
however, the shell is not started with `-e`, so commands in
`for` loops can fail without the error actually causing
`make` to bail out with a failure status.

For instance, the following make snippet will end
successfully, printing 'SUCCESS', despite the first `chmod`
failing:

    all:
        touch a b
        for i in a-missing-file a b; do \
            chmod 666 $$i; \
        done
        @echo SUCCESS

To prevent wrong paths in install scripts from remaining
unnoticed, let's activate `set -e` in the `for` loop
subshells.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/Makefile.am

index 7b0aeec8e6ea5b981785ede37e9f753c5f5f99bc..f175928a60ccecd9d121f1bd1269d6bb353b2e17 100644 (file)
@@ -136,17 +136,17 @@ install-am: all-am
        $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
        ln -sf newgrp   $(DESTDIR)$(ubindir)/sg
        ln -sf vipw     $(DESTDIR)$(usbindir)/vigr
-       for i in $(suidbins); do \
+       set -e; for i in $(suidbins); do \
                chmod $(suidperms) $(DESTDIR)$(bindir)/$$i; \
        done
-       for i in $(suidubins); do \
+       set -e; for i in $(suidubins); do \
                chmod $(suidperms) $(DESTDIR)$(ubindir)/$$i; \
        done
-       for i in $(suidusbins); do \
+       set -e; for i in $(suidusbins); do \
                chmod $(suidperms) $(DESTDIR)$(usbindir)/$$i; \
        done
 if WITH_TCB
-       for i in $(shadowsgidubins); do \
+       set -e; for i in $(shadowsgidubins); do \
                chown root:shadow $(DESTDIR)$(ubindir)/$$i; \
                chmod $(sgidperms) $(DESTDIR)$(ubindir)/$$i; \
        done