Add a boolean GUC parameter "bonjour" to control whether a Bonjour-enabled
authorTom Lane <[email protected]>
Tue, 8 Sep 2009 17:08:36 +0000 (17:08 +0000)
committerTom Lane <[email protected]>
Tue, 8 Sep 2009 17:08:36 +0000 (17:08 +0000)
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.

doc/src/sgml/config.sgml
src/backend/postmaster/postmaster.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/include/postmaster/postmaster.h

index 7c828355f68950737ff766e6a171ff6b95d1bde0..a775c52e543b56d0ce27fb5eb90cb23d0b262730 100644 (file)
@@ -472,6 +472,20 @@ SET ENABLE_SEQSCAN TO OFF;
       </listitem>
      </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">
       <term><varname>bonjour_name</varname> (<type>string</type>)</term>
       <indexterm>
@@ -479,7 +493,7 @@ SET ENABLE_SEQSCAN TO OFF;
       </indexterm>
       <listitem>
        <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
         empty string <literal>''</> (which is the default).  This parameter is
         ignored if the server was not compiled with
index 0bb523391b4031f19abb740af67c5203e5fdf0cd..e94181a8c12a6e086e72dfeb2807dd808c30edd6 100644 (file)
@@ -200,6 +200,7 @@ bool                log_hostname;           /* for ps display and logging */
 bool           Log_connections = false;
 bool           Db_user_namespace = false;
 
+bool           enable_bonjour = false;
 char      *bonjour_name;
 
 /* PIDs of special child processes; 0 when not running */
@@ -854,7 +855,7 @@ PostmasterMain(int argc, char *argv[])
 
 #ifdef USE_BONJOUR
        /* Register for Bonjour only if we opened TCP socket(s) */
-       if (ListenSocket[0] != -1)
+       if (enable_bonjour && ListenSocket[0] != -1)
        {
                DNSServiceErrorType err;
 
index 6d363b0da6ed3002a01487b1658ba34296d9c0e1..63bb32949274f30e573d9676427e7a9d70a44171 100644 (file)
@@ -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,
                                                           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_stage_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,
                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,
                        gettext_noop("Enables SSL connections."),
@@ -2199,7 +2208,7 @@ static struct config_string ConfigureNamesString[] =
 
        {
                {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
-                       gettext_noop("Sets the Bonjour broadcast service name."),
+                       gettext_noop("Sets the Bonjour service name."),
                        NULL
                },
                &bonjour_name,
@@ -7394,6 +7403,21 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
        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
 assign_ssl(bool newval, bool doit, GucSource source)
 {
index c6c02fcd812ab8d4186cbc1b7dbd0b383ef3e771..4a361391f2c7b6c33e07cb2a864326d9a933ae16 100644 (file)
@@ -69,6 +69,8 @@
 #unix_socket_group = ''                        # (change requires restart)
 #unix_socket_permissions = 0777                # begin with 0 to use octal notation
                                        # (change requires restart)
+#bonjour = off                         # advertise server via Bonjour
+                                       # (change requires restart)
 #bonjour_name = ''                     # defaults to the computer name
                                        # (change requires restart)
 
index bb110c2bbd5bd2de644c4f0a6d4039e8ce48e9c4..1a8cdc403382d371baad6a5e8e81baf3a7b16804 100644 (file)
@@ -27,6 +27,7 @@ extern int    PreAuthDelay;
 extern int     AuthenticationTimeout;
 extern bool Log_connections;
 extern bool log_hostname;
+extern bool enable_bonjour;
 extern char *bonjour_name;
 
 #ifdef WIN32