1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils toolchain-funcs versionator
8 DESCRIPTION="A Perl CGI for accessing and sharing files, or calendar/addressbooks via WebDAV."
9 HOMEPAGE="http://webdavcgi.sourceforge.net/"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
14 # Provide slotting on minor versions. WebDAV CGI is a web application which
15 # can be shared by multiple instances and thus major updates shouldn't be
16 # enforced to all users/instances at the same time.
17 SLOT="$(get_version_component_range 1-2)"
20 IUSE="afs git kerberos ldap mysql pdf postgres rcs samba +sqlite +suid"
23 RDEPEND="afs? ( net-fs/openafs )
28 dev-perl/DateTime-Format-Human-Duration
29 dev-perl/File-Copy-Link
31 dev-perl/List-MoreUtils
40 kerberos? ( virtual/krb5 )
41 ldap? ( dev-perl/perl-ldap )
42 media-gfx/graphicsmagick[perl]
44 mysql? ( dev-perl/DBD-mysql )
45 pdf? ( app-text/ghostscript-gpl )
46 postgres? ( dev-perl/DBD-Pg )
48 samba? ( net-fs/cifs-utils dev-perl/Filesys-SmbClient )
49 sqlite? ( dev-perl/DBD-SQLite )
50 virtual/perl-File-Spec
51 virtual/perl-Module-Load
52 || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
54 REQUIRED_USE="|| ( mysql postgres sqlite )"
60 WEBDAVWRAPPERS="webdavwrapper" # Standard UID/GID wrapper
62 use afs && WEBDAVWRAPPERS+=" webdavwrapper-afs"
63 use kerberos && WEBDAVWRAPPERS+=" webdavwrapper-krb"
68 for wrapper in ${WEBDAVWRAPPERS}; do
69 $(tc-getCC) ${LDFLAGS} ${CFLAGS} \
70 -o "${CGIBINDIR}/${wrapper}" \
71 "helper/${wrapper}.c" || die "compile ${wrapper} failed"
77 exeinto "/usr/libexec/${PN}-${SLOT}/${CGIBINDIR}"
78 newexe "${CGIBINDIR}/logout-dist" "logout"
79 doexe "${CGIBINDIR}/webdav.pl"
81 use afs && doexe "${CGIBINDIR}/afswrapper"
82 use samba && doexe "${CGIBINDIR}/smbwrapper"
85 # In order to change the user and group ID at runtime, the webdavwrapper
86 # needs to be run as root (set-user-ID and set-group-ID bit)
87 exeopts -o root -g root -m 6755
90 for wrapper in ${WEBDAVWRAPPERS}; do
91 einfo "Installing UID/GID wrapper ${wrapper}"
92 doexe "${CGIBINDIR}/${wrapper}"
98 ewarn "You have the 'suid' USE flag disabled"
99 ewarn "WebDAV CGI won't be able to switch user ids"
103 local webdavConfDir="/etc/${PN}-${SLOT}/default"
105 export WEBDAVCONFIG="${webdavConfDir}/webdav.conf"
107 insinto "${webdavConfDir}"
108 doins "${confDir}/mime.types"
109 newins "${FILESDIR}/webdav-${SLOT}.conf" "webdav.conf"
111 local installBaseDir="/usr/share/${PN}-${SLOT}"
113 for currentDir in htdocs lib locale templates; do
114 insinto "${installBaseDir}/${currentDir}"
115 doins -r "${currentDir}"/*
118 if use mysql || use postgres; then
120 insinto "${installBaseDir}/${sqlDir}"
121 use mysql && doins "${sqlDir}/mysql.sql"
122 use postgres && doins "${sqlDir}/postgresql.sql"
126 # Directory where the SQLite database resides
127 local sqliteRootDir="/var/lib/${PN}/${SLOT}"
128 keepdir "${sqliteRootDir}"
130 # Default database directory where all users are able to create and
131 # share the databases, this can be changed within the config file and
132 # restricted to user/group only access if required.
133 export SQLITEDIR="${sqliteRootDir}/default"
134 keepdir "${SQLITEDIR}"
135 fperms 1777 "${SQLITEDIR}"
138 # Create default temporary directories, writable by all users
139 export TMPDIRS="trash thumbnails optimized"
140 for tmpDir in ${TMPDIRS}; do
141 keepdir "/var/tmp/${PN}/${SLOT}/default/${tmpDir}"
142 fperms 1777 "/var/tmp/${PN}/${SLOT}/default/${tmpDir}"
145 export APACHEEXAMPLECONFIG="apache-webdavcgi-${SLOT}-example.conf"
147 dodoc etc/webdav.conf.complete
148 dodoc "${FILESDIR}/${APACHEEXAMPLECONFIG}"
153 ewarn "In order to allow different users to create and share files,"
154 ewarn "some directories were installed with world write access by default."
155 ewarn "To set restrictive permissions, add all WebDAV CGI users to a"
156 ewarn "common group, and allow access to the following directories by this"
158 ewarn "Temp directories: /var/tmp/${PN}/${SLOT}/default/*"
159 use sqlite && ewarn "SQLite directory: ${SQLITEDIR}"
162 elog "The WebDAV CGI config is located at ${WEBDAVCONFIG}."
164 elog "An example Apache HTTP server configuration snippet is available in"
165 elog "${ROOT%/}/usr/share/doc/${PF} in the file ${APACHEEXAMPLECONFIG}"
167 elog "An important note to systemd user's running the Apache HTTP server:"
168 elog "The default apache2.service will be started with private file system"
169 elog "namespaces for /var/tmp and /tmp enabled (PrivateTmp=true)."
170 elog "This means that you either need to disable PrivateTmp, relocate the"
171 elog "directories starting with /var/tmp within ${WEBDAVCONFIG}"
172 elog "or pre-create the directory structure with a user defined systemd"
173 elog "companion unit using the JoinsNamespaceOf directive."
175 elog "To disable the private file system namespace, override the existing"
177 elog "systemctl edit apache2.service"
179 elog "PrivateTmp=false"
182 einfo "Detailed installation and configuration instructions can be found at"
183 einfo "http://webdavcgi.sourceforge.net/"