Name: awstats Version: 6.95 Release: 1%{?dist} Summary: Advanced Web Statistics License: GPLv2 Group: Applications/Internet URL: http://awstats.sourceforge.net Source0: http://dl.sf.net/awstats/awstats-%{version}.tar.gz Source1: awstats.README.SELinux Source2: awstats.README.Fedora BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: checkpolicy, selinux-policy-devel Requires: perl Requires(post): perl Requires(postun): /sbin/service %description Advanced Web Statistics is a powerful and featureful tool that generates advanced web server graphic statistics. This server log analyzer works from command line or as a CGI and shows you all information your log contains, in graphical web pages. It can analyze a lot of web/wap/proxy servers like Apache, IIS, Weblogic, Webstar, Squid, ... but also mail or ftp servers. This program can measure visits, unique vistors, authenticated users, pages, domains/countries, OS busiest times, robot visits, type of files, search engines/keywords used, visits duration, HTTP errors and more... Statistics can be updated from a browser or your scheduler. The program also supports virtual servers, plugins and a lot of features. With the default configuration, the statistics are available: http://localhost/awstats/awstats.pl %package selinux Summary: SELinux support for Awstats Group: Applications/Internet Requires: %{name} = %{version} Requires(post): policycoreutils Requires(preun): policycoreutils Requires(postun): policycoreutils %description selinux This package adds SELinux enforcement to AWstats. %prep %setup -q # Fix style sheets. perl -pi -e 's,/icon,/awstatsicons,g' wwwroot/css/* # Fix some bad file permissions here for convenience. chmod -x tools/httpd_conf find tools/xslt -type f | xargs chmod -x # Remove \r in various files perl -pi -e 's/\r//g' docs/COPYING.TXT docs/LICENSE.TXT docs/pad_awstats.xml docs/awstats_changelog.txt docs/styles.css tools/httpd_conf tools/logresolvemerge.pl tools/awstats_exportlib.pl tools/awstats_buildstaticpages.pl tools/maillogconvert.pl tools/urlaliasbuilder.pl wwwroot/cgi-bin/awredir.pl # SELinux README cp -a %{SOURCE1} README.SELinux cp -a %{SOURCE2} README.Fedora mkdir selinux %install rm -rf $RPM_BUILD_ROOT ### Create cron job cat <awstats.cron #!/bin/bash exec %{_datadir}/awstats/tools/awstats_updateall.pl now \ -configdir="%{_sysconfdir}/awstats" \ -awstatsprog="%{_datadir}/awstats/wwwroot/cgi-bin/awstats.pl" >/dev/null exit 0 EOF ### Create folders mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{httpd/conf.d,%{name},cron.hourly} mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name} mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name} ### Install files cp -pr tools $RPM_BUILD_ROOT%{_datadir}/%{name} chmod 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/tools/*.pl chmod 644 $RPM_BUILD_ROOT%{_datadir}/%{name}/tools/httpd_conf cp -pr wwwroot $RPM_BUILD_ROOT%{_datadir}/%{name} chmod 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/wwwroot/cgi-bin/*.pl rm -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/wwwroot/classes/src ### We want these outside CGI path. rm -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/wwwroot/cgi-bin/{lang,lib,plugins} cp -pr wwwroot/cgi-bin/{lang,lib,plugins} $RPM_BUILD_ROOT%{_datadir}/%{name} rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/wwwroot/cgi-bin/awstats.model.conf ### Commit permanent changes to default configuration install -p -m 644 wwwroot/cgi-bin/awstats.model.conf \ $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/%{name}.model.conf perl -pi -e ' s|^LogFile=.*$|LogFile="%{_localstatedir}/log/httpd/access_log"|; s|^DirData=.*$|DirData="%{_localstatedir}/lib/awstats"|; s|^DirCgi=.*$|DirCgi="/awstats"|; s|^DirIcons=.*$|DirIcons="/awstatsicons"|; s|^SiteDomain=.*$|SiteDomain="localhost.localdomain"|; s|^HostAliases=.*$|HostAliases="localhost 127.0.0.1"|; s|^EnableLockForUpdate=.*$|EnableLockForUpdate=1|; s|^SaveDatabaseFilesWithPermissionsForEveryone=.*$|SaveDatabaseFilesWithPermissionsForEveryone=0|; s|^SkipHosts=.*$|SkipHosts="127.0.0.1"|; s|^Expires=.*$|Expires=3600|; ' $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/%{name}.model.conf install -p -m 644 $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/%{name}.{model,localhost.localdomain}.conf # Fix scripts perl -pi -e 's|/usr/local/awstats|%{_datadir}/awstats|g' \ $RPM_BUILD_ROOT%{_datadir}/%{name}/tools/{*.pl,httpd_conf} # Fix encoding of changelog iconv -f iso-8859-1 -t utf-8 < docs/awstats_changelog.txt > docs/awstats_changelog.txt.utf8 mv docs/awstats_changelog.txt.utf8 docs/awstats_changelog.txt # Apache configuration install -p -m 644 tools/httpd_conf $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d/%{name}.conf perl -pi -e 's|/usr/local|%{_datadir}|g;s|Allow from all|Allow from 127.0.0.1|g' \ $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d/%{name}.conf echo "# Additional Perl modules SetEnv PERL5LIB %{_datadir}/awstats/lib:%{_datadir}/awstats/plugins " >> $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d/%{name}.conf # Cron job install -m 0755 awstats.cron $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/%{name} # SELinux support cd selinux echo 'policy_module(%{name}, 1.0)' > %{name}.te echo '%{_datadir}/awstats/wwwroot/cgi-bin(/.*)? system_u:object_r:httpd_sys_script_exec_t:s0' > %{name}.fc echo '%{_localstatedir}/lib/awstats(/.*)? system_u:object_r:httpd_sys_script_rw_t:s0' >> %{name}.fc touch %{name}.if make -f %{_datadir}/selinux/devel/Makefile install -p -m 644 -D %{name}.pp $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/%{name}.pp %clean rm -rf $RPM_BUILD_ROOT %post if [ $1 -eq 1 ]; then if [ ! -f %{_sysconfdir}/%{name}/%{name}.`hostname`.conf ]; then %{__cat} %{_sysconfdir}/%{name}/%{name}.model.conf | \ %{__perl} -p -e 's|^SiteDomain=.*$|SiteDomain="'`hostname`'"|; s|^HostAliases=.*$|HostAliases="REGEX[^.*'${HOSTNAME//./\\\\.}'\$]"|; ' > %{_sysconfdir}/%{name}/%{name}.`hostname`.conf || : fi fi %postun if [ $1 -ne 0 ]; then /sbin/service httpd condrestart >/dev/null 2>&1 fi %post selinux if [ "$1" -le "1" ]; then # Fist install semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || : fixfiles -R %{name} restore fi %preun selinux if [ "$1" -lt "1" ]; then # Final removal semodule -r %{name} 2>/dev/null || : fixfiles -R %{name} restore fi %postun selinux if [ "$1" -ge "1" ]; then # Upgrade # Replaces the module if it is already loaded semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || : fi %files %defattr(-,root,root,755) # Apache configuration file %config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf %config(noreplace) %attr(755,root,root) %{_sysconfdir}/cron.hourly/%{name} %config(noreplace) %{_sysconfdir}/%{name}/ %{_localstatedir}/lib/%{name} %dir %{_datadir}/%{name} %dir %{_datadir}/%{name}/wwwroot %{_datadir}/%{name}/tools %{_datadir}/%{name}/wwwroot/cgi-bin # Different defattr to fix lots of files which should not be +x. %defattr(644,root,root,755) %doc README.TXT README.Fedora docs/* %{_datadir}/%{name}/lang %{_datadir}/%{name}/lib %{_datadir}/%{name}/plugins %{_datadir}/%{name}/wwwroot/classes %{_datadir}/%{name}/wwwroot/css %{_datadir}/%{name}/wwwroot/icon %{_datadir}/%{name}/wwwroot/js %files selinux %defattr(644, root, root, 755) %doc README.SELinux %{_datadir}/selinux/packages/%{name}/%{name}.pp %changelog * Thu Nov 26 2009 Tim Jackson - 6.95-1 - Update to version 6.95 (security fix) * Sat May 30 2009 Tim Jackson 6.9-1 - Update to 6.9 * Mon Dec 15 2008 Tim Jackson 6.7-5 - remove extraneous file awstats.orig from package * Sat Dec 06 2008 Tim Jackson 6.7-4 - Use Debian's patch for CVE-2008-3714 (#474396) - Add README.Fedora file pointing people towards the -selinux subpackage * Sat Aug 23 2008 Tim Jackson 6.7-3 - Fix CVE-2008-3714: cross-site scripting security issue (#459605) * Sun Mar 16 2008 Tim Jackson 6.7-2 - awstats does not actually require httpd (#406901) - Fix cron script to be compatible with SELinux (#435101) - Mark httpd config as noreplace - Fix encoding of awstats_changelog.txt - Remove some stray upstream temp files - Fix EOL encoding of documentation to be consistent * Tue Sep 18 2007 Tim Jackson 6.7-1 - initial import to EPEL-5, from Fedora