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
266326ed
...
266326edae58d3dd7542534859a5c26c57c3b7ac
authored
2001-11-11 07:49:42 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Bunch of changes due to introduction of new DBM interface.
1 parent
01865aec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
48 deletions
pop3d/apop.c
pop3d/pop3d.h
pop3d/apop.c
View file @
266326e
...
...
@@ -41,76 +41,73 @@
/* Check if a username exists in APOP password file
returns pointer to password if found, otherwise NULL */
char
*
pop3d_apopuser
(
const
char
*
user
)
{
char
*
password
;
int
rc
;
char
buf
[
POP_MAXCMDLEN
];
struct
stat
st
;
/* Check the mode, for security reasons. */
#ifdef WITH_BDB2
if
(
stat
(
APOP_PASSFILE
".db"
,
&
st
)
!=
-
1
)
#else
if
(
stat
(
APOP_PASSFILE
".passwd"
,
&
st
)
!=
-
1
)
#endif
if
((
st
.
st_mode
&
0777
)
!=
0600
)
{
syslog
(
LOG_INFO
,
"Bad permissions on APOP password file"
);
return
NULL
;
}
#ifdef WITH_BDB2
#ifdef USE_DBM
{
int
status
;
DB
*
dbp
;
DBT
key
,
data
;
status
=
db_open
(
APOP_PASSFILE
".db"
,
DB_HASH
,
DB_RDONLY
,
0600
,
NULL
,
NULL
,
&
dbp
);
if
(
status
!=
0
)
DBM_FILE
db
;
DBM_DATUM
key
,
data
;
rc
=
mu_dbm_open
(
APOP_PASSFILE
,
&
db
,
MU_STREAM_READ
,
0600
);
if
(
rc
)
{
syslog
(
LOG_ERR
,
"Unable to open APOP db: %s"
,
strerror
(
status
));
if
(
rc
==
-
1
)
syslog
(
LOG_INFO
,
"Bad permissions on APOP password db"
);
else
syslog
(
LOG_ERR
,
"Unable to open APOP db: %s"
,
strerror
(
rc
));
return
NULL
;
}
memset
(
&
key
,
0
,
sizeof
DBT
);
memset
(
&
data
,
0
,
sizeof
DBT
);
memset
(
&
key
,
0
,
sizeof
key
);
memset
(
&
data
,
0
,
sizeof
data
);
strncpy
(
buf
,
user
,
sizeof
buf
);
/* strncpy () is lame and does not NULL terminate. */
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
key
.
data
=
buf
;
key
.
size
=
strlen
(
buf
);
status
=
dbp
->
get
(
dbp
,
NULL
,
&
key
,
&
data
,
0
);
if
(
status
!=
0
)
{
syslog
(
LOG_ERR
,
"db_get error: %s"
,
strerror
(
status
));
dbp
->
close
(
dbp
,
0
);
return
NULL
;
}
MU_DATUM_PTR
(
key
)
=
buf
;
MU_DATUM_SIZE
(
key
)
=
strlen
(
buf
);
password
=
calloc
(
data
.
size
+
1
,
sizeof
(
*
password
));
if
(
password
==
NULL
)
rc
=
mu_dbm_fetch
(
db
,
key
,
&
data
);
mu_dbm_close
(
db
);
if
(
rc
)
{
dbp
->
close
(
dbp
,
0
);
syslog
(
LOG_ERR
,
"Can't fetch APOP data: %s"
,
strerror
(
rc
)
);
return
NULL
;
}
password
=
calloc
(
MU_DATUM_SIZE
(
data
)
+
1
,
sizeof
(
*
password
));
if
(
password
==
NULL
)
return
NULL
;
sprintf
(
password
,
"%.*s"
,
(
int
)
data
.
size
,
(
char
*
)
data
.
data
);
dbp
->
close
(
dbp
,
0
);
sprintf
(
password
,
"%.*s"
,
(
char
*
)
MU_DATUM_SIZE
(
data
),
(
int
)
MU_DATUM_PTR
(
data
)
);
return
password
;
}
#else
/* !
WITH_BDBD2
*/
#else
/* !
USE_DBM
*/
{
char
*
tmp
;
FILE
*
apop_file
;
apop_file
=
fopen
(
APOP_PASSFILE
".passwd"
,
"r"
);
if
(
mu_check_perm
(
APOP_PASSFILE
,
0600
))
{
syslog
(
LOG_INFO
,
"Bad permissions on APOP password file"
);
return
NULL
;
}
apop_file
=
fopen
(
APOP_PASSFILE
,
"r"
);
if
(
apop_file
==
NULL
)
{
syslog
(
LOG_INFO
,
"Unable to open APOP password file"
);
syslog
(
LOG_INFO
,
"Unable to open APOP password file %s"
,
strerror
(
errno
));
return
NULL
;
}
password
=
calloc
(
APOP_DIGEST
,
sizeof
(
*
password
));
if
(
password
==
NULL
)
{
...
...
@@ -146,7 +143,7 @@ pop3d_apopuser (const char *user)
return
password
;
}
#endif
/* WITH_BDB2 */
#endif
}
int
...
...
pop3d/pop3d.h
View file @
266326e
...
...
@@ -17,9 +17,11 @@
#ifndef _POP3D_H
#define _POP3D_H 1
#ifdef HAVE_CONFIG_H
# include
"config.h"
# include
<config.h>
#endif
#include <mu_dbm.h>
/* The implementation */
#define IMPL "GNU POP3 Daemon"
...
...
@@ -58,7 +60,13 @@
/* APOP password file, without .db or .passwd, which are added based on file
type automatically */
#define APOP_PASSFILE SYSCONFDIR"/apop"
#define APOP_PASSFILE_NAME "apop"
#ifdef USE_DBM
# define APOP_PASSFILE SYSCONFDIR "/" APOP_PASSFILE_NAME
#else
# define APOP_PASSFILE SYSCONFDIR "/" APOP_PASSFILE_NAME ".passwd"
#endif
/* Size of the MD5 digest for APOP */
#define APOP_DIGEST 70
...
...
@@ -69,7 +77,9 @@
/* Buffer size to use for output */
#define BUFFERSIZE 1024
#define _GNU_SOURCE
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#define _QNX_SOURCE
#include <stdarg.h>
#include <stdio.h>
...
...
@@ -104,8 +114,8 @@
#include <mailutils/header.h>
#include <mailutils/body.h>
#include <mailutils/registrar.h>
#include <mailutils/mutil.h>
#include <mailutils/error.h>
#include <mailutils/mutil.h>
/* For Berkley DB2 APOP password file */
#ifdef HAVE_DB_H
...
...
Please
register
or
sign in
to post a comment