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
c11f1eac
...
c11f1eac143a6685d43c0d0029e2b96bf0546b78
authored
2003-10-13 12:54:40 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(options): New option --permissions allows to override default permissions on the database file.
1 parent
54b4b266
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
pop3d/popauth.c
pop3d/popauth.c
View file @
c11f1ea
...
...
@@ -28,6 +28,8 @@ int db_make (char *input_name, char *output_name);
#define ACT_LIST 3
#define ACT_CHPASS 4
static
int
permissions
=
0600
;
struct
action_data
{
int
action
;
char
*
input_name
;
...
...
@@ -80,6 +82,7 @@ static struct argp_option options[] =
{
"output"
,
'o'
,
N_
(
"FILE"
),
0
,
N_
(
"Direct output to file"
),
3
},
{
"password"
,
'p'
,
N_
(
"STRING"
),
0
,
N_
(
"Specify user's password"
),
3
},
{
"user"
,
'u'
,
N_
(
"USERNAME"
),
0
,
N_
(
"Specify user name"
),
3
},
{
"permissions"
,
'P'
,
N_
(
"PERM"
),
0
,
N_
(
"Force given permissions on the database"
),
3
},
{
NULL
,
}
};
...
...
@@ -98,6 +101,24 @@ static const char *popauth_argp_capa[] = {
NULL
};
static
void
set_db_perms
(
struct
argp_state
*
astate
,
char
*
opt
,
int
*
pperm
)
{
int
perm
=
0
;
if
(
isdigit
(
opt
[
0
]))
{
char
*
p
;
perm
=
strtoul
(
opt
,
&
p
,
8
);
if
(
*
p
)
{
argp_error
(
astate
,
_
(
"invalid octal number: %s"
),
opt
);
exit
(
1
);
}
}
*
pperm
=
perm
;
}
static
error_t
popauth_parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
astate
)
{
...
...
@@ -150,6 +171,10 @@ popauth_parse_opt (int key, char *arg, struct argp_state *astate)
ap
->
username
=
optarg
;
break
;
case
'P'
:
set_db_perms
(
astate
,
optarg
,
&
permissions
);
break
;
case
ARGP_KEY_FINI
:
if
(
ap
->
action
==
-
1
)
{
...
...
@@ -159,7 +184,8 @@ popauth_parse_opt (int key, char *arg, struct argp_state *astate)
else
ap
->
action
=
ACT_CHPASS
;
}
break
;
default:
return
ARGP_ERR_UNKNOWN
;
}
...
...
@@ -206,7 +232,7 @@ check_user_perm (int action, struct action_data *ap)
if
(
ap
->
action
==
ACT_ADD
)
{
DBM_FILE
db
;
if
(
mu_dbm_open
(
ap
->
input_name
,
&
db
,
MU_STREAM_CREAT
,
0600
))
if
(
mu_dbm_open
(
ap
->
input_name
,
&
db
,
MU_STREAM_CREAT
,
permissions
))
{
mu_error
(
_
(
"can't create %s: %s"
),
ap
->
input_name
,
mu_strerror
(
errno
));
...
...
@@ -253,7 +279,7 @@ action_list (struct action_data *ap)
DBM_DATUM
contents
;
check_user_perm
(
ACT_LIST
,
ap
);
if
(
mu_dbm_open
(
ap
->
input_name
,
&
db
,
MU_STREAM_READ
,
0600
))
if
(
mu_dbm_open
(
ap
->
input_name
,
&
db
,
MU_STREAM_READ
,
permissions
))
{
mu_error
(
_
(
"can't open %s: %s"
),
ap
->
input_name
,
mu_strerror
(
errno
));
return
1
;
...
...
@@ -338,7 +364,7 @@ action_create (struct action_data *ap)
if
(
!
ap
->
output_name
)
ap
->
output_name
=
APOP_PASSFILE
;
if
(
mu_dbm_open
(
ap
->
output_name
,
&
db
,
MU_STREAM_CREAT
,
0600
))
if
(
mu_dbm_open
(
ap
->
output_name
,
&
db
,
MU_STREAM_CREAT
,
permissions
))
{
mu_error
(
_
(
"can't create %s: %s"
),
ap
->
output_name
,
mu_strerror
(
errno
));
return
1
;
...
...
@@ -398,7 +424,7 @@ open_io (int action, struct action_data *ap, DBM_FILE *db, int *not_owner)
int
rc
=
check_user_perm
(
action
,
ap
);
if
(
not_owner
)
*
not_owner
=
rc
;
if
(
mu_dbm_open
(
ap
->
input_name
,
db
,
MU_STREAM_RDWR
,
0600
))
if
(
mu_dbm_open
(
ap
->
input_name
,
db
,
MU_STREAM_RDWR
,
permissions
))
{
mu_error
(
_
(
"can't open %s: %s"
),
ap
->
input_name
,
mu_strerror
(
errno
));
return
1
;
...
...
Please
register
or
sign in
to post a comment