Repository: spack/spack

Issue:
Installation issue: openssh
### Steps to reproduce the issue

The current user is part of the group `my_group`:
```
% cd /opt
% sudo git clone https://github.com/spack/spack.git
% sudo chmod -R 774 spack/
% sudo chgrp -R my_group spack/
% cp spack/etc/spack/defaults/packages.yaml spack/etc/spack/packages.yaml
% nano spack/etc/spack/packages.yaml 

# modify packages.yaml as following:
# packages:
#  all:
#    compiler: [gcc, intel, pgi, clang, xl, nag, fj, aocc]
#    providers:
#        ...
#    permissions:
#      read: world
#      write: group
#      group: my_group

% spack/bin/spack install openssh
```

### Error message

```
==> Installing openssh-8.9p1-bduceyccy4v7q7v3chwm4m2r7djoacxq
==> No binary for openssh-8.9p1-bduceyccy4v7q7v3chwm4m2r7djoacxq found: installing from source
==> Using cached archive: /opt/spack/var/spack/cache/_source-cache/archive/fd/fd497654b7ab1686dac672fb83dfb4ba4096e8b5ffcdaccd262380ae58bec5e7.tar.gz
==> No patches needed for openssh
==> openssh: Executing phase: 'autoreconf'
==> openssh: Executing phase: 'configure'
==> openssh: Executing phase: 'build'
==> openssh: Executing phase: 'install'
==> Warning: Module file /opt/spack/share/spack/modules/linux-ubuntu20.04-sandybridge/openssh-8.9p1-gcc-10.3.0-bduceyc exists and will not be overwritten
==> Error: InvalidPermissionsError: Attempting to set suid with group writable

/opt/spack/lib/spack/spack/build_environment.py:1065, in _setup_pkg_and_run:
       1062        tb_string = traceback.format_exc()
       1063
       1064        # build up some context from the offending package so we can
  >>   1065        # show that, too.
       1066        package_context = get_package_context(tb)
       1067
       1068        logfile = None


```


### Information on your system

```
* **Spack:** 0.18.0.dev0 (cd0b6b90881126c73f050ba3b29e0cc570827f10)
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-sandybridge
* **Concretizer:** clingo

```

### Additional information

[spack-build-03-build-out.txt](https://github.com/spack/spack/files/8441673/spack-build-03-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/8441684/spack-build-env.txt)

@bernhardkaindl

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
Just for a short confirmation: I'm running into the same issue
I'm seeing the same issue from openssh-8.7p1-ntpy44vhmpzfymlooanrskm46vor7os5 when it's installed as part of git@2.31.1
(I was able to install git through spack by specifying my OS's openssl and openssh as a external packages, but that's certainly not a solution to this particular issue :) )


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openssh/package.py b/var/spack/repos/builtin/packages/openssh/package.py
old mode 100644
new mode 100755
--- a/var/spack/repos/builtin/packages/openssh/package.py
+++ b/var/spack/repos/builtin/packages/openssh/package.py
@@ -62,6 +62,10 @@ def determine_version(cls, exe):
         match = re.search(r'OpenSSH_([^, ]+)', output)
         return match.group(1) if match else None
 
+    def patch(self):
+        # #29938: skip set-suid (also see man ssh-key-sign: it's not enabled by default)
+        filter_file(r'\$\(INSTALL\) -m 4711', '$(INSTALL) -m711', 'Makefile.in')
+
     def configure_args(self):
         # OpenSSH's privilege separation path defaults to /var/empty. At
         # least newer versions want to create the directory during the


Test patch: