Server IP : 103.119.228.120 / Your IP : 18.188.13.127 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/lib64/perl5/Sys/ |
Upload File : |
package Sys::Hostname; use strict; use Carp; require Exporter; our @ISA = qw/ Exporter /; our @EXPORT = qw/ hostname /; our $VERSION; our $host; BEGIN { $VERSION = '1.16'; { local $SIG{__DIE__}; eval { require XSLoader; XSLoader::load(); }; warn $@ if $@; } } sub hostname { # method 1 - we already know it return $host if defined $host; # method 1' - try to ask the system $host = ghname() if defined &ghname; return $host if defined $host; if ($^O eq 'VMS') { # method 2 - no sockets ==> return DECnet node name eval { local $SIG{__DIE__}; $host = (gethostbyname('me'))[0] }; if ($@) { return $host = $ENV{'SYS$NODE'}; } # method 3 - has someone else done the job already? It's common for the # TCP/IP stack to advertise the hostname via a logical name. (Are # there any other logicals which TCP/IP stacks use for the host name?) $host = $ENV{'ARPANET_HOST_NAME'} || $ENV{'INTERNET_HOST_NAME'} || $ENV{'MULTINET_HOST_NAME'} || $ENV{'UCX$INET_HOST'} || $ENV{'TCPWARE_DOMAINNAME'} || $ENV{'NEWS_ADDRESS'}; return $host if $host; # method 4 - does hostname happen to work? my($rslt) = `hostname`; if ($rslt !~ /IVVERB/) { ($host) = $rslt =~ /^(\S+)/; } return $host if $host; # rats! $host = ''; croak "Cannot get host name of local machine"; } elsif ($^O eq 'MSWin32') { ($host) = gethostbyname('localhost'); chomp($host = `hostname 2> NUL`) unless defined $host; return $host; } elsif ($^O eq 'epoc') { $host = 'localhost'; return $host; } else { # Unix # is anyone going to make it here? local $ENV{PATH} = '/usr/bin:/bin:/usr/sbin:/sbin'; # Paranoia. # method 2 - syscall is preferred since it avoids tainting problems # XXX: is it such a good idea to return hostname untainted? eval { local $SIG{__DIE__}; require "syscall.ph"; $host = "\0" x 65; ## preload scalar syscall(&SYS_gethostname, $host, 65) == 0; } # method 2a - syscall using systeminfo instead of gethostname # -- needed on systems like Solaris || eval { local $SIG{__DIE__}; require "sys/syscall.ph"; require "sys/systeminfo.ph"; $host = "\0" x 65; ## preload scalar syscall(&SYS_systeminfo, &SI_HOSTNAME, $host, 65) != -1; } # method 3 - trusty old hostname command || eval { local $SIG{__DIE__}; local $SIG{CHLD}; $host = `(hostname) 2>/dev/null`; # bsdish } # method 4 - use POSIX::uname(), which strictly can't be expected to be # correct || eval { local $SIG{__DIE__}; require POSIX; $host = (POSIX::uname())[1]; } # method 5 - sysV uname command (may truncate) || eval { local $SIG{__DIE__}; $host = `uname -n 2>/dev/null`; ## sysVish } # bummer || croak "Cannot get host name of local machine"; # remove garbage $host =~ tr/\0\r\n//d; $host; } } 1; __END__ =head1 NAME Sys::Hostname - Try every conceivable way to get hostname =head1 SYNOPSIS use Sys::Hostname; $host = hostname; =head1 DESCRIPTION Attempts several methods of getting the system hostname and then caches the result. It tries the first available of the C library's gethostname(), C<`$Config{aphostname}`>, uname(2), C<syscall(SYS_gethostname)>, C<`hostname`>, C<`uname -n`>, and the file F</com/host>. If all that fails it C<croak>s. All NULs, returns, and newlines are removed from the result. =head1 AUTHOR David Sundstrom E<lt>F<sunds@asictest.sc.ti.com>E<gt> Texas Instruments XS code added by Greg Bacon E<lt>F<gbacon@cs.uah.edu>E<gt> =cut