Bug 151314 - www/shellinabox: update rc script to allow passing of user/group
Summary: www/shellinabox: update rc script to allow passing of user/group
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Po-Chuan Hsieh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 17:10 UTC by Eric F Crist
Modified: 2011-10-26 18:43 UTC (History)
1 user (show)

See Also:


Attachments
siab.diff (1.36 KB, patch)
2010-10-08 17:10 UTC, Eric F Crist
no flags Details | Diff
shellinabox.rev3.patch.txt (907 bytes, text/plain; charset=US-ASCII)
2011-10-21 09:17 UTC, olivier
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric F Crist 2010-10-08 17:10:02 UTC
	This patch will fix the shellinabox rc script to allow for passing of user and group through variables set in rc.conf.  This patch honors existing configs by defaulting to shellinabox as user/group.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2010-10-08 17:10:06 UTC
Maintainer of www/shellinabox,

Please note that PR ports/151314 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/151314

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2010-10-08 17:10:08 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Po-Chuan Hsieh freebsd_committer freebsd_triage 2010-10-09 15:19:21 UTC
Responsible Changed
From-To: freebsd-ports-bugs->sunpoet

I'll take it.
Comment 4 Sunpoet Po-Chuan Hsieh 2010-10-11 12:34:51 UTC
On Sun, Oct 10, 2010 at 08:19:52AM +0200, Olivier Cochard-Labb wrote:
> On Sat, Oct 9, 2010 at 4:19 PM,  <sunpoet@freebsd.org> wrote:
> > Synopsis: www/shellinabox: update rc script to allow passing of user/group
> >
> > Responsible-Changed-From-To: freebsd-ports-bugs->sunpoet
> > Responsible-Changed-By: sunpoet
> > Responsible-Changed-When: Sat Oct 9 14:19:21 UTC 2010
> > Responsible-Changed-Why:
> > I'll take it.
> >
> > http://www.freebsd.org/cgi/query-pr.cgi?pr=151314
> >
> 
> This patch is OK, how should I proceed now:
> - Re-summit a full shar of the patched port ?
> - Re-summit a full diff of the port ?
> - Saying that this patch is OK is enough ?
> 
> Thanks,
> 
> Olivier


Hi Olivier,

  I've tested the patch. It works fine. While I'm here, I would like to do
  some modification. My modified patch is attached. It utilizes ETCDIR and
  merges post-install: to do-install:. Please review it. Thanks.

Regards,
sunpoet

--- shellinabox.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/www/shellinabox/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- Makefile	16 Aug 2010 00:04:03 -0000	1.3
+++ Makefile	11 Oct 2010 11:33:30 -0000
@@ -9,8 +9,7 @@
 PORTVERSION=	2.10
 PORTREVISION=	2
 CATEGORIES=	www
-MASTER_SITES=	${MASTER_SITE_GOOGLE_CODE}
-DISTNAME=	${PORTNAME}-${PORTVERSION}
+MASTER_SITES=	GOOGLE_CODE
 
 MAINTAINER=	olivier@cochard.me
 COMMENT=	Publish command line shell through AJAX interface
@@ -25,8 +24,8 @@
 LICENSE_FILE=	${WRKSRC}/COPYING
 
 USE_RC_SUBR=	shellinaboxd
-USERS=	shellinabox
-GROUPS=	shellinabox
+USERS?=		shellinabox
+GROUPS?=	shellinabox
 
 MAN1=		shellinaboxd.1
 
@@ -35,18 +34,17 @@
 PKGDEINSTALL=	${WRKDIR}/pkg-deinstall
 
 SUB_FILES=	pkg-deinstall
-
-post-install:
-	@${MKDIR} ${PREFIX}/etc/shellinabox
-	@${CHMOD} 700 ${PREFIX}/etc/shellinabox
-	@${CHOWN} ${USERS}:${GROUPS} ${PREFIX}/etc/shellinabox
-	${INSTALL_MAN} ${WRKSRC}/shellinaboxd.1 ${PREFIX}/man/man1
+SUB_LIST=	USERS=${USERS} GROUPS=${GROUPS}
 
 do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/shellinaboxd ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/shellinaboxd ${PREFIX}/bin/
 .if !defined(NOPORTDOCS)
-	${MKDIR} ${DOCSDIR}
-	cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}
+	${MKDIR} ${DOCSDIR}/
+	cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}/
 .endif
+	${MKDIR} ${ETCDIR}/
+	${CHMOD} 700 ${ETCDIR}/
+	${CHOWN} ${USERS}:${GROUPS} ${ETCDIR}/
+	${INSTALL_MAN} ${WRKSRC}/shellinaboxd.1 ${MANPREFIX}/man/man1/
 
 .include <bsd.port.mk>
Index: files/shellinaboxd.in
===================================================================
RCS file: /home/ncvs/ports/www/shellinabox/files/shellinaboxd.in,v
retrieving revision 1.2
diff -u -r1.2 shellinaboxd.in
--- files/shellinaboxd.in	16 Aug 2010 00:04:03 -0000	1.2
+++ files/shellinaboxd.in	11 Oct 2010 11:33:30 -0000
@@ -16,8 +16,10 @@
 # You can fine tune others variables too:
 # shellinaboxd_fib="NONE"
 # shellinaboxd_pidfile="/var/run/shellinabox.pid"
+# shellinaboxd_user="%%USERS%%"
+# shellinaboxd_group="%%GROUPS%%"
 # shellinaboxd_port="4200"
-# shellinaboxd_certdir="%%PREFIX%%/etc/shellinabox"
+# shellinaboxd_certdir="%%ETCDIR%%"
 # shellinaboxd_certfile=""
 # 	Example: shellinaboxd_certfile="/your/cert.pem"
 # shellinaboxd_flags=""
@@ -46,12 +48,14 @@
 
 shellinaboxd_enable=${shellinaboxd_enable:-"NO"}
 shellinaboxd_fib=${shellinaboxd_fib:-"NONE"}
+shellinaboxd_user=${shellinaboxd_user:-"%%USERS%%"}
+shellinaboxd_group=${shellinaboxd_group:-"%%GROUPS%%"}
 shellinaboxd_port=${shellinaboxd_port:-"4200"}
-shellinaboxd_certdir=${shellinaboxd_certdir:-"%%PREFIX%%/etc/shellinabox"}
+shellinaboxd_certdir=${shellinaboxd_certdir:-"%%ETCDIR%%"}
 
 pidfile=${shellinaboxd_pidfile:-"/var/run/shellinaboxd.pid"}
 
-command_args="--group=shellinabox --user=shellinabox --port=${shellinaboxd_port} --background=${pidfile}"
+command_args="--user=${shellinaboxd_user} --group=${shellinaboxd_group} --port=${shellinaboxd_port} --background=${pidfile}"
 
 if [ "${shellinaboxd_certfile}" = "" ]; then
 	required_dirs="${shellinaboxd_certdir}"
--- shellinabox.patch ends here ---

-- 
          4096R/CC57E36B 8AD8 68F2 7D2B 0A10 7E9B  8CC0 DC44 247E CC57 E36B
  Sunpoet Po-Chuan Hsieh <sunpoet at sunpoet.net>, <sunpoet at FreeBSD.org>
Comment 5 olivier 2010-10-13 09:32:28 UTC
On Mon, Oct 11, 2010 at 1:34 PM, Sunpoet Po-Chuan Hsieh
<sunpoet@sunpoet.net> wrote:

>
> =A0I've tested the patch. It works fine. While I'm here, I would like to =
do
> =A0some modification. My modified patch is attached. It utilizes ETCDIR a=
nd
> =A0merges post-install: to do-install:. Please review it. Thanks.
>

I didn't reach to apply your diff (have strange =AB3D=BB characters in
place of tab the diff file), but the patch seems OK.

Regards,


--=20
http://freenas.org
http://bsdrp.net
Comment 6 dfilter service freebsd_committer freebsd_triage 2010-10-13 13:50:12 UTC
sunpoet     2010-10-13 12:50:07 UTC

  FreeBSD ports repository

  Modified files:
    www/shellinabox      Makefile 
    www/shellinabox/files shellinaboxd.in 
  Log:
  - Update rc.d script: add user/group variables
  - Use ETCDIR
  - Minor cleanups: remove DISTNAME, merge post-install: to do-install:
  
  PR:             ports/151314
  Submitted by:   Eric F Crist <ecrist@secure-computing.net>
  Approved by:    Olivier Cochard-Labb <olivier@cochard.me> (maintainer), pgollucci (mentor, implicit)
  
  Revision  Changes    Path
  1.4       +11 -13    ports/www/shellinabox/Makefile
  1.3       +8 -4      ports/www/shellinabox/files/shellinaboxd.in
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Po-Chuan Hsieh freebsd_committer freebsd_triage 2010-10-13 13:50:31 UTC
State Changed
From-To: feedback->closed

Committed, with minor changes. Thanks!
Comment 8 Ed Schouten 2011-08-04 08:29:01 UTC
Hi all,

It seems this patch has slightly broken shellinabox. Previously one
could use shellinaboxd_certfile="..." to start shellinabox with a
root-owned pem file. Now shellinabox will perform switching to the
target user twice, since the _user and _group flags will cause rc.subr
to call the command with su.

I've solved it by changing the script to do this:

shellinaboxd_user=
shellinaboxd_group=
run_rc_command "$1"

Would it still be possible to get this fixed before 9.0?

-- 
 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/
Comment 9 Ed Schouten freebsd_committer freebsd_triage 2011-10-19 22:37:49 UTC
State Changed
From-To: closed->open

This PR still has an unanswered comment at the bottom.
Comment 10 olivier 2011-10-21 09:17:29 UTC
Hi all,
I'm using shellinabox in a very simple maner, this is why I didn't
detect this problem.
Sorry.

Ed: Can you confirm that the patch attached is what you are looking for ?

Regards,

Olivier
Comment 11 Ed Schouten 2011-10-21 12:25:36 UTC
* Olivier Cochard-Labbé <olivier@cochard.me>, 20111021 10:17:
> I'm using shellinabox in a very simple maner, this is why I didn't
> detect this problem.
> Sorry.
> 
> Ed: Can you confirm that the patch attached is what you are looking for ?


It works. Thanks! :-)

-- 
 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/
Comment 12 Ed Schouten 2011-10-21 14:44:45 UTC
Hi,

I was thinking, maybe it's a bit more elegant if we used `unset var'
instead of `var='?

-- 
 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/
Comment 13 olivier 2011-10-24 12:27:59 UTC
2011/10/21 Ed Schouten <ed@80386.nl>:
> Hi,
>
> I was thinking, maybe it's a bit more elegant if we used `unset var'
> instead of `var='?
>

If sunpoet is agree with this more elegant solution, I'm agree too.

Regards,

Olivier
Comment 14 Po-Chuan Hsieh freebsd_committer freebsd_triage 2011-10-26 18:43:07 UTC
State Changed
From-To: open->closed

Committed. Thanks!