Hash: SHA1
MD5 f0ccb6eae44507f9faf8faf911bc9b9a bfilter-0.9.4.ebuild 1259
-MD5 04de055e268efcd15fcf2790fd58a71b ChangeLog 505
+MD5 5e376f233d32f4ec3a4c15c1b695720b bfilter-0.10.1.ebuild 1732
+MD5 fc1aed6e4a96c650ceb84bbfb168cb5f ChangeLog 723
MD5 2b32df81d3a9693c235baddd9386cce9 metadata.xml 1179
+MD5 8c7f7fd24bd2fc2681e185c511db4d57 files/digest-bfilter-0.10.1 67
MD5 59c8af85f08eaafc38f6c3421caa8ca3 files/bfilter-0.9.4-droppriv.patch 5108
MD5 e6e2c311139ed184131d6a945b12a3fb files/digest-bfilter-0.9.4 66
MD5 51acec84c4acfc995ab2a02fd8a3c7fe files/bfilter.8 9512
+MD5 13b255051243f8ef4f66a4118d4a1cbd files/bfilter-0.10.1-droppriv.patch 3650
MD5 598c43884dae3c39ecd580f74fbf5bef files/bfilter.conf 154
MD5 cf9b6d00bed0c12ed1fc046cda9b49e5 files/bfilter.init 493
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
-iD8DBQFDLk4+NSP4Vda7IdsRApnQAJ4jGiEGDIrq7SRfGU4NVc/Zg9KMRgCgj2xx
-0ix4zKv2Os0caEGIS+2i3TA=
-=zGg0
+iD8DBQFDgA/fNSP4Vda7IdsRAkudAJ9L7z0XHSSpYTtxbWFsOLjbCgXtDACdGTPI
+EABD5ZeaUbwlXl2LKzWsh5U=
+=wgt4
-----END PGP SIGNATURE-----
--- /dev/null
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/bfilter/bfilter-0.10.1.ebuild,v 1.1 2005/11/20 05:55:23 mrness Exp $
+
+inherit eutils
+
+DESCRIPTION="An ad-filtering web proxy featuring an effective heuristic ad-detection algorithm"
+HOMEPAGE="http://bfilter.sourceforge.net/"
+SRC_URI="mirror://sourceforge/bfilter/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~x86"
+IUSE="X debug"
+
+RDEPEND="sys-libs/zlib
+ dev-libs/ace
+ =dev-libs/libsigc++-1.2*
+ X? ( =dev-cpp/gtkmm-2.4* )"
+DEPEND="${RDEPEND}
+ dev-util/scons
+ dev-util/pkgconfig"
+
+src_unpack() {
+ unpack ${A}
+
+ # Provide user, group and chroot privilege lowering
+ epatch ${FILESDIR}/${P}-droppriv.patch
+}
+
+src_compile() {
+ econf `use_enable debug` `use_with X gui` || die "econf failed"
+ emake -j1 || die "emake failed"
+}
+
+src_install() {
+ make DESTDIR="${D}" install || die "make install failed"
+
+ # This is also created by openssh for privilege separation
+ keepdir /var/empty
+
+ #doman ${FILESDIR}/bfilter.8
+
+ dodoc AUTHORS ChangeLog
+ dohtml doc/*.png doc/*.jpg doc/*.html
+
+ newinitd ${FILESDIR}/bfilter.init bfilter
+ newconfd ${FILESDIR}/bfilter.conf bfilter
+}
+
+pkg_preinst() {
+ enewgroup bfilter
+ enewuser bfilter -1 -1 -1 bfilter
+}
+
+pkg_postinst() {
+ if has_version =${CATEGORY}/${PN}-0.9.4 ; then
+ ewarn "Please note that the filtering configuration files have been changed."
+ ewarn "Any custom settings defined in the rules and rules.local files"
+ ewarn "need to be converted to the new url and url.local files"
+ ewarn "(the old rules and rules.local can then be deleted). "
+ ewarn "See http://bfilter.sourceforge.net/doc/url-patterns.php for further details."
+ fi
+}
--- /dev/null
+diff -ur bfilter-0.10.1/main/daemon/Daemon.cpp bfilter-0.10.1-droppriv/main/daemon/Daemon.cpp
+--- bfilter-0.10.1/main/daemon/Daemon.cpp 2005-10-10 23:52:20.000000000 +0100
++++ bfilter-0.10.1-droppriv/main/daemon/Daemon.cpp 2005-11-14 20:05:40.000000000 +0000
+@@ -52,6 +52,10 @@
+ #include <deque>
+ #include <list>
+ #include <cstdlib>
++#include <sys/stat.h>
++#include <pwd.h>
++#include <grp.h>
++#include <netdb.h>
+
+ namespace po = boost::program_options;
+ using namespace std;
+@@ -340,6 +344,69 @@
+ }
+
+ bool
++Daemon::droppriv(std::string const& chrootdir, std::string const& user, std::string const& group)
++{
++ uid_t uid = 0;
++ uid_t gid = 0;
++
++ if (!chrootdir.empty() || !user.empty() || !group.empty()) {
++ struct stat stat_r;
++ struct passwd *user_r;
++ struct group *group_r;
++
++ if (getuid()) {
++ std::cerr << "Cannot lower privileges, not running as root" << std::endl;
++ return false;
++ }
++ if (!chrootdir.empty() && stat(chrootdir.c_str(), &stat_r)) {
++ if (!S_ISDIR(stat_r.st_mode)) {
++ std::cerr << "Cannot lower privileges, chroot directory does not exist" << std::endl;
++ return false;
++ }
++ }
++ if (!user.empty()) {
++ user_r = getpwnam(user.c_str());
++ if (user_r) {
++ uid = user_r->pw_uid;
++ } else {
++ std::cerr << "Cannot lower privileges, unknown user" << std::endl;
++ return false;
++ }
++ }
++ if (!group.empty()) {
++ group_r = getgrnam(group.c_str());
++ if (group_r) {
++ gid = group_r->gr_gid;
++ } else {
++ std::cerr << "Cannot lower privileges, unknown group" << std::endl;
++ return false;
++ }
++ }
++ }
++
++ if (!chrootdir.empty()) {
++ // Using gethostbyname before chrooting means that the chroot
++ // directory can be empty (no etc/resolv.conf or dynamically
++ // loaded lib/libnss* libraries). Using localhost here to
++ // prevent remote name resolution does not work.
++ gethostbyname("slashdot.org");
++ if (chroot(chrootdir.c_str())) {
++ std::cerr << "Cannot lower privileges, chroot directory no longer exists" << std::endl;
++ return false;
++ }
++ chdir("/");
++ }
++ if (gid) {
++ setgroups(0, NULL);
++ setgid(gid);
++ }
++ if (uid) {
++ setuid(uid);
++ }
++ return true;
++}
++
++bool
+ Daemon::run(bool nodaemon)
+ {
+ if (!nodaemon) {
+@@ -447,13 +514,19 @@
+ {
+ bool nodaemon = false;
+ std::string confdir = string(SYSCONFDIR) + "/bfilter";
+-
++ std::string chrootdir;
++ std::string user;
++ std::string group;
++
+ try {
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help,h", "Print help message")
+ ("version,v", "Print version")
+ ("confdir,c", po::value<string>(&confdir), "Set custom config directory")
++ ("chroot,r", po::value<string>(&chrootdir), "Set chroot directory")
++ ("user,u", po::value<string>(&user), "Set unprivileged user")
++ ("group,g", po::value<string>(&group), "Set unprivileged group")
+ ("nodaemon,n", po::bool_switch(&nodaemon), "Disable background daemon mode")
+ ;
+ po::variables_map vm;
+@@ -476,6 +549,9 @@
+ if (!daemon.init(confdir)) {
+ exit(EXIT_FAILURE);
+ }
++ if (!daemon.droppriv(chrootdir, user, group)) {
++ exit(EXIT_FAILURE);
++ }
+ if (!daemon.run(nodaemon)) {
+ exit(EXIT_FAILURE);
+ }
+diff -ur bfilter-0.10.1/main/daemon/Daemon.h bfilter-0.10.1-droppriv/main/daemon/Daemon.h
+--- bfilter-0.10.1/main/daemon/Daemon.h 2005-01-14 16:54:32.000000000 +0000
++++ bfilter-0.10.1-droppriv/main/daemon/Daemon.h 2005-11-14 18:22:58.000000000 +0000
+@@ -33,7 +33,7 @@
+ {
+ public:
+ bool init(std::string const& confdir);
+-
++ bool droppriv(std::string const& chrootdir, std::string const& user, std::string const& group);
+ bool run(bool nodaemon);
+ private:
+ class ConfigErrorHandler;