From: Jaleel Ahmed <jaleelahmed@yahoo.com>
Subject: Summary: daemon process attached to a user
Date: Wed, 22 May 2002 20:44:19 -0700 (PDT) [thread overview]
Message-ID: <20020523034419.54020.qmail@web13904.mail.yahoo.com> (raw)
In-Reply-To: <20020521105152.3584.qmail@web13904.mail.yahoo.com>
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
prev parent reply other threads:[~2002-05-23 3:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-21 10:51 daemon process attached to a user Jaleel Ahmed
2002-05-23 3:44 ` Jaleel Ahmed [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox