This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Making 'su' work under a cygwin bash shell

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
$ runas

RUNAS [/profile] [/env] [/netonly] /user:<UserName> 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           <UserName> should be in form USER@DOMAIN or DOMAIN\USER
   program         command line for EXE.  See below for examples

> runas /profile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env / "notepad \"my file.txt\""

NOTE:  Enter user's password only when prompted.
NOTE:  USER@DOMAIN is not compatible with /netonly.

*  Peter Wohlers *

"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
> $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
> 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:
> Bug reporting:
> Documentation:
> FAQ:         

*  Peter Wohlers *

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]