access-lookup.c revision 5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen/* Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file */
fcca16701767c6b92227a9ee125de69d257882f6Timo Sirainenstatic void access_lookup_input(struct access_lookup *lookup)
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen } else if (ret == 0) {
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen /* connection close -> no success */
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen } else if (ret == 2 && buf[0] == '0' && buf[1] == '\n') {
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen /* no success */
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen } else if (ret == 2 && buf[0] == '1' && buf[1] == '\n') {
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen i_error("access(%s): Invalid input", lookup->path);
a6f281d078ed03d555802c1a8e15fefce80132dcTimo Sirainenstatic void access_lookup_timeout(struct access_lookup *lookup)
a6f281d078ed03d555802c1a8e15fefce80132dcTimo Sirainen i_error("access(%s): Timed out while waiting for reply", lookup->path);
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainenaccess_lookup(const char *path, int client_fd, const char *daemon_name,
6967fa47dde9f2726bd86019a50627dacf2d7509Timo Sirainen access_lookup_callback_t *callback, void *context)
c1d4780bc0c9017e8e5d366b81e4fad31174c0adTimo Sirainen const char *cmd;
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen ret = fd_send(fd, client_fd, cmd, strlen(cmd));
2201e2cc1b3f744dac61c2bf8095bcb6b5719540Timo Sirainen i_error("fd_send(%s) didn't write enough bytes", path);
fcca16701767c6b92227a9ee125de69d257882f6Timo Sirainen lookup->io = io_add(fd, IO_READ, access_lookup_input, lookup);
fcca16701767c6b92227a9ee125de69d257882f6Timo Sirainen lookup->to = timeout_add(ACCESS_LOOKUP_TIMEOUT_MSECS,
4307c886579381dbb1897ea1388ae6978c96f560Timo Sirainenvoid access_lookup_destroy(struct access_lookup **_lookup)
7bcb308d0e13dfa48b483b0addccd889a77bb598Timo Sirainen i_error("close(%s) failed: %m", lookup->path);