From decibel@decibel.org  Fri Feb  3 02:22:49 2006
Return-Path: <decibel@decibel.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A211016A420
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  3 Feb 2006 02:22:49 +0000 (GMT)
	(envelope-from decibel@decibel.org)
Received: from noel.decibel.org (noel.decibel.org [67.100.216.10])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4D1EC43D48
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  3 Feb 2006 02:22:49 +0000 (GMT)
	(envelope-from decibel@decibel.org)
Received: by noel.decibel.org (Postfix, from userid 1001)
	id E2C0739846; Thu,  2 Feb 2006 20:22:38 -0600 (CST)
Message-Id: <20060203022238.E2C0739846@noel.decibel.org>
Date: Thu,  2 Feb 2006 20:22:38 -0600 (CST)
From: Jim C. Nasby <decibel@decibel.org>
Reply-To: Jim C. Nasby <decibel@decibel.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Add ability to run slon as a different user
X-Send-Pr-Version: 3.113
X-GNATS-Notify: vivek@khera.org

>Number:         92755
>Category:       ports
>Synopsis:       databases/slony1: Add ability to run slon as a different user
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 03 02:30:02 GMT 2006
>Closed-Date:    Tue Sep 05 01:07:43 GMT 2006
>Last-Modified:  Fri Sep 22 17:50:20 GMT 2006
>Originator:     Jim C. Nasby
>Release:        FreeBSD 6.0-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD noel.decibel.org 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Wed Nov 2 19:07:38 UTC 2005 root@rat.samsco.home:/usr/obj/usr/src/sys/GENERIC amd64



--- files/slon.sh.in.org	Thu Feb  2 18:19:19 2006
+++ files/slon.sh.in	Thu Feb  2 19:51:57 2006
@@ -18,13 +18,30 @@
 name="%%NAME%%"
 rcvar=`set_rcvar`
 
+slon_user=${slon_user:-"root"}
 pidfile="/var/run/$name.pid"
 command="%%PREFIX%%/bin/slon"
 command_args="-f %%PREFIX%%/etc/$name.conf -p $pidfile &"
 required_files="%%PREFIX%%/etc/$name.conf"
 
+start_cmd="slon_command start"
+start_precmd="check_pid"
+
 # read configuration and set defaults
 load_rc_config "$name"
 : ${%%NAME%%_enable="NO"}
+
+slon_command()
+{
+    su -l ${slon_user} -c "exec ${command} ${command_args}"
+}
+
+check_pid()
+{
+    if ! su -l ${slon_user} -c "[ -w $pidfile ]"; then
+        touch $pidfile
+        chown ${slon_user} $pidfile
+    fi
+}
 
 run_rc_command "$1"
>Description:
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Fri Feb 3 21:17:52 UTC 2006 
State-Changed-Why:  
Awaiting maintainers feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92755 

From: Vivek Khera <vivek@khera.org>
To: bug-followup@FreeBSD.org,
 decibel@decibel.org
Cc:  
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Mon, 6 Feb 2006 16:04:55 -0500

 I'll accept this enhancement.
 
 But doesn't setting the slon_user variable automatically make it run  
 under that user?  I'm wondering what the point of the slon_command()  
 function is.  The only difference is the normal way would run with  
 'su -m' but yours does 'su -l'.  I think the former is preferable  
 since it doesn't require slony_user have a valid shell or password.
 
 Also, the variable slon_user should be filtered through %%NAME%%  
 expansion, and might be best located down where the enable flag is  
 defaulted, too.
 
 

From: "Jim C. Nasby" <decibel@decibel.org>
To: Vivek Khera <vivek@khera.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Mon, 6 Feb 2006 17:30:17 -0600

 On Mon, Feb 06, 2006 at 04:04:55PM -0500, Vivek Khera wrote:
 > I'll accept this enhancement.
 > 
 > But doesn't setting the slon_user variable automatically make it run  
 > under that user?  I'm wondering what the point of the slon_command()  
 > function is.  The only difference is the normal way would run with  
 > 'su -m' but yours does 'su -l'.  I think the former is preferable  
 > since it doesn't require slony_user have a valid shell or password.
 
 Hrm, is there magic in the rc system to account for slon_user? I just
 copied what the pgsql port does...
 
 > Also, the variable slon_user should be filtered through %%NAME%%  
 > expansion, and might be best located down where the enable flag is  
 > defaulted, too.
 
 I'm sure there's all sorts of better ways to do what I did... feel free.
 :)
 
 BTW, if you want to get fancy, there's currently nothing in the port
 about creating a user account. Might be best to just run under a slony
 user by default...
 -- 
 Jim C. Nasby, Database Architect                decibel@decibel.org 
 Give your computer some brain candy! www.distributed.net Team #1828
 
 Windows: "Where do you want to go today?"
 Linux: "Where do you want to go tomorrow?"
 FreeBSD: "Are you guys coming, or what?"

From: Vivek Khera <vivek@khera.org>
To: "Jim C. Nasby" <decibel@decibel.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Mon, 6 Feb 2006 21:53:56 -0500

 On Feb 6, 2006, at 6:30 PM, Jim C. Nasby wrote:
 
 > I'm sure there's all sorts of better ways to do what I did... feel  
 > free.
 > :)
 >
 > BTW, if you want to get fancy, there's currently nothing in the port
 > about creating a user account. Might be best to just run under a slony
 > user by default...
 
 Personally I run under the pgsql user and use daemontools to monitor  
 and keep the slon's running.
 
 Basically, all you have to do to your patch is whack out the  
 start_slon function and it is just what we need.
 

From: "Jim C. Nasby" <decibel@decibel.org>
To: Vivek Khera <vivek@khera.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Mon, 6 Feb 2006 21:22:53 -0600

 On Mon, Feb 06, 2006 at 09:53:56PM -0500, Vivek Khera wrote:
 > 
 > On Feb 6, 2006, at 6:30 PM, Jim C. Nasby wrote:
 > 
 > >I'm sure there's all sorts of better ways to do what I did... feel  
 > >free.
 > >:)
 > >
 > >BTW, if you want to get fancy, there's currently nothing in the port
 > >about creating a user account. Might be best to just run under a slony
 > >user by default...
 > 
 > Personally I run under the pgsql user and use daemontools to monitor  
 > and keep the slon's running.
 > 
 > Basically, all you have to do to your patch is whack out the  
 > start_slon function and it is just what we need.
 
 Do you want me to submit a new one?
 -- 
 Jim C. Nasby, Database Architect                decibel@decibel.org 
 Give your computer some brain candy! www.distributed.net Team #1828
 
 Windows: "Where do you want to go today?"
 Linux: "Where do you want to go tomorrow?"
 FreeBSD: "Are you guys coming, or what?"

From: Vivek Khera <vivek@khera.org>
To: "Jim C. Nasby" <decibel@decibel.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Tue, 7 Feb 2006 13:26:24 -0500

 On Feb 6, 2006, at 10:22 PM, Jim C. Nasby wrote:
 
 > Do you want me to submit a new one?
 
 Yes, please.  It makes it easier on the committer.  You could just  
 follow up to the PR with the revised patch.
 
 PS: what do you use for monitoring slon daemons and restarting them  
 if they die?
 

From: "Jim C. Nasby" <decibel@decibel.org>
To: Vivek Khera <vivek@khera.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Tue, 7 Feb 2006 15:29:12 -0600

 On Tue, Feb 07, 2006 at 01:26:24PM -0500, Vivek Khera wrote:
 > 
 > On Feb 6, 2006, at 10:22 PM, Jim C. Nasby wrote:
 > 
 > >Do you want me to submit a new one?
 > 
 > Yes, please.  It makes it easier on the committer.  You could just  
 > follow up to the PR with the revised patch.
 > 
 > PS: what do you use for monitoring slon daemons and restarting them  
 > if they die?
  
 Haven't gotten that far yet, but I know that their perl tools are
 capable of that.
 -- 
 Jim C. Nasby, Database Architect                decibel@decibel.org 
 Give your computer some brain candy! www.distributed.net Team #1828
 
 Windows: "Where do you want to go today?"
 Linux: "Where do you want to go tomorrow?"
 FreeBSD: "Are you guys coming, or what?"

From: Shaun Amott <shaun@FreeBSD.org>
To: "Jim C. Nasby" <decibel@decibel.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org, Vivek Khera <vivek@khera.org>
Subject: Re: ports/92755: Add ability to run slon as a different user
Date: Tue, 8 Aug 2006 17:57:43 +0100

 On Thu, Feb 02, 2006 at 08:22:38PM -0600, Jim C. Nasby wrote:
 > >Number:         92755
 > >Category:       ports
 > >Synopsis:       Add ability to run slon as a different user
 
 Any news on this?
 
 -- 
 Shaun Amott [ PGP: 0x6B387A9A ]
     Scientia Est Potentia.
State-Changed-From-To: feedback->closed 
State-Changed-By: shaun 
State-Changed-When: Tue Sep 5 01:02:17 UTC 2006 
State-Changed-Why:  
The submitter has not responded to requests for feedback in some time. 
Also, the solution originally proposed can be accomplished using 
existing rc.d infrastructure. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92755 

From: Jim Nasby <decibel@decibel.org>
To: bug-followup@FreeBSD.org,
 Nasby Jim <decibel@decibel.org>
Cc:  
Subject: Re: ports/92755: databases/slony1: Add ability to run slon as a different user
Date: Fri, 22 Sep 2006 13:45:02 -0400

 Sorry, I got side-tracked from this (and the email got routed to  
 someplace I don't normally check).
 
  > Also, the variable slon_user should be filtered through %%NAME%%
  > expansion, and might be best located down where the enable flag is
  > defaulted, too.
 
 I guess I'm not clear on this, esp. since I'm defaulting to root?
 
 +slon_user=${slon_user:-"root"}
 
  > Basically, all you have to do to your patch is whack out the
  > start_slon function and it is just what we need.
 
 I'm not seeing a start_slon function anywhere, so I'm not sure what  
 the intent here is...
>Unformatted:
