From owner-freebsd-bugs Sun Jun 25 11:30:01 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id LAA00919 for bugs-outgoing; Sun, 25 Jun 1995 11:30:01 -0700 Received: (from gnats@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id LAA00912 ; Sun, 25 Jun 1995 11:30:01 -0700 Date: Sun, 25 Jun 1995 11:30:01 -0700 Message-Id: <199506251830.LAA00912@freefall.cdrom.com> From: peter@haywire.dialix.com Reply-To: peter@haywire.dialix.com To: freebsd-bugs Subject: kern/562: netscape (bsdi executable) can't do a uname (fix provided) In-Reply-To: Your message of Mon, 26 Jun 1995 02:28:10 +0800 <199506251828.CAA02312@jhome.DIALix.COM> Sender: bugs-owner@FreeBSD.org Precedence: bulk >Number: 562 >Category: kern >Synopsis: netscape (bsdi executable) can't do a uname (fix provided) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs (FreeBSD bugs mailing list) >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jun 25 11:30:00 1995 >Originator: Peter Wemm >Organization: DIALix Services >Release: FreeBSD 2.0-BUILT-19950625 i386 >Environment: FreeBSD-current FreeBSD jhome.DIALix.COM 2.0-BUILT-19950625 FreeBSD 2.0-BUILT-19950625 #4: Sun Jun 25 22:05:25 WST 1995 pwroot@jhome.DIALix.COM:/usr/src/sys/compile/JHOME i386 >Description: Netscape 1.1N does a uname() at startup to discover the Host OS type. This information is presented to every server that it connects to, and is probably logged for statistics, at least on home.netscape.com. The problem is, that it identifies itself as (while running on FreeBSD) as something like this: GET / HTTP/1.0 User-Agent: Mozilla/1.1N (X11; I; BSD/386 uname failed) Accept: */* Accept: image/gif Accept: image/x-xbitmap Accept: image/jpeg This does not do much to help convince Netscape to support FreeBSD in the future.... :-) After applying this patch, it identifies itself like this: (Thanks to Gary Palmer for the idea on how to see this info) GET / HTTP/1.0 User-Agent: Mozilla/1.1N (X11; I; FreeBSD 2.0-BUILT-1995060 i386) Accept: */* Accept: image/gif Accept: image/x-xbitmap Accept: image/jpeg (BTW: FreeBSD-current is still "2.0-built-nnnnn"????) Also, when starting up netscape, there is a very annoying printf "uname() failed; can't tell what system we're running on" >How-To-Repeat: Run netscape... >Fix: Apply this patch to /usr/src/sys/kern/kern_sysctl.c and make sure COMPAT_43 is defined (netscape is a 4.3BSD-net2 binary, so it should have COMPAT_43 defined anyway) Apologies for the ugly code here.. -Peter *** kern_sysctl-dist.c Tue May 30 18:58:22 1995 --- kern_sysctl.c Mon Jun 26 02:01:21 1995 *************** *** 767,772 **** --- 767,818 ---- #define KINFO_LOADAVG (5<<8) #define KINFO_CLOCKRATE (6<<8) + /* Non-standard BSDI extension - only present on their 4.3 net-2 releases */ + #define KINFO_BSDI_SYSINFO (101<<8) + + /* + * XXX this is bloat, but I hope it's better here than on the potentially + * limited kernel stack... -Peter + */ + + struct { + char *bsdi_machine; /* "i386" on BSD/386 */ + char *pad0; + long pad1; + long pad2; + long pad3; + u_long pad4; + u_long pad5; + u_long pad6; + + char *bsdi_ostype; /* "BSD/386" on BSD/386 */ + char *bsdi_osrelease; /* "1.1" on BSD/386 */ + long pad7; + long pad8; + char *pad9; + + long pad10; + long pad11; + int pad12; + long pad13; + quad_t pad14; + long pad15; + + struct timeval pad16; + /* we dont set this, because BSDI's uname used gethostname() instead */ + char *bsdi_hostname; /* hostname on BSD/386 */ + + /* the actual string data is appended here */ + + } bsdi_si; + /* + * this data is appended to the end of the bsdi_si structure during copyout. + * The "char *" offsets are relative to the base of the bsdi_si struct. + * This contains "FreeBSD\02.0-BUILT-nnnnnn\0i386\0", and these strings + * should not exceed the length of the buffer here... (or else!! :-) + */ + char bsdi_strings[80]; /* It had better be less than this! */ + struct getkerninfo_args { int op; char *where; *************** *** 829,834 **** --- 875,937 ---- name[0] = KERN_CLOCKRATE; error = kern_sysctl(name, 1, uap->where, &size, NULL, 0, p); break; + + case KINFO_BSDI_SYSINFO: { + /* + * this is pretty crude, but it's just enough for uname() + * from BSDI's 1.x libc to work. + */ + + u_int needed; + u_int left; + char *s; + + bzero((char *)&bsdi_si, sizeof(bsdi_si)); + bzero(bsdi_strings, sizeof(bsdi_strings)); + + s = bsdi_strings; + + bsdi_si.bsdi_ostype = ((char *)(s - bsdi_strings)) + sizeof(bsdi_si); + strcpy(s, ostype); + s += strlen(s) + 1; + + bsdi_si.bsdi_osrelease = ((char *)(s - bsdi_strings)) + sizeof(bsdi_si); + strcpy(s, osrelease); + s += strlen(s) + 1; + + bsdi_si.bsdi_machine = ((char *)(s - bsdi_strings)) + sizeof(bsdi_si); + strcpy(s, machine); + s += strlen(s) + 1; + + needed = sizeof(bsdi_si) + (s - bsdi_strings); + + if (uap->where == NULL) { + /* process is asking how much buffer to supply.. */ + size = needed; + error = 0; + break; + } + + /* if too much buffer supplied, trim it down */ + if (size > needed) + size = needed; + + /* how much of the buffer is remaining */ + left = size; + + if ((error = copyout((char *)&bsdi_si, uap->where, left)) != 0) + break; + + /* is there any point in continuing? */ + if (left > sizeof(bsdi_si)) + left -= sizeof(bsdi_si); + else + break; + + error = copyout(&bsdi_strings, uap->where + sizeof(bsdi_si), + left); + break; + } default: return (EOPNOTSUPP); >Audit-Trail: >Unformatted: