Couple of bugfixes
Showing
1 changed file
with
8 additions
and
3 deletions
... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
22 | static int | 22 | static int |
23 | open_stat_db (DBM_FILE *db, int mode) | 23 | open_stat_db (DBM_FILE *db, int mode) |
24 | { | 24 | { |
25 | int rc = mu_dbm_open (login_stat_file, db, mode, 0600); | 25 | int rc = mu_dbm_open (login_stat_file, db, mode, 0660); |
26 | if (rc) | 26 | if (rc) |
27 | { | 27 | { |
28 | if (rc == -1) | 28 | if (rc == -1) |
... | @@ -47,18 +47,19 @@ check_login_delay (char *username) | ... | @@ -47,18 +47,19 @@ check_login_delay (char *username) |
47 | return 0; | 47 | return 0; |
48 | 48 | ||
49 | time (&now); | 49 | time (&now); |
50 | if (open_stat_db (&db, MU_STREAM_READ)) | 50 | if (open_stat_db (&db, MU_STREAM_RDWR)) |
51 | return 0; | 51 | return 0; |
52 | 52 | ||
53 | memset (&key, 0, sizeof key); | ||
53 | MU_DATUM_PTR(key) = username; | 54 | MU_DATUM_PTR(key) = username; |
54 | MU_DATUM_SIZE(key) = strlen (username); | 55 | MU_DATUM_SIZE(key) = strlen (username); |
55 | memset (&data, 0, sizeof data); | 56 | memset (&data, 0, sizeof data); |
56 | 57 | ||
57 | rc = mu_dbm_fetch (db, key, &data); | 58 | rc = mu_dbm_fetch (db, key, &data); |
58 | mu_dbm_close (db); | ||
59 | if (rc) | 59 | if (rc) |
60 | { | 60 | { |
61 | syslog (LOG_ERR, _("Can't fetch APOP data: %s"), mu_strerror (rc)); | 61 | syslog (LOG_ERR, _("Can't fetch APOP data: %s"), mu_strerror (rc)); |
62 | mu_dbm_close (db); | ||
62 | return 0; | 63 | return 0; |
63 | } | 64 | } |
64 | 65 | ||
... | @@ -66,11 +67,13 @@ check_login_delay (char *username) | ... | @@ -66,11 +67,13 @@ check_login_delay (char *username) |
66 | { | 67 | { |
67 | syslog (LOG_ERR, _("Invalid entry for '%s': wrong timestamp size"), | 68 | syslog (LOG_ERR, _("Invalid entry for '%s': wrong timestamp size"), |
68 | username); | 69 | username); |
70 | mu_dbm_close (db); | ||
69 | return 0; | 71 | return 0; |
70 | } | 72 | } |
71 | 73 | ||
72 | memcpy (text, MU_DATUM_PTR(data), MU_DATUM_SIZE(data)); | 74 | memcpy (text, MU_DATUM_PTR(data), MU_DATUM_SIZE(data)); |
73 | text[MU_DATUM_SIZE(data)] = 0; | 75 | text[MU_DATUM_SIZE(data)] = 0; |
76 | mu_dbm_close (db); | ||
74 | 77 | ||
75 | prev_time = strtoul (text, &p, 0); | 78 | prev_time = strtoul (text, &p, 0); |
76 | if (*p) | 79 | if (*p) |
... | @@ -98,6 +101,8 @@ update_login_delay (char *username) | ... | @@ -98,6 +101,8 @@ update_login_delay (char *username) |
98 | if (open_stat_db (&db, MU_STREAM_RDWR)) | 101 | if (open_stat_db (&db, MU_STREAM_RDWR)) |
99 | return; | 102 | return; |
100 | 103 | ||
104 | memset(&key, 0, sizeof(key)); | ||
105 | memset(&data, 0, sizeof(data)); | ||
101 | MU_DATUM_PTR(key) = username; | 106 | MU_DATUM_PTR(key) = username; |
102 | MU_DATUM_SIZE(key) = strlen (username); | 107 | MU_DATUM_SIZE(key) = strlen (username); |
103 | snprintf (text, sizeof text, "%lu", (unsigned long) now); | 108 | snprintf (text, sizeof text, "%lu", (unsigned long) now); | ... | ... |
-
Please register or sign in to post a comment