Summary: daemon process attached to a user

From: Jaleel Ahmed (jaleelahmed@yahoo.com)
Date: Wed May 22 2002 - 23:44:19 EDT


Hi all
 Thanks to all who responded .. it was quite a simple
thing , i must have read some man pages or documents
before posting a query.
 The original question was

> A programming related question .. i have written a
> sockets based server which takes requests from
> clients
> and depending on the requests, forks a process .
> This
> server should run all the time as a daemon.
> Now this server has to be deployed (init i suppose
> )
> and i want this server to be run attached to a
> particular user ,inheriting the environment of that
> user. The processes forked ,access database and
> populate data. for this purpose the forked processes
> should be attached to a particular login.
> I hope i conveyed the problem properly .. it is
> quite
> a simple thing for you all but i couldnt get any
> thing
> on this (attaching the daemon created by init to a
> particuler login )
>
> Thanks in advance
>
>

The responses are
 "Stuart Whitby" <swhitby@legato.com>
   Leave the binary in /usr/bin, or wherever. Create
an rc file which starts the daemon using
      su - user -c /usr/bin/binary
 and stop by killing the binary (or issuing it a
shutdown).

"Dyer, Steve J." <Steve.Dyer@alcoa.com>

I believe you want to write a bourne shell script that
has a link into
the
/sbin/rc3.d directory.

Use a command like this:

# ln -s /usr/myappdir/S99usrapp.sh
/sbin/rc3.d/S99usrapp

Sample S99usrapp.sh below - substitute in your user
and your myapp (the
socket application)

#
# If we're starting up, invoke script with "start"
argument
#
if [ $1 = "start" ]; then
   su - [user]; nohup myapp
fi
#
# If we're shutting down, invoke script with "stop"
argument
#
if [ $1 = "stop" ]; then
# whatever you want to do when the system is shutting
down
fi

  mcaplin@miami.edu

You'll have to have the daemon do a setuid() and
possibly a setgid().
Since init runs as root, having privilege to change
uid/gid isn't an
issue. Other-wise, you'd have to have the daemon
owned by root and
have a
6750 (or similar) permission.

"John Venier" <venier@odin.mdacc.tmc.edu>

/bin/su - <username> -c '<command>'

possibly with nohup in front of it?

Here, <username> should be replaced by the user name
of interest,
linkewise <command> should be replaced by the command
of interest.

"Ann Majeske" <Ann.Majeske@hp.com>

 If all you want to do is fork a process to run as a
specific user you can use the sia_become_user()
routine
followed by setruid(). See the man pages and the
Security manual for more information.

Thanks again to all
 setuid worked for me
 jaleel

=====
 May Innocence and Joy Prevail

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:48:42 EDT