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

« back to all changes in this revision

Viewing changes to src/util/dict_cidr.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:
32
32
/* System library. */
33
33
 
34
34
#include <sys_defs.h>
 
35
#include <sys/stat.h>
35
36
#include <stdlib.h>
36
37
#include <unistd.h>
37
38
#include <string.h>
52
53
#include <myaddrinfo.h>
53
54
#include <cidr_match.h>
54
55
#include <dict_cidr.h>
 
56
#include <warn_stat.h>
55
57
 
56
58
/* Application-specific. */
57
59
 
78
80
    if (msg_verbose)
79
81
        msg_info("dict_cidr_lookup: %s: %s", dict->name, key);
80
82
 
81
 
    dict_errno = 0;
 
83
    dict->error = 0;
82
84
 
83
85
    if ((entry = (DICT_CIDR_ENTRY *)
84
86
         cidr_match_execute(&(dict_cidr->head->cidr_info), key)) != 0)
164
166
{
165
167
    DICT_CIDR *dict_cidr;
166
168
    VSTREAM *map_fp;
167
 
    VSTRING *line_buffer = vstring_alloc(100);
168
 
    VSTRING *why = vstring_alloc(100);
 
169
    struct stat st;
 
170
    VSTRING *line_buffer;
 
171
    VSTRING *why;
169
172
    DICT_CIDR_ENTRY *rule;
170
173
    DICT_CIDR_ENTRY *last_rule = 0;
171
174
    int     lineno = 0;
174
177
     * Sanity checks.
175
178
     */
176
179
    if (open_flags != O_RDONLY)
177
 
        msg_fatal("%s:%s map requires O_RDONLY access mode",
178
 
                  DICT_TYPE_CIDR, mapname);
 
180
        return (dict_surrogate(DICT_TYPE_CIDR, mapname, open_flags, dict_flags,
 
181
                               "%s:%s map requires O_RDONLY access mode",
 
182
                               DICT_TYPE_CIDR, mapname));
 
183
 
 
184
    /*
 
185
     * Open the configuration file.
 
186
     */
 
187
    if ((map_fp = vstream_fopen(mapname, O_RDONLY, 0)) == 0)
 
188
        return (dict_surrogate(DICT_TYPE_CIDR, mapname, open_flags, dict_flags,
 
189
                               "open %s: %m", mapname));
 
190
    if (fstat(vstream_fileno(map_fp), &st) < 0)
 
191
        msg_fatal("fstat %s: %m", mapname);
 
192
 
 
193
    /*
 
194
     * No early returns without memory leaks.
 
195
     */
 
196
    line_buffer = vstring_alloc(100);
 
197
    why = vstring_alloc(100);
179
198
 
180
199
    /*
181
200
     * XXX Eliminate unnecessary queries by setting a flag that says "this
188
207
    dict_cidr->dict.flags = dict_flags | DICT_FLAG_PATTERN;
189
208
    dict_cidr->head = 0;
190
209
 
191
 
    if ((map_fp = vstream_fopen(mapname, O_RDONLY, 0)) == 0)
192
 
        msg_fatal("open %s: %m", mapname);
 
210
    dict_cidr->dict.owner.uid = st.st_uid;
 
211
    dict_cidr->dict.owner.status = (st.st_uid != 0);
193
212
 
194
213
    while (readlline(line_buffer, map_fp, &lineno)) {
195
214
        rule = dict_cidr_parse_rule(vstring_str(line_buffer), why);