summaryrefslogtreecommitdiff
path: root/pop3d
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-10-13 12:54:40 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-10-13 12:54:40 +0000
commitc11f1eac143a6685d43c0d0029e2b96bf0546b78 (patch)
treeb78b0379c2b0220b0c5eee61ab5d5c08f9641101 /pop3d
parent54b4b2665a42e9a5b7fe43e495c6a0c2b595f06d (diff)
downloadmailutils-c11f1eac143a6685d43c0d0029e2b96bf0546b78.tar.gz
mailutils-c11f1eac143a6685d43c0d0029e2b96bf0546b78.tar.bz2
(options): New option --permissions allows to override default permissions on the database file.
Diffstat (limited to 'pop3d')
-rw-r--r--pop3d/popauth.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/pop3d/popauth.c b/pop3d/popauth.c
index cef617794..b1418d2fa 100644
--- a/pop3d/popauth.c
+++ b/pop3d/popauth.c
@@ -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;

Return to:

Send suggestions and report system problems to the System administrator.