1/*- 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Karels at Berkeley Software Design, Inc. 7 * 8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD --- 22 unchanged lines hidden (view full) --- 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/kern/kern_mib.c 180291 2008-07-05 13:10:10Z rwatson $"); |
40 41#include "opt_compat.h" 42#include "opt_posix.h" 43#include "opt_config.h" 44 45#include <sys/param.h> 46#include <sys/kernel.h> 47#include <sys/sbuf.h> --- 155 unchanged lines hidden (view full) --- 203SYSCTL_ULONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, ""); 204 205static char machine_arch[] = MACHINE_ARCH; 206SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD, 207 machine_arch, 0, "System architecture"); 208 209char hostname[MAXHOSTNAMELEN]; 210 |
211/* 212 * This mutex is used to protect the hostname and domainname variables, and 213 * perhaps in the future should also protect hostid, hostuid, and others. 214 */ 215struct mtx hostname_mtx; 216MTX_SYSINIT(hostname_mtx, &hostname_mtx, "hostname", MTX_DEF); 217 |
218static int 219sysctl_hostname(SYSCTL_HANDLER_ARGS) 220{ 221 struct prison *pr; 222 char tmphostname[MAXHOSTNAMELEN]; 223 int error; 224 225 pr = req->td->td_ucred->cr_prison; --- 16 unchanged lines hidden (view full) --- 242 /* 243 * Copy the locally set hostname to the jail, if 244 * appropriate. 245 */ 246 mtx_lock(&pr->pr_mtx); 247 bcopy(tmphostname, pr->pr_host, MAXHOSTNAMELEN); 248 mtx_unlock(&pr->pr_mtx); 249 } |
250 } else { 251 mtx_lock(&hostname_mtx); 252 bcopy(hostname, tmphostname, MAXHOSTNAMELEN); 253 mtx_unlock(&hostname_mtx); 254 error = sysctl_handle_string(oidp, tmphostname, 255 sizeof tmphostname, req); 256 if (req->newptr != NULL && error == 0) { 257 mtx_lock(&hostname_mtx); 258 bcopy(tmphostname, hostname, MAXHOSTNAMELEN); 259 mtx_unlock(&hostname_mtx); 260 } 261 } |
262 return (error); 263} 264 265SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname, 266 CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON, 267 0, 0, sysctl_hostname, "A", "Hostname"); 268 269static int regression_securelevel_nonmonotonic = 0; --- 69 unchanged lines hidden (view full) --- 339 return (sysctl_handle_string(oidp, kernconfstring, 340 strlen(kernconfstring), req)); 341} 342 343SYSCTL_PROC(_kern, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RW, 344 0, 0, sysctl_kern_config, "", "Kernel configuration file"); 345#endif 346 |
347char domainname[MAXHOSTNAMELEN]; /* Protected by hostname_mtx. */ |
348 |
349static int 350sysctl_domainname(SYSCTL_HANDLER_ARGS) 351{ 352 char tmpdomainname[MAXHOSTNAMELEN]; 353 int error; 354 355 mtx_lock(&hostname_mtx); 356 bcopy(domainname, tmpdomainname, MAXHOSTNAMELEN); 357 mtx_unlock(&hostname_mtx); 358 error = sysctl_handle_string(oidp, tmpdomainname, 359 sizeof tmpdomainname, req); 360 if (req->newptr != NULL && error == 0) { 361 mtx_lock(&hostname_mtx); 362 bcopy(tmpdomainname, domainname, MAXHOSTNAMELEN); 363 mtx_unlock(&hostname_mtx); 364 } 365 return (error); 366} 367 368SYSCTL_PROC(_kern, KERN_NISDOMAINNAME, domainname, CTLTYPE_STRING|CTLFLAG_RW, 369 0, 0, sysctl_domainname, "A", "NAme of the current YP/NIS domain"); 370 |
371u_long hostid; 372SYSCTL_ULONG(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, "Host ID"); 373char hostuuid[64] = "00000000-0000-0000-0000-000000000000"; 374SYSCTL_STRING(_kern, KERN_HOSTUUID, hostuuid, CTLFLAG_RW, hostuuid, 375 sizeof(hostuuid), "Host UUID"); 376 377SYSCTL_NODE(_kern, OID_AUTO, features, CTLFLAG_RD, 0, "Kernel Features"); 378 --- 86 unchanged lines hidden --- |