help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Option execfail does not work in subshells


From: DJ Mills
Subject: Re: [Help-bash] Option execfail does not work in subshells
Date: Wed, 9 Aug 2017 13:38:45 -0400

If you don't mind my asking, why are you having a user pass commands in the
first place? That's an excellent way to be rather insecure.

On Wed, Aug 9, 2017 at 8:43 AM, R. Diez <address@hidden> wrote:

>
>
> I had to look at the source. Subshells are specifically exempted from the
>> execfail settings. It's been this way for at least 24 years, so the exact
>> reason is lost to time.
>>
>
> Thanks for looking. I could almost forgive your wrong answer yesterday.
> }8-)
>
> I am writing a shell script which needs execfail to work in a subshell,
> specifically when starting a background process with & . The reason is, I
> want to print a proper error message when the user passes the wrong command
> (for example), but I could think of other actions, like logging the failure
> somewhere.
>
> There does not seem to be a valid reason for execfail to not work in a
> subshell. Should I create a bug for this? (I am assuming that there is a
> public bug tracker for Bash).
>
> There is one other thing that I noticed. When the 'exec' calls redirects
> stdout and stderr, they remain redirected after 'exec' fails. I resorted to
> saving and restoring their file descriptors in this scenario. However, I
> think that this fact should be clearly documented, because, at the moment,
> after reading the docs you tend to believe that such a permanent
> redirection should only be the case if you specify no command to run in the
> 'exec' calls.
>
> In any case, I wonder what other things do not get restored properly after
> 'exec' fails.
>
> Regards,
>   rdiez
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]