delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/05/08/21:37:37

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <008801c315cb$8f7f60e0$c800a8c0@docbill>
From: "Bill C Riemers" <docbill AT freeshell DOT org>
To: <cygwin AT cygwin DOT com>
Subject: Re: cron
Date: Thu, 8 May 2003 21:37:32 -0400
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Note-from-DJ: This may be spam

------=_NextPart_000_0085_01C315AA.08321770
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Coronna,

That is exactly what I did when I realized the UID trick doesn't work under cygwin.  In fact I wrote myself a short script
as "/usr/local/bin/su" to use in place of "/usr/bin/su".   Like most scripts I write I found I really don't use it.  I just
keep it around incase something I download includes a script or a Makefile that requires a working version of su.

                                                             Bill



> That's way easier:
>
> Add a home dir and a useful shell to SYSTEM's /etc/passwd entry:
>
>   SYSTEM:*:18:544:,S-1-5-18:/home/system:/bin/bash
>
> Then:  Install sshd as service, create a private/public key pair, put
> the public key into /home/system/.ssh/authorized_keys and login to your
> system using `ssh -l system localhost'.
>
>
> Or:  Install inetd as service, remove the `*' from SYSTEM's password
> field and login to localhost using rlogin or telnet.
>
> Corinna
>
> -
>

------=_NextPart_000_0085_01C315AA.08321770
Content-Type: application/octet-stream;
	name="su"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="su"

#!/usr/bin/bash=0A=
# assign the environment to a=0A=
a=3D`env |sed -n -e '/^!::=3D/d' -e 's,$,_EOL_,g' -e 's,'\'',_APOS_,g' =
-e 's/\([A-Za-z0-9_][A-Za-z0-9_]*\)=3D/'\'';\1=3D'\''/' -e '/./p'`=0A=
=0A=
rm -f /tmp/env.$$=0A=
echo "#!`which bash`" > /tmp/env.$$=0A=
chmod 755 /tmp/env.$$=0A=
=0A=
userarg=3D"Administrator"=0A=
=0A=
options=3D":lc:fmps:"=0A=
repeat=3D1;=0A=
while [ $repeat -ne 0 ] ; do=0A=
  getopts $options arg=0A=
  if [ $? -ne 0 ] ; then=0A=
    arg=3D"$1"=0A=
    OPTIND=3D2=0A=
  fi=0A=
  case "x$arg" in =0A=
    xl | x- | x--login)=0A=
      loginarg=3D1=0A=
      if [ -z "$shellarg" ] ; then=0A=
        shellarg=3D`which bash`=0A=
      fi=0A=
      ;;=0A=
    xc | x--command | x--command)=0A=
      commandarg=3D"$OPTARG"=0A=
      ;;=0A=
    x--command=3D*)=0A=
      commandarg=3D"${arg##--command=3D}"=0A=
      ;;=0A=
    xf | x--fast )=0A=
      fastarg=3D1=0A=
      if [ -z "$shellarg" ] ; then=0A=
        shellarg=3D`which tcsh`=0A=
      fi=0A=
      if [ -z "$shellarg" ] ; then=0A=
        shellarg=3D`which csh`=0A=
      fi=0A=
      ;;=0A=
    xm | xp | x--preserve-environment)=0A=
      echo $a|sed -e 's,^'\'';,,' -e 's,_EOL_$,'\'',' -e 's,_EOL_ =
'\'';,'\'';\=0A=
,g' -e "s,_APOS_,'\\'',g" -e 's,_EOL_ ,\=0A=
,g' >> /tmp/env.$$=0A=
      env|sed -n -e 's,\([A-Za-z0-9_][A-Za-z0-9_]*\)=3D.*,export \1;,p' =
>> /tmp/env.$$=0A=
      preservearg=3D1=0A=
      ;;=0A=
    xs )=0A=
      shellarg=3D"$OPTARG"=0A=
      ;;=0A=
    x--shell)=0A=
      shellarg=3D"$OPTARG"=0A=
      OPTIND=3D3=0A=
      ;;=0A=
    x--shell=3D*)=0A=
      shellarg=3D"${arg##--shell=3D}"=0A=
      ;;=0A=
    *)=0A=
      repeat=3D0=0A=
      OPTIND=3D1=0A=
      ;;=0A=
  esac=0A=
  while [ $OPTIND -gt 1 ] ; do=0A=
    shift=0A=
    OPTIND=3D`expr $OPTIND - 1`=0A=
  done=0A=
done=0A=
if [ -n "$1" ] ; then=0A=
  userarg=3D"$1"=0A=
  shift=0A=
fi=0A=
if [ -z "$shellarg" ] ; then=0A=
  shellarg=3D`which bash`=0A=
fi=0A=
if [ -n "$commandarg" ] ; then=0A=
  echo "exec \"$shellarg\" $fastarg $loginarg -c \"$commandarg\"" =
>>/tmp/env.$$=0A=
elif [ -n "$*" ] ; then=0A=
  echo "exec \"$shellarg\" $fastarg $loginarg -c \"$@\"" >>/tmp/env.$$=0A=
else=0A=
  echo "exec \"$shellarg\" $fastarg $loginarg -i -s" >>/tmp/env.$$=0A=
fi=0A=
trap "rm -f /tmp/env.$$" EXIT=0A=
ssh -l "$userarg" localhost /tmp/env.$$=0A=
exit $?=0A=
=0A=
SU(1)                            User Commands                           =
SU(1)=0A=
=0A=
=0A=
=0A=
NAME=0A=
       su - run a shell with substitute user and group IDs=0A=
=0A=
SYNOPSIS=0A=
       su [OPTION]... [-] [USER [ARG]...]=0A=
=0A=
DESCRIPTION=0A=
       Change the effective user id and group id to that of USER.=0A=
=0A=
       -, -l, --login=0A=
              make the shell a login shell=0A=
=0A=
       -c, --commmand=3DCOMMAND=0A=
              pass a single COMMAND to the shell with -c=0A=
=0A=
       -f, --fast=0A=
              pass -f to the shell (for csh or tcsh)=0A=
=0A=
       -m, --preserve-environment=0A=
              do not reset environment variables=0A=
=0A=
       -p     same as -m=0A=
=0A=
       -s, --shell=3DSHELL=0A=
              run SHELL if /etc/shells allows it=0A=
=0A=
       --help display this help and exit=0A=
=0A=
       --version=0A=
              output version information and exit=0A=
=0A=
       A mere - implies -l.   If USER not given, assume root.=0A=
=0A=
AUTHOR=0A=
       Written by David MacKenzie.=0A=
=0A=
REPORTING BUGS=0A=
       Report bugs to <bug-sh-utils AT gnu DOT org>.=0A=
=0A=
COPYRIGHT=0A=
       Copyright (C) 2002 Free Software Foundation, Inc.=0A=
       This is free software; see the source for copying conditions.  =
There is=0A=
       NO warranty; not even for MERCHANTABILITY or FITNESS FOR  A  =
PARTICULAR=0A=
       PURPOSE.=0A=
=0A=
SEE ALSO=0A=
       The  full  documentation  for su is maintained as a Texinfo =
manual.  If=0A=
       the info and su programs are properly installed at your site, the =
 com-=0A=
       mand=0A=
=0A=
              info su=0A=
=0A=
       should give you access to the complete manual.=0A=
=0A=
=0A=
=0A=
su (sh-utils) 2.0.15              August 2002                            =
SU(1)=0A=


------=_NextPart_000_0085_01C315AA.08321770
Content-Type: text/plain; charset=us-ascii

--
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/
------=_NextPart_000_0085_01C315AA.08321770--


- Raw text -


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