1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the License). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/CDDL.txt 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/CDDL.txt. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets [] replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * 26 * dns_svc_start.c - Start method for highly available DNS 27 */ 28 29 #pragma ident "@(#)dns_svc_start.c 1.18 07/06/06 SMI" 30 31 #include <string.h> 32 #include "dns.h" 33 34 /* 35 * The start method for HA-DNS. Does some sanity checks on 36 * the resource settings then starts the DNS under PMF with 37 * a action script. 38 * XXX Maybe better do all this in prenet_start?. 39 */ 40 41 int 42 main(int argc, char *argv[]) 43 { 44 scds_handle_t handle; 45 int retval; 46 char *mode; 47 scha_extprop_value_t *mode_used; 48 49 if (scds_initialize(&handle, argc, argv) != SCHA_ERR_NOERR) 50 return (1); 51 52 if (scds_get_ext_property(handle, DNS_MODE_USED, SCHA_PTYPE_STRING, 53 &mode_used) != SCHA_ERR_NOERR) { 54 scds_syslog(LOG_ERR, "Property %s is not set.", DNS_MODE_USED); 55 scds_close(&handle); 56 return (1); 57 } else { 58 /* make a copy of the mode and free the ext property */ 59 mode = strdup(mode_used->val.val_str); 60 scds_free_ext_property(mode_used); 61 if (mode == NULL) { 62 scds_syslog(LOG_ERR, "INTERNAL ERROR: %s.", 63 "Out of memory"); 64 scds_close(&handle); 65 return (1); 66 } 67 } 68 69 /* Start the server */ 70 retval = svc_start(handle, mode); 71 free(mode); 72 if (retval != 0) { 73 scds_close(&handle); 74 return (retval); 75 } 76 scds_syslog_debug(DBG_LEVEL_HIGH, 77 "Done with svc_start, calling svc_wait."); 78 79 /* 80 * Now wait until the server is operational, 81 * indicated by its ability to respond to probes. 82 */ 83 retval = svc_wait(handle); 84 scds_syslog_debug(DBG_LEVEL_HIGH, 85 "Done with svc_wait which returned <%d>.", retval); 86 87 scds_close(&handle); 88 return (retval); 89 } 90