6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * CDDL HEADER START
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * The contents of this file are subject to the terms of the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Common Development and Distribution License (the "License").
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * You may not use this file except in compliance with the License.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * or http://www.opensolaris.org/os/licensing.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * See the License for the specific language governing permissions
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * and limitations under the License.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * When distributing Covered Code, include this CDDL HEADER in each
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * If applicable, add the following below this CDDL HEADER, with the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * fields enclosed by brackets "[]" replaced with your own identifying
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * information: Portions Copyright [yyyy] [name of copyright owner]
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * CDDL HEADER END
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Use is subject to license terms.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * netcfgd - network configuration daemon. At present, this daemon implements
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * the configuration backend for libnwam (via calls to nwam_backend_init()
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * and nwam_backend_fini()). Initialization of the backend creates a door
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * that libnwam calls use to read, update and destroy persistent configuration.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * More long-term, netcfgd will be used to manage other sources of configuration
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * data and the backend functionality currently contained in libnwam will be
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * generalized.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * This function allows you to drop a dtrace probe here and trace
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * complete strings (not just those containing formatting). It's
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * important that we actually format the strings so we could trace them
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * even if we choose not to log them.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey (void) fprintf(stderr, "%s: %s\n", progname, str);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/* PRINTFLIKE2 */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * A little bit of magic here. By the first fork+setsid, we
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * disconnect from our current controlling terminal and become
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * a session group leader. By forking again without calling
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * setsid again, we make certain that we are not the session
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * group leader and can never reacquire a controlling terminal.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey nlog(LOG_DEBUG, "child %ld exited, daemonizing", pid);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/* ARGSUSED */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if ((progname = strrchr(argv[0], '/')) == NULL)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey while ((c = getopt(argc, argv, "f")) != -1) {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey (void) fprintf(stderr, "%s: unrecognized option %c\n",
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if ((err = nwam_backend_init()) != NWAM_SUCCESS) {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey "couldn't initialize libnwam backend: %s",
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey /* NOTREACHED */