diff options
author | Ondřej Surý <ondrej@sury.org> | 2013-08-05 10:39:45 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2013-08-05 10:39:45 +0200 |
commit | 1e122bfdc41292bc0b1f9310a02aebeca828b483 (patch) | |
tree | 37a5ed63177c5e989cb7b0fae0427bdd14a7b3aa | |
parent | 72b8edd817d64e1b9ef245556b38795a81ca8bbc (diff) | |
download | knot-1e122bfdc41292bc0b1f9310a02aebeca828b483.tar.gz |
Pull some pre 1.3.0 patches to test in the package
-rw-r--r-- | debian/patches/knot-v1.3.0-rc5-git-update.patch | 581 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 582 insertions, 0 deletions
diff --git a/debian/patches/knot-v1.3.0-rc5-git-update.patch b/debian/patches/knot-v1.3.0-rc5-git-update.patch new file mode 100644 index 0000000..07f2ac3 --- /dev/null +++ b/debian/patches/knot-v1.3.0-rc5-git-update.patch @@ -0,0 +1,581 @@ +diff --git a/configure.ac b/configure.ac +index 5747c8f..7e92016 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -296,7 +296,7 @@ AC_TYPE_SSIZE_T + AC_DEFINE([DSFMT_MEXP], [521], [DSFMT parameters]) + + # Checks for library functions. +-AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise poll posix_memalign pselect pthread_setaffinity_np regcomp select setgroups]) ++AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise poll posix_memalign pselect pthread_setaffinity_np regcomp select setgroups initgroups]) + + # Check for cpu_set_t/cpuset_t compatibility + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])], +diff --git a/doc/reference.texi b/doc/reference.texi +index 04b1fcb..dd92d89 100644 +--- a/doc/reference.texi ++++ b/doc/reference.texi +@@ -34,10 +34,9 @@ else. + + @example + @code{system} @code{@{} +- [ @code{identity} @code{"}@kbd{string}@code{";} ] +- [ @code{version} @code{"}@kbd{string}@code{";} ] +- [ @code{hostname} @code{"}@kbd{string}@code{";} ] +- [ @code{nsid} ( @code{"}@kbd{string}@code{"} | @kbd{hex_string} )@code{;} ] ++ [ @code{identity} ( @code{on} | @code{"}@kbd{string}@code{"} )@code{;} ] ++ [ @code{version} ( @code{on} | @code{"}@kbd{string}@code{"} )@code{;} ] ++ [ @code{nsid} ( @code{on} | @code{"}@kbd{string}@code{"} | @kbd{hex_string} )@code{;} ] + [ @code{storage} @code{"}@kbd{string}@code{";} ] + [ @code{rundir} @code{"}@kbd{string}@code{";} ] + [ @code{pidfile} @code{"}@kbd{string}@code{";} ] +@@ -59,7 +58,6 @@ else. + @menu + * identity:: + * version:: +-* hostname:: + * nsid:: + * storage:: + * rundir:: +@@ -80,14 +78,16 @@ else. + @vindex identity + + Identity of the server returned in a response for the query for TXT record +-@code{id.server.} in the CHAOS class ++@code{id.server.} or @code{hostname.bind.} in the CHAOS class + (see @url{http://tools.ietf.org/html/rfc4892,RFC 4892}). + + If not specified or empty, the server returns REFUSED status code. ++If a boolean value of @code{on} is used, FQDN hostname is used as a default. + + @example + system @{ +- identity "Knot DNS"; ++ identity "ns01.example.com"; ++ identity on; + @} + @end example + +@@ -96,30 +96,16 @@ system @{ + @vindex version + + Version of the server software returned in a response for the query for TXT +-record @code{version.server.} in the CHAOS class ++record @code{version.server.} or @code{version.bind.} in the CHAOS class + (see @url{http://tools.ietf.org/html/rfc4892,RFC 4892}). + +-If not specified or empty, the server returns REFUSED status code. +- +-@example +-system @{ +- version "1.3.0"; +-@} +-@end example +- +-@node hostname +-@subsubsection hostname +-@vindex hostname +- +-Host name of the server returned in a response for the query for TXT record +-@code{hostname.server.} in the CHAOS class +-(see @url{http://tools.ietf.org/html/rfc4892,RFC 4892}). +- +-If not specified or empty, the server returns REFUSED status code. ++Option allows a boolean value @code{on|off}, if @code{on}, automatic version ++string is set as a default. If not specified or empty, the server returns REFUSED status code. + + @example + system @{ +- hostname "a.ns.example.com"; ++ version "Knot DNS 1.3.0"; ++ version on; # Reports current version + @} + @end example + +@@ -130,10 +116,13 @@ system @{ + DNS Name Server Identifier (see @url{http://tools.ietf.org/html/rfc5001,RFC 5001}). + + Use a string format "text" or a hexstring (e.g. 0x01ab00) ++If a boolean value of @code{on} is used, FQDN hostname is used as a default. + + @example + system @{ + nsid 0x00cafe; ++ nsid "cafe"; ++ nsid on; + @} + @end example + +diff --git a/man/knot.conf.5.in b/man/knot.conf.5.in +index 7f85bba..e6bffcd 100644 +--- a/man/knot.conf.5.in ++++ b/man/knot.conf.5.in +@@ -21,18 +21,22 @@ serves as an example of the configuration for knotc(8) and knotd(8). + system { + + # Identity of the server (see RFC 4892). +- identity "I have no mouth and must scream"; ++ # Used for answer to CH TXT 'id.server' or 'hostname.bind' ++ # Use string format "text" ++ # Or on|off. When 'on', FQDN hostname will be used as default. ++ identity off; + + # Version of the server (see RFC 4892). +- version "1.3"; +- +- # Host name of the server (see RFC 4892). +- hostname "myserver0.ns.example.com"; ++ # Used for answer to CH TXT 'version.server' or 'version.bind' ++ # Use string format "text" ++ # Or on|off. When 'on', current server version will be used as default. ++ version off; + + # Server identifier + # Use string format "text" + # Or hexstring 0x01ab00 +- nsid "myserver0"; ++ # Or on|off. When 'on', FQDN hostname will be used as default. ++ nsid off; + + # This is a default directory to place slave zone files, journals etc. + # default: ${localstatedir}/lib/knot, configured with --with-storage +diff --git a/samples/knot.full.conf b/samples/knot.full.conf +index 815038a..80c2902 100644 +--- a/samples/knot.full.conf ++++ b/samples/knot.full.conf +@@ -15,18 +15,22 @@ + system { + + # Identity of the server (see RFC 4892). +- identity "I have no mouth and must scream"; ++ # Used for answer to CH TXT 'id.server' or 'hostname.bind' ++ # Use string format "text" ++ # Or on|off. When 'on', FQDN hostname will be used as default. ++ identity off; + + # Version of the server (see RFC 4892). +- version "1.3"; +- +- # Host name of the server (see RFC 4892). +- hostname "myserver0.ns.example.com"; ++ # Used for answer to CH TXT 'version.server' or 'version.bind' ++ # Use string format "text" ++ # Or on|off. When 'on', current server version will be used as default. ++ version off; + + # Server identifier + # Use string format "text" + # Or hexstring 0x01ab00 +- nsid "myserver0"; ++ # Or on|off. When 'on', FQDN hostname will be used as default. ++ nsid off; + + # This is a default directory to place slave zone files, journals etc. + # default: ${localstatedir}/lib/knot, configured with --with-storage +diff --git a/samples/knot.sample.conf.in b/samples/knot.sample.conf.in +index 5d04c92..f16925c 100644 +--- a/samples/knot.sample.conf.in ++++ b/samples/knot.sample.conf.in +@@ -7,7 +7,10 @@ + + system { + # Identity of the server (see RFC 4892). +- identity "@package@ @version@"; ++ identity on; ++ ++ # Version of the server (see RFC 4892) ++ version on; + + # User for running server + # May also specify user.group (e.g. knot.knot) +diff --git a/src/common/sockaddr.c b/src/common/sockaddr.c +index 4444343..f87b458 100644 +--- a/src/common/sockaddr.c ++++ b/src/common/sockaddr.c +@@ -21,8 +21,11 @@ + #include <sys/socket.h> + #include <netinet/in.h> + #include <arpa/inet.h> ++#include <netdb.h> ++#include <unistd.h> + + #include "common/sockaddr.h" ++#include "libknot/consts.h" + + int sockaddr_init(sockaddr_t *addr, int af) + { +@@ -191,3 +194,41 @@ void sockaddr_prep(sockaddr_t *addr) + addr->len = sizeof(struct sockaddr_in); + #endif + } ++ ++char *sockaddr_hostname(void) ++{ ++ /* Fetch hostname. */ ++ char host[KNOT_MAX_DNAME_LENGTH]; ++ if (gethostname(host, KNOT_MAX_DNAME_LENGTH) != 0) { ++ return NULL; ++ } ++ ++ /* Fetch canonical name for this address/DNS. */ ++ int ret = 0; ++ struct addrinfo hints, *info; ++ memset(&hints, 0, sizeof hints); ++ hints.ai_family = AF_UNSPEC; ++ hints.ai_socktype = SOCK_DGRAM; ++ hints.ai_flags = AI_CANONNAME; ++ if ((ret = getaddrinfo(host, "domain", &hints, &info)) != 0) { ++ return NULL; ++ } ++ ++ /* Fetch first valid hostname. */ ++ char *hname = NULL; ++ struct addrinfo *p = NULL; ++ for (p = info; p != NULL; p = p->ai_next) { ++ if (p->ai_canonname) { ++ hname = strdup(p->ai_canonname); ++ break; ++ } ++ } ++ ++ /* No valid hostname found, resort to gethostname() result */ ++ if (hname == NULL) { ++ hname = strdup(host); ++ } ++ ++ freeaddrinfo(info); ++ return hname; ++} +diff --git a/src/common/sockaddr.h b/src/common/sockaddr.h +index 84e2b70..c422f76 100644 +--- a/src/common/sockaddr.h ++++ b/src/common/sockaddr.h +@@ -153,6 +153,13 @@ int sockaddr_family(const sockaddr_t *addr); + */ + void sockaddr_prep(sockaddr_t *addr); + ++/*! ++ * \brief Get host FQDN address. ++ * \retval hostname string ++ * \retval NULL on error ++ */ ++char *sockaddr_hostname(void); ++ + #endif /* _KNOTD_SOCKADDR_H_ */ + + /*! @} */ +diff --git a/src/knot/conf/cf-parse.y b/src/knot/conf/cf-parse.y +index 9b277ab..b36cd1f 100644 +--- a/src/knot/conf/cf-parse.y ++++ b/src/knot/conf/cf-parse.y +@@ -376,6 +376,41 @@ static int conf_mask(void* scanner, int nval, int prefixlen) { + return nval; + } + ++/*! \brief Replace string value. */ ++static void opt_replace(char **opt, char *new_opt, bool val) ++{ ++ /* Clear old value. */ ++ free(*opt); ++ *opt = NULL; ++ /* Replace if val is True. */ ++ if (val) { ++ *opt = new_opt; ++ } else { ++ free(new_opt); ++ } ++} ++ ++/*! \brief Generate automatic defaults for server identity, version and NSID. */ ++static void ident_auto(int tok, conf_t *conf, bool val) ++{ ++ switch(tok) { ++ case SVERSION: ++ opt_replace(&conf->version, strdup("Knot DNS " PACKAGE_VERSION), val); ++ break; ++ case IDENTITY: ++ opt_replace(&conf->identity, sockaddr_hostname(), val); ++ break; ++ case NSID: ++ opt_replace(&conf->nsid, sockaddr_hostname(), val); ++ if (conf->nsid) { ++ conf->nsid_len = strlen(conf->nsid); ++ } ++ break; ++ default: ++ break; ++ } ++} ++ + %} + + %pure-parser +@@ -525,16 +560,23 @@ interfaces: + system: + SYSTEM '{' + | system SVERSION TEXT ';' { new_config->version = $3.t; } ++ | system SVERSION BOOL ';' { ident_auto(SVERSION, new_config, $3.i); } + | system IDENTITY TEXT ';' { new_config->identity = $3.t; } +- | system HOSTNAME TEXT ';' { new_config->hostname = $3.t; } ++ | system IDENTITY BOOL ';' { ident_auto(IDENTITY, new_config, $3.i); } ++ | system HOSTNAME TEXT ';' { ++ fprintf(stderr, "warning: Config option 'system.hostname' is deprecated. " ++ "Use 'system.identity' instead.\n"); ++ free($3.t); ++ } + | system NSID HEXSTR ';' { new_config->nsid = $3.t; new_config->nsid_len = $3.l; } + | system NSID TEXT ';' { new_config->nsid = $3.t; new_config->nsid_len = strlen(new_config->nsid); } ++ | system NSID BOOL ';' { ident_auto(NSID, new_config, $3.i); } + | system STORAGE TEXT ';' { new_config->storage = $3.t; } + | system RUNDIR TEXT ';' { new_config->rundir = $3.t; } + | system PIDFILE TEXT ';' { new_config->pidfile = $3.t; } + | system KEY TSIG_ALGO_NAME TEXT ';' { + fprintf(stderr, "warning: Config option 'system.key' is deprecated " +- "and has no effect.\n"); ++ "and has no effect.\n"); + free($4.t); + } + | system WORKERS NUM ';' { +diff --git a/src/knot/conf/conf.c b/src/knot/conf/conf.c +index fae998b..8dbb40a 100644 +--- a/src/knot/conf/conf.c ++++ b/src/knot/conf/conf.c +@@ -666,10 +666,6 @@ void conf_truncate(conf_t *conf, int unload_hooks) + free(conf->identity); + conf->identity = 0; + } +- if (conf->hostname) { +- free(conf->hostname); +- conf->hostname = 0; +- } + if (conf->version) { + free(conf->version); + conf->version = 0; +diff --git a/src/knot/conf/conf.h b/src/knot/conf/conf.h +index dd61e52..1a5bcf9 100644 +--- a/src/knot/conf/conf.h ++++ b/src/knot/conf/conf.h +@@ -190,9 +190,8 @@ typedef struct conf_t { + * System + */ + char *filename; /*!< Name of the config file. */ +- char *identity; /*!< Identity to return on CH TXT id.server. */ +- char *hostname; /*!< Host name to return on CH TXT hostname.{bind,server} */ +- char *version; /*!< Version for CH TXT version.{bind|server} */ ++ char *identity; /*!< Identity to return on CH TXT id.server. or hostname.bind. */ ++ char *version; /*!< Version for CH TXT version.{bind|server}. */ + char *storage; /*!< Persistent storage path for databases and such. */ + char *rundir; /*!< Run-time directory path. */ + char *pidfile; /*!< PID file location. */ +diff --git a/src/knot/ctl/process.c b/src/knot/ctl/process.c +index 564fff2..133f45b 100644 +--- a/src/knot/ctl/process.c ++++ b/src/knot/ctl/process.c +@@ -27,6 +27,8 @@ + #include <sys/wait.h> + #include <sys/stat.h> + #include <fcntl.h> ++#include <sys/types.h> ++#include <pwd.h> + + #include "knot/knot.h" + #include "knot/ctl/process.h" +@@ -142,8 +144,22 @@ int proc_update_privileges(int uid, int gid) + " for uid '%d' (%s).\n", + getuid(), strerror(errno)); + } ++# ifdef HAVE_INITGROUPS ++ struct passwd *pw; ++ if ((pw = getpwuid(uid)) == NULL) { ++ log_server_warning("Failed to get passwd entry" ++ " for uid '%d' (%s).\n", ++ uid, strerror(errno)); ++ } else { ++ if (initgroups(pw->pw_name, gid) < 0) { ++ log_server_warning("Failed to set supplementary groups" ++ " for uid '%d' (%s).\n", ++ uid, strerror(errno)); ++ } ++ } + } +-#endif ++# endif /* HAVE_INITGROUPS */ ++#endif /* HAVE_SETGROUPS */ + + /* Watch uid/gid. */ + if ((gid_t)gid != getgid()) { +diff --git a/src/knot/server/server.c b/src/knot/server/server.c +index 2e9b4c5..dfa88d9 100644 +--- a/src/knot/server/server.c ++++ b/src/knot/server/server.c +@@ -573,6 +573,8 @@ int server_conf_hook(const struct conf_t *conf, void *data) + return KNOT_EINVAL; + } + ++ log_server_info("Knot DNS %s starting.\n", PACKAGE_VERSION); ++ + /* Estimate number of threads/manager. */ + int ret = KNOT_EOK; + int tu_size = conf->workers; +diff --git a/src/knot/server/tcp-handler.c b/src/knot/server/tcp-handler.c +index 3ebdfe4..e5bf511 100644 +--- a/src/knot/server/tcp-handler.c ++++ b/src/knot/server/tcp-handler.c +@@ -523,7 +523,8 @@ int tcp_loop_master(dthread_t *thread) + break; + } + +- for (unsigned i = 0; nfds > 0 && i < set.n; ++i) { ++ unsigned i = 0; ++ while (nfds > 0 && i < set.n && !dt_is_cancelled(thread)) { + + /* Error events. */ + if (set.pfd[i].revents & (POLLERR|POLLHUP|POLLNVAL)) { +@@ -531,23 +532,27 @@ int tcp_loop_master(dthread_t *thread) + fdset_remove(&set, i); + --nfds; /* Treat error event as activity. */ + continue; /* Stay on the same index. */ +- } +- +- /* Accept POLLIN events. */ +- if (!(set.pfd[i].revents & POLLIN)) ++ } else if (!(set.pfd[i].revents & POLLIN)) { ++ /* Inactive sockets. */ ++ ++i; + continue; ++ } + + /* Accept client. */ + --nfds; /* One less active event. */ + int client = tcp_accept(set.pfd[i].fd); +- if (client < 0) +- continue; ++ if (client >= 0) { ++ /* Add to worker in RR fashion. */ ++ id = get_next_rr(id, unit->size - 1); ++ ret = write(workers[id]->pipe[1], &client, ++ sizeof(int)); ++ if (ret < 0) { ++ close(client); ++ } ++ } + +- /* Add to worker in RR fashion. */ +- id = get_next_rr(id, unit->size - 1); +- ret = write(workers[id]->pipe[1], &client, sizeof(int)); +- if (ret < 0) +- close(client); ++ /* Next socket. */ ++ ++i; + } + } + +@@ -599,7 +604,7 @@ int tcp_loop_worker(dthread_t *thread) + + /* Process incoming events. */ + unsigned i = 0; +- while (nfds > 0 && i < set->n) { ++ while (nfds > 0 && i < set->n && !dt_is_cancelled(thread)) { + + /* Terminate faulty connections. */ + int fd = set->pfd[i].fd; +@@ -608,17 +613,15 @@ int tcp_loop_worker(dthread_t *thread) + close(fd); + --nfds; /* Treat error event as activity. */ + continue; /* Stay on the same index. */ +- } +- +- if (!(set->pfd[i].revents & set->pfd[i].events)) { ++ } else if (!(set->pfd[i].revents & set->pfd[i].events)) { + /* Skip inactive. */ + ++i; + continue; +- } else { +- /* One less active event. */ +- --nfds; + } + ++ /* One less active event. */ ++ --nfds; ++ + /* Register new TCP client or process a query. */ + if (fd == w->pipe[0]) { + tcp_loop_assign(fd, set); +diff --git a/src/knot/server/xfr-handler.c b/src/knot/server/xfr-handler.c +index 04a0669..a0da91a 100644 +--- a/src/knot/server/xfr-handler.c ++++ b/src/knot/server/xfr-handler.c +@@ -1114,6 +1114,10 @@ int xfr_worker(dthread_t *thread) + ret = xfr_async_finish(&set, i); + else + ret = xfr_process_event(w, rq); ++ } else { ++ /* Inactive connection. */ ++ ++i; ++ continue; + } + + /* Check task state. */ +diff --git a/src/knot/server/zones.c b/src/knot/server/zones.c +index e1c295f..f3380e5 100644 +--- a/src/knot/server/zones.c ++++ b/src/knot/server/zones.c +@@ -2677,7 +2677,6 @@ int zones_ns_conf_hook(const struct conf_t *conf, void *data) + /* Server identification, RFC 4892. */ + ns->identity = conf->identity; + ns->version = conf->version; +- ns->hostname = conf->hostname; + + knot_zonedb_t *old_db = 0; + +diff --git a/src/libknot/nameserver/chaos.c b/src/libknot/nameserver/chaos.c +index e548482..dd00283 100644 +--- a/src/libknot/nameserver/chaos.c ++++ b/src/libknot/nameserver/chaos.c +@@ -31,12 +31,14 @@ static const char *get_txt_response_string(const knot_nameserver_t *nameserver, + char *qname_str = knot_dname_to_str(qname); + const char *response = NULL; + +- if (strcasecmp("id.server.", qname_str) == 0) { ++ /* id.server and hostname.bind should have similar meaning */ ++ if (strcasecmp("id.server.", qname_str) == 0 || ++ strcasecmp("hostname.bind.", qname_str) == 0) { + response = nameserver->identity; +- } else if (strcasecmp("version.server.", qname_str) == 0) { ++ /* allow both version version.{server, bind}. for compatibility */ ++ } else if (strcasecmp("version.server.", qname_str) == 0 || ++ strcasecmp("version.bind.", qname_str) == 0) { + response = nameserver->version; +- } else if (strcasecmp("hostname.server.", qname_str) == 0) { +- response = nameserver->hostname; + } + + free(qname_str); +diff --git a/src/libknot/nameserver/name-server.c b/src/libknot/nameserver/name-server.c +index db42d9a..03b7c25 100644 +--- a/src/libknot/nameserver/name-server.c ++++ b/src/libknot/nameserver/name-server.c +@@ -3135,7 +3135,6 @@ knot_nameserver_t *knot_ns_create() + + ns->identity = NULL; + ns->version = NULL; +- ns->hostname = NULL; + + knot_packet_free(&err); + +diff --git a/src/libknot/nameserver/name-server.h b/src/libknot/nameserver/name-server.h +index 6574539..b52dbd0 100644 +--- a/src/libknot/nameserver/name-server.h ++++ b/src/libknot/nameserver/name-server.h +@@ -68,9 +68,8 @@ typedef struct knot_nameserver { + size_t err_resp_size; /*!< Size of the prepared error response. */ + knot_opt_rr_t *opt_rr; /*!< OPT RR with the server's EDNS0 info. */ + +- const char *identity; //!< RFC 4892, server identity (id.server). +- const char *version; //!< RFC 4892, server version (version.server). +- const char *hostname; //!< RFC 4892, server host name (hostname.server). ++ const char *identity; //!< RFC 4892, server identity (id.server, hostname.bind). ++ const char *version; //!< RFC 4892, server version (version.{server, bind}). + + void *data; + } knot_nameserver_t; diff --git a/debian/patches/series b/debian/patches/series index e69de29..0821141 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -0,0 +1 @@ +knot-v1.3.0-rc5-git-update.patch |