Browse Source

privoxy: moved to github and update to 3.0.22

- moved from oldpackages to github
- set maintainer
- update pkg source to new version 3.0.22
- run privoxy as non root user privoxy:privoxy
- using procd including network events to restart on changes
- log start and stop to syslog, privoxy not using syslog

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Steven Barth 10 years ago
parent
commit
eeabfeed8e

+ 168
- 0
net/privoxy/Makefile View File

@@ -0,0 +1,168 @@
1
+#
2
+# Copyright (C) 2006-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=privoxy
11
+PKG_VERSION:=3.0.22
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-stable-src.tar.gz
15
+PKG_SOURCE_URL:=@SF/ijbswa
16
+PKG_MD5SUM:=aa121751d332a51d37d3c6e4b7594daa
17
+
18
+PKG_LICENSE:=GPL-2.0
19
+PKG_LICENSE_FILES:=LICENSE
20
+
21
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-stable
22
+PKG_FIXUP:=autoreconf
23
+PKG_INSTALL:=1
24
+
25
+PKG_MAINTAINER:=christian.schoenebeck@gmail.com
26
+
27
+include $(INCLUDE_DIR)/package.mk
28
+
29
+define Package/privoxy
30
+  SECTION:=net
31
+  CATEGORY:=Network
32
+  SUBMENU:=Web Servers/Proxies
33
+  DEPENDS:=+libpcre +libpthread +zlib
34
+  TITLE:=web proxy with advanced filtering capabilities
35
+  URL:=http://www.privoxy.org/
36
+  USERID:=privoxy=8118:privoxy=8118
37
+endef
38
+
39
+define Package/privoxy/description
40
+Privoxy is a web proxy with advanced filtering capabilities for
41
+ protecting privacy, modifying web page content, managing cookies,
42
+ controlling access, and removing ads, banners, pop-ups and other
43
+ obnoxious Internet junk. Privoxy has a very flexible configuration
44
+ and can be customized to suit individual needs and tastes. Privoxy
45
+ has application for both stand-alone systems and multi-user networks.
46
+Version: $(PKG_VERSION)-$(PKG_RELEASE)
47
+endef
48
+
49
+CONFIGURE_ARGS += \
50
+	--sysconfdir=/etc/privoxy \
51
+
52
+# needed otherwise errors during compile
53
+MAKE_FLAGS:=
54
+
55
+define Build/Install
56
+	$(call Build/Install/Default,)
57
+	# rename original sample config from pkg_source to save existing one during install
58
+	mv $(PKG_INSTALL_DIR)/etc/privoxy/config $(PKG_INSTALL_DIR)/etc/privoxy/config.privoxy
59
+endef
60
+
61
+define Package/privoxy/conffiles
62
+/etc/config/privoxy
63
+/etc/privoxy/config	# temporary needed if updating from old version
64
+endef
65
+
66
+define Package/privoxy/preinst
67
+	#!/bin/sh
68
+	# if run within buildroot exit
69
+	[ -n "$${IPKG_INSTROOT}" ] && exit 0
70
+	# stop service # if PKG_UPGRADE NOT WORKING
71
+	# [ "$${PKG_UPGRADE}" = "1" ] && /etc/init.d/privoxy stop
72
+	/etc/init.d/privoxy stop >/dev/null 2>&1
73
+	exit 0	# supress errors from stop command
74
+endef
75
+
76
+define Package/privoxy/install
77
+	$(INSTALL_DIR) $(1)/usr/sbin
78
+	$(CP) $(PKG_INSTALL_DIR)/usr/sbin/privoxy $(1)/usr/sbin/
79
+	$(INSTALL_DIR) $(1)/etc/init.d
80
+	$(INSTALL_BIN) ./files/privoxy.init $(1)/etc/init.d/privoxy
81
+	# no longer needed because running with procd
82
+	# $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
83
+	# $(INSTALL_BIN) ./files/privoxy.hotplug $(1)/etc/hotplug.d/iface/80-privoxy
84
+
85
+	$(INSTALL_DIR) $(1)/etc/privoxy
86
+	$(CP) $(PKG_INSTALL_DIR)/etc/privoxy/* $(1)/etc/privoxy/
87
+	# temporary needed if updating from old version
88
+	# otherwise old config file will be delete by opkg
89
+	$(INSTALL_CONF) ./files/privoxy.oldconfig $(1)/etc/privoxy/config
90
+	# create .old file to be removed with next pacakge builds during update
91
+	$(INSTALL_CONF) ./files/privoxy.oldconfig $(1)/etc/privoxy/config.old
92
+
93
+	$(INSTALL_DIR) $(1)/etc/config
94
+	$(INSTALL_CONF) ./files/privoxy.config $(1)/etc/config/privoxy
95
+endef
96
+
97
+define Package/privoxy/postinst
98
+	#!/bin/sh
99
+
100
+	# if fresh install we don't need old config file in privoxy directory
101
+	[ "$${PKG_UPGRADE}" = "0" ] && rm -f /etc/privoxy/config
102
+
103
+	# if run within buildroot exit here
104
+	[ -n "$${IPKG_INSTROOT}" ] && exit 0
105
+
106
+	# if PKG_UPGRADE then build uci configuration
107
+	# from existing(?) old /etc/privoxy/config file
108
+	if [ "$${PKG_UPGRADE}" = "1" -a -f /etc/privoxy/config ]; then
109
+
110
+		echo "converting OLD config to NEW uci configuration"
111
+
112
+		SECTION="privoxy.privoxy"
113
+		CFGFILE=/etc/privoxy/config
114
+
115
+		echo -n > /etc/config/privoxy		# clear/create uci configuration file
116
+		cp -f $${CFGFILE} $${CFGFILE}.old	# save old configuration
117
+
118
+		# cleanup
119
+		sed -i 's/^[ \t]*//;s/[ \t]*$$//' $${CFGFILE}	# remove invisible chars at beginning and end of lines
120
+		sed -i '/^#/d' $${CFGFILE}			# remove lines with "#"
121
+		sed -i '/^$$/d' $${CFGFILE}			# remove empty lines
122
+
123
+		uci -q set $${SECTION}="privoxy"		# create section
124
+
125
+		cat $${CFGFILE} | while read LINE; do
126
+			# option is first parameter; uci did not like "-" in option names
127
+			OPT=$$(echo $${LINE} | awk '{print $$1}' | sed 's/-/_/g')
128
+			VAL=$$(echo $${LINE} | awk '{print $$2}')
129
+			case $${OPT} in
130
+				# debug 1024 => debug_1024 '1'
131
+				debug)
132
+					uci -q set $${SECTION}.debug_$${VAL}="1"
133
+					;;
134
+				# handle list values; splitted case for better reading
135
+				actionsfile|filterfile|listen_address)
136
+					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
137
+					;;
138
+				permit_access|deny_access)
139
+					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
140
+					;;
141
+				trust_info_url|forward)
142
+					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
143
+					;;
144
+				forward_socks4|forward_socks4a)
145
+					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
146
+					;;
147
+				forward_socks5|forward_socks5t)
148
+					uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
149
+					;;
150
+				# all others are normal options
151
+				*)
152
+					uci -q set $${SECTION}.$${OPT}="$${VAL}"
153
+					;;
154
+			esac
155
+		done
156
+		uci -q commit privoxy	# commit changes
157
+		rm -f $${CFGFILE}	# remove old configuration file
158
+	fi
159
+
160
+	# set permissions to privoxy group
161
+	echo "setting permissions"
162
+	chgrp -R privoxy /etc/privoxy/*
163
+	chmod 664 /etc/privoxy/*
164
+	chmod 755 /etc/privoxy/templates
165
+	chmod 644 /etc/privoxy/templates/*
166
+endef
167
+
168
+$(eval $(call BuildPackage,privoxy))

+ 43
- 0
net/privoxy/files/privoxy.config View File

@@ -0,0 +1,43 @@
1
+# this file support all available configuration options of
2
+# Privoxy web-proxy
3
+# the scripts move all options to the final privoxy readable configuration file
4
+#
5
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6
+# !!! privoxy uses "-" in option names but uci only support "_"         !!!
7
+# !!! privoxy "listen-address" must be uci "listen_address"             !!!
8
+# !!!                                                                   !!!
9
+# !!! if you add entries please use                                      !!!
10
+# !!! option for options with one parameter (option confdir)             !!!
11
+# !!! list   for options with multiple parameters (list listen_address) !!!
12
+# !!!                                                                   !!!
13
+# !!! special handling for debug option                                 !!!
14
+# !!! privoxy option "debug 1024" must be uci option debug_1024 '1'     !!!
15
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
+#
17
+config	privoxy	'privoxy'
18
+	option	confdir		'/etc/privoxy'
19
+	option	logdir		'/var/log'
20
+	option	logfile		'privoxy.log'
21
+	list	filterfile	'default.filter'
22
+	list	actionsfile	'match-all.action'
23
+	list	actionsfile	'default.action'
24
+#	list	actionsfile	'user.action'
25
+	list	listen_address	'127.0.0.1:8118'
26
+	list	listen_address	'192.168.1.1:8118'
27
+	option	toggle		'1'
28
+	option	enable_remote_toggle	'1'
29
+	option	enable_remote_http_toggle	'0'
30
+	option	enable_edit_actions	'1'
31
+	option	enforce_blocks		'0'
32
+	option	buffer_limit		'4096'
33
+	option	forwarded_connect_retries	'0'
34
+	option	accept_intercepted_requests	'0'
35
+	option	allow_cgi_request_crunching	'0'
36
+	option	split_large_forms	'0'
37
+	option	keep_alive_timeout	'300'
38
+	option	socket_timeout		'300'
39
+	list	permit_access		'192.168.1.0/24'
40
+	option	debug_1		'0'
41
+	option	debug_1024	'0'
42
+	option	debug_4096	'1'
43
+	option	debug_8192	'1'

+ 124
- 0
net/privoxy/files/privoxy.init View File

@@ -0,0 +1,124 @@
1
+#!/bin/sh /etc/rc.common
2
+
3
+START=80
4
+USE_PROCD=1
5
+
6
+PIDFILE=/var/run/privoxy.pid
7
+CFGFILE=/var/etc/privoxy.conf
8
+CFGTEMP=/var/etc/privoxy.conf.tmp
9
+
10
+_uci2conf() {
11
+	local _LOGDIR="/var/log"	# set default
12
+	local _LOGFILE="privoxy.log"	# set default
13
+
14
+	# redefined callback for options when calling config_load
15
+	option_cb()
16
+	{
17
+		# $1	name of variable
18
+		# $2	value
19
+		local __OPT="$1"
20
+		local __VAL="$2"
21
+		case $__OPT in
22
+			logdir)		# logdir handled later
23
+				_LOGDIR="$__VAL"  ;;
24
+			logfile)	# logfile handled later
25
+				_LOGFILE="$__VAL" ;;
26
+			*)
27
+				# detect list options (LENGTH) and ignore
28
+				echo $__OPT | grep -i "_LENGTH" >/dev/null 2>&1 && return
29
+				# detect list options (ITEM) and ignore
30
+				echo $__OPT | grep -i "_ITEM" >/dev/null 2>&1 && __OPT=$(echo $__OPT | sed -e "s#_ITEM.##g")
31
+				# filter debug_*
32
+				echo $__OPT | grep -i "debug_" >/dev/null 2>&1 && {
33
+					[ $__VAL -eq 0 ] && return	# not set ignore
34
+					__VAL=$(echo $__OPT | sed -e "s#debug_##g")
35
+					__OPT="debug"
36
+				}
37
+				# uci only accept "_" but we need "-"
38
+				local __OPT=$(echo $__OPT | sed -e "s#_#-#g")
39
+				# write to config
40
+				echo -e "$__OPT\t$__VAL" >> $CFGTEMP
41
+				;;
42
+		esac
43
+	}
44
+
45
+	mkdir -m0755 -p /var/etc
46
+	echo "" > $CFGTEMP	# create tmp config file
47
+	chmod 644 $CFGTEMP	# garantee that privoxy can read
48
+	chgrp privoxy $CFGTEMP
49
+
50
+	echo '### AUTO-GENERATED CONFIGURATION'	   >> $CFGTEMP
51
+	echo '### USED BY PRIVOXY'		   >> $CFGTEMP
52
+	echo '### DO NOT EDIT'			   >> $CFGTEMP
53
+	echo '### SEE /etc/config/privoxy INSTEAD' >> $CFGTEMP
54
+	echo ''					   >> $CFGTEMP
55
+
56
+	config_load privoxy	# calling above option_cb()
57
+
58
+	# write logdir/logfile to config
59
+	echo -e "logdir\t$_LOGDIR" >> $CFGTEMP
60
+	echo -e "logfile\t$_LOGFILE" >> $CFGTEMP
61
+
62
+	# create logfile and set permissions
63
+	touch $_LOGDIR/$_LOGFILE
64
+	chmod 664 $_LOGDIR/$_LOGFILE
65
+	chown privoxy:privoxy $_LOGDIR/$_LOGFILE
66
+
67
+	# move temp to final privoxy readable configuration
68
+	mv -f $CFGTEMP $CFGFILE
69
+}
70
+
71
+# privoxy should auto-reload it's configuration
72
+# but it only reload on next connect to one of the listen_address
73
+# if we create a new listen_address privoxy never reload
74
+reload_service() {
75
+	# so we restart here because rc.common reload_service only start without stopping
76
+	restart "$@"
77
+
78
+	# the following should normally work but see above
79
+#	_uci2conf	# convert uci config
80
+}
81
+
82
+service_triggers() {
83
+	procd_add_reload_trigger "privoxy"
84
+}
85
+
86
+start_service() {
87
+	# redefined callback for sections when calling config_load
88
+	config_cb() {
89
+		# $1	type of config section
90
+		# $2	name of section
91
+		[ "$1" = "interface" ] && \
92
+			procd_add_interface_trigger interface.* $2 /etc/init.d/privoxy restart
93
+	}
94
+
95
+	_uci2conf	# convert uci config
96
+
97
+	procd_open_instance
98
+
99
+	procd_set_param command /usr/sbin/privoxy
100
+	procd_append_param command --no-daemon			# for procd run in foreground
101
+	procd_append_param command --pidfile $PIDFILE		# set pid file
102
+	procd_append_param command --user privoxy.privoxy	# set user
103
+	procd_append_param command $CFGFILE			# config file
104
+
105
+	procd_set_param file $CFGFILE	# set configration file
106
+
107
+        procd_open_trigger	# we need a restart on interface events not a reload
108
+	config_load network	# load network configuration and set trigger(s) in config_cb() above
109
+        procd_close_trigger
110
+
111
+	procd_close_instance
112
+}
113
+
114
+service_running() {
115
+	logger_trick() {
116
+		sleep 1		# give privoxy time to completely come up
117
+		logger -p daemon.notice -t "privoxy[$(cat $PIDFILE)]" "Service started successfully"
118
+	}
119
+	logger_trick &
120
+}
121
+
122
+stop_service() {
123
+	logger -p daemon.notice -t "privoxy[$(cat $PIDFILE)]" "Service shutdown"
124
+}

+ 33
- 0
net/privoxy/files/privoxy.oldconfig View File

@@ -0,0 +1,33 @@
1
+#
2
+# original configuration file used by privoxy
3
+# this is no longer supported by this package
4
+# it's converted and moved to uci configuration
5
+# please look at /etc/config/privoxy
6
+#
7
+confdir /etc/privoxy
8
+logdir /var/log
9
+logfile privoxy.log
10
+filterfile default.filter
11
+actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
12
+actionsfile default.action   # Main actions file
13
+#actionsfile user.action      # User customizations
14
+listen-address  127.0.0.1:8118
15
+toggle  1
16
+enable-remote-toggle  1
17
+enable-remote-http-toggle  0
18
+enable-edit-actions 1
19
+enforce-blocks 0
20
+buffer-limit 4096
21
+forwarded-connect-retries  0
22
+accept-intercepted-requests 0
23
+allow-cgi-request-crunching 0
24
+split-large-forms 0
25
+keep-alive-timeout 300
26
+socket-timeout 300
27
+permit-access  192.168.1.0/24
28
+debug   1    # show each GET/POST/CONNECT request
29
+debug   4096 # Startup banner and warnings
30
+debug   8192 # Errors - *we highly recommended enabling this*
31
+#admin-address privoxy-admin@example.com
32
+#proxy-info-url http://www.example.com/proxy-service.html
33
+