Mailing List Archive

Sys::Domain
For those who are interested here is the Sys::Domain package
I have come up with which attempts to find the current host's internet
FQDN.

It provides 3 functions :-

domainname() Identify and return the FQDN of the current host.
hostname() Returns the smallest part of the FQDN which can be used to identify the host.
hostdomain() Returns the remainder of the FQDN after the I<hostname> has been removed

Regards,
Graham.

--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--
begin 660 Sys-Domain-1.01.tar.gz
M'XL("!NN2C " U-Y<RU$;VUA:6XM,2XP,2YT87( [5I[<]LV$N^_P:?8DYQ:
M2F12#S\N4NS:C>5&$[_.<M+FHM2A2$A"39$*0<G6.>YGOUV +\F)>]=)?#<=
M<D:6""P6^_HM%H"[<[FV[X\MX:W5C&K-_.X;/ "PM54%^MY8WU#?M49#?4=/
M%6"S6J]OU+>JC3J^;ZY7J]_!=_GSS9_NDO^/K$L^$"XW3@^_IO_1H5_V_V:U
MD?%_#7NKZ[7UW/\/\4PEA_9U^#H4KFPVR?OT"5HLX!^G(N!0,$P='\9D7&@Q
MQGX.1,CC,"FQ1]J';]IGW<[),?[:W@$,JF93CVHVW_! "M\KE2LQ[?'>45O_
M0MK5#/%J0M)]U3E-2-Y]O"K)T J%#<[<L\;"+K]/*%<=(</5B/+FQ<G1Z5F[
MVR7&PW^)":P]&R!7N.?IOCXXZ/RRO8/TJQ5@CQX1X]N4ORN\2WZ-4Q#_P\[Q
MJ_.WIVTE^6J6S':YY:U&8AQT#MM=^E5X8O2M2WCR&)X8HW#L%FX792FC1?^O
M\!_*\)OD_XU[\-]8QC]LU;8V<_P_Q%/\FSF5@>GZMN6:?>&9$QZXL';%&&4&
M5_0!P6>8??R%L4IM&;Q2W\B7(6*2@Z.:U$]JTZ\XII@,>AF18LQ/ N&%$(_%
MW%#H>9A=='/*::DCY9MTX)/C_ROB/\GU#X?_+2H.%NJ_6K6^7L_Q_R#X1RQ:
M]J4U7 !V2\/_A15,TDJ@?3WQ@Y!J@]U.=P^V"?UQ&\;Q;ON7TY.S\XN35[KK
M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T)PDXNL<?A%=6P%LP]Z?*&5A?"ZSH17\:ZA+;<TP_8&/?(;=@PU39
M1OF67$&0EH!V.*53*Q%*[@Z,1.JS]IM.5^VITJWD2M*[]_K\Y<D98QGIX7G?
M=X:[H9A>1IN-G=BHK$:U["O.)TGY/K(FDSEC%Q?MX_V+"YSDT!\V(3E J<Q@
M!?<J\<QJ#ZOL95;_;M(I9[W:;&PT&U6 81\G1]J.)T*!ZV40C<'=U4.?_\1G
M=*B P8</<__3J#66SG]JM?6M_/SG?W'^DSFCO>=$(SH*UN=#_^4!T>+I$"W1
M-K*!@L-Q:T:5L)/LF%<71%JM+!^R%*CD7OGUYQ;!D^7G/W_B_&<9_V?MO?VC
M]E>__[G__G=K:^G^?ZO1R.]_'N1ABPF?UF9<A_FU-9ZX''#AG;J$#2O,%$NT
MWYNXELTI\A8@RG")OA)8 =C6G5L?BMMED% @(H15 4:O$-\^*2;"PRW7. YO
M&GMGOC\H1^"Y?C'H96%=SQ8J+"E40-4ID\ ?!LCAF]<IIRZW)!5]E".1R1SZ
MTZ$TY70XQ*H5"P!)1ONR#HQ]=?P?[1UW#MK=\Z^-_\W[_O]GJ[:,_XV-C1S_
M#_$DY>I2(F!Q(+#,?P0QO3JP4(8LQ_]? O\Y O(G?_+]7W[_G]__Y_?_^?U_
M?O^?W__G]__Y_7]^_Y_?_^?W__G]?W[_G]__Y_?_^?U_?O^?W__G]_]_O?.?
*?P.LNTG8 $ ']^

end
--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--

--
.-----------------------------------------------------------.
//// | Graham Barr Email: bodg@tiuk.ti.com | \\\\
| 00 | VLSI Cell Designer or: bodg@ti.com | 00 |
O ^ | MOS Design TI MSG: BODG | ^ O
\ ~/ | Texas Instruments Ltd Phone: +44 (0)1604 66 3419 | \~ /
| ENGLAND Fax: +44 (0)1604 66 3456 |
`-----------------------------------------------------------'
Re: Sys::Domain [ In reply to ]
On Mon, 4 Sep 1995, Graham Barr wrote:

> For those who are interested here is the Sys::Domain package
> I have come up with which attempts to find the current host's internet
> FQDN.
>
> It provides 3 functions :-
>
> domainname() Identify and return the FQDN of the current host.
> hostname() Returns the smallest part of the FQDN which can be used to identify the host.
> hostdomain() Returns the remainder of the FQDN after the I<hostname> has been removed

With a quick test, they work fine here.

> Regards,
> Graham.

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: Sys::Domain [ In reply to ]
I have a /etc/resolv.conf that looks like this:

search oslonett.no nr.no
nameserver ...

Thus you will need something like the following patch for extracting the
domain from it:

--- Domain.pm.dist Mon Sep 4 09:43:22 1995
+++ Domain.pm Mon Sep 4 16:02:59 1995
@@ -123,7 +123,7 @@

if(open(RES,"/etc/resolv.conf")) {
while(<RES>) {
- if(/\A\s*domain\s+(\S+)/) {
+ if(/\A\s*(?:domain|search)\s+(\S+)/) {
$domain = $1;
last;
}

--
Gisle Aas <aas@oslonett.no>
Oslonett AS http://www.oslonett.no/home/aas/
Re: Sys::Domain [ In reply to ]
Thanks for the patch, however it is not 100% correct. According to the manual
the search and domain parameters, although mutually exclusive, can both appear
in /etc/resolve.conf. If they do both appear then the last overrides any
previous declaration. Therefore the 'last' statement needs to be removed from
the loop.

I would normally send a patch but our system is buggered at the moment.

Regards,
Graham.

> search oslonett.no nr.no
> nameserver ...
>
>Thus you will need something like the following patch for extracting the
>domain from it:
>
>--- Domain.pm.dist Mon Sep 4 09:43:22 1995
>+++ Domain.pm Mon Sep 4 16:02:59 1995
>@@ -123,7 +123,7 @@
>
> if(open(RES,"/etc/resolv.conf")) {
> while(<RES>) {
>- if(/\A\s*domain\s+(\S+)/) {
>+ if(/\A\s*(?:domain|search)\s+(\S+)/) {
> $domain = $1;
> last;
> }

--
.-----------------------------------------------------------.
//// | Graham Barr Email: bodg@tiuk.ti.com | \\\\
| 00 | VLSI Cell Designer or: bodg@ti.com | 00 |
O ^ | MOS Design TI MSG: BODG | ^ O
\ ~/ | Texas Instruments Ltd Phone: +44 (0)1604 66 3419 | \~ /
| ENGLAND Fax: +44 (0)1604 66 3456 |
`-----------------------------------------------------------'
Re: Sys::Domain [ In reply to ]
For those who are interested here is the Sys::Domain package
I have come up with which attempts to find the current host's internet
FQDN.

It provides 3 functions :-

domainname() Identify and return the FQDN of the current host.
hostname() Returns the smallest part of the FQDN which can be used to identify the host.
hostdomain() Returns the remainder of the FQDN after the I<hostname> has been removed

i tried this on my solaris 1 and 2 hosts, and it didn't work. in fact, it looped
endlessly in the LOOP part of domainname().

also, you aren't chop()ing the `` commands, giving domains like `lair\n' from
domainname(1). patch for this below

.mrg.

*** Domain.pm Mon Sep 4 17:43:22 1995
--- blib/Sys/Domain.pm Wed Sep 6 11:07:27 1995
***************
*** 54,66 ****

# method 3 - trusty old hostname command
|| eval {
! $host = `(hostname) 2>/dev/null`; # bsdish
}


! # method 4 - sysV uname command (may truncate)
|| eval {
! $host = `uname -n 2>/dev/null`; ## sysVish
}


--- 54,66 ----

# method 3 - trusty old hostname command
|| eval {
! chop($host = `(hostname) 2>/dev/null`); # bsdish
}


! # method 4 - sysV/POSIX uname command (may truncate)
|| eval {
! ($host = `uname -n 2>/dev/null`); ## sysVish && POSIXish
}


***************
*** 101,107 ****

unless ($host =~ /\./){
eval {
! $dom = `domainname 2>/dev/null`;
};
unshift(@hosts, "$host.$dom") if ($dom ne "");
}
--- 101,107 ----

unless ($host =~ /\./){
eval {
! chop($dom = `domainname 2>/dev/null`);
};
unshift(@hosts, "$host.$dom") if ($dom ne "");
}
Re: Sys::Domain [ In reply to ]
I tested only 4 installations. The 4th revealed a bug in the code. I
think I fixed it in your sense. Here is the patch.


*** Domain.pm.1.01 Mon Sep 4 09:43:22 1995
--- Domain.pm Fri Sep 8 20:51:21 1995
***************
*** 169,187 ****

my @h = @host;

! LOOP:
! while(@h) {
my @d = @domain;
! while(@d) {
my $tmp = join(".",@h,@d);
if((gethostbyname($tmp))[0]) {
@fqdn = (@h,@d);
$fqdn = $tmp;
last LOOP;
}
! shift @d;
! }
! }

if(@fqdn) {
$host = shift @fqdn;
--- 169,187 ----

my @h = @host;

! LOOP: {
! do {
my @d = @domain;
! do {
my $tmp = join(".",@h,@d);
if((gethostbyname($tmp))[0]) {
@fqdn = (@h,@d);
$fqdn = $tmp;
last LOOP;
}
! } while shift @d;
! } while pop @h;
! }

if(@fqdn) {
$host = shift @fqdn;


We have a machine here whise hostname(1) returns the FQDN. This
machine went into an infinite loop.


andreas, perlin' not only for berlin
Re: Sys::Domain [ In reply to ]
I tested only 4 installations. The 4th revealed a bug. I think I fixed
it in your sense. Here is the patch.


*** Domain.pm.1.01 Mon Sep 4 09:43:22 1995
--- Domain.pm Fri Sep 8 20:51:21 1995
***************
*** 169,187 ****

my @h = @host;

! LOOP:
! while(@h) {
my @d = @domain;
! while(@d) {
my $tmp = join(".",@h,@d);
if((gethostbyname($tmp))[0]) {
@fqdn = (@h,@d);
$fqdn = $tmp;
last LOOP;
}
! shift @d;
! }
! }

if(@fqdn) {
$host = shift @fqdn;
--- 169,187 ----

my @h = @host;

! LOOP: {
! do {
my @d = @domain;
! do {
my $tmp = join(".",@h,@d);
if((gethostbyname($tmp))[0]) {
@fqdn = (@h,@d);
$fqdn = $tmp;
last LOOP;
}
! } while shift @d;
! } while pop @h;
! }

if(@fqdn) {
$host = shift @fqdn;


We have a machine here whose hostname(1) returns the FQDN. This
machine went into an infinite loop.


andreas, perlin' not only for berlin
Re: Sys::Domain [ In reply to ]
On Sat, 9 Sep 1995, Andreas Koenig wrote:

> We have a machine here whose hostname(1) returns the FQDN. This
> machine went into an infinite loop.

Nice to know that not only Perl has trouble agreeing on what hostname(1)
should do!

> andreas, perlin' not only for berlin

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: Sys::Domain [ In reply to ]
>From: Graham Barr <bodg@tiuk.ti.com>
>
>
>Andreas,
> I will do a full release soon,
>however I need an ftp stie to send it to as the one I was using is
>no longer avaliable for uploads
>

Graham,

you missed a VERY important posting of mine, where I invited you to
upload to ftp://franz.ww.tu-berlin.de/incoming.

See http://franz.ww.tu-berlin.de/modulelist/ for further
information. (E.g., how to complete the upload into your personal
directory or changing your name and address in the database)

This offer is valid for everybody doing perl5 porting. And even if you
think, franz is slow, it is worth the short investment of time, as
franz is mirrored every hour to

ftp://ftp.pasteur.fr/pub/Perl/CPAN/pml/byauthor/ and from there daily to
ftp://ftp.cs.ruu.nl/pub/PERL/perl5.0/CPAN/pml/byauthor/

More mirrors to follow. I will enhance the service, if it is accepted
by the community.

I'm away for two days in a few minutes, so I can neither test your
Sys::Domain nor can I do the uploading for you. You may use your old
password, it's still valid. I would be glad, if you'd show, the thing
is working :)

Email to me for completing an upload is no problem at all, when I'm
here. The advantage of this installation apparently is, that it SHOULD
work, when I'm not here.

Thanks,
andreas
Re: Sys::Domain [ In reply to ]
On Mon, 11 Sep 1995, Andreas Koenig wrote:

> This offer is valid for everybody doing perl5 porting. And even if you
> think, franz is slow, it is worth the short investment of time, as
> franz is mirrored every hour to
>
> ftp://ftp.pasteur.fr/pub/Perl/CPAN/pml/byauthor/ and from there daily to
> ftp://ftp.cs.ruu.nl/pub/PERL/perl5.0/CPAN/pml/byauthor/
>
> More mirrors to follow. I will enhance the service, if it is accepted
> by the community.

I'd like to offer ftp.delphi.com as a mirror for the CPAN, I've already
mentioned it to the guy running the anon ftp service at Delphi. Who else
should I talk to and what other sites could Delphi usefully mirror?

Mike

--
Mike Stok | The "`Stok' disclaimers" apply.
stok@pencom.com | Pencom Systems Administration (work)
stok@cybercom.net | Cyber Access (play)
http://www.cybercom.net/~stok/ | The inevitable WWW page (?)
Re: Sys::Domain [ In reply to ]
> From: Mike Stok <stok@cybercom.net>
>
> On Mon, 11 Sep 1995, Andreas Koenig wrote:
>
> > This offer is valid for everybody doing perl5 porting. And even if you
> > think, franz is slow, it is worth the short investment of time, as
> > franz is mirrored every hour to
> >
> > ftp://ftp.pasteur.fr/pub/Perl/CPAN/pml/byauthor/ and from there daily to
> > ftp://ftp.cs.ruu.nl/pub/PERL/perl5.0/CPAN/pml/byauthor/
> >
> > More mirrors to follow. I will enhance the service, if it is accepted
> > by the community.
>
> I'd like to offer ftp.delphi.com as a mirror for the CPAN, I've already
> mentioned it to the guy running the anon ftp service at Delphi. Who else
> should I talk to and what other sites could Delphi usefully mirror?
>
For the UK the CPAN is mirrored at:

ftp.demon.co.uk:/pub/perl/CPAN/

Tim.
Re: Sys::Domain [ In reply to ]
> I'd like to offer ftp.delphi.com as a mirror for the CPAN, I've already
> mentioned it to the guy running the anon ftp service at Delphi. Who else
> should I talk to and what other sites could Delphi usefully mirror?

You might want to take this to the packrats list, Mike. If you mirror
the CPAN, I don't see any reason you'd *want* to mirror anything else.
That's kind of the point of the C, see? ;-)

Has anyone been to UF lately to see if they've started mirroring? I've
been so busy with other things lately, I haven't had a chance to check.

-spp
Re: Sys::Domain [ In reply to ]
Andreas,
You seem to be using an older version of Sys::Domain than I have here.
Someone else found this problem and I fixed it in a different way to
yourself.

Here is the latest copy of Domain.pm. I will do a full release soon,
however I need an ftp stie to send it to as the one I was using is
no longer avaliable for uploads

Let me know if this code still causes problems.

Regards,
Graham.


--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--
#

package Sys::Domain;

use Carp;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(hostname domainname hostdomain);

$VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
sub Version { $VERSION }

=head1 NAME

Sys::Domain - Attempt to evaluate the current host's internet name and domain

=head1 SYNOPSIS

use Sys::Domain qw(hostname domainname hostdomain);

=head1 DESCRIPTION

Using various methods B<attempt> to find the FQDN of the current host. From
this find the hostname and the hostdomain.

=cut

$host = undef;
$domain = undef;
$fqdn = undef;

#
# Try every conceivable way to get hostname.
#

sub _hostname {
# by David Sundstrom sunds@asictest.sc.ti.com
# Texas Instruments

# method 1 - we already know it

return $host if(defined $host);

# method 2 - syscall is preferred since it avoids tainting problems
eval {
{
package main;
require "syscall.ph";
}
my $tmp = "\0" x 65; ## preload scalar
$host = (syscall(&main::SYS_gethostname, $tmp, 65) == 0) ? $tmp : undef;
}


# method 3 - trusty old hostname command
|| eval {
chop($host = `(hostname) 2>/dev/null`); # bsdish
}


# method 4 - sysV/POSIX uname command (may truncate)
|| eval {
chop($host = `uname -n 2>/dev/null`); ## sysVish && POSIXish
}


# method 5 - Apollo pre-SR10
|| eval {
$host = (split(/[:\. ]/,`/com/host`,6))[0];
}

|| eval {
$host = "";
};

# remove garbage
$host =~ s/[\0\r\n]+//g;
$host =~ s/(\A\.+|\.+\Z)//g;
$host =~ s/\.\.+/\./;

$host;
}

sub _hostdomain {

##
## return imediately if we have already found the domainname;
##

return $domain if(defined $domain);

##
## First attempt, just try hostname and system calls
##

my $host = _hostname();
my($dom,$site,@hosts);
local($_);

@hosts = ($host,"localhost");

unless ($host =~ /\./){
eval {
chop($dom = `domainname 2>/dev/null`);
};
unshift(@hosts, "$host.$dom") if ($dom ne "");
}


foreach (@hosts) { # Attempt to locate FQDN
my @info = gethostbyname($_);
if(@info) {
foreach $site ($info[0], split(/ /,$info[1])) { # look at real name & aliases
if(rindex($site,".") > 0) {
($domain = $site) =~ s/\A[^\.]+\.//; # Extract domain from FQDN
return $domain;
}
}
}
}

##
## try looking in /etc/resolv.conf
##

local *RES;

if(open(RES,"/etc/resolv.conf")) {
while(<RES>) {
if(/\A\s*(?:domain|search)\s+(\S+)/) {
$domain = $1;
}
}
close(RES);

return $domain if(defined $domain);
}

##
## Look for environment variable
##

return $domain = $ENV{DOMAIN} if(defined $ENV{DOMAIN});

$domain =~ s/[\r\n\0]+//g;
$domain =~ s/(\A\.+|\.+\Z)//g;
$domain =~ s/\.\.+/\./g;

$domain;
}

=head2 domainname()

Identify and return the FQDN of the current host.

=cut

sub domainname {

return $fqdn if(defined $fqdn);

_hostname();
_hostdomain();

my @host = split(/\./, $host);
my @domain = split(/\./, $domain);
my @fqdn = ();

##
## Determine from @host & @domain the FQDN
##

my @d = @domain;

LOOP:
while(1) {
my @h = @host;
while(@h) {
my $tmp = join(".",@h,@d);
if((gethostbyname($tmp))[0]) {
@fqdn = (@h,@d);
$fqdn = $tmp;
last LOOP;
}
pop @h;
}
last unless shift @d;
}

if(@fqdn) {
$host = shift @fqdn;
until((gethostbyname($host))[0]) {
$host .= "." . shift @fqdn;
}
$domain = join(".", @fqdn);
}
else {
undef $host;
undef $domain;
undef $fqdn;
}

$fqdn;
}

=head2 hostname()

Returns the smallest part of the FQDN which can be used to identify the host.

=cut

sub hostname {
domainname() unless(defined $host);
return $host;

}

=head2 hostdomain()

Returns the remainder of the FQDN after the I<hostname> has been removed

=cut

sub hostdomain {
domainname() unless(defined $domain);
return $domain;
}

=head1 COPYRIGHT

Copyright (c) 1995 Graham Barr. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 REVISION

$Revision: 1.5 $

=head1 AUTHOR

Graham Barr <bodg@tiuk.ti.com>

=cut


1; # Keep require happy

__END__

$Log: Domain.pm,v $
# Revision 1.5 1995/09/11 10:55:55 gbarr
# modified code to check all host name aliases
# for a FQDN
#
# Revision 1.4 1995/09/06 06:08:42 gbarr
# Applied patch from Matthew.Green@fulcrum.com.au to chop
# results from `` commands
#
# Revision 1.3 1995/09/04 15:03:51 gbarr
# changed the /etc/resolve.conf code to look for search and
# domain parameters and use the last one found
#
# Revision 1.2 1995/09/04 11:22:59 gbarr
# Added documentation
#
# Revision 1.1 1995/08/31 20:35:30 gbarr
# Initial revision
#
--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--

--
.-----------------------------------------------------------.
//// | Graham Barr Email: bodg@tiuk.ti.com | \\\\
| 00 | VLSI Cell Designer or: bodg@ti.com | 00 |
O ^ | MOS Design TI MSG: BODG | ^ O
\ ~/ | Texas Instruments Ltd Phone: +44 (0)1604 66 3419 | \~ /
| ENGLAND Fax: +44 (0)1604 66 3456 |
`-----------------------------------------------------------'
Re: Sys::Domain [ In reply to ]
Mike Stok writes:
> I'd like to offer ftp.delphi.com as a mirror for the CPAN, I've already
> mentioned it to the guy running the anon ftp service at Delphi. Who else
> should I talk to and what other sites could Delphi usefully mirror?

Excerpt from my message to "Christopher C. Chan-Nui" <channui@austin.ibm.com>:

: > which kicks off at 0:17 funet time (if I've done the time conversion
: > correctly).
: Fear not, at least because of funet, it is a big enough machine that
: serving something as small as CPAN should not matter, a daily pull is
: fine. There is the matter of regional mirroring, though: it might not
: make sense bandwidth-wise for all the now and future CPAN U.S. mirrors
: to grab their own copy, maybe some sort of mirroring hierarchy in
: there? But let us worry that when more US sites join in.

The mirror Christopher is maintaining is at

> ftp://janus.sedl.org/pub/mirrors/CPAN/

mirroring the GMoaPa (Grand-Mother of all Perl archives)

> ftp://ftp.funet.fi/pub/languages/perl/CPAN/

++jhi;