Hi VK,

(btw. this is possibly not the right alias for this sort of question,
perhaps opensolaris-discuss would have been better, but I'll try to help
anyway..)

On Fri, 2006-09-15 at 08:01 -0700, vivek kamat wrote:
> I want all the activity to be logged for that user.

Why? Are you sure you want it done this way, rather using the builtin
auditing facility?

More at:
http://docs.sun.com/app/docs/doc/816-4557/6maosrjoi?a=view


> The process starts successfully.  The parent process id changes to 1
> as expected. however terminal is still showing /dev/pts/1.
> As soon as i log out of the menu My process gets killed.

Weird. Without seeing your shell script, it's hard to know what's really
going on.  Likewise, starting a daemon process without ctrun or smf
might be unwise, but it depends on what you're trying to achieve.

Do you definitely need to write your own menu-based shell ? There's some
potential problems with them mentioned at:
http://www.securityfocus.com/infocus/1575


OpenSolaris can restrict what commands a user can execute using RBAC,
another builtin security facility in OpenSolaris. More on Darren's blog
at:
http://blogs.sun.com/darren/entry/using_solaris_rbac_to_only


That said, if you do need a menu-based shell, there are many others out
there: we used "flash" back in UCD Netsoc, but that was some time ago -
haven't tried it on Solaris.

http://www.netsoc.ucd.ie/flash/
a quick search found some more menu based shells (none of which I've
used)
 - http://www.ibiblio.org/pub/Linux/system/shells/!INDEX.html



After all this, if you're still sure you want to write your own, here's
what works for me:

# grep test /etc/passwd
test:x:206159:1::/export/home/test:/tmp/menu.sh
# cat /tmp/menu.sh
#!/bin/ksh
FOO=1
while [ $FOO != 4 ]
do

cat <<EOF
1. Run ps -fu test
2. Run fortune
3. Start a daemon
4. Exit
EOF

 /usr/bin/echo "Enter a number : \c"
 read FOO
 case $FOO in
  1)
     ps -fu test
  ;;
  2)
    /usr/local/bin/fortune
  ;;
  3)
    # this doesn't work
    # echo "nohup grep something /dev/urandom" | at now
    # this works fine
    nohup grep "something" /dev/urandom &
    
  ;;
  4)
    return 0
  ;;
  *)
    echo "Unknown menu command"
  ;;
  esac
done


Here's me using it:

timf at haiiro[555] ssh test at localhost
Password:
Last login: Fri Sep 15 17:35:04 2006 from localhost
1. Run ps -fu test
2. Run vi
3. Start a daemon
4. Exit
Enter a number : 1
     UID    PID   PPID   C    STIME TTY         TIME CMD
    test 288792 288785   0 17:23:35 ?           0:00 /usr/lib/ssh/sshd
    test 288793 288792   0 17:23:35 pts/17
0:00 /bin/ksh /tmp/menu.sh
    test 289222 288793   0 17:26:53 pts/17      0:00 ps -fu test
1. Run ps -fu test
2. Run fortune
3. Start a daemon
4. Exit
Enter a number : 2
Love your enemies: they'll go crazy trying to figure out what you're up
to.
1. Run ps -fu test
2. Run fortune
3. Start a daemon
4. Exit
Enter a number : 3
Sending output to nohup.out
1. Run ps -fu test
2. Run fortune
3. Start a daemon
4. Exit
Enter a number : 1
     UID    PID   PPID   C    STIME TTY         TIME CMD
    test 288792 288785   0 17:23:35 ?           0:00 /usr/lib/ssh/sshd
    test 288793 288792   0 17:23:35 pts/17      0:00 /bin/ksh /tmp/menu.sh
    test 289232 288793  11 17:27:39 pts/17      0:05 grep something /dev/urandom
    test 289235 288793   0 17:27:45 pts/17      0:00 ps -fu test
1. Run ps -fu test
2. Run fortune
3. Start a daemon
4. Exit
Enter a number : 4
Connection to localhost closed.
timf at haiiro[556] ps -fu test
     UID    PID   PPID   C    STIME TTY         TIME CMD
    test 289232      1  21 17:27:39 ?           0:11 grep something /dev/urandom



Okay - hope all this helps,

        cheers,
                        tim


-- 
Tim Foster, Sun Microsystems Inc, Solaris Engineering Ops
http://blogs.sun.com/timf


Reply via email to