RE: SSH Path Bug
Sorry I haven't replied sooner, was a bank holiday weekend over here. Thanks everyone for the excellent responses -- that was really educational, and beats the support you get from most paid-for systems. Thanks again, Dominic. -- 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/
Re: SSH Path Bug
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@cygwin.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/
Re: SSH Path Bug
At 05:55 AM 5/1/2005, you wrote: 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. Yeah, it looks like I must have been caught by Windows' insufferable need to be rebooted after almost any change. Why am I surprised? ;-) 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. I should have said Windows O/S here. Specifically, I tried it on W2K and XP. 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. As I said above, UGH! ;-) - 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 Yeah, this is probably the nicest from the user point of view. - Even better: Always use absolute paths when running remote applications. Yep. That certainly works and is the most portable. :-) Thanks. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- 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/
Re: SSH Path Bug
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. What is $PATH in the case when it finds the windows command, and what is $PATH when it finds the Cygwin command? Cygwin doesn't have any such notion of path priority, it just searches the path in order, so if it's finding the windows directory ahead of /usr/bin you need to figure out how your path is being set and correct it. 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. 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. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- 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/
Re: SSH Path Bug
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. What is $PATH in the case when it finds the windows command, and what is $PATH when it finds the Cygwin command? Cygwin doesn't have any such notion of path priority, it just searches the path in order, so if it's finding the windows directory ahead of /usr/bin you need to figure out how your path is being set and correct it. Brian -- 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/