Subject: User's Password

From: Shawn Walker <[email-masked]>
Date: 25 Apr 2002 16:12:05 -0500

Is there a way that I can pass/store a user's password before calling
mail_open().  I want don't want to give the password in mm_login()
callback function because I can't store a global varible since the
application need to be threaded-safe and globals don't work well in that
environment.

Another possiblity is that would be great is to pass my data pointer to
a session that can pass that into the callback (get the data pointer
from MAILSTREAM data).

Thanks!

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Thu, 25 Apr 2002 14:20:18 -0700 (PDT)

> application need to be threaded-safe and globals don't work well in that

Globals work perfectly well in threaded applications.  You just have to
understand the implications of threading when using globals.  Yes, you
probably don't want to have a
	char *password;
since another thread could change it in between the time that you set it and
it is referenced by mm_login().

On the other hand, if you have some sort of list of passwords and the
associated host and/or mailbox name for each password, then it is a relatively
simple matter to use the data from the first argument (a NETMBX*) to locate
the correct password and use it.

Let me emphasize again that the myth that "globals don't work in threaded
applications" is just that: a myth.  Globals work perfectly well, as long as
you understand how threading interacts with globals.

> a session that can pass that into the callback (get the data pointer

It can't be from MAILSTREAM, since mail_open() is likely to create the
MAILSTREAM and thus it didn't exist before you called mail_open().  However,
the NETMBX structure should have everything you need.  Note that you do need
to copy the "user" member of the NETMBX structure to the returned user if its
first byte is non-null:
	strcpy (user,mb->user);
c-client ensures that mb->user can't overflow user, so it's alright to use
strcpy().

---

From: Shawn Walker <[email-masked]>
Date: 25 Apr 2002 16:51:21 -0500

> it is referenced by mm_login().

Yes, I know it's a myth, it just that people have to know *how* to use
globals in a threaded environments which people should put a lock around
the global data before accessing and relase the lock when done.  But I
was just hoping that there was something else in the c-client that I
could use to pass the information (user's password) into c-cliebt before
calling mail_open().

> the correct password and use it.

How would I know what the address of NETBMX before calling mail_open()
so that I can create a list of passwords?

> c-client ensures that mb->user can't overflow user, so it's alright to use

I'm already using NETMBX "user" member in mm_login(). 

Thanks for the help.

---

From: Mark Crispin <[email-masked]>
Date: Thu, 25 Apr 2002 21:15:17 -0700 (Pacific Daylight Time)

> so that I can create a list of passwords?

You won't.  You have to examine the data inside the NETMBX and correlate
it with your cached list of passwords.

Pine does this, so you might want to look at Pine's code.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.

---

From: Robert Gange <[email-masked]>
Date: Fri, 26 Apr 2002 08:45:06 -0400

HELO list!

I'm relatively new to configuring IMAP on unix/linux.  I've setup a system
(RedHat 7.2) for a small office that has mail arriving directly to sendmail
and then delivered locally.  It also runs fetchmail for certain accounts and
delivers through procmail.  All users access their mail through imap
(2001a).  Clients range from OutLook Express on Mac to Netscape 6.2 under
Windows 98 (OK, not a very big range).

After reading the docs, particularly formats.txt, I decided that 'mbx' is
the way I need to go as two of the mailboxes need to have shared access.

By everything I've read, mbx seems to be the default mailbox format, enabled
by default.  But on some of those mailboxes, I get 'lost mailbox lock' even
when only 1 person is checking their mail.

Also, I brought one user over from another system already in mbox format.
What conversion tools are available to convert mbox to mbx?

Thanks for any tips and pointers.
-- 
Robert Gange

---

From: Mark Crispin <[email-masked]>
Date: Fri, 26 Apr 2002 18:10:20 -0700 (Pacific Daylight Time)

> the way I need to go as two of the mailboxes need to have shared access.

So far, so good.  I assume that you also know that only applications based
upon the c-client library (imapd, ipop[23]d, Pine, etc.) can read mbx
format files?

> by default.

No it is not.  The default mailbox format is traditional UNIX mailbox
format, also called "mbox" format (note the "o"), which is supported by
just about every UNIX mail program ever written.

> But on some of those mailboxes, I get 'lost mailbox lock' even

That proves that you are using traditional UNIX mailbox format.

Maybe only one person is checking his mail, but on the IMAP server end,
you'll find that it's two processes.  Most likely, it is a poorly-designed
client that spawned the second process.

Well-designed clients, such as Pine, do not have this problem.

> What conversion tools are available to convert mbox to mbx?

The UW imap-utils toolkit:
	ftp://ftp.cac.washington.edu/mail/imap-utils.tar.Z
has several programs which can be of use in conversion/management of
mailboxes.  Most notable for your purposes is mbxcvt.

-- Mark --

"A single glass of champagne imparts a feeling of exhiliaration.  The
nerves are braced; the imagination is agreeably strirred; the wits become
more nimble.  A bottle produces a contrary effect.  Excess causes a
comatose insensibility.  So it is with war; and the quality of both is
best discovered by sipping."  -- Winston Churchill

---

From: Robert Gange <[email-masked]>
Date: Mon, 29 Apr 2002 08:35:23 -0400

On 4/26/02 9:10 PM, "Mark Crispin" [email-masked] pressed the keys

> upon the c-client library (imapd, ipop[23]d, Pine, etc.) can read mbx

Right - even though the clients use OutLook and Netscape remotely, it's
still imap accessing the files on the server.  I really don't have any shell
users accessing mail locally.

> just about every UNIX mail program ever written.

Got it.

> client that spawned the second process.

Understood - I know OutLook tends to open multiple connections to a single
host/mailbox.

> mailboxes.  Most notable for your purposes is mbxcvt.

I'll go fetch it.  But first, some more questions - will I just be able to
run mbxcvt on the server, and imap will deal with it when users try to
access their mail?  Can I only convert the INBOX folder, or each mailbox in
the users mail folder?  What is the default location of an mbx mail folder?
/var/spool/mail?

Thanks very much, Mark.
-- 
Robert Gange

---

From: Mark Crispin <[email-masked]>
Date: Mon, 29 Apr 2002 18:23:52 -0700 (Pacific Daylight Time)

On Mon, 29 Apr 2002, Robert Gange wrote:
> will I just be able to
> access their mail?

imapd automatically detects the mailbox format and uses that format.  If
the user has both an mbx format INBOX and a traditional UNIX format mail
spool INBOX, imapd automatically moves messages from the traditional UNIX
format mail spool INBOX to the mbx format INBOX.

> Can I only convert the INBOX folder, or each mailbox in
> the users mail folder?

That is up to you.

> What is the default location of an mbx mail folder?

File "INBOX" on the user's home directory.

> /var/spool/mail?

That's reserved for traditional UNIX format.

-- Mark --

---

From: Robert Gange <[email-masked]>
Date: Wed, 01 May 2002 12:32:58 -0400

On 4/29/02 9:23 PM, "Mark Crispin" [email-masked] pressed the keys

> format mail spool INBOX to the mbx format INBOX.

Thank you, Mark.  With your help (and a little trial and error), everything
seems to be working with the new mbx format.  Seems faster to access, too.
Thanks again!
-- 
Robert Gange

---

From: Deb Teale <[email-masked]>
Date: Fri, 05 Jul 2002 15:23:19 -0600

We have moved away from /var/spool/mail inboxes to home directory mboxes
but still have a /var/spool/mail  entry for few people using filter.
This works fine for reading the mbox directly from home directory and
for merging /var/spool/mail messages to mbox.  But fails for the case of
writing a message back to INBOX either with Netscape or Pine if the user
does not have an entry in /var/spool/mail.  It may be that it tries to
write to /var/spool/mail and if an entry isn't there it fails  NO COPY
failed: Not a UNIX-format mailbox: inbox after 81 messages.

(Users would like to pull Trash messages back to INBOX is the problem I
am looking at solving).

Has anyone seen this and have a solution?  Don't want to keep an entry
for 50000 when only 70 people need one.

Thanks,

Deb Teale

---

From: Mark Crispin <[email-masked]>
Date: Fri, 5 Jul 2002 14:36:10 -0700 (Pacific Daylight Time)

On Fri, 5 Jul 2002, Deb Teale wrote:
> It may be that it tries to

That error message generally means that the user's UNIX-format INBOX file
exists, but it is not in proper traditional UNIX mail format.  So, when
that happens, you should investigate to see what the mail file looks like.

-- Mark --

---

From: Deb Teale <[email-masked]>
Date: Mon, 08 Jul 2002 09:29:01 -0600

> Science does not emerge from voting, party politics, or public debate.

Marc,  the file does not exist.    Perhaps what I am needing is a patch to
have it check the home directory mbox file if the /var/spool/mail entry
doesn't exist.  (It used to work prior to imapd2000-by accident or design).
Reading INBOX slurps the /var/spool/mail messages into mbox if they exist but
apparently writing to INBOX if the /var/spool/mail entry does NOT exist fails
to instead append to mbox in the home directory.

Deb

---

From: Mark Crispin <[email-masked]>
Date: Mon, 8 Jul 2002 09:37:56 -0700 (PDT)

On Mon, 08 Jul 2002 09:29:01 -0600, Deb Teale wrote:
> Reading INBOX slurps the /var/spool/mail messages into mbox if they exist
> but apparently writing to INBOX if the /var/spool/mail entry does NOT exist
> fails to instead append to mbox in the home directory.

I just tried the following tests:
 APPEND to INBOX when no spool or mbox file exists
 APPEND to INBOX when spool exists but no mbox
 APPEND to INBOX when mbox exists but no spool
 COPY to INBOX when no spool or mbox file exists
 COPY to INBOX when spool exists but no mbox
 COPY to INBOX when mbox exists but no spool

In all cases, the expected behavior happened.

So, what is happening to you is mysterious to me.  Have you made any
modifications to imapd which may in some way be implicated?  Have you tried
the latest imap 2002 development snapshot to see if the problem occurs there?

---

From: Deb Teale <[email-masked]>
Date: Mon, 08 Jul 2002 14:04:29 -0600

> the latest imap 2002 development snapshot to see if the problem occurs there?

We haven't set access to write to /var/spool/mail but create an entry for those
who are using filter which delivers there.   postfix delivers to home directory
mbox otherwise.   Appends to other folders fine.

The only local change is to check for a .locked file when opening to deny read of
inbox.

IMAP DEBUG 11:26:30 7/8: 00000002 OK [READ-WRITE] SELECT completed
IMAP 11:26:30 7/8 mm_log babble: Mailbox is empty
Opened folder "{iproxy2.acs.ucalgary.ca:143/imap/user=sikorski}inbox"
with 0 messages
Sorting by Arrival/reverse

    ---- MAIN_MENU_SCREEN ----
IMAP DEBUG 11:26:30 7/8: 00000003 NOOP
IMAP DEBUG 11:26:30 7/8: 00000003 OK NOOP completed
mm_list "Mail/oldinbox": delim: '/', , no inferiors, unmarked
broach folder, name entered "oldinbox"
About to open folder "oldinbox"    inbox: "INBOX"
Close - saved inbox state: max 0
=== mm_exists(83,/u108/sikorski/Mail/oldinbox) called ===
Opened folder "/u108/sikorski/Mail/oldinbox" with 83 messages
Sorting by Arrival/reverse

 ---- MAIL INDEX ----

 ---- INDEX MANAGER ----
IMAP DEBUG 11:27:02 7/8: 00000004 LIST "" inbox
IMAP DEBUG 11:27:02 7/8: * LIST (\NoInferiors) NIL INBOX
mm_list "{iproxy.ucalgary.ca}INBOX": delim: 'X', , no inferiors
IMAP DEBUG 11:27:02 7/8: 00000004 OK LIST completed
IMAP DEBUG 11:27:02 7/8: 00000005 APPEND inbox () "18-Mar-2002 10:10:09
-0700" {756}
IMAP DEBUG 11:27:02 7/8: + Ready for argument
IMAP DEBUG 11:27:02 7/8:
IMAP DEBUG 11:27:02 7/8: 00000005 NO APPEND failed: Not a UNIX-format
mailbox: inbox
IMAP 11:27:02 7/8 mm_log ERROR: APPEND failed: Not a UNIX-format mailbox:
inbox
FAILED save of msg 76 (c-client sequence #)
IMAP DEBUG 11:27:13 7/8: 00000006 APPEND saved-messages () "18-Mar-2002
10:10:09 -0700" {756}
IMAP DEBUG 11:27:13 7/8: + Ready for argument
IMAP DEBUG 11:27:13 7/8:
IMAP DEBUG 11:27:14 7/8: 00000006 OK APPEND completed
MAIL_CMD: quit

---

From: Mark Crispin <[email-masked]>
Date: Mon, 8 Jul 2002 19:11:21 -0700 (Pacific Daylight Time)

> mbox otherwise.   Appends to other folders fine.

To clarify:

The user can not create a file owned by him/her on /var/spool/mail?

If there is also no mbox file in the user's home directory, I can believe
that you might get a mysterious error like this.  c-client never creates
an mbox file.

-- Mark --

---

From: Deb Teale <[email-masked]>
Date: Tue, 09 Jul 2002 10:34:54 -0600

> The user can not create a file owned by him/her on /var/spool/mail?

Don't want the user to create a file in /var/spool/mail.  Want imap to skip this if
it doesn't exist and go right to the mbox.

> that you might get a mysterious error like this.  c-client never creates

The mbox exists, is readable, etc, but is not appendable.  Probably due to the
condition that it tries to append /var/spool/mail instead.   Want it to skip that
part if it can't find it there and go right to the mbox I guess is what I am looking
for.

---

From: Mark Crispin <[email-masked]>
Date: Tue, 9 Jul 2002 10:32:10 -0700 (Pacific Daylight Time)

On Tue, 9 Jul 2002, Deb Teale wrote:
> Don't want the user to create a file in /var/spool/mail.  Want imap to
> skip this if it doesn't exist and go right to the mbox.

You'll have to modify some code.  c-client does not support the
environment you want; therefore you must modify it to do so.  You have a
non-standard environment.

By definition, INBOX always exists and is appendable.  mbox is *never*
created by c-client (and people would be very angry if it was); it must be
explicitly created by some external entity.  Therefore, if mbox does not
exist, c-client must append to the file in /var/spool/mail, creating it if
necessary.

> The mbox exists, is readable, etc, but is not appendable.

Why is that?

In any case, the environment that you describe is non-standard, and
c-client does not support it out of the box.  The only way to support it
is to modify c-client.  Fortunately, you have sources.  Unfortunately, the
modifications aren't going to be as trivial as changing a single line
someplace.

-- Mark --

---

From: Deb Teale <[email-masked]>
Date: Tue, 09 Jul 2002 14:05:03 -0600

> > The mbox exists, is readable, etc, but is not appendable.

I guess I was confirming whether indeed the operation was non-standard or just
overlooked.  In the case of reading mail, IMAP goes to the mbox (always
exists) when it find no spool entry, but in the case of appending it isn't
doing that--it stops with that error and I guess I was looking for an answer
to where that might be fixable.

Deb

---

From: Mark Crispin <[email-masked]>
Date: Wed, 10 Jul 2002 20:44:49 -0700 (Pacific Daylight Time)

> to where that might be fixable.

Let's back up a moment.

Are you saying that the mbox file is write-locked?  If so, how do you
expect writes to work to it?

If you are saying that appends to a write-enabled mbox don't work, I can't
reproduce that problem.

-- Mark --