~ubuntu-branches/debian/sid/postfix/sid

« back to all changes in this revision

Viewing changes to src/util/dict_dbm.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2012-03-20 13:47:16 UTC
  • mfrom: (1.1.34) (39.1.16 trunk)
  • Revision ID: package-import@ubuntu.com-20120320134716-o62kosz3odzt1rh6
Tags: 2.9.1-2
Drop unnecessary openssl check, since sonames will save us.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
#include "stringops.h"
61
61
#include "dict.h"
62
62
#include "dict_dbm.h"
 
63
#include "warn_stat.h"
63
64
 
64
65
/* Application-specific. */
65
66
 
82
83
    datum   dbm_value;
83
84
    const char *result = 0;
84
85
 
 
86
    dict->error = 0;
 
87
 
85
88
    /*
86
89
     * Sanity check.
87
90
     */
88
91
    if ((dict->flags & (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL)) == 0)
89
92
        msg_panic("dict_dbm_lookup: no DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL flag");
90
93
 
91
 
    dict_errno = 0;
92
 
 
93
94
    /*
94
95
     * Optionally fold the key.
95
96
     */
147
148
 
148
149
/* dict_dbm_update - add or update database entry */
149
150
 
150
 
static void dict_dbm_update(DICT *dict, const char *name, const char *value)
 
151
static int dict_dbm_update(DICT *dict, const char *name, const char *value)
151
152
{
152
153
    DICT_DBM *dict_dbm = (DICT_DBM *) dict;
153
154
    datum   dbm_key;
154
155
    datum   dbm_value;
155
156
    int     status;
156
157
 
 
158
    dict->error = 0;
 
159
 
157
160
    /*
158
161
     * Sanity check.
159
162
     */
169
172
        vstring_strcpy(dict->fold_buf, name);
170
173
        name = lowercase(vstring_str(dict->fold_buf));
171
174
    }
172
 
 
173
175
    dbm_key.dptr = (void *) name;
174
176
    dbm_value.dptr = (void *) value;
175
177
    dbm_key.dsize = strlen(name);
224
226
    if ((dict->flags & DICT_FLAG_LOCK)
225
227
        && myflock(dict->lock_fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
226
228
        msg_fatal("%s: unlock dictionary: %m", dict_dbm->dict.name);
 
229
 
 
230
    return (status);
227
231
}
228
232
 
229
233
/* dict_dbm_delete - delete one entry from the dictionary */
234
238
    datum   dbm_key;
235
239
    int     status = 1;
236
240
 
 
241
    dict->error = 0;
 
242
 
237
243
    /*
238
244
     * Sanity check.
239
245
     */
312
318
    datum   dbm_value;
313
319
    int     status;
314
320
 
 
321
    dict->error = 0;
 
322
 
315
323
    /*
316
324
     * Acquire a shared lock.
317
325
     */
423
431
    if (dict_flags & DICT_FLAG_LOCK) {
424
432
        dbm_path = concatenate(path, ".dir", (char *) 0);
425
433
        if ((lock_fd = open(dbm_path, open_flags, 0644)) < 0)
426
 
            msg_fatal("open database %s: %m", dbm_path);
 
434
            return (dict_surrogate(DICT_TYPE_DBM, path, open_flags, dict_flags,
 
435
                                   "open database %s: %m", dbm_path));
427
436
        if (myflock(lock_fd, INTERNAL_LOCK, MYFLOCK_OP_SHARED) < 0)
428
437
            msg_fatal("shared-lock database %s for open: %m", dbm_path);
429
438
    }
432
441
     * XXX SunOS 5.x has no const in dbm_open() prototype.
433
442
     */
434
443
    if ((dbm = dbm_open((char *) path, open_flags, 0644)) == 0)
435
 
        msg_fatal("open database %s.{dir,pag}: %m", path);
 
444
        return (dict_surrogate(DICT_TYPE_DBM, path, open_flags, dict_flags,
 
445
                               "open database %s.{dir,pag}: %m", path));
436
446
 
437
447
    if (dict_flags & DICT_FLAG_LOCK) {
438
448
        if (myflock(lock_fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
453
463
    if (fstat(dict_dbm->dict.stat_fd, &st) < 0)
454
464
        msg_fatal("dict_dbm_open: fstat: %m");
455
465
    dict_dbm->dict.mtime = st.st_mtime;
 
466
    dict_dbm->dict.owner.uid = st.st_uid;
 
467
    dict_dbm->dict.owner.status = (st.st_uid != 0);
456
468
 
457
469
    /*
458
470
     * Warn if the source file is newer than the indexed file, except when