~ubuntu-branches/ubuntu/maverick/postfix/maverick-security

« back to all changes in this revision

Viewing changes to src/global/dict_proxy.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, Wietse Venema, LaMont Jones
  • Date: 2009-06-03 14:17:08 UTC
  • mfrom: (1.1.22 upstream)
  • Revision ID: james.westby@ubuntu.com-20090603141708-o9u59xlor7nmd2x1
[Wietse Venema]

* New upstream release: 2.6.2~rc1

[LaMont Jones]

* move postfix-add-{filter,policy} manpages to section 8, and deliver
* provide: default-mta on ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
308
308
    int     server_flags;
309
309
    int     status;
310
310
    const char *service;
311
 
    const char *relative_path;
 
311
    char   *relative_path;
312
312
    char   *kludge = 0;
313
313
    char   *prefix;
314
314
    CLNT_STREAM **pstream;
315
315
 
316
316
    /*
317
 
     * Sanity checks.
 
317
     * If this map can't be proxied then we silently do a direct open. This
 
318
     * allows sites to benefit from proxying the virtual mailbox maps without
 
319
     * unnecessary pain.
 
320
     */
 
321
    if (dict_flags & DICT_FLAG_NO_PROXY)
 
322
        return (dict_open(map, open_flags, dict_flags));
 
323
 
 
324
    /*
 
325
     * Use a shared stream for proxied table lookups of the same type.
318
326
     * 
319
327
     * XXX A complete implementation would also allow O_RDWR without O_CREAT.
320
328
     * But we must not pass on every possible set of flags to the proxy
321
329
     * server; only sets that make sense. For now, the flags are passed
322
330
     * implicitly by choosing between the proxymap or proxywrite service.
 
331
     * 
 
332
     * XXX Use absolute pathname to make this work from non-daemon processes.
323
333
     */
324
334
    if (open_flags == O_RDONLY) {
325
335
        pstream = &proxymap_stream;
326
 
        service = MAIL_SERVICE_PROXYMAP;
327
 
        relative_path = MAIL_CLASS_PRIVATE "/" MAIL_SERVICE_PROXYMAP;
 
336
        service = var_proxymap_service;
328
337
    } else if (open_flags == (O_RDWR | O_CREAT)) {
329
338
        pstream = &proxywrite_stream;
330
 
        service = MAIL_SERVICE_PROXYWRITE;
331
 
        relative_path = MAIL_CLASS_PRIVATE "/" MAIL_SERVICE_PROXYWRITE;
 
339
        service = var_proxywrite_service;
332
340
    } else
333
341
        msg_fatal("%s: %s map open requires O_RDONLY or O_RDWR|O_CREAT mode",
334
342
                  map, DICT_TYPE_PROXY);
335
343
 
336
 
    /*
337
 
     * OK. If this map can't be proxied then we silently do a direct open.
338
 
     * This allows sites to benefit from proxying the virtual mailbox maps
339
 
     * without unnecessary pain.
340
 
     */
341
 
    if (dict_flags & DICT_FLAG_NO_PROXY)
342
 
        return (dict_open(map, open_flags, dict_flags));
343
 
 
344
 
    /*
345
 
     * Local initialization.
346
 
     */
347
 
    dict_proxy = (DICT_PROXY *)
348
 
        dict_alloc(DICT_TYPE_PROXY, map, sizeof(*dict_proxy));
349
 
    dict_proxy->dict.lookup = dict_proxy_lookup;
350
 
    dict_proxy->dict.update = dict_proxy_update;
351
 
    dict_proxy->dict.delete = dict_proxy_delete;
352
 
    dict_proxy->dict.close = dict_proxy_close;
353
 
    dict_proxy->in_flags = dict_flags;
354
 
    dict_proxy->result = vstring_alloc(10);
355
 
 
356
 
    /*
357
 
     * Use a shared stream for proxied table lookups of the same type.
358
 
     * 
359
 
     * XXX Use absolute pathname to make this work from non-daemon processes.
360
 
     */
361
344
    if (*pstream == 0) {
 
345
        relative_path = concatenate(MAIL_CLASS_PRIVATE "/",
 
346
                                    service, (char *) 0);
362
347
        if (access(relative_path, F_OK) == 0)
363
348
            prefix = MAIL_CLASS_PRIVATE;
364
349
        else
368
353
                                      var_ipc_ttl_limit);
369
354
        if (kludge)
370
355
            myfree(kludge);
 
356
        myfree(relative_path);
371
357
    }
 
358
 
 
359
    /*
 
360
     * Local initialization.
 
361
     */
 
362
    dict_proxy = (DICT_PROXY *)
 
363
        dict_alloc(DICT_TYPE_PROXY, map, sizeof(*dict_proxy));
 
364
    dict_proxy->dict.lookup = dict_proxy_lookup;
 
365
    dict_proxy->dict.update = dict_proxy_update;
 
366
    dict_proxy->dict.delete = dict_proxy_delete;
 
367
    dict_proxy->dict.close = dict_proxy_close;
 
368
    dict_proxy->in_flags = dict_flags;
 
369
    dict_proxy->result = vstring_alloc(10);
372
370
    dict_proxy->clnt = *pstream;
373
371
    dict_proxy->service = service;
374
372