activemq icon indicating copy to clipboard operation
activemq copied to clipboard

Renames env script to avoid possible POSIX env shadowing

Open bric3 opened this issue 9 years ago • 12 comments

Got an issue with other shell scripts, turns out that when one prepends $PATH by activemq/bin, env is shadowed by ActiveMQ's env.

That means that script that want to run commands in customized environment will simple don't be executed like :

env A=aaa B=bbb mv ...

Worse such lines won't fail, because this will return the 0 exit status. The workaround is simple, i.e. append in %PATH instead of prepend. But a proper fix is needed. This PR proposes to rename the shell script from env to activemq-env.

bric3 avatar Jun 08 '15 13:06 bric3

ActiveMQ-PR-Build #55 SUCCESS This pull request looks good

asfbot avatar Jun 08 '15 13:06 asfbot

There's other executable that may be renamed, like diag, I can extends this PR if this makes sense.

bric3 avatar Jun 08 '15 14:06 bric3

Another matter why this PR should be accepted, env is actually part of the POSIX specification : http://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html

bric3 avatar Jun 09 '15 20:06 bric3

ActiveMQ-PR-Build #82 SUCCESS This pull request looks good

asfbot avatar Jul 01 '15 13:07 asfbot

While I agree that env should not be shadowed, you probably don't need it. Your example works fine without env:

A=aaa B=bbb mv ...

The env command is more useful when you need :

  • to print your shell script/prompt environment (env)
  • to run a command with a clean environment (env -i A=aaa B=bbb mv ...)
  • an absolute path for a command, like in scripts shebangs (#!/usr/bin/env python)

dridi avatar Jul 01 '15 16:07 dridi

@Dridi The problem is it's a POSIX command. And any script has a right to rely on that command. It's not even about scripts I own, it actually broke scripts written by others. And they shouldn't have to rewrote them because of this.

bric3 avatar Jul 01 '15 19:07 bric3

@bric3 As I said, I agree with you. I highlighted the fact that you don't need env in the example you give, hoping that would help you until it's fixed in activemq.

dridi avatar Jul 03 '15 10:07 dridi

@Dridi Yeah sure, but still

bric3 avatar Jul 03 '15 13:07 bric3

Does this happen because the file "env" has exec permissions and the activemq bin folder is part of the PATH variable?

scoopex avatar Jul 04 '15 06:07 scoopex

@scoopex Yes, just like any developer add path/to/maven/bin to $PATH

bric3 avatar Jul 05 '15 23:07 bric3

If "activemmq/bin/env" is not an executable, you should not have the problem. ("env" is just a configuration for the initscript - so it might be better to move it to the "conf" folder)

scoopex avatar Jul 07 '15 05:07 scoopex

If "activemmq/bin/env" is not an executable, you should not have the problem.

It is executable otherwise I wouldn't have encountered the issue, agreed that is another solution, but with that solution the problem can come back in the future, any developer of activemq may want to chmod +x the bin folder.

bric3 avatar Jul 07 '15 06:07 bric3

Superseeded by #1074 1074

jbonofre avatar Oct 16 '23 09:10 jbonofre