From owner-freebsd-bugs Wed Feb 9 13:50:30 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by builder.freebsd.org (Postfix) with ESMTP id CE3DE4196 for ; Wed, 9 Feb 2000 13:50:26 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id NAA97018; Wed, 9 Feb 2000 13:50:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from mail11.disney.com (mail11.disney.com [208.246.35.55]) by builder.freebsd.org (Postfix) with ESMTP id BA518427A for ; Wed, 9 Feb 2000 13:45:16 -0800 (PST) Received: from panic.noceast.dws.disney.com (root@panic.noceast.dws.disney.com [153.6.248.200]) by mail11.disney.com (8.9.1/8.9.1) with SMTP id NAA01670 for ; Wed, 9 Feb 2000 13:44:16 -0800 (PST) Received: from louie.fa.disney.com by panic.noceast.dws.disney.com with ESMTP for FreeBSD-gnats-submit@freebsd.org; Wed, 9 Feb 2000 16:44:40 -0500 Received: from snowhite.faf.fa.disney.com (snowhite.faf.fa.disney.com [153.7.115.1]) by louie.fa.disney.com (8.9.2/8.9.2) with ESMTP id NAA25284 for ; Wed, 9 Feb 2000 13:44:39 -0800 (PST) (envelope-from pirzyk@fa.disney.com) Received: from snoopy.faf.fa.disney.com (snoopy.faf.fa.disney.com [153.7.115.94]) by snowhite.faf.fa.disney.com (8.9.2/8.9.2) with ESMTP id QAA28367 for ; Wed, 9 Feb 2000 16:44:37 -0500 (EST) (envelope-from pirzyk@fa.disney.com) Received: (from pirzyk@localhost) by snoopy.faf.fa.disney.com (8.9.3/8.9.2) id QAA58474; Wed, 9 Feb 2000 16:44:37 -0500 (EST) (envelope-from pirzyk@fa.disney.com) Message-Id: <200002092144.QAA58474@snoopy.faf.fa.disney.com> Date: Wed, 9 Feb 2000 16:44:37 -0500 (EST) From: pirzyk@hotmail.com Reply-To: pirzyk@hotmail.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/16619: Enhancement to trimdomain library routine in libutil Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 16619 >Category: bin >Synopsis: trimdomain does not handle peer domains >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Feb 9 13:50:00 PST 2000 >Closed-Date: >Last-Modified: >Originator: Jim Pirzyk >Release: FreeBSD 3.4-RELEASE i386 >Organization: >Environment: A standard FreeBSD 3.4 enviroment with mutiple peer domains (i.e. foo.example.com and bar.example.com). >Description: when rsh/ssh/telnet into a host in a peer domain, the hostname is greater than UT_HOSTNAMELEN and so the IP number gets put into the wtmp file. To releave this, we wanted the domain in common part to be parsed out. i.e if I am on snoopy.foo.example.com and want to login to woodstock.bar.example.com the finger info should show on woodstock me logged in from snoopy.foo >How-To-Repeat: Just login to a host in a peer domain. >Fix: *** logwtmp.c.orig Wed Feb 9 10:42:22 2000 --- logwtmp.c Wed Feb 9 12:00:19 2000 *************** *** 55,77 **** #include void ! trimdomain(char *fullhost, int hostsize) { - static char domain[MAXHOSTNAMELEN]; - static int first = 1; - static size_t dlen; char *s, *end; int spn, ok; ! ! if (first) { ! first = 0; ! if (gethostname(domain, sizeof(domain) - 1) == 0 && ! (s = strchr(domain, '.'))) ! memmove(domain, s + 1, strlen(s + 1) + 1); ! else ! domain[0] = '\0'; ! dlen = strlen(domain); ! } if (domain[0] != '\0') { s = fullhost; --- 55,65 ---- #include void ! _trimdomain(char *fullhost, int hostsize, char *domain) { char *s, *end; int spn, ok; ! size_t dlen = strlen(domain); if (domain[0] != '\0') { s = fullhost; *************** *** 105,110 **** --- 93,126 ---- } } } + + void + trimdomain(char *fullhost, int hostsize) + { + static char domain[MAXHOSTNAMELEN]; + static int first = 1, dots = 0; + int i; + size_t len = strlen (fullhost); + char *s, *ptr = domain; + + if (first) { + first = 0; + if (gethostname(domain, sizeof(domain) - 1) == 0 && + (s = strchr(domain, '.'))) { + memmove(domain, s + 1, strlen(s + 1) + 1); + while ((ptr = strchr(ptr+1, '.'))) dots++; + } else { + domain[0] = '\0'; + } + } + + for (i=0, ptr=domain; i < dots && ptr; i++) { + _trimdomain(fullhost, hostsize, ptr); + if ( strlen (fullhost) != len ) break; + ptr = strchr (ptr, '.')+1; + } + } + void logwtmp(line, name, host) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message