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
83ea18f2
...
83ea18f24c9dbf255e02a4d3a6632467432be4a8
authored
2001-05-20 02:37:38 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Not to use mailbox_create_defaut.
1 parent
a9a11cf9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
32 deletions
pop3d/apop.c
pop3d/pop3d.h
pop3d/user.c
pop3d/apop.c
View file @
83ea18f
...
...
@@ -148,13 +148,14 @@ pop3d_apopuser (const char *user)
int
pop3d_apop
(
const
char
*
arg
)
{
char
*
tmp
,
*
user_digest
,
*
password
;
char
*
tmp
,
*
user_digest
,
*
user
,
*
password
;
struct
passwd
*
pw
;
char
buf
[
POP_MAXCMDLEN
];
struct
md5_ctx
md5context
;
unsigned
char
md5digest
[
16
];
int
status
;
int
lockit
=
1
;
char
*
mailbox_name
=
NULL
;
if
(
state
!=
AUTHORIZATION
)
return
ERR_WRONG_STATE
;
...
...
@@ -162,20 +163,18 @@ pop3d_apop (const char *arg)
if
(
strlen
(
arg
)
==
0
)
return
ERR_BAD_ARGS
;
user
name
=
pop3d_cmd
(
arg
);
if
(
strlen
(
user
name
)
>
(
POP_MAXCMDLEN
-
APOP_DIGEST
))
user
=
pop3d_cmd
(
arg
);
if
(
strlen
(
user
)
>
(
POP_MAXCMDLEN
-
APOP_DIGEST
))
{
free
(
username
);
username
=
NULL
;
free
(
user
);
return
ERR_BAD_ARGS
;
}
user_digest
=
pop3d_args
(
arg
);
password
=
pop3d_apopuser
(
user
name
);
password
=
pop3d_apopuser
(
user
);
if
(
password
==
NULL
)
{
free
(
username
);
username
=
NULL
;
free
(
user
);
free
(
user_digest
);
return
ERR_BAD_LOGIN
;
}
...
...
@@ -197,30 +196,26 @@ pop3d_apop (const char *arg)
if
(
strcmp
(
user_digest
,
buf
))
{
free
(
username
);
username
=
NULL
;
free
(
user
);
free
(
user_digest
);
return
ERR_BAD_LOGIN
;
}
free
(
user_digest
);
pw
=
getpwnam
(
username
);
pw
=
getpwnam
(
user
);
free
(
user
);
if
(
pw
==
NULL
)
{
free
(
username
);
username
=
NULL
;
return
ERR_BAD_LOGIN
;
}
return
ERR_BAD_LOGIN
;
/* Reset the uid. */
if
(
setuid
(
pw
->
pw_uid
)
==
-
1
)
{
free
(
username
);
username
=
NULL
;
return
ERR_BAD_LOGIN
;
}
return
ERR_BAD_LOGIN
;
mailbox_name
=
calloc
(
strlen
(
_PATH_MAILDIR
)
+
1
+
strlen
(
pw
->
pw_name
)
+
1
,
1
)
;
sprintf
(
mailbox_name
,
"%s/%s"
,
_PATH_MAILDIR
,
pw
->
pw_name
);
if
((
status
=
mailbox_create
_default
(
&
mbox
,
user
name
))
!=
0
if
((
status
=
mailbox_create
(
&
mbox
,
mailbox_
name
))
!=
0
||
(
status
=
mailbox_open
(
mbox
,
MU_STREAM_RDWR
))
!=
0
)
{
mailbox_destroy
(
&
mbox
);
...
...
@@ -230,33 +225,33 @@ pop3d_apop (const char *arg)
if
(
mailbox_create
(
&
mbox
,
"/dev/null"
)
!=
0
||
mailbox_open
(
mbox
,
MU_STREAM_READ
)
!=
0
)
{
free
(
username
);
username
=
NULL
;
free
(
mailbox_name
);
state
=
AUTHORIZATION
;
return
ERR_UNKNOWN
;
}
}
else
{
free
(
username
);
username
=
NULL
;
free
(
mailbox_name
);
state
=
AUTHORIZATION
;
return
ERR_MBOX_LOCK
;
}
lockit
=
0
;
/* Do not attempt to lock /dev/null ! */
}
free
(
mailbox_name
);
if
(
lockit
&&
pop3d_lock
())
{
mailbox_close
(
mbox
);
mailbox_destroy
(
&
mbox
);
state
=
AUTHORIZATION
;
free
(
username
);
username
=
NULL
;
return
ERR_MBOX_LOCK
;
}
state
=
TRANSACTION
;
username
=
strdup
(
pw
->
pw_name
);
if
(
username
==
NULL
)
pop3d_abquit
(
ERR_NO_MEM
);
fprintf
(
ofile
,
"+OK opened mailbox for %s
\r\n
"
,
username
);
/* mailbox name */
{
...
...
pop3d/pop3d.h
View file @
83ea18f
...
...
@@ -114,8 +114,10 @@
/* The path to the mail spool files */
#ifdef HAVE_PATHS_H
#include <paths.h>
#else
#define _PATH_MAILDIR "/usr/spool/mail"
#endif
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/usr/spool/mail"
#endif
#ifdef HAVE_SECURITY_PAM_APPL_H
...
...
pop3d/user.c
View file @
83ea18f
...
...
@@ -83,6 +83,7 @@ pop3d_user (const char *arg)
struct
passwd
*
pw
;
int
status
;
int
lockit
=
1
;
char
*
mailbox_name
;
if
(
state
!=
AUTHORIZATION
)
return
ERR_WRONG_STATE
;
...
...
@@ -179,7 +180,11 @@ pop3d_user (const char *arg)
if
(
pw
!=
NULL
&&
pw
->
pw_uid
>
1
)
setuid
(
pw
->
pw_uid
);
if
((
status
=
mailbox_create_default
(
&
mbox
,
arg
))
!=
0
mailbox_name
=
calloc
(
strlen
(
_PATH_MAILDIR
)
+
1
+
strlen
(
pw
->
pw_name
)
+
1
,
1
);
sprintf
(
mailbox_name
,
"%s/%s"
,
_PATH_MAILDIR
,
pw
->
pw_name
);
if
((
status
=
mailbox_create
(
&
mbox
,
mailbox_name
))
!=
0
||
(
status
=
mailbox_open
(
mbox
,
MU_STREAM_RDWR
))
!=
0
)
{
mailbox_destroy
(
&
mbox
);
...
...
@@ -190,16 +195,19 @@ pop3d_user (const char *arg)
||
mailbox_open
(
mbox
,
MU_STREAM_READ
)
!=
0
)
{
state
=
AUTHORIZATION
;
free
(
mailbox_name
);
return
ERR_UNKNOWN
;
}
}
else
{
state
=
AUTHORIZATION
;
free
(
mailbox_name
);
return
ERR_MBOX_LOCK
;
}
lockit
=
0
;
/* Do not attempt to lock /dev/null ! */
}
free
(
mailbox_name
);
if
(
lockit
&&
pop3d_lock
())
{
...
...
@@ -209,7 +217,7 @@ pop3d_user (const char *arg)
return
ERR_MBOX_LOCK
;
}
username
=
strdup
(
arg
);
username
=
strdup
(
pw
->
pw_name
);
if
(
username
==
NULL
)
pop3d_abquit
(
ERR_NO_MEM
);
state
=
TRANSACTION
;
...
...
Please
register
or
sign in
to post a comment