[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: HOSTALIASES ne fonctionne pas sur debian?



Salut,

>    $ export HOSTALIASES=~/.hosts
>    $ echo 127.0.0.1 wow> $HOSTALIASES
>    $ ping wow
>    ping: wow: Aucune adresse associée avec le nom de l'hôte
>

Il me semble que ping n'utilise pas gethostbyname mais getaddrinfo:

bash$ sudo ltrace ping google.com
__cxa_atexit(0x5574d608c060, 0, 0x5574d6092328, 0) = 0
cap_get_proc(0x7f1acd5be718, 1, 3, 32)           = 0x5574d71af294
cap_init(0x5574d71af294, 0x5574d71af29c, 0x5574d71af290, 0x7f1acd4fcd17) = 0x5574d71af2c4
cap_get_flag(0x5574d71af294, 12, 1, 0x7fff8da6a454) = 0
cap_set_flag(0x5574d71af2c4, 1, 1, 0x5574d60923e0) = 0
cap_get_flag(0x5574d71af294, 13, 1, 0x7fff8da6a454) = 0
cap_set_flag(0x5574d71af2c4, 1, 1, 0x5574d60923e4) = 0
cap_set_proc(0x5574d71af2c4, 1, 0x3000, 4096)    = 0
prctl(8, 1, 0x3000, 0x7f1acd4fcd47)              = 0
getuid()                                         = 0
setuid(0)                                        = 0
prctl(8, 0, 0x3000, 0)                           = 0
cap_free(0x5574d71af2c4, 0, 0x3000, 0x7f1acd4fd0aa) = 0
cap_free(0x5574d71af294, 1, 0, 0x5574d71af010)   = 0
getuid()                                         = 0
geteuid()                                        = 0
setlocale(LC_ALL, "") = "LC_CTYPE=en_US.UTF-8;LC_NUMERIC="...
bindtextdomain("iputils", "/usr/share/locale")   = "/usr/share/locale"
textdomain("iputils")                            = "iputils"
strlen("ping")                                   = 4
getopt(2, 0x7fff8da6a5f8, "h?4bRT:6F:N:aABc:dDfi:I:l:Lm:M:n"...) = -1
cap_get_proc(13, 1, 1, 0)                        = 0x5574d71af2c4
cap_get_flag(0x5574d71af2c4, 13, 1, 0x7fff8da6a454) = 0
cap_set_flag(0x5574d71af2c4, 0, 1, 0x7fff8da6a44c) = 0
cap_set_proc(0x5574d71af2c4, 0, 8192, 0)         = 0
cap_free(0x5574d71af2c4, 0x5574d71af2cc, 8192, 0x7f1acd4fcd47) = 0
__errno_location()                               = 0x7f1acd3def80
socket(2, 2, 1)                                  = -1
socket(2, 3, 1)                                  = 3
__errno_location()                               = 0x7f1acd3def80
socket(10, 2, 58)                                = -1
socket(10, 3, 58)                                = 4
cap_get_proc(13, 0, 58, 0x7f1acd4fdac7)          = 0x5574d71af2c4
cap_get_flag(0x5574d71af2c4, 13, 1, 0x7fff8da6a454) = 0
cap_set_flag(0x5574d71af2c4, 0, 1, 0x7fff8da6a44c) = 0
cap_set_proc(0x5574d71af2c4, 0, 0, 0)            = 0
cap_free(0x5574d71af2c4, 0x5574d71af2cc, 0, 0x7f1acd4fcd47) = 0
getaddrinfo("google.com", nil, 0x7fff8da6a4b0, 0x7fff8da6a498) = 0
inet_aton("google.com", { 0 })                   = 0
...

Par ailleurs, getaddrinfo est plus simple à utiliser que gethostbyname : ça te retourne les resolutions avec tous les type de familles ; et il ne faut pas oublier ce buffer overflow (aka "GHOST") : https://www.qualys.com/2015/01/27/cve-2015-0235/GHOST-CVE-2015-0235.txt


--
Nisar JAGABAR
 ,= ,-_-. =.
((_/)o o(\_))
 `-'(. .)`-'
     \_/


Reply to: