This is the mail archive of the
mailing list for the Cygwin project.
Re: SSH Path Bug
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Sun, 1 May 2005 11:55:20 +0200
- Subject: Re: SSH Path Bug
- References: <AAE27702C6ACD84FA3BB03D6C04C2B67B5F6@swebtec-exchang.Swebtec.com> <4272E677.CB0D7E3A@dessent.net> <email@example.com>
- Reply-to: cygwin at cygwin dot com
On Apr 30 14:53, Larry Hall wrote:
> At 09:59 PM 4/29/2005, you wrote:
> >Dominic Chambers wrote:
> >> Running commands via SSH causes windows executables to be given path
> >> priority, so that they run ahead of identically named UNIX executables. I
> >> found this while trying to use the find command as part of an SSH call.
> >> For example, assuming you have an SSH server set up:
> >I would think this has more to do with how you set your path than
> >anything else. [...]
> No, it's not that. I was able to reproduce the described behavior even
> when my system path has Cygwin's bin path before Windows.
Sounds more like a cockpit error. I just tried it and I can't reproduce it.
> Running 'sshd'
> in debug mode showed the imported path that was not an exact match to any
> path I'd set anywhere. So far, I haven't been able to get far enough
> that I know why this happens. But I can say that it happens for me
> and on more than 1 system and O/S.
It's not a bug, it's a feature :-)
What happens is a combination of what's done in cygrunsrv and sshd.
First, cygrunsrv adds the path to /bin to the environment before starting
a child process. But it *appends* /bin to the path, so that the order
of path evaluation isn't changed. So that can be taken out of the equation.
And what does sshd? Sshd is equivalent to a login process, so on non-Cygwin
systems, it has to set the PATH variable to the default path value for the
system. Usually something like PATH="/usr/bin:/bin".
On Windows it's a bit different because the PATH variable given to service
process (== the system environment) already contains paths, which are
required to run any process on Windows. So the PATH variable must not be
replaced by default paths as on other systems. Consequentially, Cygwin-sshd
does not change $PATH at all, but uses the default PATH as it is set in the
Windows system environment. This is, IMHO, the equivalent to the default
PATH on other systems.
What you can do:
- Prepend Cygwin paths to your system environment and restart(!) the PC.
- Set the default PATH only for your sshd service, for instance
cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd -a -D \
assuming your Windows is installed in C:\Windows
- Even better: Always use absolute paths when running remote applications.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader mailto:firstname.lastname@example.org
Red Hat, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html