Inheritance of PATH env var

Matt Johnston matt at ucc.asn.au
Wed Sep 11 19:55:54 AWST 2024


Hi Elliot,

I think it was an oversight - the -e flag was added later.

Your proposed behaviour sounds good as a default, it doesn't need to 
have a flag.
Maybe that could be documented in dropbear.8 and I'll mention in the 
changelog.

/sbin will probably already be in the path if it's running as root,
and otherwise the existing PATH from the parent should be suitable.

Cheers,
Matt

On 2024-09-11 7:34 pm, Elliot Bräck wrote:
> Hi there,
> 
> When running dropbear with the flag -e ("Pass on server process
> environment to child process"), I noticed that the PATH variable still
> was not inherited.
> 
> This is due to PATH unconditionally being set inside of 
> `svr-chansession.c`:
> 
> ```c
>         if (getuid() == 0) {
>                 addnewvar("PATH", DEFAULT_ROOT_PATH);
>         } else {
>                 addnewvar("PATH", DEFAULT_PATH);
>         }
> ```
> 
> Is this behaviour intentional?
> If not, what should the behaviour be? That if `-e` is set
> (svr_opts.pass_on_env), PATH should only be set to the default value
> if it does not already have a value from the environment?
> If it is, would a patch adding a non-default compile-time flag that
> changes this behaviour be accepted?
> 
> My use-case is that I would like to run a dropbear server which
> inherits the PATH environment variable from the executing environment,
> but the value of this environment variable is not known at compile
> time.
> 
> Thankful for your input,
> 
> ELLIOT BRÄCK
> Software Engineer
> Investment, OTC Core, Instruments Modelling
> 
> SimCorp A/S
> Weidekampsgade 16, 2300 Copenhagen S, Denmark
> www.simcorp.com
> Company reg. no. 15505281
> 
> 
> This message, and any associated files, is intended only for the use
> of the individual or entity to which it is addressed and may contain
> information that is confidential, privileged, subject to copyright or
> constitute a trade secret. If you are not the intended recipient you
> are hereby notified that any dissemination, copying, or distribution
> of this message or files associated with this message is strictly
> prohibited. If you have received this message in error, please notify
> us immediately or forward this message immediately to
> info at SimCorp.com...
> 
> Thank You
> ________________________________


More information about the Dropbear mailing list