7165887 /etc/rndc.key is missing from S11
authorWilliam.Johnston <William.Johnston@Sun.Com>
Mon, 25 Jun 2012 10:28:06 -0700
changeset 892 fe7f5469cc2d
parent 891 261cfb9e0648
child 893 f9f75acab23a
7165887 /etc/rndc.key is missing from S11
components/bind/Solaris/dns-server.sh
--- a/components/bind/Solaris/dns-server.sh	Fri Jun 22 04:06:30 2012 -0400
+++ b/components/bind/Solaris/dns-server.sh	Mon Jun 25 10:28:06 2012 -0700
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 # smf_method(5) start/stop script required for server DNS
@@ -42,6 +42,9 @@
 case "$method" in
 'start')
     configuration_file=/etc/named.conf
+    rndc_config_file=/etc/rndc.conf
+    rndc_key_file=/etc/rndc.key
+    rndc_cmd_opts="-a"
     cmdopts=""
     properties="debug_level ip_interfaces listen_on_port
 	threads chroot_dir configuration_file server"
@@ -102,7 +105,25 @@
     # If chroot option is set, note zones(5) are preferred, then
     # configuration file lives under chroot directory.
     if [ "${chroot_dir}" != "" ]; then
-      configuration_file=${chroot_dir}/${configuration_file}
+      configuration_file=${chroot_dir}${configuration_file}
+      rndc_config_file=${chroot_dir}${rndc_config_file}
+      rndc_key_file=${chroot_dir}${rndc_key_file}
+      rndc_cmd_opts="${rndc_cmd_opts} -t ${chroot_dir}"
+    fi
+
+    # Check if the rndc config file exists.
+    if [ ! -f ${rndc_config_file} ]; then
+      # If not, check if the default rndc key file exists.
+      if [ ! -f ${rndc_key_file} ]; then
+        echo "$I: Creating default rndc key file: ${rndc_key_file}." >&2
+        /usr/sbin/rndc-confgen ${rndc_cmd_opts}
+        if [ $? -ne 0 ]; then
+          echo "$I : Warning: rndc configuration failed! Use of 'rndc' to" \
+		    "control 'named' may fail and 'named' may report further error" \
+		    "messages to the system log. This is not fatal. For more" \
+		    "information see rndc(1M) and rndc-confgen(1M)." >&2
+        fi
+      fi
     fi
 
     # Check configuration file exists.