From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jaleel Ahmed Newsgroups: gmane.os.tru64.managers Subject: Summary: daemon process attached to a user Date: Wed, 22 May 2002 20:44:19 -0700 (PDT) Sender: tru64-unix-managers-owner@ornl.gov Message-ID: <20020523034419.54020.qmail@web13904.mail.yahoo.com> References: <20020521105152.3584.qmail@web13904.mail.yahoo.com> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1022125461 16255 127.0.0.1 (23 May 2002 03:44:21 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 23 May 2002 03:44:21 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.33 #1 (Debian)) id 17AjWX-0004E4-00 for ; Thu, 23 May 2002 05:44:21 +0200 Original-Received: (qmail 1633 invoked by uid 5); 23 May 2002 03:44:47 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 1625 invoked from network); 23 May 2002 03:44:47 -0000 Original-Received: from unknown (HELO emroute1.cind.ornl.gov) (134.167.3.119) by 0 with SMTP; 23 May 2002 03:44:47 -0000 Original-Received: from emroute1.cind.ornl.gov (localhost [127.0.0.1]) by emroute1.cind.ornl.gov (PMDF V6.1 #39060) with ESMTP id <0GWJ00M9MP2MCZ@emroute1.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 22 May 2002 23:44:47 -0400 (EDT) Original-Received: from web13904.mail.yahoo.com (web13904.mail.yahoo.com [216.136.175.67]) by emroute1.cind.ornl.gov (PMDF V6.1 #39060) with SMTP id <0GWJ00087P1W63@emroute1.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 22 May 2002 23:44:20 -0400 (EDT) Original-Received: from [202.54.32.161] by web13904.mail.yahoo.com via HTTP; Wed, 22 May 2002 20:44:19 -0700 (PDT) In-Reply-To: <20020521105152.3584.qmail@web13904.mail.yahoo.com> Original-To: 'tru64unix Xref: main.gmane.org gmane.os.tru64.managers:294 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:294 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" 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." 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" /bin/su - -c '' possibly with nohup in front of it? Here, should be replaced by the user name of interest, linkewise should be replaced by the command of interest. "Ann Majeske" 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