Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3C2D12E4.57081AA@whack.org> Date: Fri, 28 Dec 2001 16:48:36 -0800 From: Peter Wohlers X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: "DePriest, Jason R." CC: "'cygwin AT cygwin DOT com'" Subject: Re: Making 'su' work under a cygwin bash shell References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 Dec 2001 00:48:43.0583 (UTC) FILETIME=[90BE9CF0:01C19002] Try using the native win2k command runas, which more closely resembles sudo than su The su.exe from NT4 days doesn's seem to be compatible with W2k. $ which runas /cygdrive/c/winnt/system32/runas $ runas RUNAS USAGE: RUNAS [/profile] [/env] [/netonly] /user: program /profile if the user's profile needs to be loaded /env to use current environment instead of user's. /netonly use if the credentials specified are for remote access only. /user should be in form USER AT DOMAIN or DOMAIN\USER program command line for EXE. See below for examples Examples: > runas /profile /user:mymachine\administrator cmd > runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc" > runas /env /user:user AT domain DOT microsoft DOT com "notepad \"my file.txt\"" NOTE: Enter user's password only when prompted. NOTE: USER AT DOMAIN is not compatible with /netonly. -- ****************** * Peter Wohlers * * pedro AT whack DOT org* ****************** "DePriest, Jason R." wrote: > > I have had only moderate success getting su.exe from the Windows 2000 > Resource Kit working as a drop-in for the unix 'su' command. > The version of su.exe that I am using is one that is not yet publicly > available, but the issues still remain (I had to get the newer version to > fix another issue I was having). > ************************************************************ > SU for Windows NT v3.00 Jun 28 2000 19:48:15 > (c) Copyright 1995, 1996, 1997. Written by Scott Field > ************************************************************ > > I don't know true shell scripting, so I wrote a simple perl script instead. > Assume the variables are defined correctly. > ************************************************************ > $ cat su2.pl > $user = 'Administrator'; > $password = '********'; > $domain = 'LocalHost'; > $cygrootNT = 'C:\\cygwin'; > $supathCYG = '/cygdrive/c/Program Files/Resource Kit'; > open(PASSTMP,">/tmp/$user.password"); > print PASSTMP $password; > close(PASSTMP); > print "\nAttemtping to execute the following:\n"; > print "\"$supathCYG\\su.exe\" $user \"$cygrootNT\\bin\\bash.exe\" $domain -v > -e < \"$cygrootNT\\tmp\\$user.password\"\n"; > system("\"$supathCYG\\su.exe\" $user \"$cygrootNT\\bin\\bash.exe\" $domain > -v -e < \"$cygrootNT\\tmp\\$user.password\""); > open(PASSTMP); > close(PASSTMP); > exit; > ************************************************************ > > The script ~almost~ works as desired. It runs the resultant bash prompt in > a new window. I want to figure out how to make the new bash shell run > inside the bash shell it was run from. > Here is the output from when I run it: > ************************************************************ > $ perl su2.pl > Attempting to execute the following: > "/cygdrive/c/Program Files/Resource Kit\su.exe" Administrator > "C:\cygwin\bin\bash.exe" THIN-LINE -v -e < > "C:\cygwin\tmp\Administrator.password" > User=Administrator > Domain=LocalHost > ReferencedDomain=LocalHost > CommandLine=C:\cygwin\bin\bash.exe > TextualSid=S-1-5-21-1960408961-152049171-1060284298-500 > LogonSid=S-1-5-5-0-7029156 > CurrentWinsta+Desktop=WinSta0\Default > TargetWinsta+Desktop=WinSta0\Default > ************************************************************ > > If anyone can tell me how to keep the shell in the same window, I'd be > appreciative. Or if anyone knows of some version of su that works natively > under a cygwin bash shell, I'd be even more appreciative! > > Thank you! > > Jason R DePriest > First Tennessee National Corporation > > ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ > > The views and ideas expressed in this message, while not necessarily the > opinion of the parent organization, are none the less confidential and > intended only for the designated recipient. > If you want to disseminate the information, you must obtain permission from > the originating sender or from the Data Security department of First > Tennessee National Corporation. > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Bug reporting: http://cygwin.com/bugs.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ -- ****************** * Peter Wohlers * * pedro AT whack DOT org* ****************** -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/