You are not logged in.

#1 2019-01-06 08:20:14

kde35
Member
Registered: 2015-04-13
Posts: 38

Dovecot and su [Solved]

Hi, I have dovecot and postfix servers running on archlinux as explained in archwiki.  Things do work fine except when I log in as userA and then su to userB.
After su to userB, if I issue command

mail

then I am still reading mails for userA and not for userB.  Example:

[userA@hostname ~]$ su userB
[userB@hostname userA]$ mail
mail: /var/spool/mail/userA: No such entry, file or directory
mail version v14.9.11.  Type `?' for help
(Currently no active mailbox)
No more mail.
There are new messages in the error message ring (denoted by ERROR)
  The `errors' command manages this message ring
ERROR# ? 

here, there is no mail account corresponding to userA, whence the error, but the issue is, if I change my identity to userB to read mails, then I should be able to read mails for userB and not for userA.   Is this the expected behavior of dovecot, or am I doing something wrong?

Last edited by kde35 (2019-01-06 17:17:47)

Offline

#2 2019-01-06 10:06:19

respiranto
Member
Registered: 2015-05-15
Posts: 398
Website

Re: Dovecot and su [Solved]

Most environment variables do not change, when you run `su userB', though $USER does.

Not that I would trust it to work, but try `su --login userB'.

Last edited by respiranto (2019-01-06 10:13:12)

Offline

#3 2019-01-06 14:58:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 21,098
Website

Re: Dovecot and su [Solved]

Which "mail" implementation are you using?  S-nail's mail does not use $USER if $MAIL or $MBOX are set.  If either of the latter two are set in userA's environment, su'ing to userB will still inherit that environment.  The `su` man page also strongly advises to use the above-noted --login flag for this very reason.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2019-01-06 17:17:32

kde35
Member
Registered: 2015-04-13
Posts: 38

Re: Dovecot and su [Solved]

Thank you very much, 

su --login

works.  Yes, I am using s-nail.

Offline

Board footer

Powered by FluxBB