Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit eeb6cb1

Browse files
committed
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.
1 parent 59b9f3d commit eeb6cb1

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

doc/src/sgml/config.sgml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.224 2009/08/24 20:08:31 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.225 2009/09/08 17:08:36 tgl Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -472,14 +472,28 @@ SET ENABLE_SEQSCAN TO OFF;
472472
</listitem>
473473
</varlistentry>
474474

475+
<varlistentry id="guc-bonjour" xreflabel="bonjour">
476+
<term><varname>bonjour</varname> (<type>boolean</type>)</term>
477+
<indexterm>
478+
<primary><varname>bonjour</> configuration parameter</primary>
479+
</indexterm>
480+
<listitem>
481+
<para>
482+
Enables advertising the server's existence via
483+
<productname>Bonjour</productname>. The default is off.
484+
This parameter can only be set at server start.
485+
</para>
486+
</listitem>
487+
</varlistentry>
488+
475489
<varlistentry id="guc-bonjour-name" xreflabel="bonjour_name">
476490
<term><varname>bonjour_name</varname> (<type>string</type>)</term>
477491
<indexterm>
478492
<primary><varname>bonjour_name</> configuration parameter</primary>
479493
</indexterm>
480494
<listitem>
481495
<para>
482-
Specifies the <productname>Bonjour</productname> broadcast
496+
Specifies the <productname>Bonjour</productname> service
483497
name. The computer name is used if this parameter is set to the
484498
empty string <literal>''</> (which is the default). This parameter is
485499
ignored if the server was not compiled with

src/backend/postmaster/postmaster.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.595 2009/09/08 16:08:26 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.596 2009/09/08 17:08:36 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -200,6 +200,7 @@ bool log_hostname; /* for ps display and logging */
200200
bool Log_connections = false;
201201
bool Db_user_namespace = false;
202202

203+
bool enable_bonjour = false;
203204
char *bonjour_name;
204205

205206
/* PIDs of special child processes; 0 when not running */
@@ -854,7 +855,7 @@ PostmasterMain(int argc, char *argv[])
854855

855856
#ifdef USE_BONJOUR
856857
/* Register for Bonjour only if we opened TCP socket(s) */
857-
if (ListenSocket[0] != -1)
858+
if (enable_bonjour && ListenSocket[0] != -1)
858859
{
859860
DNSServiceErrorType err;
860861

src/backend/utils/misc/guc.c

+26-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.515 2009/09/03 22:08:05 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.516 2009/09/08 17:08:36 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -152,6 +152,7 @@ static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
152152
static const char *assign_custom_variable_classes(const char *newval, bool doit,
153153
GucSource source);
154154
static bool assign_debug_assertions(bool newval, bool doit, GucSource source);
155+
static bool assign_bonjour(bool newval, bool doit, GucSource source);
155156
static bool assign_ssl(bool newval, bool doit, GucSource source);
156157
static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
157158
static bool assign_log_stats(bool newval, bool doit, GucSource source);
@@ -681,6 +682,14 @@ static struct config_bool ConfigureNamesBool[] =
681682
&session_auth_is_superuser,
682683
false, NULL, NULL
683684
},
685+
{
686+
{"bonjour", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
687+
gettext_noop("Enables advertising the server via Bonjour."),
688+
NULL
689+
},
690+
&enable_bonjour,
691+
false, assign_bonjour, NULL
692+
},
684693
{
685694
{"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
686695
gettext_noop("Enables SSL connections."),
@@ -2199,7 +2208,7 @@ static struct config_string ConfigureNamesString[] =
21992208

22002209
{
22012210
{"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2202-
gettext_noop("Sets the Bonjour broadcast service name."),
2211+
gettext_noop("Sets the Bonjour service name."),
22032212
NULL
22042213
},
22052214
&bonjour_name,
@@ -7394,6 +7403,21 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
73947403
return true;
73957404
}
73967405

7406+
static bool
7407+
assign_bonjour(bool newval, bool doit, GucSource source)
7408+
{
7409+
#ifndef USE_BONJOUR
7410+
if (newval)
7411+
{
7412+
ereport(GUC_complaint_elevel(source),
7413+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7414+
errmsg("Bonjour is not supported by this build")));
7415+
return false;
7416+
}
7417+
#endif
7418+
return true;
7419+
}
7420+
73977421
static bool
73987422
assign_ssl(bool newval, bool doit, GucSource source)
73997423
{

src/backend/utils/misc/postgresql.conf.sample

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
#unix_socket_group = '' # (change requires restart)
7070
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
7171
# (change requires restart)
72+
#bonjour = off # advertise server via Bonjour
73+
# (change requires restart)
7274
#bonjour_name = '' # defaults to the computer name
7375
# (change requires restart)
7476

src/include/postmaster/postmaster.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.20 2009/05/05 19:59:00 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.21 2009/09/08 17:08:36 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -27,6 +27,7 @@ extern int PreAuthDelay;
2727
extern int AuthenticationTimeout;
2828
extern bool Log_connections;
2929
extern bool log_hostname;
30+
extern bool enable_bonjour;
3031
extern char *bonjour_name;
3132

3233
#ifdef WIN32

0 commit comments

Comments
 (0)