/[mailutils]/mailutils/pop3d/logindelay.c
ViewVC logotype

Diff of /mailutils/pop3d/logindelay.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by gray, Sat Oct 11 10:58:50 2003 UTC revision 1.2 by gray, Mon Oct 13 12:38:12 2003 UTC
# Line 22  Line 22 
22  static int  static int
23  open_stat_db (DBM_FILE *db, int mode)  open_stat_db (DBM_FILE *db, int mode)
24  {  {
25    int rc = mu_dbm_open (login_stat_file, db, mode, 0600);    int rc = mu_dbm_open (login_stat_file, db, mode, 0660);
26    if (rc)    if (rc)
27      {      {
28        if (rc == -1)        if (rc == -1)
# Line 47  check_login_delay (char *username) Line 47  check_login_delay (char *username)
47      return 0;      return 0;
48        
49    time (&now);    time (&now);
50    if (open_stat_db (&db, MU_STREAM_READ))    if (open_stat_db (&db, MU_STREAM_RDWR))
51      return 0;      return 0;
52        
53      memset (&key, 0, sizeof key);
54    MU_DATUM_PTR(key) = username;    MU_DATUM_PTR(key) = username;
55    MU_DATUM_SIZE(key) = strlen (username);    MU_DATUM_SIZE(key) = strlen (username);
56    memset (&data, 0, sizeof data);    memset (&data, 0, sizeof data);
57    
58    rc = mu_dbm_fetch (db, key, &data);    rc = mu_dbm_fetch (db, key, &data);
   mu_dbm_close (db);  
59    if (rc)    if (rc)
60      {      {
61        syslog (LOG_ERR, _("Can't fetch APOP data: %s"), mu_strerror (rc));        syslog (LOG_ERR, _("Can't fetch APOP data: %s"), mu_strerror (rc));
62          mu_dbm_close (db);
63        return 0;        return 0;
64      }      }
65    
# Line 66  check_login_delay (char *username) Line 67  check_login_delay (char *username)
67      {      {
68        syslog (LOG_ERR, _("Invalid entry for '%s': wrong timestamp size"),        syslog (LOG_ERR, _("Invalid entry for '%s': wrong timestamp size"),
69                username);                username);
70          mu_dbm_close (db);
71        return 0;        return 0;
72      }      }
73    
74    memcpy (text, MU_DATUM_PTR(data), MU_DATUM_SIZE(data));    memcpy (text, MU_DATUM_PTR(data), MU_DATUM_SIZE(data));
75    text[MU_DATUM_SIZE(data)] = 0;    text[MU_DATUM_SIZE(data)] = 0;
76      mu_dbm_close (db);
77    
78    prev_time = strtoul (text, &p, 0);    prev_time = strtoul (text, &p, 0);
79    if (*p)    if (*p)
# Line 98  update_login_delay (char *username) Line 101  update_login_delay (char *username)
101    if (open_stat_db (&db, MU_STREAM_RDWR))    if (open_stat_db (&db, MU_STREAM_RDWR))
102      return;      return;
103        
104      memset(&key, 0, sizeof(key));
105      memset(&data, 0, sizeof(data));
106    MU_DATUM_PTR(key) = username;    MU_DATUM_PTR(key) = username;
107    MU_DATUM_SIZE(key) = strlen (username);    MU_DATUM_SIZE(key) = strlen (username);
108    snprintf (text, sizeof text, "%lu", (unsigned long) now);    snprintf (text, sizeof text, "%lu", (unsigned long) now);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26