3 ms·
If this is how passing functions is supposed to work in bash, then why do I get different results, depending on which system I'm on? I've been madly patching m
by rootbear 12y ago
If this is how passing functions is supposed to work in bash, then why do I get different results, depending on which system I'm on? I've been madly patching my systems since yesterday and on a RHEL 6.5 system I get a different result than from an Ubuntu 12.04 system:
[RHEL-6.5 tmp]$ uname -a
Linux hostname1 2.6.32-431.23.3.el6.x86_64 #1 SMP Wed Jul 16 06:12:23 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
[RHEL-6.5 tmp]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
[RHEL-6.5 tmp]$ ls
file1 file2 file3
[RHEL-6.5 tmp]$ env ls='() { echo vulnerable; }' bash -c ls
file1 file2 file3
Linux hostname2 3.8.0-44-generic #66~precise1-Ubuntu SMP Tue Jul 15 04:01:04 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 12.04:~/tmp$ bash --version
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
Ubuntu 12.04:~/tmp$ ls
file1 file2 file3
Ubuntu 12.04:~/tmp$ env ls='() { echo vulnerable; }' bash -c ls
vulnerable
Is this a basic difference in the feature sets of Bash 4.1 and Bash 4.2? Like several posters, I was unaware of this feature and have certainly never used it. Perhaps it should be off by defaults? How big of a mess would that make? I would also like to see more distributions use something other than bash as /bin/sh, but that's another discussion, I guess.
- dahjelle 12y agoAs I mentioned in my other comment[1], I'm not 100% sure, but I think RedHat's patches for the 2nd vulnerability also cover this one. [1] https://news.ycombinator.com/item?id=8373320 https://news.ycombinator.com/item?id=8373320
- rootbear 12y agoBut which behavior is correct? On Ubuntu, ls is redefined, but isn't that what a shell function is supposed to do? If Red Hat "fixed" this, then haven't they disabled a feature? Sorry, not trying to be obtuse...
- dahjelle 12y agoGood question, I don't know…but looks like mzs's comment answers us both. ;-)
- mzs 12y agoYou need to use export -f now, the specifics of how functions are exported have changed in the redhat patch, ls='() { ... is not sufficient anymore. Nothing has broken unless you had something calling bash that was not bash and you used this internal to bash implementation hack-like knowledge that 'foo=() {' is how those pre this redhat patch versions of bash did it.
- rootbear 12y agoThank you! I haven't had time to read the documentation for Red Hat's change.
- daveloyall 12y agos/vulnerable/working/ Fixed that for you. :)