diff options
author | Alin Năstac <mrness@gentoo.org> | 2008-04-20 05:07:39 +0000 |
---|---|---|
committer | Alin Năstac <mrness@gentoo.org> | 2008-04-20 05:07:39 +0000 |
commit | d095f210f7ca736391f1b41daf0733788fdb0df1 (patch) | |
tree | b8c5c4f160eaaaadfdb4ce06322dc339e82183c7 /net-dns/pdnsd | |
parent | version bump from upstream (diff) | |
download | historical-d095f210f7ca736391f1b41daf0733788fdb0df1.tar.gz historical-d095f210f7ca736391f1b41daf0733788fdb0df1.tar.bz2 historical-d095f210f7ca736391f1b41daf0733788fdb0df1.zip |
Make resolvconf script compatible with baselayout-2 (#218031).
Package-Manager: portage-2.1.4.4
Diffstat (limited to 'net-dns/pdnsd')
-rw-r--r-- | net-dns/pdnsd/ChangeLog | 8 | ||||
-rw-r--r-- | net-dns/pdnsd/Manifest | 16 | ||||
-rw-r--r-- | net-dns/pdnsd/files/pdnsd.resolvconf-r1 | 631 | ||||
-rw-r--r-- | net-dns/pdnsd/pdnsd-1.2.6-r1.ebuild (renamed from net-dns/pdnsd/pdnsd-1.2.5-r1.ebuild) | 31 |
4 files changed, 660 insertions, 26 deletions
diff --git a/net-dns/pdnsd/ChangeLog b/net-dns/pdnsd/ChangeLog index 372d1806162d..228d525dad0f 100644 --- a/net-dns/pdnsd/ChangeLog +++ b/net-dns/pdnsd/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for net-dns/pdnsd # Copyright 2002-2008 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/ChangeLog,v 1.76 2008/01/14 19:14:56 angelos Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/ChangeLog,v 1.77 2008/04/20 05:07:38 mrness Exp $ + +*pdnsd-1.2.6-r1 (20 Apr 2008) + + 20 Apr 2008; Alin Năstac <mrness@gentoo.org> +files/pdnsd.resolvconf-r1, + -pdnsd-1.2.5-r1.ebuild, +pdnsd-1.2.6-r1.ebuild: + Make resolvconf script compatible with baselayout-2 (#218031). 14 Jan 2008; Christoph Mende <angelos@gentoo.org> pdnsd-1.2.6.ebuild: Stable on amd64 wrt bug #203769 diff --git a/net-dns/pdnsd/Manifest b/net-dns/pdnsd/Manifest index 5683b6d0e697..3c1ae410aebe 100644 --- a/net-dns/pdnsd/Manifest +++ b/net-dns/pdnsd/Manifest @@ -1,10 +1,20 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + AUX pdnsd.conf.test 377 RMD160 fbf25b78728754fa1f9cf5259c43cce9cb22a995 SHA1 bd7fdc0d89873921d5284e8d6713e62a424de704 SHA256 8ef1e68c43cefde86598158d2b624cbdd66d2436d681cabbc6327d34d5886058 AUX pdnsd.online 452 RMD160 45ecfe4acf625d62a299ee1ba46c6559901e2e66 SHA1 23998f42399430a457f3122ec906b9ef1b701520 SHA256 6fe3f33c7c5554f9577abfc5f7dc9547ba508ab68fe3590d8f1bb9598a865e9a AUX pdnsd.rc6 850 RMD160 9700c23cbe4a8fb18a6492c04ec4e8d7b8d2c082 SHA1 b7a231bb4c486015895f1efc7fe566c2210fe384 SHA256 4406f536e237fb92547e25373500b16198e6eb1cf6ab6e54e9ed3effa4eaa4ba AUX pdnsd.resolvconf 17365 RMD160 ea64795ebe6db99bbb304c86f2f2718ae3f9b034 SHA1 1485d59bbfdefa9faf3209b9bea2de30b204e813 SHA256 065679543e9cf3e20622265e3d009c5b68c213136c7632d257af0096b49fbbed -DIST pdnsd-1.2.5-par.tar.gz 537586 RMD160 c1444a746e3a8d1552608d0356cb14ed03d86fc1 SHA1 835a399a5ef3ea24f626c36b8eef0816985847b1 SHA256 679b308373cf89983bd21432090aad11bb3109ea2e58532f2e2ac0cb3b97462f +AUX pdnsd.resolvconf-r1 17538 RMD160 a79ab764cd96a7203165771d50b14f4bf3907141 SHA1 3afbba4b8eb5fad1e1268dab85cc1fc04b1258b2 SHA256 40bdcc876ba8bb86069d52f8023fed468974004f47c235c202ca7eac88aa0fe3 DIST pdnsd-1.2.6-par.tar.gz 451465 RMD160 4d7fc3b4bafc6dafc41e4d4b00e601f7de200c53 SHA1 ca9fcf1d214829dfcc7771a3443e9500fe6d305c SHA256 84a4165471856f71725e5dc958978d9aee671c33b94a7dca0be09e60d99069ed -EBUILD pdnsd-1.2.5-r1.ebuild 3837 RMD160 f46492ed01c1e96ad604f6c156af7907b06d25a5 SHA1 4cea51b4349a5055562e6d3aba244f3d45b79d62 SHA256 1656019c4c9e90b62cf5bb9b837ce60605894b5bc7a25d625306c6c30f7170e0 +EBUILD pdnsd-1.2.6-r1.ebuild 3433 RMD160 d4bc71626377f6d0d6e5050e52f9b1b324c8b1c1 SHA1 3aeae32c713f4b1c1d0cbf0b5ba1f62243877851 SHA256 3216cea70895a98ecf6a98d2c2937c5af70da71bb516d6ddbc816d59d167ef62 EBUILD pdnsd-1.2.6.ebuild 3421 RMD160 64e4f721d547e7e56ab652c5b25b7482a84b81a1 SHA1 9ca68ba923cfdc51b568f81bf5d9fbd6826958ad SHA256 23a2fb7f96bcdd7101adf82cb50f72c5126f14f121d25967b20126dbd4032604 -MISC ChangeLog 11345 RMD160 806b63b1e66dcc04849ade23bfc017933499f855 SHA1 797a69e691b1b0ef2811e221ab16974c4d90e9e6 SHA256 1c93aa04f5ebc966dff6b4945cc1b5112663524b09f6a90430b27513c92dae32 +MISC ChangeLog 11567 RMD160 f88ac221d2d3fd008cd2141f5a606ffc7eaa752d SHA1 a423bdc6138c3f669bb6c26a423e765c91609ec1 SHA256 2ad78bea7d36de4eab3d49438aaebb0ccfab9df4ac6ae6c7c2d6c330a6263617 MISC metadata.xml 402 RMD160 2dbd46b28843db4e7c216ec2d38354fe544d3d4b SHA1 8e51bef82c01c04db3c4a130b8bf726195c3acb9 SHA256 d5dba4f72c2ee03f15efe1a6954b8e81dc4d2e2842611cf5db90b9c241433ac6 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.7 (GNU/Linux) + +iD8DBQFICs+m+fWpoTWIA9ERAmWAAJ9G3KytrX3sa1mWowfGSDSyBd7NKQCfW4gr +FBrmInk2kMnSMrOm6+GevGg= +=4ffA +-----END PGP SIGNATURE----- diff --git a/net-dns/pdnsd/files/pdnsd.resolvconf-r1 b/net-dns/pdnsd/files/pdnsd.resolvconf-r1 new file mode 100644 index 000000000000..edc1c9994f0a --- /dev/null +++ b/net-dns/pdnsd/files/pdnsd.resolvconf-r1 @@ -0,0 +1,631 @@ +#!/bin/bash +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# /etc/pdnsd/pdnsd.conf updater +# Written by Oldrich Jedlicka (oldium.pro@seznam.cz) + +# Implementation notes: +# * The assumptions are same as for other scripts like bind and dnsmasq: +# - We assume that we are a local dns cache - after all, why would a server +# use resolvconf? +# - Now that we have assumed this, we also assume that generic DHCP clients +# will enter their domains and search domains ONLY in the "search" field +# in their resolv.confs and VPN clients will put the domain they are for +# into the domain field only. +# - This allows pdnsd to forward domains for a specific VPN domain to the +# VPN nameserver and everything else to the standard name servers. +# +# HOW-TO CONFIGURE: +# +# To get this working, you need to do only two steps +# +# 1. Create a basic configuration of /etc/pdnsd/pdnsd.conf, you can use +# /etc/pdnsd/pdnsd.conf.example to start. +# +# Additional configuration will be created automatically be resolvconf. +# The generated server sections has labels starting with "resolvconf", so +# +# DO NOT USE "resolvconf" IN YOUR LABELS! +# +# Check if the status_ctl is set to "on", otherwise the configuration +# will not be automatically reloaded - see sample config file. +# +# You are free to edit automatically created server sections, but always +# write one option per line. There are few options that are always recreated +# and your changes in them will be lost. Here is the list (with example +# values): +# +# preset=on; +# 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: +# +#global { +# perm_cache=2048; +# run_as="pdnsd"; +# status_ctl = on; # Important to enable status control +# run_ipv4=on; +# par_queries=2; # How many servers are probed in parallel +# interface = "lo"; # Interface on which the pdnsd listens +#} +# +# 2. The last step is to configure dns configuration for /etc/resolv.conf +# for the lo interface. In Gentoo we set it up like so in /etc/conf.d/net +# +# dns_servers_lo=( "127.0.0.1" ) + +# pdnsd config file +PDNSDCONFIG="/etc/pdnsd/pdnsd.conf" + +# Backup suffix +BACKUPSUFFIX=".backup" + +# Load our variables from resolvconf +VARS="$(resolvconf -v)" +eval "${VARS}" + +COMMENT=' +# Automatically generated by resolvconf. +# +# Following server sections are automatically enabled and disabled. +# +# !!! WARNING !!! +# DO NOT RENAME LABELS! +# +# No section will be deleted and only some options are automatically changed. +# Feel free to add your own options, but do not use pair comments /* */ as they +# are not recognised. +# +# DO NOT USE resolvconf ANYWHERE IN YOUR LABELS! +# +# Automatically changed options are (with examples): +# 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"; + preset=off; +}' + +INSTALLATION_CHECK='^[[:space:]]*label[[:space:]]*=[[:space:]]*"resolvconf"' + +### +# Sed script configuration +# +# Composed sequence of lines: +# +# (1) SED_LOOP with @MATCH_LABELS@ substituted by several SED_MATCH_ONE_LABEL +# (2) SED_EDIT_ONE_SERVER several times +# (3) SED_ADDING with new servers +# +# Notes: +# +# * @LABEL@ is a string "resolvconf-<domain>" or "resolvconf" for global +# section +# * @RULE@ is @LABEL@ with translated characters '-' and '.' into '_'. +### + +### +# Main loop with label match - it will redirect the processing to +# SED_EDIT_ONE_SERVER, when the label match is found. Special match is +# for "resolvconf" label - the control flow is redirected to SED_ADDING to +# allow adding new sections. +# +# To summarize: Old sections are edited as they appear in the file and new +# sections are added before the "resolvconf" section. +SED_LOOP=\ +'/^[[:space:]]*server[[:space:]]*[\{]/ b server; +p; d; +:server; h; +:server_loop; n; +/^[[:space:]]*server[[:space:]]*[\{]/ { x; p; b server_loop; }; +@MATCH_LABELS@ +/^[[:space:]]*label[[:space:]]*=[[:space:]]*"resolvconf"/ { H; b adding; }; +/^[[:space:]]*[\}]/ { H; x; p; d; }; +H; +b server_loop; +' + +### +# Match for one label with a jump to SED_EDIT_ONE_SERVER +SED_MATCH_ONE_LABEL=\ +'/^[[:space:]]*label[[:space:]]*=[[:space:]]*"@LABEL@"/ { H; x; b main_@RULE@; }; +' + +### +# Editing one server. New lines are put into @SETUP@, lines are composed +# in function compose_lines(). After the new lines are added, all "preset", +# "ip" and "include" options are removed (not printed). +# +# Sanity checks: Check if there is a second label or another server directive. +# In both cases, there is some error in the file, so go to the beginning by +# jumping to SED_LOOP's :server. +SED_EDIT_ONE_SERVER=\ +':main_@RULE@; +p; @SETUP@ +:loop_@RULE@; +n; +/^[[:space:]]*server[[:space:]]*[\{]/ b server; +/^[[:space:]]*label[[:space:]]*=/ b server; +/^[[:space:]]*preset[[:space:]]*=/ b loop_@RULE@; +/^[[: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@; +' + +### +# Add new servers. All lines composed by function compose_lines() are put into +# @SETUP@. Then the control flow is returned to one special SED_EDIT_ONE_SERVER +# section with label "resolvconf". +SED_ADDING=\ +':adding; +@SETUP@ +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 + +### +# char* [] uniqify(char* list[]) +# +# Uniqify the items in the list +uniqify() { + local result= + while [ -n "$1" ] ; do + case " ${result} " in + *" $1 "*) ;; + *) result="${result} $1" ;; + esac + shift + done + echo "${result# *}" +} + +### +# char *make_pdnsd_label(char *domain) +# +# Translate domain name into pdnsd's label +make_pdnsd_label() { + local domain=$1 + if [[ -n ${domain} ]] ; then + echo -n "resolvconf-${domain}" + else + echo -n "resolvconf" + fi +} + +### +# char *make_sed_label(char *pdnsd_label) +# +# Translate pdnsd's label into sed's label +make_sed_label() { + local label="$1" + label="${label//-/_}" + label="${label//./_}" + echo -n "${label}" +} + +# char *compose_lines(...) +# +# Compose a sed command that prints lines +compose_lines() { + local line result + for line in "$@" ; do + result="${result}i\\\\\\n${line// /\\t}\\n" + done + echo "${result}" +} + +### +# char *build_settings(char *nameservers, char *domains, char *directive) +# +# 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) # [nameserver list is empty] +# preset=off; +# +# (2) # [domain list is empty] +# preset=on; +# ip="address","address"...; +# +# (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 there will always be only one domain in "include" directive. +# +build_settings() { + local ns="$1" domains="$2" directive="$3" + if [[ -n ${ns} ]] ; then + local x list_ns list_domains + for x in ${ns} ; do + list_ns="${list_ns},\"${x}\"" + done + list_ns="${list_ns#,}" + if [[ -n ${domains} ]] ; then + for x in ${domains} ; do + list_domains="${list_domains},\".${x}.\"" + done + 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};" + fi + else + compose_lines \ + " preset=off;" + fi +} + +### +# char *build_match_labels(char *domains...) +# +# Build the label match part of the sed script +# +build_match_labels() { + local domain result label destination new_match + for domain in "$@" ; do + label="$(make_pdnsd_label "${domain}")" + rule="$(make_sed_label "${label}")" + new_match="${SED_MATCH_ONE_LABEL//@LABEL@/${label}}" + new_match="${new_match//@RULE@/${rule}}" + result="${result}${new_match}" + done + echo "${result}" +} + +### +# char *build_domain_list_logic(char *domains, char *directive) +# +# Build a logic for changing (removing) domains from a directive. +# +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 + 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 *nameservers, \ +# char *add_domains, char *remove_domains, +# char *directive) +# +# 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" 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 "${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_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 +# +build_add_part() { + local add="$1" x label rule add_part new_part result + shift + for x in ${add} ; do + 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_settings "${ns}" "${domain}" "include")" + new_part="${new_part}$(compose_lines "}" "")" + add_part="${add_part}${new_part}" + done + result="${SED_ADDING//@SETUP@/${add_part}}" + echo "${result}" +} + +### +# char *build_sed_script(char *nameservers, char *domain_config, +# char *change, char *add, +# char *active_domains, char *known_domains) +# +# 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" 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_domain_edit_part "${x}" ${domain_config})" + done + edit_changed="${edit_changed}$( \ + build_edit_part "" "${ns}" "${active_domains}" "${known_domains}" "exclude")" + + local added + added="$(build_add_part "${add}" ${domain_config})" + + local full + full="${SED_LOOP//@MATCH_LABELS@/${match_labels}}" + echo -ne "${full}" + echo -ne "${edit_changed}" + echo -ne "${added}" +} + +### +# char *read_configured_domains(char *config_file) +# +# Reads labels of servers starting with resolvconf* from the configuration file. +# +read_configured_domains() { + local config_file="$1" result + result="\ + $(sed -nre 's/^[[:space:]]+label=\"?resolvconf-([^;\"]*)\";.*/\1/p' \ + ${config_file})" + echo -n "${result}" +} + +### +# void installation_check(char *config_file) +# +# Check if the pdnsd is installed and can be configured. Prepare also the file +# for resolvconf. +# +installation_check() { + local config_file="$1" + if [[ -e ${config_file} ]] ; then + if ! grep ${INSTALLATION_CHECK} ${config_file} &>/dev/null ; then + echo -e "${COMMENT}" >> ${config_file} + echo -e "\n${BASIC_SETTINGS}" >> ${config_file} + fi + return 0 + else + return 1 + fi +} + +### +# void initialization(char *config_file) +# +# Setup basic variables NAMESERVERS, DOMAINS an CONFIGURED_DOMAINS +# +initialization() { + local config_file="$1" + + for N in ${NEWNS} ; do + NAMESERVERS="${NAMESERVERS} ${N}" + done + + for N in ${NEWSEARCH} ; do + NAMESERVERS="${NAMESERVERS} ${N#*,}" + done + + for DN in ${NEWDOMAIN} ; do + DOMAINS="${DOMAINS} ${DN%,*}" + done + + CONFIGURED_DOMAINS=$(read_configured_domains ${config_file}) + + NAMESERVERS=$(uniqify ${NAMESERVERS}) + DOMAINS=$(uniqify ${DOMAINS}) + CONFIGURED_DOMAINS=$(uniqify ${CONFIGURED_DOMAINS}) +} + +### +# void find_changed_and_added(char *configured, char *domains) +# +# Find already configured and newly added domains. Sets variables +# 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 + CHANGE_DOMAINS="${CHANGE_DOMAINS} ${x}" + fi + done + + # Find what has to be added + for x in ${domains} ; do + if [[ " ${configured} " != *" ${x} "* ]] ; then + ADD_DOMAINS="${ADD_DOMAINS} ${x}" + else + CHANGE_DOMAINS="${CHANGE_DOMAINS} ${x}" + fi + done + + ADD_DOMAINS=$(uniqify ${ADD_DOMAINS}) + CHANGE_DOMAINS=$(uniqify ${CHANGE_DOMAINS}) + KNOWN_DOMAINS=$(uniqify ${KNOWN_DOMAINS}) +} + +### +# bool make_configuration_change(char *config_file, char *backup_suffix, +# char *sed_script) +# +# Applies any configuration change. Returns true, if there was a change. +# +make_configuration_change() { + local config_file="$1" backup_suffix="$2" sed_script="$3" + local old_config new_config + + old_config=$(< ${config_file}) + + # Sanity check: add '}' at the end of the file + new_config=$( (echo -n "${old_config}" && echo -ne "\n}" ) | \ + sed -nre "${sed_script}") + # Now remove what we added + new_config=${new_config%?\}} + + if [[ "${old_config}" != "${new_config}" ]] ; then + cp ${config_file} ${config_file}${backup_suffix} + echo "${new_config}" > "${config_file}" + return 0 + else + return 1 + fi +} + +################################################################################ +# Main part + +# Check, if pdnsd configuration file is installed and possibly prepare it +installation_check "${PDNSDCONFIG}" || exit 0 + +# Basic initialization of NAMESERVERS, DOMAINS and CONFIGURED_DOMAINS +initialization "${PDNSDCONFIG}" + +find_changed_and_added "${CONFIGURED_DOMAINS}" "${DOMAINS}" + +sed_script="$(build_sed_script "${NAMESERVERS}" "${NEWDOMAIN}" \ + "${CHANGE_DOMAINS}" "${ADD_DOMAINS}" \ + "${DOMAINS}" "${KNOWN_DOMAINS}")" + +# Check if the config changed +if make_configuration_change "${PDNSDCONFIG}" "${BACKUPSUFFIX}" "${sed_script}" ; then + # Checks for running pdnsd + [ -x /usr/sbin/pdnsd-ctl ] || exit 0 + [ -e /var/cache/pdnsd/pdnsd.status ] || exit 0 + + # Reload config files + /usr/sbin/pdnsd-ctl config &>/dev/null +fi + +exit 0 diff --git a/net-dns/pdnsd/pdnsd-1.2.5-r1.ebuild b/net-dns/pdnsd/pdnsd-1.2.6-r1.ebuild index fef7c5e3a28f..30b202f6da00 100644 --- a/net-dns/pdnsd/pdnsd-1.2.5-r1.ebuild +++ b/net-dns/pdnsd/pdnsd-1.2.6-r1.ebuild @@ -1,6 +1,6 @@ -# Copyright 1999-2007 Gentoo Foundation +# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/pdnsd-1.2.5-r1.ebuild,v 1.2 2007/11/05 05:49:02 mrness Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/pdnsd-1.2.6-r1.ebuild,v 1.1 2008/04/20 05:07:38 mrness Exp $ inherit eutils @@ -8,10 +8,10 @@ DESCRIPTION="Proxy DNS server with permanent caching" HOMEPAGE="http://www.phys.uu.nl/~rombouts/pdnsd.html" SRC_URI="http://www.phys.uu.nl/~rombouts/pdnsd/releases/${P}-par.tar.gz" -LICENSE="|| ( BSD GPL-2 )" +LICENSE="GPL-3" SLOT="0" -KEYWORDS="alpha amd64 arm ppc s390 sparc x86" -IUSE="ipv6 debug isdn nptl underscores" +KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~s390 ~sparc ~x86" +IUSE="debug ipv6 isdn nptl underscores urandom" pkg_setup() { enewgroup pdnsd @@ -20,16 +20,13 @@ pkg_setup() { src_compile() { local myconf="" - use debug && myconf="${myconf} --with-debug=3" use nptl && myconf="${myconf} --with-thread-lib=NPTL" - - [ -c /dev/urandom ] && myconf="${myconf} --with-random-device=/dev/urandom" + use 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) \ @@ -52,7 +49,7 @@ src_install() { newinitd "${FILESDIR}/pdnsd.rc6" pdnsd newinitd "${FILESDIR}/pdnsd.online" pdnsd-online - keepdir /etc/conf.d + dodir /etc/conf.d local config="${D}/etc/conf.d/pdnsd-online" echo -e "# Enter the interface that connects you to the dns servers" >> "${config}" @@ -66,9 +63,9 @@ src_install() { use ipv6 && echo PDNSDCONFIG="-a" >> "${config}" \ || echo PDNSDCONFIG="" >> "${config}" - #resolvconf-gentoo support + # gentoo resolvconf support exeinto /etc/resolvconf/update.d - newexe "${FILESDIR}/pdnsd.resolvconf" pdnsd + newexe "${FILESDIR}/pdnsd.resolvconf-r1" pdnsd } src_test() { @@ -93,16 +90,6 @@ src_test() { fi } -pkg_preinst() { - # Copy cache from older versions - [ -f "${ROOT}/var/lib/pdnsd/pdnsd.cache" ] && \ - cp "${ROOT}/var/lib/pdnsd/pdnsd.cache" "${D}/var/cache/pdnsd/pdnsd.cache" - - # Preserve the cache from previous version - [ -f "${ROOT}/var/cache/pdnsd/pdnsd.cache" ] && \ - cp "${ROOT}/var/cache/pdnsd/pdnsd.cache" "${D}/var/cache/pdnsd/pdnsd.cache" -} - pkg_postinst() { elog elog "Add pdnsd to your default runlevel - rc-update add pdnsd default" |