Bug 163339

Summary: ftp/pure-ftpd: rc script not supports pure-authd
Product: Ports & Packages Reporter: Gabor HALASZ <halasz.g>
Component: Individual Port(s)Assignee: Po-Chuan Hsieh <sunpoet>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Gabor HALASZ 2011-12-16 16:00:24 UTC
The /usr/local/etc/rc.d/pure-ftpd not contains any support for pure-authd,
the external authentication agent of pure-ftpd.

Fix: I added few lines to rc.d/pure-ftpd, see the attached diff file. 

Patch attached with submission follows:
How-To-Repeat: Install the package. My version is pure-ftpd-1.0.34.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-12-16 16:04:51 UTC
Responsible Changed
From-To: freebsd-ports-bugs->garga

Fix synopsis and assign.
Comment 2 Renato Botelho freebsd_committer freebsd_triage 2011-12-28 10:46:51 UTC
State Changed
From-To: open->feedback

Could you please provide a patch to apply to 
/usr/ports/ftp/pure-ftpd/files/pure-ftpd.sh.in instead of installed file?
Comment 3 Renato Botelho freebsd_committer freebsd_triage 2012-03-18 11:48:00 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Gabor,

Sorry for the long delay to answer.

The only part of the patch i don't agree is the following line:

pureftpd_authsocket=`grep ^ExtAuth /usr/local/etc/pure-ftpd.conf | sed s/^ExtAuth[\ \t]*//`

I believe it's not a "safe" way to do it, it's fragile and easy to be
broken.

Could you please try to find a diferent way to get authsocket
information?

Regards
- -- 
Renato Botelho <garga @ FreeBSD.org>
               <garga @ freebsdbrasil.com.br>
GnuPG Key: http://www.FreeBSD.org/~garga/pubkey.asc

To laugh at men of sense is the privilege of fools.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (Darwin)

iEYEARECAAYFAk9ly24ACgkQ6CRbiSJE7andkACgm7iEePT4c2hnWdKxT3pT7/Iu
9zwAoIiomt9FiaqHkOlCPe9PY/ItgpgE
=uJYO
-----END PGP SIGNATURE-----
Comment 4 Gabor HALASZ 2012-03-18 19:50:59 UTC
On 3/18/2012 12:48 PM, Renato Botelho wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello Gabor,
>
> Sorry for the long delay to answer.
>
> The only part of the patch i don't agree is the following line:
>
> pureftpd_authsocket=`grep ^ExtAuth /usr/local/etc/pure-ftpd.conf | sed s/^ExtAuth[\ \t]*//`
>
> I believe it's not a "safe" way to do it, it's fragile and easy to be
> broken.
>
> Could you please try to find a diferent way to get authsocket
> information?
>

Hi!

Please, inform me, which part isn't safe? The next concept is better?

exec 9>&0 <pure-ftpd.conf
while read key value
do
         test "${key}" = "ExtAuth" && break
done
exec 0>&9 0>&-


Regards
Comment 5 Renato Botelho freebsd_committer freebsd_triage 2012-04-07 12:30:51 UTC
Responsible Changed
From-To: garga->freebsd-ports-bugs

Back this PR to the pool. I'm not maintainer of this port anymore and 
don't have time to deal with it properly.
Comment 6 Michael Scheidell freebsd_committer freebsd_triage 2012-05-12 06:58:36 UTC
State Changed
From-To: feedback->closed

Feedback Timeout
Comment 7 Gabor Pali freebsd_committer freebsd_triage 2012-05-12 10:38:05 UTC
State Changed
From-To: closed->open

Re-open per the submitter's request. 


Comment 8 Gabor Pali freebsd_committer freebsd_triage 2012-05-12 10:38:05 UTC
Responsible Changed
From-To: freebsd-ports-bugs->sunpoet

Over to the new maintainer.
Comment 9 dfilter service freebsd_committer freebsd_triage 2014-03-31 15:12:48 UTC
Author: sunpoet
Date: Mon Mar 31 14:12:42 2014
New Revision: 349753
URL: http://svnweb.freebsd.org/changeset/ports/349753
QAT: https://qat.redports.org/buildarchive/r349753/

Log:
  - Add pure-authd support in rc script [1][2]
  - Indent rc script
  - Cosmetic change
  - Bump PORTREVISION for package change
  
  PR:		ports/163339 [1], ports/180992 [2] (based on)
  Submitted by:	Gabor HALASZ <halasz.g@freemail.hu> [1]
  		Ari Maniatis <ari@ish.com.au> [2]

Added:
  head/ftp/pure-ftpd/files/pure-alwaysfail   (contents, props changed)
Modified:
  head/ftp/pure-ftpd/Makefile
  head/ftp/pure-ftpd/files/pure-ftpd.in
  head/ftp/pure-ftpd/pkg-plist

Modified: head/ftp/pure-ftpd/Makefile
==============================================================================
--- head/ftp/pure-ftpd/Makefile	Mon Mar 31 14:08:09 2014	(r349752)
+++ head/ftp/pure-ftpd/Makefile	Mon Mar 31 14:12:42 2014	(r349753)
@@ -3,6 +3,7 @@
 
 PORTNAME=	pure-ftpd
 PORTVERSION=	1.0.36
+PORTREVISION=	1
 CATEGORIES=	ftp ipv6
 MASTER_SITES=	http://download.pureftpd.org/pub/pure-ftpd/releases/ \
 		ftp://ftp.pureftpd.org/pub/pure-ftpd/releases/ \
@@ -105,6 +106,7 @@ post-install:
 	${INSTALL_DATA} ${WRKSRC}/pureftpd-pgsql.conf ${STAGEDIR}${PREFIX}/etc/pureftpd-pgsql.conf.sample
 	${INSTALL_DATA} ${WRKSRC}/configuration-file/pure-ftpd.conf ${STAGEDIR}${PREFIX}/etc/pure-ftpd.conf.sample
 	${INSTALL_SCRIPT} ${WRKSRC}/configuration-file/pure-config.pl ${STAGEDIR}${PREFIX}/sbin/
+	${INSTALL_SCRIPT} ${FILESDIR}/pure-alwaysfail ${STAGEDIR}${PREFIX}/sbin/
 	${MKDIR} ${STAGEDIR}${DOCSDIR}/
 	cd ${WRKSRC}/ && ${INSTALL_DATA} ${PORTDOCS} ${STAGEDIR}${DOCSDIR}/
 	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}/

Added: head/ftp/pure-ftpd/files/pure-alwaysfail
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/ftp/pure-ftpd/files/pure-alwaysfail	Mon Mar 31 14:12:42 2014	(r349753)
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo auth_ok:0
+echo end

Modified: head/ftp/pure-ftpd/files/pure-ftpd.in
==============================================================================
--- head/ftp/pure-ftpd/files/pure-ftpd.in	Mon Mar 31 14:08:09 2014	(r349752)
+++ head/ftp/pure-ftpd/files/pure-ftpd.in	Mon Mar 31 14:12:42 2014	(r349753)
@@ -1,19 +1,26 @@
 #!/bin/sh
-
+#
 # $FreeBSD$
 #
+
 # PROVIDE: pureftpd
 # REQUIRE: NETWORKING SERVERS
 # BEFORE: DAEMON
 # KEYWORD: shutdown
-#
+
 # Add the following lines to /etc/rc.conf to enable pure-ftpd:
 #
-# pureftpd_enable="YES"
+# pureftpd_enable="yes"
+#
+# Add the following lines to /etc/rc.conf to enable pure-authd daemon:
 #
-# For launch uploadscript daemon define
-# pureftpd_upload_enable="YES"
-# pureftpd_uploadscript="/full/path/to/launch_script"
+# pureftpd_authd_enable="yes"
+# pureftpd_authdscript="/full/path/to/auth_script"
+#
+# Add the following lines to /etc/rc.conf to enable uploadscript daemon:
+#
+# pureftpd_upload_enable="yes"
+# pureftpd_uploadscript="/full/path/to/upload_script"
 
 . /etc/rc.subr
 
@@ -23,42 +30,68 @@ rcvar=pureftpd_enable
 load_rc_config $name
 
 command=%%PREFIX%%/sbin/pure-config.pl
-command_upload=%%PREFIX%%/sbin/pure-uploadscript
-pureftpd_uploadscript=${pureftpd_uploadscript:-"/usr/bin/touch"}
-pureftpd_config=${pureftpd_config:-"%%PREFIX%%/etc/pure-ftpd.conf"}
-required_files=${pureftpd_config}
+command_args="${pureftpd_config} -g${pidfile}"
 pidfile=/var/run/pure-ftpd.pid
-pidfile2=/var/run/pure-uploadscript.pid
 procname=pure-ftpd
-
-pureftpd_enable=${pureftpd_enable:-"NO"}
-command_args="${pureftpd_config} -g${pidfile}"
+pureftpd_config=${pureftpd_config:-"%%PREFIX%%/etc/pure-ftpd.conf"}
+pureftpd_enable=${pureftpd_enable:-"no"}
+required_files=${pureftpd_config}
+# authd
+command_authd=%%PREFIX%%/sbin/pure-authd
+command_authd_args="-B -r ${pureftpd_authdscript} -s ${pureftpd_authsocket}"
+pidfile_authd=/var/run/pure-authd.pid
+pureftpd_authdscript=${pureftpd_authdscript:-"%%PREFIX%%/sbin/pure-alwaysfail"}
+pureftpd_authsocket=`%%PREFIX%%/sbin/pure-config.pl ${pureftpd_config} | grep -o ' -lextauth:[^ ]*' | cut -d: -f2`
+# uploadscript
+command_upload=%%PREFIX%%/sbin/pure-uploadscript
 command_upload_args="-B -r ${pureftpd_uploadscript}"
+pidfile_uploadscript=/var/run/pure-uploadscript.pid
+pureftpd_uploadscript=${pureftpd_uploadscript:-"/usr/bin/touch"}
 
+start_precmd=start_precmd
 start_postcmd=start_postcmd
 stop_postcmd=stop_postcmd
 
+start_precmd()
+{
+	if test -n ${pureftpd_authd_enable:-""} && checkyesno pureftpd_authd_enable && test -x ${pureftpd_authdscript}; then
+		echo "Starting ${command_authd}."
+		${command_authd} ${command_authd_args}
+	fi
+}
+
 start_postcmd()
 {
-       if test -n ${pureftpd_upload_enable:-""} && checkyesno pureftpd_upload_enable; then
-       echo "Starting ${command_upload}."
-       ${command_upload} ${command_upload_args}  
-       fi
+	if test -n ${pureftpd_upload_enable:-""} && checkyesno pureftpd_upload_enable; then
+		echo "Starting ${command_upload}."
+		${command_upload} ${command_upload_args}  
+	fi
 }
 
 stop_postcmd()
 {
-        if test -n ${pureftpd_upload_enable:-""} && checkyesno pureftpd_upload_enable; then
-        pid=$(check_pidfile ${pidfile2} ${command_upload})
-        if [ -z ${pid} ]; then
-        echo "Upload script not running? (check ${pidfile2})."
-        return 1
-        fi
-        echo "Stopping ${command_upload}."
-        kill -${sig_stop:-TERM} ${pid}
-        [ $? -ne 0 ] && [ -z "$rc_force" ] && return 1
-        wait_for_pids ${pid}
-        fi
+	if test -n ${pureftpd_authd_enable:-""} && checkyesno pureftpd_authd_enable; then
+		pid=$(check_pidfile ${pidfile_authd} ${pidfile_authd} ${command_authd})
+		if [ -z ${pid} ]; then
+			echo "pure-authd not running? (check ${pidfile_authd})."
+			return 1
+		fi
+		echo "Stopping ${command_authd}."
+		kill -${sig_stop:-TERM} ${pid}
+		[ $? -ne 0 ] && [ -z "$rc_force" ] && return 1
+		wait_for_pids ${pid}
+	fi
+	if test -n ${pureftpd_upload_enable:-""} && checkyesno pureftpd_upload_enable; then
+		pid=$(check_pidfile ${pidfile_uploadscript} ${command_upload})
+		if [ -z ${pid} ]; then
+			echo "Upload script not running? (check ${pidfile_uploadscript})."
+			return 1
+		fi
+		echo "Stopping ${command_upload}."
+		kill -${sig_stop:-TERM} ${pid}
+		[ $? -ne 0 ] && [ -z "$rc_force" ] && return 1
+		wait_for_pids ${pid}
+	fi
 }
 
 run_rc_command "$1"

Modified: head/ftp/pure-ftpd/pkg-plist
==============================================================================
--- head/ftp/pure-ftpd/pkg-plist	Mon Mar 31 14:08:09 2014	(r349752)
+++ head/ftp/pure-ftpd/pkg-plist	Mon Mar 31 14:12:42 2014	(r349753)
@@ -14,6 +14,7 @@ man/man8/pure-pwconvert.8.gz
 man/man8/pure-quotacheck.8.gz
 man/man8/pure-statsdecode.8.gz
 man/man8/pure-uploadscript.8.gz
+sbin/pure-alwaysfail
 sbin/pure-authd
 sbin/pure-config.pl
 sbin/pure-ftpd
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 10 Po-Chuan Hsieh freebsd_committer freebsd_triage 2014-03-31 15:13:04 UTC
State Changed
From-To: open->closed

Committed. Thanks!