Add a boolean GUC parameter "bonjour" to control whether a Bonjour-enabled

build actually attempts to advertise itself via Bonjour.  Formerly it always
did so, which meant that packagers had to decide for their users whether
this behavior was wanted or not.  The default is "off" to be on the safe
side, though this represents a change in the default behavior of a
Bonjour-enabled build.  Per discussion.
This commit is contained in:
Tom Lane 2009-09-08 17:08:36 +00:00
parent 59b9f3d36d
commit eeb6cb143a
5 changed files with 49 additions and 7 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.224 2009/08/24 20:08:31 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.225 2009/09/08 17:08:36 tgl Exp $ -->
<chapter Id="runtime-config"> <chapter Id="runtime-config">
<title>Server Configuration</title> <title>Server Configuration</title>
@ -472,6 +472,20 @@ SET ENABLE_SEQSCAN TO OFF;
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry id="guc-bonjour" xreflabel="bonjour">
<term><varname>bonjour</varname> (<type>boolean</type>)</term>
<indexterm>
<primary><varname>bonjour</> configuration parameter</primary>
</indexterm>
<listitem>
<para>
Enables advertising the server's existence via
<productname>Bonjour</productname>. The default is off.
This parameter can only be set at server start.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-bonjour-name" xreflabel="bonjour_name"> <varlistentry id="guc-bonjour-name" xreflabel="bonjour_name">
<term><varname>bonjour_name</varname> (<type>string</type>)</term> <term><varname>bonjour_name</varname> (<type>string</type>)</term>
<indexterm> <indexterm>
@ -479,7 +493,7 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Specifies the <productname>Bonjour</productname> broadcast Specifies the <productname>Bonjour</productname> service
name. The computer name is used if this parameter is set to the name. The computer name is used if this parameter is set to the
empty string <literal>''</> (which is the default). This parameter is empty string <literal>''</> (which is the default). This parameter is
ignored if the server was not compiled with ignored if the server was not compiled with

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.595 2009/09/08 16:08:26 tgl Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.596 2009/09/08 17:08:36 tgl Exp $
* *
* NOTES * NOTES
* *
@ -200,6 +200,7 @@ bool log_hostname; /* for ps display and logging */
bool Log_connections = false; bool Log_connections = false;
bool Db_user_namespace = false; bool Db_user_namespace = false;
bool enable_bonjour = false;
char *bonjour_name; char *bonjour_name;
/* PIDs of special child processes; 0 when not running */ /* PIDs of special child processes; 0 when not running */
@ -854,7 +855,7 @@ PostmasterMain(int argc, char *argv[])
#ifdef USE_BONJOUR #ifdef USE_BONJOUR
/* Register for Bonjour only if we opened TCP socket(s) */ /* Register for Bonjour only if we opened TCP socket(s) */
if (ListenSocket[0] != -1) if (enable_bonjour && ListenSocket[0] != -1)
{ {
DNSServiceErrorType err; DNSServiceErrorType err;

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.515 2009/09/03 22:08:05 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.516 2009/09/08 17:08:36 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
@ -152,6 +152,7 @@ static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
static const char *assign_custom_variable_classes(const char *newval, bool doit, static const char *assign_custom_variable_classes(const char *newval, bool doit,
GucSource source); GucSource source);
static bool assign_debug_assertions(bool newval, bool doit, GucSource source); static bool assign_debug_assertions(bool newval, bool doit, GucSource source);
static bool assign_bonjour(bool newval, bool doit, GucSource source);
static bool assign_ssl(bool newval, bool doit, GucSource source); static bool assign_ssl(bool newval, bool doit, GucSource source);
static bool assign_stage_log_stats(bool newval, bool doit, GucSource source); static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
static bool assign_log_stats(bool newval, bool doit, GucSource source); static bool assign_log_stats(bool newval, bool doit, GucSource source);
@ -681,6 +682,14 @@ static struct config_bool ConfigureNamesBool[] =
&session_auth_is_superuser, &session_auth_is_superuser,
false, NULL, NULL false, NULL, NULL
}, },
{
{"bonjour", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
gettext_noop("Enables advertising the server via Bonjour."),
NULL
},
&enable_bonjour,
false, assign_bonjour, NULL
},
{ {
{"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY, {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
gettext_noop("Enables SSL connections."), gettext_noop("Enables SSL connections."),
@ -2199,7 +2208,7 @@ static struct config_string ConfigureNamesString[] =
{ {
{"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS, {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
gettext_noop("Sets the Bonjour broadcast service name."), gettext_noop("Sets the Bonjour service name."),
NULL NULL
}, },
&bonjour_name, &bonjour_name,
@ -7394,6 +7403,21 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
return true; return true;
} }
static bool
assign_bonjour(bool newval, bool doit, GucSource source)
{
#ifndef USE_BONJOUR
if (newval)
{
ereport(GUC_complaint_elevel(source),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("Bonjour is not supported by this build")));
return false;
}
#endif
return true;
}
static bool static bool
assign_ssl(bool newval, bool doit, GucSource source) assign_ssl(bool newval, bool doit, GucSource source)
{ {

View File

@ -69,6 +69,8 @@
#unix_socket_group = '' # (change requires restart) #unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation #unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart) # (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name #bonjour_name = '' # defaults to the computer name
# (change requires restart) # (change requires restart)

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.20 2009/05/05 19:59:00 tgl Exp $ * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.21 2009/09/08 17:08:36 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -27,6 +27,7 @@ extern int PreAuthDelay;
extern int AuthenticationTimeout; extern int AuthenticationTimeout;
extern bool Log_connections; extern bool Log_connections;
extern bool log_hostname; extern bool log_hostname;
extern bool enable_bonjour;
extern char *bonjour_name; extern char *bonjour_name;
#ifdef WIN32 #ifdef WIN32