308
308
int server_flags;
310
310
const char *service;
311
const char *relative_path;
312
312
char *kludge = 0;
314
314
CLNT_STREAM **pstream;
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
321
if (dict_flags & DICT_FLAG_NO_PROXY)
322
return (dict_open(map, open_flags, dict_flags));
325
* Use a shared stream for proxied table lookups of the same type.
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.
332
* XXX Use absolute pathname to make this work from non-daemon processes.
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;
333
341
msg_fatal("%s: %s map open requires O_RDONLY or O_RDWR|O_CREAT mode",
334
342
map, DICT_TYPE_PROXY);
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.
341
if (dict_flags & DICT_FLAG_NO_PROXY)
342
return (dict_open(map, open_flags, dict_flags));
345
* Local initialization.
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);
357
* Use a shared stream for proxied table lookups of the same type.
359
* XXX Use absolute pathname to make this work from non-daemon processes.
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;
368
353
var_ipc_ttl_limit);
356
myfree(relative_path);
360
* Local initialization.
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;