Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
28e55af0
...
28e55af09e0b54a468abc8983d19b47bb0c76d60
authored
2001-08-30 00:02:06 +0000
by
Jakob Kaivo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add virtual domain support
1 parent
0edae243
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
10 deletions
imap4d/copy.c
imap4d/imap4d.h
imap4d/login.c
imap4d/select.c
imap4d/status.c
imap4d/copy.c
View file @
28e55af
...
...
@@ -73,7 +73,7 @@ imap4d_copy0 (char *arg, int isuid, char *resp, size_t resplen)
return
RESP_BAD
;
}
if
(
strcasecmp
(
name
,
"INBOX"
)
==
0
)
if
(
strcasecmp
(
name
,
"INBOX"
)
==
0
&&
!
is_virtual
)
{
struct
passwd
*
pw
=
getpwuid
(
getuid
());
mailbox_name
=
strdup
((
pw
)
?
pw
->
pw_name
:
""
);
...
...
imap4d/imap4d.h
View file @
28e55af
...
...
@@ -149,6 +149,7 @@ extern char *homedir;
extern
char
*
rootdir
;
extern
int
state
;
extern
volatile
size_t
children
;
extern
int
is_virtual
;
/* Imap4 commands */
extern
int
imap4d_append
__P
((
struct
imap4d_command
*
,
char
*
));
...
...
imap4d/login.c
View file @
28e55af
...
...
@@ -21,6 +21,40 @@
#include "../MySql/MySql.h"
#endif
int
is_virtual
=
0
;
#ifdef USE_VIRTUAL_DOMAINS
static
struct
passwd
*
imap4d_virtual
(
const
char
*
u
)
{
struct
passwd
*
pw
;
FILE
*
pfile
;
int
i
=
0
,
len
=
strlen
(
u
),
delim
=
0
;
for
(
i
=
0
;
i
<
len
&&
delim
==
0
;
i
++
)
if
(
u
[
i
]
==
'!'
||
u
[
i
]
==
':'
||
u
[
i
]
==
'@'
)
delim
=
i
;
if
(
delim
==
0
)
return
NULL
;
chdir
(
"/etc/domains"
);
pfile
=
fopen
(
&
u
[
delim
+
1
],
"r"
);
while
(
pfile
!=
NULL
&&
(
pw
=
fgetpwent
(
pfile
))
!=
NULL
)
{
if
(
strlen
(
pw
->
pw_name
)
==
delim
&&
!
strncmp
(
u
,
pw
->
pw_name
,
delim
))
{
is_virtual
=
1
;
return
pw
;
}
}
return
NULL
;
}
#endif
/*
* FIXME: this should support PAM, shadow, and normal password
*/
...
...
@@ -107,14 +141,16 @@ imap4d_login (struct imap4d_command *command, char *arg)
pw
=
getpwnam
(
username
);
if
(
pw
==
NULL
)
#ifdef HAVE_MYSQL
{
pw
=
getMpwnam
(
username
);
if
(
pw
==
NULL
)
return
util_finish
(
command
,
RESP_NO
,
"User name or passwd rejected"
);
}
#else
/* HAVE_MYSQL */
return
util_finish
(
command
,
RESP_NO
,
"User name or passwd rejected"
);
if
(
pw
==
NULL
)
#endif
/* HAVE_MYSQL */
#ifdef USE_VIRTUAL_DOMAINS
pw
=
imap4d_virtual
(
username
);
if
(
pw
==
NULL
)
#endif
/* USE_VIRTUAL_DOMAINS */
return
util_finish
(
command
,
RESP_NO
,
"User name or passwd rejected"
);
#ifndef USE_LIBPAM
if
(
pw
->
pw_uid
<
1
)
...
...
@@ -154,7 +190,7 @@ imap4d_login (struct imap4d_command *command, char *arg)
openlog
(
"gnu-imap4d"
,
LOG_PID
,
LOG_MAIL
);
#endif
/* USE_LIBPAM */
if
(
pw
->
pw_uid
>
1
)
if
(
pw
->
pw_uid
>
0
&&
!
is_virtual
)
setuid
(
pw
->
pw_uid
);
homedir
=
util_normalize_path
(
strdup
(
pw
->
pw_dir
),
"/"
);
...
...
imap4d/select.c
View file @
28e55af
...
...
@@ -57,7 +57,7 @@ imap4d_select0 (struct imap4d_command *command, char *arg, int flags)
imap4d_sync
();
}
if
(
strcasecmp
(
mailbox_name
,
"INBOX"
)
==
0
)
if
(
strcasecmp
(
mailbox_name
,
"INBOX"
)
==
0
&&
!
is_virtual
)
{
pw
=
getpwuid
(
getuid
());
if
(
pw
)
...
...
imap4d/status.c
View file @
28e55af
...
...
@@ -45,7 +45,7 @@ imap4d_status (struct imap4d_command *command, char *arg)
if
(
!
name
||
*
name
==
'\0'
||
!
sp
||
*
sp
==
'\0'
)
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
if
(
strcasecmp
(
name
,
"INBOX"
)
==
0
)
if
(
strcasecmp
(
name
,
"INBOX"
)
==
0
&&
!
is_virtual
)
{
struct
passwd
*
pw
=
getpwuid
(
getuid
());
mailbox_name
=
strdup
((
pw
)
?
pw
->
pw_name
:
""
);
...
...
Please
register
or
sign in
to post a comment