Thanks to Martin McCormick for reporting and Ken for diagnosing.
12 files changed:
- An -attendee switch has been added to mhical(1), for use when more than one
(or zero) attendees match a user's mailbox.
- An -attendee switch has been added to mhical(1), for use when more than one
(or zero) attendees match a user's mailbox.
+- Fixed inc(1) and %(me) function escape to not obey Local-Mailbox profile
+ component.
extern char *spoollocking;
#define MAILDIR (mmdfldir && *mmdfldir ? mmdfldir : getenv ("HOME"))
extern char *spoollocking;
#define MAILDIR (mmdfldir && *mmdfldir ? mmdfldir : getenv ("HOME"))
-#define MAILFIL (mmdflfil && *mmdflfil ? mmdflfil : getusername ())
+#define MAILFIL (mmdflfil && *mmdflfil ? mmdflfil : getusername (1))
-char *getusername(void);
char *getfullname(void);
char *getlocalmbox(void);
char *getfullname(void);
char *getlocalmbox(void);
*/
if (am == NULL) {
mq.m_next = NULL;
*/
if (am == NULL) {
mq.m_next = NULL;
- mq.m_mbox = getusername ();
+ mq.m_mbox = getusername (0);
if ((am = context_find ("local-mailbox"))) {
if ((am = context_find ("local-mailbox"))) {
}
if ((am = context_find ("alternate-mailboxes")) == NULL)
}
if ((am = context_find ("alternate-mailboxes")) == NULL)
else {
mp = mq.m_next ? mq.m_next : &mq;
oops = false;
else {
mp = mq.m_next ? mq.m_next : &mq;
oops = false;
creds->pass = NULL;
if (cred_style == NULL || ! strcmp (cred_style, "legacy")) {
creds->pass = NULL;
if (cred_style == NULL || ! strcmp (cred_style, "legacy")) {
- creds->user = user == NULL ? mh_xstrdup(getusername ()) : mh_xstrdup(user);
+ creds->user = user == NULL ? mh_xstrdup(getusername (1)) : mh_xstrdup(user);
} else if (! strncasecmp (cred_style, "file:", 5) ||
! strncasecmp (cred_style, "file-nopermcheck:", 17)) {
/*
} else if (! strncasecmp (cred_style, "file:", 5) ||
! strncasecmp (cred_style, "file-nopermcheck:", 17)) {
/*
- LS(t->f_type, getusername());
+ LS(t->f_type, getusername(1));
char *spoollocking = DEFAULT_LOCKING;
char *spoollocking = DEFAULT_LOCKING;
-/* Cache the username, fullname, and mailbox of the user */
+/* Cache the username, fullname, mailbox name, and mailbox of the user */
static char username[BUFSIZ];
static char fullname[BUFSIZ];
static char username[BUFSIZ];
static char fullname[BUFSIZ];
+/* mboxname comes from a Local-Mailbox profile component, or if that
+ doesn't exist, the username. */
+static char mboxname[BUFSIZ];
static char localmbox[2*BUFSIZ+3];
/*
static char localmbox[2*BUFSIZ+3];
/*
case 0: s--;
/* FALLTHRU */
case 0: s--;
/* FALLTHRU */
if (!isdigit ((unsigned char) *s)) {
*bp++ = QUOTE;
*bp = *s;
if (!isdigit ((unsigned char) *s)) {
*bp++ = QUOTE;
*bp = *s;
/*
* Get the username of current user
/*
* Get the username of current user
+ *
+ * If flag is 0, then attempt to extract username from Local-Mailbox profile
+ * component, if present.
+ * If flag is 1, then only use the "proper" local hostname.
{
if (username[0] == '\0')
getuserinfo();
{
if (username[0] == '\0')
getuserinfo();
+ return flag == 0 ? mboxname : username;
- * Find the user's username and full name, and cache them.
+ * Find and cache the user's username, full name, and local mbox.
+ if (username[0] == '\0') {
+ strncpy (username, pw->pw_name, sizeof(username));
+ }
+ username[sizeof(username) - 1] = '\0';
+
+ /* localmbox and mboxname */
/* If there's a Local-Mailbox profile component, try to extract
the username from it. But don't try very hard, this assumes
the very simple User Name <user@name.com> form.
/* If there's a Local-Mailbox profile component, try to extract
the username from it. But don't try very hard, this assumes
the very simple User Name <user@name.com> form.
if (left_angle_bracket && at_sign && right_angle_bracket) {
if (at_sign > left_angle_bracket &&
at_sign - left_angle_bracket < BUFSIZ) {
if (left_angle_bracket && at_sign && right_angle_bracket) {
if (at_sign > left_angle_bracket &&
at_sign - left_angle_bracket < BUFSIZ) {
- strncpy(username, left_angle_bracket + 1,
+ strncpy(mboxname, left_angle_bracket + 1,
at_sign - left_angle_bracket - 1);
}
}
at_sign - left_angle_bracket - 1);
}
}
+ } else {
+ snprintf(localmbox, sizeof(localmbox), "%s <%s@%s>", fullname,
+ username, LocalName(0));
-
- if (username[0] == '\0') {
- strncpy (username, pw->pw_name, sizeof(username));
+ localmbox[sizeof(localmbox) - 1] = '\0';
+ if (mboxname[0] == '\0') {
+ strncpy (mboxname, username, sizeof(mboxname));
-
- username[sizeof(username) - 1] = '\0';
-
- escape_local_part(username, sizeof(username));
-
+ mboxname[sizeof(mboxname) - 1] = '\0';
+ escape_local_part(mboxname, sizeof(mboxname));
/* fullname */
np = pw->pw_gecos;
/* fullname */
np = pw->pw_gecos;
strncpy (fullname, cp, sizeof(fullname));
else if ((cp = context_find("Signature")))
strncpy (fullname, cp, sizeof(fullname));
strncpy (fullname, cp, sizeof(fullname));
else if ((cp = context_find("Signature")))
strncpy (fullname, cp, sizeof(fullname));
fullname[sizeof(fullname) - 1] = '\0';
fullname[sizeof(fullname) - 1] = '\0';
escape_display_name(fullname, sizeof(fullname));
escape_display_name(fullname, sizeof(fullname));
-
-
- /* localmbox, if not using Local-Mailbox */
- if (localmbox[0] == '\0') {
- snprintf(localmbox, sizeof(localmbox), "%s <%s@%s>", fullname,
- username, LocalName(0));
- }
-
- localmbox[sizeof(localmbox) - 1] = '\0';
-#### Use ap to get the username. That will either be what's in the
-#### Local-Mailbox profile component, which we don't use in the test
-#### suite, or the user's login name. ap will escape (quote) it if
-#### needed.
-user=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(me)' 0`
+#### Remove existing Local-Mailbox: profile component, if any.
+grep -v 'Local-Mailbox: ' "$MH" > "$MH".new
+mv -f "$MH".new "$MH"
+
+user=`id -nu`
set +e
host=`${MH_OBJ_DIR}/test/getcanon`
set -e
set +e
host=`${MH_OBJ_DIR}/test/getcanon`
set -e
myname="Random User <random@user.something.com>"
myname="Random User <random@user.something.com>"
-#### Remove existing Local-Mailbox: profile component, if any. Then
-#### add one.
-grep -v 'Local-Mailbox: ' "$MH" > "$MH".new
-mv -f "$MH".new "$MH"
+#### Add Local-Mailbox profile component.
echo "Local-Mailbox: ${myname}" >> "$MH"
run_test "echo \
echo "Local-Mailbox: ${myname}" >> "$MH"
run_test "echo \
1 "Local-Mailbox test"
output=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
1 "Local-Mailbox test"
output=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
-run_test "echo $output" 0 "Local-mailbox overriding user@host test"
+run_test "echo $output" 0 "Local-Mailbox overriding user@host test"
+
+#### Test getusername() when there is a Local-Mailbox profile component.
+run_test 'fmttest -raw -format %(me) ""' "${user}"
# Add an Alternate-Mailbox. This caused ismymbox() to lose the
# Local-Mailbox, Bug #36635: -nocc me doesn't account for
# Add an Alternate-Mailbox. This caused ismymbox() to lose the
# Local-Mailbox, Bug #36635: -nocc me doesn't account for
if (e->eb_flags) {
user = "anonymous";
if (e->eb_flags) {
user = "anonymous";
- snprintf (buffer, sizeof(buffer), "%s@%s", getusername (),
+ snprintf (buffer, sizeof(buffer), "%s@%s", getusername (1),
LocalName (1));
pass = buffer;
} else {
LocalName (1));
pass = buffer;
} else {
snoop, sasl, saslmech, tlsflag, auth_svc);
}
} else {
snoop, sasl, saslmech, tlsflag, auth_svc);
}
} else {
- if (user == NULL) user = getusername ();
+ if (user == NULL) user = getusername (1);
if (vecp == 0) {
char *home;
if (vecp == 0) {
char *home;
if ((md = vecp ? message_fd (vec) : header_fd ()) == NOTOK)
exit(1);
if ((md = vecp ? message_fd (vec) : header_fd ()) == NOTOK)
exit(1);
- user = getusername();
-
+ user = getusername(1);
+
setutxent();
while ((utp = getutxent()) != NULL) {
if (utp->ut_type == USER_PROCESS && utp->ut_user[0] != 0
setutxent();
while ((utp = getutxent()) != NULL) {
if (utp->ut_type == USER_PROCESS && utp->ut_user[0] != 0
arglist = argsplit(mailproc, &program, &argp);
arglist = argsplit(mailproc, &program, &argp);
- arglist[argp++] = getusername();
+ arglist[argp++] = getusername(1);
arglist[argp++] = "-subject";
arglist[argp++] = buf;
arglist[argp] = NULL;
arglist[argp++] = "-subject";
arglist[argp++] = buf;
arglist[argp] = NULL;
+ addr = getusername (1);
+ user = getusername (1);
}
if ((pw = getpwnam (user)) == NULL)
die("no such local user as %s", user);
}
if ((pw = getpwnam (user)) == NULL)
die("no such local user as %s", user);