Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Jan 2003 15:23:02 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        gkshenaut@ucdavis.edu
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Reading rc.conf from C programs?
Message-ID:  <20030102132302.GG419@straylight.oblivion.bg>
In-Reply-To: <200301020200.h0220dx78981@thistle.bogs.org>
References:  <20030101181840.P29988-100000@april.chuckr.org> <200301020200.h0220dx78981@thistle.bogs.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030102132302.GG419>