Skip to content

Commit 8d1e9a3

Browse files
committed
Add support for external auth
1 parent 45526a1 commit 8d1e9a3

File tree

4 files changed

+142
-1
lines changed

4 files changed

+142
-1
lines changed

manifests/config/extauth.pp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# == Class: pureftpd::config::exauth
2+
#
3+
# Manages the pure-ftpd external authentication. This class should be considered
4+
# private.
5+
#
6+
#
7+
8+
class pureftpd::config::extauth($extauth_handler) {
9+
10+
11+
notify {$extauth_handler:}
12+
13+
if $extauth_handler =~ /^puppet:\/\// {
14+
15+
$tmp = split($extauth_handler,'/')
16+
$leght = size($tmp)
17+
$filename = $tmp[$size-1]
18+
19+
file {"/etc/pure-ftpd/${filename}":
20+
ensure => file,
21+
owner => 'root',
22+
group => 'root',
23+
mode => '0755',
24+
source => $extauth_handler,
25+
notify => Service['pure-authd'],
26+
}
27+
} else {
28+
$filename = $extauth_handler
29+
}
30+
31+
file {'/etc/init.d/pure-authd':
32+
ensure => file,
33+
owner => 'root',
34+
group => 'root',
35+
mode => '0755',
36+
content => template('pureftpd/pure-authd.erb')
37+
}
38+
39+
service {'pure-authd':
40+
ensure => running,
41+
enable => true,
42+
hasrestart => true,
43+
hasstatus => true,
44+
require => File['/etc/init.d/pure-authd']
45+
}
46+
47+
}

manifests/init.pp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@
4646
$config_ldap = {},
4747
$config_mysql = {},
4848
$config_pgsql = {},
49+
$extauth_enabled = false,
50+
$extauth_handler = '',
4951
) {
5052
validate_bool($use_selinux)
5153
validate_hash($config)
5254
validate_hash($config_ldap)
5355
validate_hash($config_mysql)
5456
validate_hash($config_pgsql)
57+
validate_bool($extauth_enabled)
58+
validate_string($extauth_handler)
5559

5660
include pureftpd::service
5761

@@ -112,12 +116,21 @@
112116
Class[ 'pureftpd::config::pgsql' ]
113117
}
114118

119+
if extauth_enabled {
120+
$extauth_config = { extauth => $pureftpd::params::authd_socket }
121+
122+
create_resources('class',
123+
{'pureftpd::config::extauth' => {extauth_handler => $extauth_handler}}
124+
)
125+
}
126+
115127
$safe_config = merge(
116128
$config,
117129
{ notify => Class[ 'pureftpd::service' ] },
118130
$enable_ldap,
119131
$enable_mysql,
120-
$enable_pgsql
132+
$enable_pgsql,
133+
$extauth_config
121134
)
122135

123136
create_resources( 'class', { 'pureftpd::config' => $safe_config } )

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
$pgsql_conf_erb = 'pure-ftpd.conf.erb'
2525
$pgsql_conf_path = "${config_dir}/pureftpd-pgsql.conf"
26+
27+
$authd_socket = '/var/run/ftpd.sock'
2628
}
2729
default:{
2830
fail("Module ${module_name} is not supported on ${::operatingsystem}")

templates/pure-authd.erb

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
#
3+
# Startup script for the pure-authd FTP Server $Revision: 1.1 $
4+
#
5+
# chkconfig: - 85 15
6+
# description: Pure-FTPd is an FTP auth daemon based upon Troll-FTPd
7+
# processname: pure-authd
8+
# pidfile: /var/run/pure-authd.pid
9+
10+
# Source function library.
11+
. /etc/init.d/functions
12+
13+
# Source networking configuration.
14+
. /etc/sysconfig/network
15+
16+
# Check that networking is configured.
17+
[ ${NETWORKING} = "no" ] && exit 0
18+
19+
RETVAL=0
20+
21+
prog="pure-authd"
22+
23+
# Path to the pure-ftp binaries.
24+
fullpath=/usr/sbin/pure-authd
25+
pidfile="/var/run/pure-authd.pid"
26+
pure_config="-p $pidfile -B -s /var/run/ftpd.sock -r <%= @filename %>"
27+
28+
29+
start() {
30+
echo -n $"Starting $prog: "
31+
daemon --pidfile $pidfile "$fullpath $pure_config > /dev/null"
32+
RETVAL=$?
33+
[ $RETVAL = 0 ] && touch /var/lock/subsys/pure-authd
34+
echo
35+
}
36+
37+
stop() {
38+
echo -n $"Stopping $prog: "
39+
killproc pure-authd
40+
RETVAL=$?
41+
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/pure-authd
42+
echo
43+
}
44+
45+
# See how we were called.
46+
case "$1" in
47+
start)
48+
start
49+
;;
50+
stop)
51+
stop
52+
;;
53+
restart)
54+
stop
55+
start
56+
;;
57+
reload)
58+
echo -n $"Reloading $prog: "
59+
killproc pure-ftpd -HUP
60+
RETVAL=$?
61+
echo
62+
;;
63+
condrestart)
64+
if [ -f /var/lock/subsys/pure-authd ] ; then
65+
stop
66+
# avoid race
67+
sleep 3
68+
start
69+
fi
70+
;;
71+
status)
72+
status pure-authd
73+
RETVAL=$?
74+
;;
75+
*)
76+
echo $"Usage: pure-authd {start|stop|restart|status}"
77+
RETVAL=1
78+
esac
79+
exit $RETVAL

0 commit comments

Comments
 (0)