From Jim.Pirzyk@disney.com  Fri Sep  8 13:38:28 2000
Return-Path: <Jim.Pirzyk@disney.com>
Received: from mail11.disney.com (mail11.disney.com [208.246.35.55])
	by hub.freebsd.org (Postfix) with ESMTP id 7E40C37B424
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  8 Sep 2000 13:38:14 -0700 (PDT)
Received: from pain.corp.disney.com (pain.corp.disney.com [153.7.231.100])
	by mail11.disney.com (Switch-2.0.1/Switch-2.0.1) with SMTP id e88KnJ203704
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 8 Sep 2000 13:49:20 -0700 (PDT)
Received: from louie.fa.disney.com by pain.corp.disney.com with ESMTP for FreeBSD-gnats-submit@freebsd.org; Fri, 8 Sep 2000 13:38:39 -0700
Received: from plio.fan.fa.disney.com (plio.fan.fa.disney.com [153.7.118.2])
	by louie.fa.disney.com (8.9.2/8.9.2) with ESMTP id NAA28598
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 8 Sep 2000 13:38:08 -0700 (PDT)
	(envelope-from pirzyk@fa.disney.com)
Received: from snoopy.fan.fa.disney.com (snoopy.fan.fa.disney.com [172.30.228.110])
	by plio.fan.fa.disney.com (8.9.2/8.9.2) with ESMTP id NAA28440
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 8 Sep 2000 13:38:07 -0700 (PDT)
	(envelope-from pirzyk@fa.disney.com)
Received: (from pirzyk@localhost)
	by snoopy.fan.fa.disney.com (8.9.3/8.9.3) id NAA00820;
	Fri, 8 Sep 2000 13:38:07 -0700 (PDT)
	(envelope-from pirzyk@fa.disney.com)
Message-Id: <200009082038.NAA00820@snoopy.fan.fa.disney.com>
Date: Fri, 8 Sep 2000 13:38:07 -0700 (PDT)
From: Jim.Pirzyk@disney.com
Reply-To: Jim.Pirzyk@disney.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: kern.hostid 31bit field and not a 32bit field
X-Send-Pr-Version: 3.2

>Number:         21132
>Category:       kern
>Synopsis:       setting kern.hostid to 2887705710 fails.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pirzyk
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 08 13:40:01 PDT 2000
>Closed-Date:    Fri Jun 22 09:11:56 PDT 2001
>Last-Modified:  Fri Jun 22 09:12:25 PDT 2001
>Originator:     Jim Pirzyk
>Release:        FreeBSD 4.1-RELEASE i386
>Organization:
>Environment:

	Any standard 4.1 enviroment

>Description:

	kern.hostid can only be set up to LONG_MAX

>How-To-Repeat:

	sysctl -w kern.hostid=2887705710

>Fix:

	
*** sbin/sysctl/sysctl.c.orig	Fri Sep  8 12:55:12 2000
--- sbin/sysctl/sysctl.c	Fri Sep  8 13:03:46 2000
***************
*** 121,127 ****
  {
  	int len, i, j;
  	void *newval = 0;
! 	int intval, newsize = 0;
  	quad_t quadval;
  	int mib[CTL_MAXNAME];
  	char *cp, *bufp, buf[BUFSIZ];
--- 122,128 ----
  {
  	int len, i, j;
  	void *newval = 0;
! 	unsigned int intval, newsize = 0;
  	quad_t quadval;
  	int mib[CTL_MAXNAME];
  	char *cp, *bufp, buf[BUFSIZ];
***************
*** 167,173 ****
  	
  		switch (kind & CTLTYPE) {
  			case CTLTYPE_INT:
! 				intval = (int) strtol(newval, NULL, 0);
  				newval = &intval;
  				newsize = sizeof intval;
  				break;
--- 168,174 ----
  	
  		switch (kind & CTLTYPE) {
  			case CTLTYPE_INT:
! 				intval = (unsigned int) strtoul(newval, NULL, 0);
  				newval = &intval;
  				newsize = sizeof intval;
  				break;
*** sys/kern/kern_mib.c.orig	Fri Sep  8 12:17:20 2000
--- sys/kern/kern_mib.c	Fri Sep  8 12:29:55 2000
***************
*** 186,194 ****
  SYSCTL_STRING(_kern, KERN_NISDOMAINNAME, domainname, CTLFLAG_RW,
      &domainname, sizeof(domainname), "Name of the current YP/NIS domain");
  
! long hostid;
  /* Some trouble here, if sizeof (int) != sizeof (long) */
! SYSCTL_INT(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, "Host ID");
  
  /*
   * This is really cheating.  These actually live in the libc, something
--- 186,194 ----
  SYSCTL_STRING(_kern, KERN_NISDOMAINNAME, domainname, CTLFLAG_RW,
      &domainname, sizeof(domainname), "Name of the current YP/NIS domain");
  
! unsigned long hostid;
  /* Some trouble here, if sizeof (int) != sizeof (long) */
! SYSCTL_UINT(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, "Host ID");
  
  /*
   * This is really cheating.  These actually live in the libc, something
*** sys/kern/kern_xxx.c.orig	Fri Sep  8 12:35:33 2000
--- sys/kern/kern_xxx.c	Fri Sep  8 12:36:17 2000
***************
*** 103,109 ****
  	struct ogethostid_args *uap;
  {
  
! 	*(long *)(p->p_retval) = hostid;
  	return (0);
  }
  #endif /* COMPAT_43 || COMPAT_SUNOS */
--- 103,109 ----
  	struct ogethostid_args *uap;
  {
  
! 	*(unsigned long *)(p->p_retval) = hostid;
  	return (0);
  }
  #endif /* COMPAT_43 || COMPAT_SUNOS */
***************
*** 111,117 ****
  #ifdef COMPAT_43
  #ifndef _SYS_SYSPROTO_H_
  struct osethostid_args {
! 	long	hostid;
  };
  #endif
  /* ARGSUSED */
--- 111,117 ----
  #ifdef COMPAT_43
  #ifndef _SYS_SYSPROTO_H_
  struct osethostid_args {
! 	unsigned long	hostid;
  };
  #endif
  /* ARGSUSED */
*** sys/sys/kernel.h.orig	Fri Sep  8 12:18:01 2000
--- sys/sys/kernel.h	Fri Sep  8 12:18:12 2000
***************
*** 55,61 ****
  /* Global variables for the kernel. */
  
  /* 1.1 */
! extern long hostid;
  extern char hostname[MAXHOSTNAMELEN];
  extern int hostnamelen;
  extern char domainname[MAXHOSTNAMELEN];
--- 55,61 ----
  /* Global variables for the kernel. */
  
  /* 1.1 */
! extern unsigned long hostid;
  extern char hostname[MAXHOSTNAMELEN];
  extern int hostnamelen;
  extern char domainname[MAXHOSTNAMELEN];


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->pirzyk 
Responsible-Changed-By: pirzyk 
Responsible-Changed-When: Mon Jun 4 11:41:44 PDT 2001 
Responsible-Changed-Why:  
Picked up this bug report to work on. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=21132 
State-Changed-From-To: open->closed 
State-Changed-By: pirzyk 
State-Changed-When: Fri Jun 22 09:11:56 PDT 2001 
State-Changed-Why:  
Fixed in current, will be MFC'ed in 1 month. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=21132 
>Unformatted:
