multiple users sharing a mailbox
Piet Ruyssinck
Piet.Ruyssinck at rug.ac.be
Thu Feb 13 03:06:17 EST 2003
As a quick hack, I replaced auth_getpwent.c in the saslauthd source code
with the following code :
#include "mechanisms.h"
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#define RETURN(x) return strdup(x)
#define CYRPASSWD "/etc/cyrpasswd"
char *auth_getpwent (const char *login,
const char *password,
const char *service __attribute__((unused)),
const char *realm __attribute__((unused))) {
FILE *fptr;
int OK = 0;
if (fptr = fopen (CYRPASSWD, "r")) {
char buffer [1024];
while (fgets (buffer, 1024, fptr)) {
int eol = 0;
char *p;
for (p = buffer; *p && *p != ':' && *p != '\n'; p++);
if (*p == '\0' || *p == '\n')
eol = 1;
*p = '\0';
if (!eol) {
if (strcmp (buffer, login) == 0) {
char *q;
while (!eol) {
p++;
for (q = p; *q && *q != ':' && *q != '\n'; q++);
if (*q == '\0' || *q == '\n')
eol = 1;
*q = '\0';
if (strcmp (p, (char *) crypt (password, p)) == 0) {
OK = 1;
eol = 1;
}
p = q;
}
}
}
}
fclose (fptr);
}
if (OK)
RETURN ("OK");
RETURN ("NO");
}
This allows me to authenticate against the entries in the file /etc/cyrpasswd.
This file can contain multiple passwords for each account. e.g. :
# cat /etc/cyrpasswd (all entries are fake)
bill:EYoCf4XigIZ6w
john:uUb3fyLD49SL2
peter:HOMwYGfZuUv02
carol:hcvhHC1RM2Q5Y
beth:RwQqf7n3w9sUc
helpdesk:HOMwYGfZuUv02:RwQqf7n3w9sUc
dick:EYoCf1XkgIZ6w
All users have their own personal mailbox, but both peter and beth have
access to the helpdesk mailbox, using their personal password.
We had tried before to share the helpdesk mailbox to peter and beth, who
would then see it under "Other users". But the problem there is that the
sender address on all outgoing mail would still be the personal address.
Specifying 'helpdesk' as the sender address necessitates an awkward
configuration of the client, if possible at all.
With /etc/cyrpasswd approach, they can just define two distict e-mail
accounts in their client. And without having to remember a second,
shared, password - which is important for us.
--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Piet RUYSSINCK e-mail: Piet.Ruyssinck at rug.ac.be
Unix Systeem Administratie DICT tel: +32 9 264 4733
Directie Informatie- en Communicatietechnologie fax: +32 9 264 4994
Universiteit Gent (RUG) Krijgslaan 281, gebouw S9 - 9000 Gent, Belgie
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Please avoid sending me Word or PowerPoint attachments
See http://www.fsf.org/philosophy/no-word-attachments.html
More information about the Info-cyrus
mailing list