~ubuntu-branches/ubuntu/vivid/postfix/vivid-proposed

« back to all changes in this revision

Viewing changes to src/util/dict_unix.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2012-03-20 13:47:16 UTC
  • mfrom: (1.1.33)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20120320134716-v7ab94fmor2z9pvp
Tags: upstream-2.9.1
ImportĀ upstreamĀ versionĀ 2.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    static VSTRING *buf;
70
70
    static int sanity_checked;
71
71
 
72
 
    dict_errno = 0;
 
72
    dict->error = 0;
73
73
 
74
74
    /*
75
75
     * Optionally fold the key.
86
86
            errno = 0;
87
87
            if (getpwuid(0) == 0) {
88
88
                msg_warn("cannot access UNIX password database: %m");
89
 
                dict_errno = DICT_ERR_RETRY;
 
89
                dict->error = DICT_ERR_RETRY;
90
90
            }
91
91
        }
92
92
        return (0);
111
111
    char  **cpp;
112
112
    static int sanity_checked;
113
113
 
114
 
    dict_errno = 0;
 
114
    dict->error = 0;
115
115
 
116
116
    /*
117
117
     * Optionally fold the key.
128
128
            errno = 0;
129
129
            if (getgrgid(0) == 0) {
130
130
                msg_warn("cannot access UNIX group database: %m");
131
 
                dict_errno = DICT_ERR_RETRY;
 
131
                dict->error = DICT_ERR_RETRY;
132
132
            }
133
133
        }
134
134
        return (0);
159
159
 
160
160
/* dict_unix_open - open UNIX map */
161
161
 
162
 
DICT   *dict_unix_open(const char *map, int unused_flags, int dict_flags)
 
162
DICT   *dict_unix_open(const char *map, int open_flags, int dict_flags)
163
163
{
164
164
    DICT_UNIX *dict_unix;
165
165
    struct dict_unix_lookup {
173
173
    };
174
174
    struct dict_unix_lookup *lp;
175
175
 
176
 
    dict_errno = 0;
 
176
    /*
 
177
     * Sanity checks.
 
178
     */
 
179
    if (open_flags != O_RDONLY)
 
180
        return (dict_surrogate(DICT_TYPE_UNIX, map, open_flags, dict_flags,
 
181
                               "%s:%s map requires O_RDONLY access mode",
 
182
                               DICT_TYPE_UNIX, map));
177
183
 
178
 
    dict_unix = (DICT_UNIX *) dict_alloc(DICT_TYPE_UNIX, map,
179
 
                                         sizeof(*dict_unix));
 
184
    /*
 
185
     * "Open" the database.
 
186
     */
180
187
    for (lp = dict_unix_lookup; /* void */ ; lp++) {
181
188
        if (lp->name == 0)
182
 
            msg_fatal("dict_unix_open: unknown map name: %s", map);
 
189
            return (dict_surrogate(DICT_TYPE_UNIX, map, open_flags, dict_flags,
 
190
                              "unknown table: %s:%s", DICT_TYPE_UNIX, map));
183
191
        if (strcmp(map, lp->name) == 0)
184
192
            break;
185
193
    }
 
194
    dict_unix = (DICT_UNIX *) dict_alloc(DICT_TYPE_UNIX, map,
 
195
                                         sizeof(*dict_unix));
186
196
    dict_unix->dict.lookup = lp->lookup;
187
197
    dict_unix->dict.close = dict_unix_close;
188
198
    dict_unix->dict.flags = dict_flags | DICT_FLAG_FIXED;
189
199
    if (dict_flags & DICT_FLAG_FOLD_FIX)
190
200
        dict_unix->dict.fold_buf = vstring_alloc(10);
 
201
    dict_unix->dict.owner.status = DICT_OWNER_TRUSTED;
191
202
 
192
203
    return (DICT_DEBUG (&dict_unix->dict));
193
204
}