From: Matt Kraai <kraai@xxxxxxxxxxxxxxxxxx> /etc/mailname contains the hostname to be used on outgoing email messages generated locally on Debian systems (cf. http://www.debian.org/doc/debian-policy/ch-customized-programs.html). If it available, use it instead of gethostname or gethostbyname. Signed-off-by: Matt Kraai <kraai@xxxxxxxxx> --- If this is only appropriate for the Debian package, I apologize. Please let me know if this is the case and I'll submit it to the Debian maintainer. ident.c | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/ident.c b/ident.c index 6612d17..3d05ae2 100644 --- a/ident.c +++ b/ident.c @@ -43,6 +43,27 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz) } +static int getmailname(char *name, size_t len) +{ + FILE *f = fopen("/etc/mailname", "r"); + int i; + + if (!f) + return -1; + if (!fgets(name, len, f)) { + fclose(f); + return -1; + } + fclose(f); + for (i = 0; !isspace(name[i]); i++) + ; + if (name[i - 1] != '.') + name[i] = '\0'; + else + name[i - 1] = '\0'; + return 0; +} + static void copy_email(const struct passwd *pw) { /* @@ -54,7 +75,10 @@ static void copy_email(const struct passwd *pw) die("Your sysadmin must hate you!"); memcpy(git_default_email, pw->pw_name, len); git_default_email[len++] = '@'; - gethostname(git_default_email + len, sizeof(git_default_email) - len); + if (getmailname(git_default_email + len, + sizeof(git_default_email) - len) < 0) + gethostname(git_default_email + len, + sizeof(git_default_email) - len); if (!strchr(git_default_email+len, '.')) { struct hostent *he = gethostbyname(git_default_email + len); char *domainname; -- 1.5.2.3 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html