diff options
author | Alin Năstac <mrness@gentoo.org> | 2006-06-25 18:54:35 +0000 |
---|---|---|
committer | Alin Năstac <mrness@gentoo.org> | 2006-06-25 18:54:35 +0000 |
commit | c1eb47ce35f0cf35122bfba9f1a7032694d173f2 (patch) | |
tree | ca37fc24399a218f194961769e3aae48f7e0b76e /net-dns/pdnsd | |
parent | Mask latest autoconf (and thus latest coreutils) as it strictened a lot the g... (diff) | |
download | historical-c1eb47ce35f0cf35122bfba9f1a7032694d173f2.tar.gz historical-c1eb47ce35f0cf35122bfba9f1a7032694d173f2.tar.bz2 historical-c1eb47ce35f0cf35122bfba9f1a7032694d173f2.zip |
Update support for resolvconf-gentoo (#134254).
Package-Manager: portage-2.1
Diffstat (limited to 'net-dns/pdnsd')
-rw-r--r-- | net-dns/pdnsd/ChangeLog | 8 | ||||
-rw-r--r-- | net-dns/pdnsd/files/digest-pdnsd-1.2.4-r3 | 3 | ||||
-rw-r--r-- | net-dns/pdnsd/files/pdnsd.resolvconf | 227 | ||||
-rw-r--r-- | net-dns/pdnsd/pdnsd-1.2.4-r3.ebuild | 126 |
4 files changed, 309 insertions, 55 deletions
diff --git a/net-dns/pdnsd/ChangeLog b/net-dns/pdnsd/ChangeLog index f3f387bb5760..e0c55d97a0a8 100644 --- a/net-dns/pdnsd/ChangeLog +++ b/net-dns/pdnsd/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for net-dns/pdnsd # Copyright 2002-2006 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/ChangeLog,v 1.60 2006/06/11 11:24:58 mrness Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/ChangeLog,v 1.61 2006/06/25 18:54:35 mrness Exp $ + +*pdnsd-1.2.4-r3 (25 Jun 2006) + + 25 Jun 2006; Alin Nastac <mrness@gentoo.org> files/pdnsd.resolvconf, + -pdnsd-1.2.4-r2.ebuild, +pdnsd-1.2.4-r3.ebuild: + Update support for resolvconf-gentoo (#134254). *pdnsd-1.2.4-r2 (11 Jun 2006) diff --git a/net-dns/pdnsd/files/digest-pdnsd-1.2.4-r3 b/net-dns/pdnsd/files/digest-pdnsd-1.2.4-r3 new file mode 100644 index 000000000000..a46253777836 --- /dev/null +++ b/net-dns/pdnsd/files/digest-pdnsd-1.2.4-r3 @@ -0,0 +1,3 @@ +MD5 aafb9d65d713b4bc2c6c4ba822e0bd3c pdnsd-1.2.4-par.tar.gz 537362 +RMD160 19cbb5d03eacdd8153ac3b9675cdbe07b1edfbd4 pdnsd-1.2.4-par.tar.gz 537362 +SHA256 b9172094feee0ebe6b2aec3c1358419cc928469e16c96718d7d0fc639fc17e55 pdnsd-1.2.4-par.tar.gz 537362 diff --git a/net-dns/pdnsd/files/pdnsd.resolvconf b/net-dns/pdnsd/files/pdnsd.resolvconf index 6c88656ba9d5..7f33c03ab0dd 100644 --- a/net-dns/pdnsd/files/pdnsd.resolvconf +++ b/net-dns/pdnsd/files/pdnsd.resolvconf @@ -40,6 +40,11 @@ # ip="192.168.0.1","192.168.0.2"; # include=".net",".com";' # +# The exclude directive in "resolvconf" server section is partly recreated. +# Known (configured) domains in the form ".<domain>" or ".<domain>." are +# added and removed automatically, unknown domains (also those not in +# the format above) found in this directive are kept. +# # The sample configuration file /etc/pdnsd/pdnsd.conf prepared to work # with resolvconf would look like this: # @@ -88,7 +93,11 @@ COMMENT=' # preset=on; # ip="192.168.0.1","192.168.0.2"; # include=".net",".com"; +# exclude=".domain.net",".domain.com"; # policy=excluded; +# +# The exclude directive is changed automatically only in "resolvconf" server +# section. Not handled servers are kept in the directive. #' BASIC_SETTINGS='server { label="resolvconf"; @@ -159,9 +168,14 @@ n; /^[[:space:]]*ip[[:space:]]*=/ b loop_@RULE@; /^[[:space:]]*include[[:space:]]*=/ b loop_@RULE@; /^[[:space:]]*policy[[:space:]]*=/ b loop_@RULE@; +/^[[:space:]]*exclude[[:space:]]*=/ b exclude_logic_@RULE; p; /^[[:space:]]*[\}]/ d; b loop_@RULE@; + +:exclude_logic_@RULE; +@EXCLUDE_LOGIC@ +b loop_@RULE@; ' ### @@ -174,6 +188,32 @@ SED_ADDING=\ x; b main_resolvconf; ' + +### +# Edit the domain list (include/exclude). All empty fields and matching domains +# are removed. Unmaintained domains (not in resolvconf-<domain>) are kept. All +# domains should be in a pipe (|) separated list and should begin, but not end +# with a dot. The list is put into @DOMAINS@. The control flow continues, where +# it ended in SED_EDIT_ONE_SERVER. +# +SED_DOMAIN_LIST_LOGIC=\ +'h; +s/^([[:space:]]*@DIRECTIVE@[[:space:]]*=[[:space:]]*).*/\\1/; +x; +s/^[[:space:]]*@DIRECTIVE@[[:space:]]*=[[:space:]]*//; + +:@DIRECTIVE@_loop_@RULE@; +/([[:space:]]*("[^"]"*|[^,;]*)[[:space:]]*,)*[[:space:]]*("(@DOMAINS@|)\.?"|(@DOMAINS@)\.?|,)[[:space:]]*[,;]/ { + s/(([[:space:]]*("[^"]"*|[^,;]*)[[:space:]]*,)*[[:space:]]*)("(@DOMAINS@|)\.?"|(@DOMAINS@)\.?|,)[[:space:]]*([,;])/\\1\\7/; + b @DIRECTIVE@_loop_@RULE@; +}; + +s/^[,;]//g; +/^[[:space:]]*$/ b @DIRECTIVE@_end_@RULE@; +H; x; s/\\n//; p; +:@DIRECTIVE@_end_@RULE@; +' + ################################################################################ # Functions @@ -213,41 +253,63 @@ compose_lines() { } ### -# char *build_settings(char *nameservers, char *domain) +# char *build_settings(char *nameservers, char *domains, char *directive) # -# Builds configuration part @SETUP@ of sed script. This involves options like +# Builds configuration part @SETUP@ of sed script. The directive parameter denotes +# if the domains are to be included ("include") or excluded ("exclude"). This +# involves options like # -# (1) preset=off; +# (1) # [nameserver list is empty] +# preset=off; # -# (2) preset=on; +# (2) # [domain list is empty] +# preset=on; # ip="address","address"...; # -# (3) preset=on; +# (3) # [directive=="include"] +# preset=on; # ip="address","address"...; # include=".domain.",".domain."...; +# policy=excluded; +# +# (4) # [directive=="exclude"] +# preset=on; +# ip="address","address"...; +# exclude=".domain.",".domain."...; +# policy=included; # -# Note: Currently the will always be only one domain in "include" option. +# Note: Currently there will always be only one domain in "include" directive. # build_settings() { - local ns="$1" domain="$2" + local ns="$1" domains="$2" directive="$3" if [[ -n ${ns} ]] ; then - local x list_ns list_domain + local x list_ns list_domains for x in ${ns} ; do list_ns="${list_ns},\"${x}\"" done - if [[ -n ${domain} ]] ; then - for x in ${domain} ; do - list_domain="${list_domain},\".${x}.\"" + list_ns="${list_ns#,}" + if [[ -n ${domains} ]] ; then + for x in ${domains} ; do + list_domains="${list_domains},\".${x}.\"" done - compose_lines \ - " preset=on;" \ - " ip=${list_ns#,};" \ - " include=${list_domain#,};" \ - " policy=excluded;" + list_domains="${list_domains#,}" + if [[ $directive == "include" ]]; then + compose_lines \ + " preset=on;" \ + " ip=${list_ns};" \ + " include=${list_domains};" \ + " policy=excluded;" + else + compose_lines \ + " preset=on;" \ + " ip=${list_ns};" \ + " exclude=${list_domains};" \ + " policy=included;" + fi else compose_lines \ " preset=on;" \ - " ip=${list_ns#,};" + " ip=${list_ns};" fi else compose_lines \ @@ -256,7 +318,7 @@ build_settings() { } ### -# char *build_match_labels(char *domains) +# char *build_match_labels(char *domains...) # # Build the label match part of the sed script # @@ -273,46 +335,90 @@ build_match_labels() { } ### -# char *build_one_domain(char *domain, char *domains...) +# char *build_domain_list_logic(char *domains, char *directive) # -# Parse the list of domains and build settings for one particular domain for -# the sed script. +# Build a logic for changing (removing) domains from a directive. # -build_one_domain() { - local domain="$1" ip_list - shift - for x in "$@" ; do - if [[ ${x} == *","* ]] ; then - if [[ ${x%,*} == ${domain} ]] ; then - ip_list="${ip_list} ${x#*,}" - fi - else - ip_list="${ip_list} ${x}" - fi +build_domain_list_logic() { + local domains="$1" directive="$2" + local x domain_list logic + + # Domains should be pipe separated list + for x in ${domains}; do + x=".${x%.}" + x="${x//./\.}" + domain_list="${domain_list}|${x}" done - ip_list="$(uniqify ${ip_list})" - build_settings "${ip_list}" "${domain}" + domain_list="${domain_list#|}" + + if [[ -z ${domain_list} ]]; then + logic="p;" + else + logic="${SED_DOMAIN_LIST_LOGIC//@DOMAINS@/${domain_list}}" + logic="${logic//@DIRECTIVE@/${directive}}" + fi + echo "${logic}" } ### -# char *build_edit_part(char *domain, char *domains...) +# char *build_edit_part(char *domain, char *nameservers, \ +# char *add_domains, char *remove_domains, +# char *directive) # -# Build edit part of the sed script for one particular domain. +# Build edit part of the sed script for a particular domain. Domain can be +# empty in the case it is the "resolvconf" server part. # build_edit_part() { - local domain="$1" x setup result label rule - shift - setup="$(build_one_domain "${domain}" "$@")" + local domain="$1" nameservers="$2" add_domains="$3" remove_domains="$4" + local directive="$5" + local setup label rule logic result + + setup="$(build_settings "${nameservers}" "${add_domains}" "${directive}")" label="$(make_pdnsd_label "${domain}")" rule="$(make_sed_label "${label}")" + logic="$(build_domain_list_logic "${remove_domains}" "${directive}")" result="${SED_EDIT_ONE_SERVER//@SETUP@/${setup}}" + result="${result//@EXCLUDE_LOGIC@/${logic}}" result="${result//@RULE@/${rule}}" - echo -n "${result}" + echo "${result}" } +### +# char *get_domain_nameservers(char *domain, char *domain_config...) +# +# Get the list of nameservers belonging to one particular domain. +# +# Domain configuration is a space separated list of pair <domain>,<ip>. +# +get_domain_nameservers() { + local domain="$1" ns + shift + for x in "$@" ; do + if [[ ${x%,*} == ${domain} ]] ; then + ns="${ns} ${x#*,}" + fi + done + ns="$(uniqify ${ns})" + echo -n "${ns}" +} ### -# char *build_add_part(char *add, char *domains) +# char *build_domain_edit_part(char *domain, char *domain_config...) +# +# Parse the list of domain configurations and build settings for one particular +# domain for the sed script. +# +# Domain configuration is a space separated list of pair <domain>,<ip>. +# +build_domain_edit_part() { + local domain="$1" ns + shift + ns="$(get_domain_nameservers "${domain}" "$@")" + build_edit_part "${domain}" "${ns}" "${domain}" "" "include" +} + +### +# char *build_add_part(char *add, char *domains...) # # Build add part of the sed script for all domains that needs to be added # @@ -320,36 +426,44 @@ build_add_part() { local add="$1" x label rule add_part new_part result shift for x in ${add} ; do - label="$(make_pdnsd_label "${x}")" + local domain="${x}" ns + ns="$(get_domain_nameservers "${domain}" "$@")" + label="$(make_pdnsd_label "${domain}")" rule="$(make_sed_label ${label})" new_part="$(compose_lines "server {" " label=\"${label}\";")" - new_part="${new_part}$(build_one_domain "${x}" "$@")" + new_part="${new_part}$(build_settings "${ns}" "${domain}" "include")" new_part="${new_part}$(compose_lines "}" "")" add_part="${add_part}${new_part}" done result="${SED_ADDING//@SETUP@/${add_part}}" - echo -n "${result}" + echo "${result}" } ### -# char *build_sed_script(char *nameservers, char *domains, -# char *change, char *add) +# char *build_sed_script(char *nameservers, char *domain_config, +# char *change, char *add, +# char *active_domains, char *known_domains) # -# Build the full sed script. +# Build the full sed script from the list of nameservers, list of domains +# (in format <domain>,<ip>), list of changed domains, list of added domains, +# list of activly used domains and a list of all known domains. # build_sed_script() { - local ns="$1" domains="$2" change="$3" add="$4" + local ns="$1" domain_config="$2" change="$3" add="$4" + local active_domains="$5" known_domains="$6" local match_labels="$(build_match_labels ${change})" local edit_changed x for x in ${change} ; do - edit_changed="${edit_changed}$(build_edit_part ${x} ${domains})" + edit_changed="${edit_changed}$( \ + build_domain_edit_part "${x}" ${domain_config})" done - edit_changed="${edit_changed}$(build_edit_part '' ${ns})" + edit_changed="${edit_changed}$( \ + build_edit_part "" "${ns}" "${active_domains}" "${known_domains}" "exclude")" local added - added="$(build_add_part "${add}" ${domains})" + added="$(build_add_part "${add}" ${domain_config})" local full full="${SED_LOOP//@MATCH_LABELS@/${match_labels}}" @@ -421,10 +535,13 @@ initialization() { # void find_changed_and_added(char *configured, char *domains) # # Find already configured and newly added domains. Sets variables -# CHANGE_DOMAINS and ADD_DOMAINS +# CHANGE_DOMAINS, ADD_DOMAINS and KNOWN_DOMAINS. # find_changed_and_added() { local configured="$1" domains="$2" x + + KNOWN_DOMAINS="${CONFIGURED_DOMAINS} ${DOMAINS}" + # Find what has to be disabled for x in ${configured} ; do if [[ " ${domains} " != *" ${x} "* ]] ; then @@ -436,13 +553,14 @@ find_changed_and_added() { for x in ${domains} ; do if [[ " ${configured} " != *" ${x} "* ]] ; then ADD_DOMAINS="${ADD_DOMAINS} ${x}" - else + else CHANGE_DOMAINS="${CHANGE_DOMAINS} ${x}" fi done ADD_DOMAINS=$(uniqify ${ADD_DOMAINS}) CHANGE_DOMAINS=$(uniqify ${CHANGE_DOMAINS}) + KNOWN_DOMAINS=$(uniqify ${KNOWN_DOMAINS}) } ### @@ -484,7 +602,8 @@ initialization "${PDNSDCONFIG}" find_changed_and_added "${CONFIGURED_DOMAINS}" "${DOMAINS}" sed_script="$(build_sed_script "${NAMESERVERS}" "${NEWDOMAIN}" \ - "${CHANGE_DOMAINS}" "${ADD_DOMAINS}")" + "${CHANGE_DOMAINS}" "${ADD_DOMAINS}" \ + "${DOMAINS}" "${KNOWN_DOMAINS}")" # Check if the config changed if make_configuration_change "${PDNSDCONFIG}" "${BACKUPSUFFIX}" "${sed_script}" ; then diff --git a/net-dns/pdnsd/pdnsd-1.2.4-r3.ebuild b/net-dns/pdnsd/pdnsd-1.2.4-r3.ebuild new file mode 100644 index 000000000000..0ff73db8eb52 --- /dev/null +++ b/net-dns/pdnsd/pdnsd-1.2.4-r3.ebuild @@ -0,0 +1,126 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/pdnsd-1.2.4-r3.ebuild,v 1.1 2006/06/25 18:54:35 mrness Exp $ + +inherit eutils + +DESCRIPTION="Proxy DNS server with permanent caching" +HOMEPAGE="http://www.phys.uu.nl/%7Erombouts/pdnsd.html http://www.phys.uu.nl/~rombouts/pdnsd.html" +SRC_URI="http://www.phys.uu.nl/%7Erombouts/pdnsd/releases/${P}-par.tar.gz" + +LICENSE="|| ( BSD GPL-2 )" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~ppc ~s390 ~sparc ~x86" +IUSE="ipv6 debug isdn nptl" + +pkg_setup() { + enewgroup pdnsd + enewuser pdnsd -1 -1 /var/lib/pdnsd pdnsd +} + +src_unpack() { + unpack ${A} + + epatch "${FILESDIR}/${P}-dbg_file.patch" +} + +src_compile() { + local myconf="" + + if use debug; then + myconf="${myconf} --with-debug=3" + CFLAGS="${CFLAGS} -g" + fi + use nptl && myconf="${myconf} --with-thread-lib=NPTL" + + [ -c /dev/urandom ] && myconf="${myconf} --with-random-device=/dev/urandom" + + econf \ + --sysconfdir=/etc/pdnsd \ + --with-cachedir=/var/cache/pdnsd \ + --infodir=/usr/share/info --mandir=/usr/share/man \ + --with-default-id=pdnsd \ + `use_enable ipv6` `use_enable isdn` \ + ${myconf} \ + || die "bad configure" + + emake all || die "compile problem" +} + +pkg_preinst() { + # Duplicated so that binary packages work + enewgroup pdnsd + enewuser pdnsd -1 -1 /var/lib/pdnsd pdnsd +} + +src_test() { + if [ -x /usr/bin/dig ]; then + mkdir "${T}/pdnsd" + echo -n -e "pd12\0\0\0\0" > "${T}/pdnsd/pdnsd.cache" + IPS=$(grep ^nameserver "${ROOT}/etc/resolv.conf" | sed -e 's/nameserver \(.*\)/\tip=\1;/g' | xargs) + sed -e "s/\tip=/${IPS}/" -e "s:cache_dir=:cache_dir=${T}/pdnsd:" "${FILESDIR}/pdnsd.conf.test" \ + > "${T}/pdnsd.conf.test" + src/pdnsd -c "${T}/pdnsd.conf.test" -g -s -d -p "${T}/pid" || die "couldn't start daemon" + sleep 3 + + find "${T}" -ls + [ -s "${T}/pid" ] || die "empty or no pid file created" + [ -S "${T}/pdnsd/pdnsd.status" ] || die "no socket created" + src/pdnsd-ctl/pdnsd-ctl -c "${T}/pdnsd" server all up || die "failed to start the daemon" + src/pdnsd-ctl/pdnsd-ctl -c "${T}/pdnsd" status || die "failed to communicate with the daemon" + sleep 3 + + dig @127.0.0.1 -p 33455 www.gentoo.org | fgrep "status: NOERROR" || die "www.gentoo.org lookup failed" + kill $(<"${T}/pid") || die "failed to terminate daemon" + fi +} + +src_install() { + emake DESTDIR="${D}" install || die + + # Copy cache from prev older versions + [ -f "${ROOT}/var/lib/pdnsd/pdnsd.cache" ] && \ + cp "${ROOT}/var/lib/pdnsd/pdnsd.cache" "${D}/var/cache/pdnsd/pdnsd.cache" + + # Don't clobber existing cache - copy prev cache so unmerging prev version + # doesn't remove the cache. + [ -f "${ROOT}/var/cache/pdnsd/pdnsd.cache" ] && \ + rm "${D}/var/cache/pdnsd/pdnsd.cache" + + dodoc AUTHORS ChangeLog* NEWS README THANKS TODO README.par + docinto contrib ; dodoc contrib/{README,dhcp2pdnsd,pdnsd_dhcp.pl} + docinto html ; dohtml doc/html/* + docinto txt ; dodoc doc/txt/* + newdoc doc/pdnsd.conf pdnsd.conf.sample + + newinitd "${FILESDIR}/pdnsd.rc6" pdnsd + newinitd "${FILESDIR}/pdnsd.online" pdnsd-online + + keepdir /etc/conf.d + local config="${D}/etc/conf.d/pdnsd-online" + + echo -e "# Enter the interface that connects you to the dns servers" >> "${config}" + echo "# This will correspond to /etc/init.d/net.${IFACE}" >> "${config}" + echo -e "\n# IMPORTANT: Be sure to run depscan.sh after modifiying IFACE" >> "${config}" + echo "IFACE=ppp0" >> "${config}" + + config="${D}/etc/conf.d/pdnsd" + "${D}/usr/sbin/pdnsd" --help | sed "s/^/# /g" > "${config}" + echo "# Command line options" >> "${config}" + use ipv6 && echo PDNSDCONFIG="-a" >> "${config}" \ + || echo PDNSDCONFIG="" >> "${config}" + + #resolvconf-gentoo support + exeinto /etc/resolvconf/update.d + newexe "${FILESDIR}/pdnsd.resolvconf" pdnsd +} + +pkg_postinst() { + einfo + einfo "Add pdnsd to your default runlevel - rc-update add pdnsd default" + einfo "" + einfo "Add pdnsd-online to your online runlevel." + einfo "The online interface will be listed in /etc/conf.d/pdnsd-online" + einfo "" + einfo "Sample config file in /etc/pdnsd/pdnsd.conf.sample" +} |