aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/safe_gethostname.c22
-rw-r--r--mailutils/sendmail.c7
3 files changed, 4 insertions, 26 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 2cc146631..f12800f53 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -795,7 +795,6 @@ void qsort_string_vector(char **sv, unsigned count) FAST_FUNC;
795int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout_ms) FAST_FUNC; 795int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout_ms) FAST_FUNC;
796 796
797char *safe_gethostname(void) FAST_FUNC; 797char *safe_gethostname(void) FAST_FUNC;
798char *safe_getdomainname(void) FAST_FUNC;
799 798
800/* Convert each alpha char in str to lower-case */ 799/* Convert each alpha char in str to lower-case */
801char* str_tolower(char *str) FAST_FUNC; 800char* str_tolower(char *str) FAST_FUNC;
diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c
index bdb989631..cac99ae03 100644
--- a/libbb/safe_gethostname.c
+++ b/libbb/safe_gethostname.c
@@ -50,25 +50,3 @@ char* FAST_FUNC safe_gethostname(void)
50 uname(&uts); 50 uname(&uts);
51 return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename)); 51 return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename));
52} 52}
53
54/*
55 * On success return the current malloced and NUL terminated domainname.
56 * On error return malloced and NUL terminated string "?".
57 * This is an illegal first character for a domainname.
58 * The returned malloced string must be freed by the caller.
59 */
60char* FAST_FUNC safe_getdomainname(void)
61{
62#if defined(__linux__)
63/* The field domainname of struct utsname is Linux specific. */
64 struct utsname uts;
65 uname(&uts);
66 return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
67#else
68 /* We really don't care about people with domain names wider than most screens */
69 char buf[256];
70 int r = getdomainname(buf, sizeof(buf));
71 buf[sizeof(buf)-1] = '\0';
72 return xstrdup(r < 0 ? "?" : buf);
73#endif
74}
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index aa381c60f..c426e9d85 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -118,7 +118,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
118 char *opt_from; 118 char *opt_from;
119 char *s; 119 char *s;
120 llist_t *list = NULL; 120 llist_t *list = NULL;
121 char *domain = sane_address(safe_getdomainname()); 121 char *host = sane_address(safe_gethostname());
122 unsigned nheaders = 0; 122 unsigned nheaders = 0;
123 int code; 123 int code;
124 124
@@ -222,8 +222,9 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
222 } 222 }
223 223
224 // we should start with modern EHLO 224 // we should start with modern EHLO
225 if (250 != smtp_checkp("EHLO %s", domain, -1)) 225 if (250 != smtp_checkp("EHLO %s", host, -1))
226 smtp_checkp("HELO %s", domain, 250); 226 smtp_checkp("HELO %s", host, 250);
227 free(host);
227 228
228 // perform authentication 229 // perform authentication
229 if (opts & OPT_a) { 230 if (opts & OPT_a) {