Double SHELL variable defined

Alejandro Lopez via sudo-workers <[email protected]> Thu, 6 Nov 2025 16:04:23 +0100
Newsgroups gmane.comp.tools.sudo.devel
Message-ID <CA+GxtHcH-KfzTujO9EfF770L9r3Vjkd1imV8dnCfUa3ObOErjg@mail.gmail.com>
--000000000000599ed30642ee62ba
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

A customer of ours found a minor bug when the `SHELL` variable is set twice
in the environment. Most of the time this is not a problem, but `zsh`
doesn't sanitize the environment as `bash` does, and two identical
variables are set. Accessing `$SHELL` will show only one of the variables,
but `env` will show both.

```
# dnf install -y zsh
# useradd -s /bin/zsh testuser
# sudo -iu testuser
$ env | grep SHELL
SHELL=3D/bin/zsh
SHELL=3D/bin/zsh
```

I wrote a fix and I would like your opinion before opening a pull request.
My fix just sets the `dupcheck` argument in the last call to
`CHECK_SETENV2()` in `rebuild_env()`, and I did this also for `TERM` and
`PATH` as I noticed they can also be set previously in the same function.

Attached is the patch. What do you guys think?

BTW, do you want me to open a ticket on Github?

Thank you.
--=20
Alejandro L=C3=B3pez
Red Hat

--000000000000599ed30642ee62ba
Content-Type: text/x-patch; charset="US-ASCII"; name="double-shell.patch"
Content-Disposition: attachment; filename="double-shell.patch"
Content-Transfer-Encoding: base64
Content-ID: <f_mhnk2kai0>
X-Attachment-Id: f_mhnk2kai0

ZGlmZiAtLWdpdCBhL3BsdWdpbnMvc3Vkb2Vycy9lbnYuYyBiL3BsdWdpbnMvc3Vkb2Vycy9lbnYu
YwppbmRleCA4NjZlZjM5OTEuLjdjN2VmYTNiYSAxMDA2NDQKLS0tIGEvcGx1Z2lucy9zdWRvZXJz
L2Vudi5jCisrKyBiL3BsdWdpbnMvc3Vkb2Vycy9lbnYuYwpAQCAtMTA4OCwxMSArMTA4OCwxMSBA
QCByZWJ1aWxkX2Vudihjb25zdCBzdHJ1Y3Qgc3Vkb2Vyc19jb250ZXh0ICpjdHgpCiAKICAgICAv
KiBQcm92aWRlIGRlZmF1bHQgdmFsdWVzIGZvciAkU0hFTEwsICRURVJNIGFuZCAkUEFUSCBpZiBu
b3Qgc2V0LiAqLwogICAgIGlmICghSVNTRVQoZGlkdmFyLCBESURfU0hFTEwpKQotCUNIRUNLX1NF
VEVOVjIoIlNIRUxMIiwgY3R4LT5ydW5hcy5wdy0+cHdfc2hlbGwsIGZhbHNlLCBmYWxzZSk7CisJ
Q0hFQ0tfU0VURU5WMigiU0hFTEwiLCBjdHgtPnJ1bmFzLnB3LT5wd19zaGVsbCwgdHJ1ZSwgZmFs
c2UpOwogICAgIGlmICghSVNTRVQoZGlkdmFyLCBESURfVEVSTSkpCi0JQ0hFQ0tfUFVURU5WKCJU
RVJNPXVua25vd24iLCBmYWxzZSwgZmFsc2UpOworCUNIRUNLX1BVVEVOVigiVEVSTT11bmtub3du
IiwgdHJ1ZSwgZmFsc2UpOwogICAgIGlmICghSVNTRVQoZGlkdmFyLCBESURfUEFUSCkpCi0JQ0hF
Q0tfU0VURU5WMigiUEFUSCIsIF9QQVRIX1NURFBBVEgsIGZhbHNlLCB0cnVlKTsKKwlDSEVDS19T
RVRFTlYyKCJQQVRIIiwgX1BBVEhfU1REUEFUSCwgdHJ1ZSwgdHJ1ZSk7CiAKICAgICAvKiBTZXQg
UFMxIGlmIFNVRE9fUFMxIGlzIHNldC4gKi8KICAgICBpZiAocHMxICE9IE5VTEwpCg==
--000000000000599ed30642ee62ba
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

____________________________________________________________
sudo-workers mailing list <[email protected]>
For list information, options, or to unsubscribe, visit:
https://www.sudo.ws/mailman/listinfo/sudo-workers

--000000000000599ed30642ee62ba--