1SUMMARY = "Secure and configurable FTP server"
2SECTION = "net"
3HOMEPAGE = "http://www.proftpd.org"
4LICENSE = "GPL-2.0-or-later"
5LIC_FILES_CHKSUM = "file://COPYING;md5=fb0d1484d11915fa88a6a7702f1dc184"
6
7SRCREV = "0a7ea9b0ba9fcdf368374a226370d08f10397d99"
8BRANCH = "1.3.8"
9
10SRC_URI = "git://github.com/proftpd/proftpd.git;branch=${BRANCH};protocol=https \
11           file://basic.conf.patch \
12           file://proftpd-basic.init \
13           file://default \
14           file://close-RequireValidShell-check.patch \
15           file://contrib.patch  \
16           file://build_fixup.patch \
17           file://proftpd.service \
18           "
19
20S = "${WORKDIR}/git"
21
22inherit autotools-brokensep useradd update-rc.d systemd multilib_script
23
24CVE_STATUS[CVE-2001-0027] = "fixed-version: version 1.2.0rc3 removed affected module"
25
26EXTRA_OECONF += "--enable-largefile INSTALL=install"
27
28PACKAGECONFIG ??= "shadow \
29                   ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 pam', d)} \
30                   static \
31                  "
32
33PACKAGECONFIG[curses] = "--enable-curses --enable-ncurses, --disable-curses --disable-ncurses, ncurses"
34PACKAGECONFIG[openssl] = "--enable-openssl, --disable-openssl, openssl, openssl"
35PACKAGECONFIG[pam] = "--enable-auth-pam, --disable-auth-pam, libpam, libpam"
36PACKAGECONFIG[ipv6] = "--enable-ipv6, --disable-ipv6"
37PACKAGECONFIG[shadow] = "--enable-shadow, --disable-shadow"
38PACKAGECONFIG[pcre] = "--enable-pcre, --disable-pcre, libpcre "
39PACKAGECONFIG[static] = "--enable-static=yes, --enable-static=no"
40
41# enable POSIX.1e capabilities
42PACKAGECONFIG[cap] = "--enable-cap, --disable-cap, libcap, libcap"
43
44#enable support for POSIX ACLs
45PACKAGECONFIG[acl] = "--enable-facl, --disable-facl"
46
47#enable proftpd controls via ftpdct
48PACKAGECONFIG[ctrls] = "--enable-ctrls, --disable-crtls"
49
50#prevent proftpd from using its bundled getopt implementation.
51PACKAGECONFIG[getopt] = "--with-getopt, --without-getopt"
52
53#do not strip debugging symbols from installed code
54PACKAGECONFIG[strip] = "--enable-strip, --disable-strip"
55
56#enable SIA authentication support (Tru64)
57PACKAGECONFIG[sia] = "--enable-sia, --disable-sia"
58PACKAGECONFIG[sendfile] = "-enable-sendfile, --disable-sendfile"
59
60#enable Native Language Support (NLS)
61PACKAGECONFIG[nls] = "--enable-nls, --disable-nls"
62
63#add mod_dso to core modules
64PACKAGECONFIG[dso] = "--enable-dso, --disable-dso"
65
66#omit mod_auth_file from core modules
67PACKAGECONFIG[auth] = "--enable-auth-file, --disable-auth-file"
68
69# proftpd uses libltdl which currently makes configuring using
70# autotools.bbclass a pain...
71do_configure () {
72    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess ${S}
73    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S}
74    oe_runconf
75    sed -e 's|--sysroot=${STAGING_DIR_HOST}||g' \
76        -e 's|${STAGING_DIR_NATIVE}||g' \
77        -e 's|-ffile-prefix-map=[^ ]*||g' \
78        -e 's|-fdebug-prefix-map=[^ ]*||g' \
79        -e 's|-fmacro-prefix-map=[^ ]*||g' \
80        -i ${B}/config.h
81}
82
83FTPUSER = "ftp"
84FTPGROUP = "ftp"
85
86do_install () {
87    oe_runmake DESTDIR=${D} install
88    rmdir ${D}${libdir}/proftpd ${D}${datadir}/locale
89    [ -d ${D}${libexecdir} ] && rmdir ${D}${libexecdir}
90    sed -i '/ *User[ \t]*/s/ftp/${FTPUSER}/' ${D}${sysconfdir}/proftpd.conf
91    sed -i '/ *Group[ \t]*/s/ftp/${FTPGROUP}/' ${D}${sysconfdir}/proftpd.conf
92    install -d ${D}${sysconfdir}/init.d
93    install -m 0755 ${UNPACKDIR}/proftpd-basic.init ${D}${sysconfdir}/init.d/proftpd
94    sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/proftpd
95    sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/proftpd
96    sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/proftpd
97    sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/proftpd
98
99    install -d ${D}${sysconfdir}/default
100    install -m 0755 ${UNPACKDIR}/default ${D}${sysconfdir}/default/proftpd
101
102    # create the pub directory
103    mkdir -p ${D}/home/${FTPUSER}/pub/
104    chown -R ${FTPUSER}:${FTPGROUP} ${D}/home/${FTPUSER}/pub
105    if ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'true', 'false', d)}; then
106        # install proftpd pam configuration
107        install -d ${D}${sysconfdir}/pam.d
108        install -m 644 ${S}/contrib/dist/rpm/ftp.pamd ${D}${sysconfdir}/pam.d/proftpd
109        sed -i '/ftpusers/d' ${D}${sysconfdir}/pam.d/proftpd
110        # specify the user Authentication config
111        sed -i '/^MaxInstances/a\AuthPAM                         on\nAuthPAMConfig                   proftpd' \
112            ${D}${sysconfdir}/proftpd.conf
113    fi
114
115    install -d ${D}/${systemd_unitdir}/system
116    install -m 644 ${UNPACKDIR}/proftpd.service ${D}/${systemd_unitdir}/system
117    sed -e 's,@BASE_SBINDIR@,${base_sbindir},g' \
118        -e 's,@SYSCONFDIR@,${sysconfdir},g' \
119        -e 's,@SBINDIR@,${sbindir},g' \
120        -i ${D}${systemd_unitdir}/system/*.service
121
122    sed -e 's|--sysroot=${STAGING_DIR_HOST}||g' \
123        -e 's|${STAGING_DIR_NATIVE}||g' \
124        -e 's|-ffile-prefix-map=[^ ]*||g' \
125        -e 's|-fdebug-prefix-map=[^ ]*||g' \
126        -e 's|-fmacro-prefix-map=[^ ]*||g' \
127        -i ${D}/${bindir}/prxs ${D}${includedir}/proftpd/Make.rules ${D}${includedir}/proftpd/config.h
128
129    # ftpmail perl script, which reads the proftpd log file and sends
130    # automatic email notifications once an upload finishs,
131    # depends on an old perl Mail::Sendmail
132    # The Mail::Sendmail has not been maintained for almost 10 years
133    # Other distribution not ship with ftpmail, so do the same to
134    # avoid confusion about having it fails to run
135    rm -rf ${D}${bindir}/ftpmail
136    rm -rf ${D}${mandir}/man1/ftpmail.1
137}
138
139INITSCRIPT_NAME = "proftpd"
140INITSCRIPT_PARAM = "defaults 85 15"
141
142SYSTEMD_PACKAGES = "${PN}"
143SYSTEMD_SERVICE:${PN} = "proftpd.service"
144
145USERADD_PACKAGES = "${PN}"
146GROUPADD_PARAM:${PN} = "--system ${FTPGROUP}"
147USERADD_PARAM:${PN} = "--system -g ${FTPGROUP} --home-dir /var/lib/${FTPUSER} --no-create-home \
148                       --shell /bin/false ${FTPUSER}"
149
150MULTILIB_SCRIPTS = "${PN}:${bindir}/prxs"
151
152FILES:${PN} += "/home/${FTPUSER}"
153
154RDEPENDS:${PN} += "perl"
155