← Commit list

e9355c432

Michael Tokarev
Michael Tokarev
2013-12-17
SUCCESS Duration: 147s

Subject

hostname: do not use gethostbyname() for "hostname -s"

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

networking/hostname.c+5 -2
@@ -106,7 +106,7 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
OPT_i = 0x4,
OPT_s = 0x8,
OPT_F = 0x10,
- OPT_dfis = 0xf,
+ OPT_dfi = 0x7,
};
unsigned opts;
@@ -134,7 +134,7 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
if (applet_name[0] == 'd') /* dnsdomainname? */
opts = OPT_d;
- if (opts & OPT_dfis) {
+ if (opts & OPT_dfi) {
/* Cases when we need full hostname (or its part) */
struct hostent *hp;
char *p;
@@ -159,6 +159,9 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
bb_putchar('\n');
}
}
+ } else if (opts & OPT_s) {
+ strchrnul(buf, '.')[0] = '\0';
+ puts(buf);
} else if (opts & OPT_F) {
/* Set the hostname */
do_sethostname(hostname_str, 1);