svn commit: r277045 - in vendor/unbound/dist: . daemon doc services smallapp util
Dag-Erling Smørgrav
des at FreeBSD.org
Mon Jan 12 07:24:05 UTC 2015
Author: des
Date: Mon Jan 12 07:24:01 2015
New Revision: 277045
URL: https://svnweb.freebsd.org/changeset/base/277045
Log:
Merge upstream version of the local socket patch (upstream svn revisions
3304 through 3309).
Modified:
vendor/unbound/dist/config.h.in
vendor/unbound/dist/configure
vendor/unbound/dist/configure.ac
vendor/unbound/dist/daemon/remote.c
vendor/unbound/dist/daemon/unbound.c
vendor/unbound/dist/doc/Changelog
vendor/unbound/dist/doc/unbound.conf.5.in
vendor/unbound/dist/services/listen_dnsport.c
vendor/unbound/dist/services/listen_dnsport.h
vendor/unbound/dist/smallapp/unbound-control.c
vendor/unbound/dist/util/config_file.c
vendor/unbound/dist/util/config_file.h
Modified: vendor/unbound/dist/config.h.in
==============================================================================
--- vendor/unbound/dist/config.h.in Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/config.h.in Mon Jan 12 07:24:01 2015 (r277045)
@@ -350,6 +350,9 @@
/* Define to 1 if `ipi_spec_dst' is a member of `struct in_pktinfo'. */
#undef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST
+/* Define to 1 if `sun_len' is a member of `struct sockaddr_un'. */
+#undef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+
/* Define if you have Swig libraries and header files. */
#undef HAVE_SWIG
Modified: vendor/unbound/dist/configure
==============================================================================
--- vendor/unbound/dist/configure Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/configure Mon Jan 12 07:24:01 2015 (r277045)
@@ -13713,7 +13713,7 @@ CC="$lt_save_CC"
# Checks for header files.
-for ac_header in stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h endian.h
+for ac_header in stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/un.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h endian.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
@@ -17820,6 +17820,22 @@ fi
fi
+ac_fn_c_check_member "$LINENO" "struct sockaddr_un" "sun_len" "ac_cv_member_struct_sockaddr_un_sun_len" "
+$ac_includes_default
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+
+"
+if test "x$ac_cv_member_struct_sockaddr_un_sun_len" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_SOCKADDR_UN_SUN_LEN 1
+_ACEOF
+
+
+fi
+
ac_fn_c_check_member "$LINENO" "struct in_pktinfo" "ipi_spec_dst" "ac_cv_member_struct_in_pktinfo_ipi_spec_dst" "
$ac_includes_default
#if HAVE_SYS_PARAM_H
Modified: vendor/unbound/dist/configure.ac
==============================================================================
--- vendor/unbound/dist/configure.ac Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/configure.ac Mon Jan 12 07:24:01 2015 (r277045)
@@ -938,6 +938,12 @@ if test $ac_cv_func_daemon = yes; then
])
fi
+AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+])
AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
AC_INCLUDES_DEFAULT
#if HAVE_SYS_PARAM_H
Modified: vendor/unbound/dist/daemon/remote.c
==============================================================================
--- vendor/unbound/dist/daemon/remote.c Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/daemon/remote.c Mon Jan 12 07:24:01 2015 (r277045)
@@ -142,6 +142,7 @@ timeval_divide(struct timeval* avg, cons
* The following function was generated using the openssl utility, using
* the command : "openssl dhparam -dsaparam -C 512"
*/
+#ifndef S_SPLINT_S
DH *get_dh512()
{
static unsigned char dh512_p[]={
@@ -170,6 +171,7 @@ DH *get_dh512()
dh->length = 160;
return(dh);
}
+#endif /* SPLINT */
struct daemon_remote*
daemon_remote_create(struct config_file* cfg)
@@ -299,6 +301,7 @@ void daemon_remote_delete(struct daemon_
* @param nr: port nr
* @param list: list head
* @param noproto_is_err: if lack of protocol support is an error.
+ * @param cfg: config with username for chown of unix-sockets.
* @return false on failure.
*/
static int
@@ -326,7 +329,7 @@ add_open(const char* ip, int nr, struct
if(fd != -1) {
if (cfg->username && cfg->username[0])
chown(ip, cfg->uid, cfg->gid);
- chmod(ip, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ chmod(ip, (mode_t)(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
}
} else {
hints.ai_socktype = SOCK_STREAM;
Modified: vendor/unbound/dist/daemon/unbound.c
==============================================================================
--- vendor/unbound/dist/daemon/unbound.c Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/daemon/unbound.c Mon Jan 12 07:24:01 2015 (r277045)
@@ -441,8 +441,6 @@ static void
perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
const char** cfgfile)
{
- log_assert(cfg);
-
#ifdef HAVE_GETPWNAM
struct passwd *pwd = NULL;
@@ -653,6 +651,7 @@ run_daemon(const char* cfgfile, int cmdl
log_warn("Continuing with default config settings");
}
apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
+ config_lookup_uid(cfg);
/* prepare */
if(!daemon_open_shared_ports(daemon))
Modified: vendor/unbound/dist/doc/Changelog
==============================================================================
--- vendor/unbound/dist/doc/Changelog Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/doc/Changelog Mon Jan 12 07:24:01 2015 (r277045)
@@ -1,6 +1,11 @@
8 December 2014: Wouter
- Fix CVE-2014-8602: denial of service by making resolver chase
endless series of delegations.
+ - patch for remote control over local sockets, from Dag-Erling
+ Smorgrav, Ilya Bakulin. Use control-interface: /path/sock and
+ control-use-cert: no.
+ - Fixup that patch and uid lookup (only for daemon).
+ - coded the default of control-use-cert, to yes.
1 December 2014: Wouter
- Fix bug#632: unbound fails to build on AArch64, protects
Modified: vendor/unbound/dist/doc/unbound.conf.5.in
==============================================================================
--- vendor/unbound/dist/doc/unbound.conf.5.in Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/doc/unbound.conf.5.in Mon Jan 12 07:24:01 2015 (r277045)
@@ -976,7 +976,7 @@ default is 8953.
If you change this and permissions have been dropped, you must restart
the server for the change to take effect.
.TP 5
-.B control-use-cert: \fI<yes or no>
+.B control\-use\-cert: \fI<yes or no>
Whether to require certificate authentication of control connections.
The default is "yes".
This should not be changed unless there are other mechanisms in place
Modified: vendor/unbound/dist/services/listen_dnsport.c
==============================================================================
--- vendor/unbound/dist/services/listen_dnsport.c Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/services/listen_dnsport.c Mon Jan 12 07:24:01 2015 (r277045)
@@ -576,15 +576,19 @@ create_tcp_accept_sock(struct addrinfo *
}
int
-create_local_accept_sock(char *path, int* noproto)
+create_local_accept_sock(const char *path, int* noproto)
{
#ifdef HAVE_SYS_UN_H
int s;
struct sockaddr_un sun;
- sun.sun_len = sizeof(sun);
+#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+ /* this member exists on BSDs, not Linux */
+ sun.sun_len = (sa_family_t)sizeof(sun);
+#endif
sun.sun_family = AF_LOCAL;
- strlcpy(sun.sun_path, path, 104);
+ /* length is 92-108, 104 on FreeBSD */
+ (void)strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
if ((s = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1) {
log_err("Cannot create local socket %s (%s)",
@@ -600,7 +604,7 @@ create_local_accept_sock(char *path, int
}
if (bind(s, (struct sockaddr *)&sun,
- sizeof(struct sockaddr_un)) == -1) {
+ (socklen_t)sizeof(struct sockaddr_un)) == -1) {
log_err("Cannot bind local socket %s (%s)",
path, strerror(errno));
return -1;
@@ -616,6 +620,7 @@ create_local_accept_sock(char *path, int
return -1;
}
+ (void)noproto; /*unused*/
return s;
#else
log_err("Local sockets are not supported");
Modified: vendor/unbound/dist/services/listen_dnsport.h
==============================================================================
--- vendor/unbound/dist/services/listen_dnsport.h Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/services/listen_dnsport.h Mon Jan 12 07:24:01 2015 (r277045)
@@ -214,6 +214,6 @@ int create_tcp_accept_sock(struct addrin
* are not supported.
* @return: the socket. -1 on error.
*/
-int create_local_accept_sock(char* path, int* noproto);
+int create_local_accept_sock(const char* path, int* noproto);
#endif /* LISTEN_DNSPORT_H */
Modified: vendor/unbound/dist/smallapp/unbound-control.c
==============================================================================
--- vendor/unbound/dist/smallapp/unbound-control.c Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/smallapp/unbound-control.c Mon Jan 12 07:24:01 2015 (r277045)
@@ -140,7 +140,7 @@ static void ssl_err(const char* s)
static SSL_CTX*
setup_ctx(struct config_file* cfg)
{
- char* s_cert, *c_key, *c_cert;
+ char* s_cert=NULL, *c_key=NULL, *c_cert=NULL;
SSL_CTX* ctx;
if(cfg->remote_control_use_cert) {
@@ -206,9 +206,11 @@ contact_server(const char* svr, struct c
} else if(svr[0] == '/') {
struct sockaddr_un* sun = (struct sockaddr_un *) &addr;
sun->sun_family = AF_LOCAL;
- sun->sun_len = sizeof(sun);
- strlcpy(sun->sun_path, svr, 104);
- addrlen = sizeof(struct sockaddr_un);
+#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+ sun->sun_len = (sa_family_t)sizeof(sun);
+#endif
+ (void)strlcpy(sun->sun_path, svr, sizeof(sun->sun_path));
+ addrlen = (socklen_t)sizeof(struct sockaddr_un);
addrfamily = AF_LOCAL;
#endif
} else {
Modified: vendor/unbound/dist/util/config_file.c
==============================================================================
--- vendor/unbound/dist/util/config_file.c Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/util/config_file.c Mon Jan 12 07:24:01 2015 (r277045)
@@ -201,6 +201,7 @@ config_create(void)
cfg->remote_control_enable = 0;
cfg->control_ifs = NULL;
cfg->control_port = UNBOUND_CONTROL_PORT;
+ cfg->remote_control_use_cert = 1;
cfg->minimal_responses = 0;
cfg->rrset_roundrobin = 0;
cfg->max_udp_size = 4096;
@@ -805,16 +806,6 @@ config_read(struct config_file* cfg, con
return 0;
}
-#ifdef HAVE_GETPWNAM
- /* translate username into uid and gid */
- if(cfg->username && cfg->username[0]) {
- struct passwd *pwd;
- if((pwd = getpwnam(cfg->username)) == NULL)
- log_err("user '%s' does not exist.", cfg->username);
- cfg->uid = pwd->pw_uid;
- cfg->gid = pwd->pw_gid;
- }
-#endif
return 1;
}
@@ -1203,6 +1194,20 @@ config_apply(struct config_file* config)
log_set_time_asc(config->log_time_ascii);
}
+void config_lookup_uid(struct config_file* cfg)
+{
+#ifdef HAVE_GETPWNAM
+ /* translate username into uid and gid */
+ if(cfg->username && cfg->username[0]) {
+ struct passwd *pwd;
+ if((pwd = getpwnam(cfg->username)) == NULL)
+ log_err("user '%s' does not exist.", cfg->username);
+ cfg->uid = pwd->pw_uid;
+ cfg->gid = pwd->pw_gid;
+ }
+#endif
+}
+
/**
* Calculate string length of full pathname in original filesys
* @param fname: the path name to convert.
Modified: vendor/unbound/dist/util/config_file.h
==============================================================================
--- vendor/unbound/dist/util/config_file.h Mon Jan 12 06:34:23 2015 (r277044)
+++ vendor/unbound/dist/util/config_file.h Mon Jan 12 07:24:01 2015 (r277045)
@@ -427,6 +427,12 @@ void config_delete(struct config_file* c
void config_apply(struct config_file* config);
/**
+ * Find username, sets uid and gid.
+ * @param config: the config structure.
+ */
+void config_lookup_uid(struct config_file* config);
+
+/**
* Set the given keyword to the given value.
* @param config: where to store config
* @param option: option name, including the ':' character.
More information about the svn-src-all
mailing list