Date: Wed, 9 Feb 2000 16:44:37 -0500 (EST) From: pirzyk@hotmail.com To: FreeBSD-gnats-submit@freebsd.org Subject: bin/16619: Enhancement to trimdomain library routine in libutil Message-ID: <200002092144.QAA58474@snoopy.faf.fa.disney.com>
next in thread | raw e-mail | index | archive | help
>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 <utmp.h> 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 <utmp.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200002092144.QAA58474>