Skip to content

Commit a14daf8

Browse files
committed
Merge branch 'jn/do-not-drop-username-when-reading-from-etc-mailname'
We used to stuff "user@" and then append what we read from /etc/mailname to come up with a default e-mail ident, but a bug lost the "user@" part. This is to fix it. * jn/do-not-drop-username-when-reading-from-etc-mailname: ident: do not drop username when reading from /etc/mailname
2 parents 67d9c41 + dc342a2 commit a14daf8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ident.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static void copy_gecos(const struct passwd *w, struct strbuf *name)
4646
static int add_mailname_host(struct strbuf *buf)
4747
{
4848
FILE *mailname;
49+
struct strbuf mailnamebuf = STRBUF_INIT;
4950

5051
mailname = fopen("/etc/mailname", "r");
5152
if (!mailname) {
@@ -54,14 +55,17 @@ static int add_mailname_host(struct strbuf *buf)
5455
strerror(errno));
5556
return -1;
5657
}
57-
if (strbuf_getline(buf, mailname, '\n') == EOF) {
58+
if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) {
5859
if (ferror(mailname))
5960
warning("cannot read /etc/mailname: %s",
6061
strerror(errno));
62+
strbuf_release(&mailnamebuf);
6163
fclose(mailname);
6264
return -1;
6365
}
6466
/* success! */
67+
strbuf_addbuf(buf, &mailnamebuf);
68+
strbuf_release(&mailnamebuf);
6569
fclose(mailname);
6670
return 0;
6771
}

0 commit comments

Comments
 (0)