Bug#426275: resolvconf: add script to update proxy and other services

2007-05-28 Thread Anon Sricharoenchai

Fix bugs found in /etc/resolvconf/update-proxy.d/squid, the squid example.

diff -durN --exclude={diff} --exclude='resolvconf/{diff}/*'
--exclude='.*.sw?' --exclude='.sw?' --
commit/resolvconf/update-proxy.d/squid resolvconf/update-proxy.d/squid
--- commit/resolvconf/update-proxy.d/squid  2007-05-26 19:50:29.0 
+0700
+++ resolvconf/update-proxy.d/squid 2007-05-28 11:57:46.0 +0700
@@ -63,7 +63,9 @@
   ++$cache_peer{lc($host)}{$port+0};
}

-$init = 0; scalar(@ARGV)  0 and shift(@ARGV) eq -i and $init = 1;
+$init = 0; if (scalar(@ARGV)  0 and $ARGV[0] eq -i) {
+   shift(@ARGV); $init = 1;
+}

my $new_acl_count = 0;

@@ -89,7 +91,10 @@
#if ($action eq +) {
   #$src_file = $ETCRESOLVCONF/squid-peer-acl/enable-$host;
   $src_file = $ETCRESOLVCONF/squid/$host-add-peer-acl;
-   $cmd = ; # leave blank file
+   #$cmd = ; # leave blank file
+   # From experiment, squid regards empty acl (blank file) as all (always
+   # match).
+   $cmd = echo 255.255.255.255/255.255.255.255;
#} elsif ($action eq -) {
#   #$src_file = $ETCRESOLVCONF/squid-peer-acl/disable-$host;
#   $src_file = $ETCRESOLVCONF/squid/$host-del-peer-acl;


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#426275: resolvconf: add script to update proxy and other services

2007-05-27 Thread Anon Sricharoenchai

Package: resolvconf
Version: 1.15
Severity: wishlist
Tags: patch

I have written the script that was primarily used to update the list of
current valid proxy servers.  However, it has later been generalized to
be capable of updating server addresses for other services, such as,
smtp server or any other types.

Those servers are updated base on the contents in resolv.conf (that is
/etc/resolvconf/run/interface/*).  The file /etc/resolvconf/proxy.conf
will contain the mapping from those resolv.conf contents to the
specified servers for each service (proxy, smtp, etc.).

/etc/resolvconf/proxy.conf:
  # This will map the resolv.conf value to the servers for each service.
  # typeval service:[(tcp|udp)/]host[:port] service:... 
...
  searchexample.com proxy:tcp/10.0.0.10:8080 proxy:10.0.0.11:8080
  searchexample.com proxy:proxy1.example.com 
proxy:proxy2.example.com:8080
  searchexample.com smtp:smtp.example.com:25
  searchhomeproxy:10.10.10.1:8080
  nameserver10.10.10.1  proxy:10.10.10.1:8080 smtp:10.10.10.1:25

Note that, the services are not limited to only proxy and smtp.  The
arbitrary service name can be added.

According to the above proxy.conf, when resolv.conf is updated, and if
it finally contains the entry like search example.com and
nameserver 10.10.10.1, the script /etc/resolvconf/update.d/proxy will
then collect all corresponding service servers, that is,

  tcp/10.0.0.10:8080
  10.0.0.11:8080
  proxy1.example.com
  proxy2.example.com:8080
  10.10.10.1:8080

for proxy service (the sort order will corresponding to
/lib/resolvconf/list-records), and

  smtp.example.com:25
  10.10.10.1:25

for smtp service.  The list of these servers will be passed to the
scripts in /etc/resolvconf/update-proxy.d and
/etc/resolvconf/update-smtp.d, respectively.  It is passed to the
command line arguments as follow,

  $ run-parts --arg=tcp/10.0.0.10:8080 --arg=10.0.0.11:8080 \
   --arg=proxy1.example.com --arg=proxy2.example.com:8080 \
   --arg=10.10.10.1:8080 /etc/resolvconf/update-proxy.d
  $ run-parts --arg=smtp.example.com:25 --arg=10.10.10.1:25 \
   /etc/resolvconf/update-smtp.d

== Usage summary ==
$ /etc/resolvconf/update.d/proxy [-i]
config:
  /etc/resolvconf/proxy.conf
  /etc/resolvconf/update-proxy.d
  /etc/resolvconf/update-smtp.d
  /etc/resolvconf/update-service.d
output:
  /etc/resolvconf/run/service/proxy
  /etc/resolvconf/run/service/smtp
  /etc/resolvconf/run/service/service
  $ run-parts [--arg=-i] --arg=host:port --arg=host:port ... \
   /etc/resolvconf/update-proxy.d
  $ run-parts [--arg=-i] --arg=host:port /etc/resolvconf/update-smtp.d
  $ run-parts [--arg=-i] ... /etc/resolvconf/update-service.d

== squid proxy example ==
The attach files, also include the file
/etc/resolvconf/update-proxy.d/squid as an example to show how it has
been adapted to configure the parent proxy peer in squid.


-- System Information:
Debian Release: testing/unstable
Architecture: i386 (i686)
Kernel: Linux 2.6.10-5-386
Locale: LANG=C, LC_CTYPE=thai

Versions of packages resolvconf depends on:
ii  debconf [debconf-2.0]1.4.29ubuntu4   Debian configuration management sy
ii  initscripts  2.85-22ubuntu12 Standard scripts needed for bootin

-- debconf information excluded


resolvconf.tgz
Description: GNU Zip compressed data