From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 12 07:01:01 2003 Return-Path: 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 B176516A4CE for ; Wed, 12 Nov 2003 07:01:01 -0800 (PST) Received: from gandalf.online.bg (gandalf.online.bg [217.75.128.9]) by mx1.FreeBSD.org (Postfix) with SMTP id E05B343FB1 for ; Wed, 12 Nov 2003 07:00:58 -0800 (PST) (envelope-from roam@ringlet.net) Received: (qmail 20953 invoked from network); 12 Nov 2003 14:59:42 -0000 Received: from office.sbnd.net (HELO straylight.ringlet.net) (217.75.140.130) by gandalf.online.bg with SMTP; 12 Nov 2003 14:59:41 -0000 Received: (qmail 3739 invoked by uid 1000); 12 Nov 2003 15:00:54 -0000 Date: Wed, 12 Nov 2003 17:00:54 +0200 From: Peter Pentchev To: Reinier Kleipool Message-ID: <20031112150054.GA453@straylight.oblivion.bg> Mail-Followup-To: Reinier Kleipool , freebsd-hackers@freebsd.org References: <001701c3a875$836b1960$5201a8c0@ovs.kleipool.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <001701c3a875$836b1960$5201a8c0@ovs.kleipool.org> User-Agent: Mutt/1.5.5.1i cc: freebsd-hackers@freebsd.org Subject: Re: kernel enviroment in sysctl MIB X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Nov 2003 15:01:01 -0000 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 11, 2003 at 06:01:55PM +0100, Reinier Kleipool wrote: > Hello, >=20 > I am investigating the possiblilies for looking at the kernel boot > parameters from within a userland utility. (Possibly a new FreeBSD install > facility) The idea is that by looking at sysctl kern.environment.* you > should be able to see the BTX variables. An install program could use this > to see an INSTALL_SERVER=3Dinstall.company.com variable (etc...) to use as > install server. The BTX loader could provide these variables at install b= oot > time, thus enableing fully automated installs. [snip] > My question is this: When looking at kern/kern_environmet.c I see routines > that install a SYSCTL_NODE kern.environment. The sysctl_kernenv routine > handles this node. What I do not understand is how the environment is > returned from this routine. Take a look at the kenv(1) utility - its source is in the src/usr.bin/kenv/kenv.c file. There is a weird comment at line 74, where the kern.environment sysctl is accessed in a really 'magic & undocumented' way. Look at what it does - basically enumerating oid's =66rom a given starting point, the starting point being obtained in said 'magic & undocumented' way - and see if you could use the same approach. Alternatively, you could just invoke kenv(1) with your variables as command-line parameters from your program/script, although this might incur a performance cost. G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@sbnd.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 =2Esiht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/sksm7Ri2jRYZRVMRAhVSAJ45V7VhY38gXM1+maZIzPgCS7dobACfRECD QxO7LVMh/kYGcVKycCXU4SQ= =XzeM -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu--