delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/01/05:55:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 1 May 2005 11:55:20 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: SSH Path Bug
Message-ID: <20050501095519.GA25694@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <AAE27702C6ACD84FA3BB03D6C04C2B67B5F6 AT swebtec-exchang DOT Swebtec DOT com> <4272E677 DOT CB0D7E3A AT dessent DOT net> <6 DOT 2 DOT 1 DOT 2 DOT 0 DOT 20050430144713 DOT 089d60f8 AT pop DOT prospeed DOT net>
Mime-Version: 1.0
In-Reply-To: <6.2.1.2.0.20050430144713.089d60f8@pop.prospeed.net>
User-Agent: Mutt/1.4.2i

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 \
              -e "PATH=/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem"

  assuming your Windows is installed in C:\Windows

- Even better: Always use absolute paths when running remote applications.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019