From owner-freebsd-hackers Thu Jan 2 5:23:59 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 26FEE37B401 for ; Thu, 2 Jan 2003 05:23:57 -0800 (PST) Received: from straylight.ringlet.net (office.sbnd.net [217.75.140.130]) by mx1.FreeBSD.org (Postfix) with SMTP id D199F43EB2 for ; Thu, 2 Jan 2003 05:23:43 -0800 (PST) (envelope-from roam@ringlet.net) Received: (qmail 84901 invoked by uid 1000); 2 Jan 2003 13:23:02 -0000 Date: Thu, 2 Jan 2003 15:23:02 +0200 From: Peter Pentchev To: gkshenaut@ucdavis.edu Cc: hackers@FreeBSD.ORG Subject: Re: Reading rc.conf from C programs? Message-ID: <20030102132302.GG419@straylight.oblivion.bg> Mail-Followup-To: gkshenaut@ucdavis.edu, hackers@FreeBSD.ORG References: <20030101181840.P29988-100000@april.chuckr.org> <200301020200.h0220dx78981@thistle.bogs.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JP+T4n/bALQSJXh8" Content-Disposition: inline In-Reply-To: <200301020200.h0220dx78981@thistle.bogs.org> User-Agent: Mutt/1.5.1i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 01, 2003 at 06:00:39PM -0800, Greg Shenaut wrote: > In message <20030101181840.P29988-100000@april.chuckr.org>, Chuck Robey c= leopede: > >On Thu, 2 Jan 2003, Matthew West wrote: > > > >> On Wed, Jan 01, 2003 at 01:51:57PM -0800, Tim Kientzle wrote: > >> > I'm trying to figure out how to read and use /etc/rc.conf > >> > configuration variables from within a C program. >=20 > One off the wall way: >=20 > #!/bin/sh >=20 > set -a > . /etc/rc.conf > exec /your/program Err.. If the original poster wants *all* the variables controlling the system startup, and not just those modified by the /etc/rc.conf file, then maybe something like the following snippet from /etc/rc would be a better choice: # If there is a global system configuration file, suck it in. # if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi This way you get the additional benefit of reading variables from other files besides /etc/rc.conf, like e.g. /etc/rc.conf.local; without this, you might miss important configudation data in some setups. G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 I had to translate this sentence into English because I could not read the = original Sanskrit. --JP+T4n/bALQSJXh8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+FD027Ri2jRYZRVMRAkiKAKCExElJeF5+0nvABOwo7uSXL+G+lwCgrVe9 1fZsblH/DdO4bPn5AyfiYGo= =iTVH -----END PGP SIGNATURE----- --JP+T4n/bALQSJXh8-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message