From: Matt Kraai <kraai@ftbfs.org>
To: git@vger.kernel.org
Cc: Matt Kraai <kraai@asturias.ftbfs.org>, Matt Kraai <kraai@ftbfs.org>
Subject: [PATCH] Use /etc/mailname for the hostname part of the email address.
Date: Fri, 6 Jul 2007 19:21:05 -0700 [thread overview]
Message-ID: <11837748652889-git-send-email-kraai@ftbfs.org> (raw)
From: Matt Kraai <kraai@asturias.ftbfs.org>
/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@ftbfs.org>
---
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
next reply other threads:[~2007-07-07 2:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-07 2:21 Matt Kraai [this message]
2007-07-07 2:54 ` [PATCH] Use /etc/mailname for the hostname part of the email address Linus Torvalds
2007-07-07 6:07 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11837748652889-git-send-email-kraai@ftbfs.org \
--to=kraai@ftbfs.org \
--cc=git@vger.kernel.org \
--cc=kraai@asturias.ftbfs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox