]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Remove access-lookup.[ch]
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 13 Oct 2022 14:09:43 +0000 (14:09 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Oct 2022 16:35:08 +0000 (16:35 +0000)
leftover from 97815ea9

src/login-common/Makefile.am
src/login-common/access-lookup.c [deleted file]
src/login-common/access-lookup.h [deleted file]
src/login-common/main.c

index f421cdb8a313d75b10b2eda5b52d95a02cbc22d0..7366d147350401dd2d4b04b967a069b4d8af44cb 100644 (file)
@@ -13,7 +13,6 @@ AM_CPPFLAGS = \
        -DMODULEDIR=\""$(moduledir)"\"
 
 liblogin_la_SOURCES = \
-       access-lookup.c \
        client-common.c \
        client-common-auth.c \
        login-proxy.c \
@@ -23,7 +22,6 @@ liblogin_la_SOURCES = \
        sasl-server.c
 
 headers = \
-       access-lookup.h \
        client-common.h \
        login-common.h \
        login-proxy.h \
diff --git a/src/login-common/access-lookup.c b/src/login-common/access-lookup.c
deleted file mode 100644 (file)
index 692b43c..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
-
-#include "lib.h"
-#include "ioloop.h"
-#include "net.h"
-#include "fdpass.h"
-#include "access-lookup.h"
-
-#include <unistd.h>
-
-#define ACCESS_LOOKUP_TIMEOUT_MSECS (1000*60)
-
-struct access_lookup {
-       int refcount;
-
-       int fd;
-       char *path;
-
-       struct io *io;
-       struct timeout *to;
-
-       access_lookup_callback_t *callback;
-       void *context;
-};
-
-static void access_lookup_input(struct access_lookup *lookup)
-{
-       unsigned char buf[3];
-       ssize_t ret;
-       bool success = FALSE;
-
-       ret = read(lookup->fd, buf, sizeof(buf));
-       if (ret < 0) {
-               i_error("read(%s) failed: %m", lookup->path);
-       } else if (ret == 0) {
-               /* connection close -> no success */
-       } else if (ret == 2 && buf[0] == '0' && buf[1] == '\n') {
-               /* no success */
-       } else if (ret == 2 && buf[0] == '1' && buf[1] == '\n') {
-               success = TRUE;
-       } else {
-               i_error("access(%s): Invalid input", lookup->path);
-       }
-
-       lookup->refcount++;
-       lookup->callback(success, lookup->context);
-       if (lookup->refcount > 1)
-               access_lookup_destroy(&lookup);
-       access_lookup_destroy(&lookup);
-}
-
-static void access_lookup_timeout(struct access_lookup *lookup)
-{
-       i_error("access(%s): Timed out while waiting for reply", lookup->path);
-
-       lookup->refcount++;
-       lookup->callback(FALSE, lookup->context);
-       if (lookup->refcount > 1)
-               access_lookup_destroy(&lookup);
-       access_lookup_destroy(&lookup);
-}
-
-struct access_lookup *
-access_lookup(const char *path, int client_fd, const char *daemon_name,
-             access_lookup_callback_t *callback, void *context)
-{
-       struct access_lookup *lookup;
-       const char *cmd;
-       ssize_t ret;
-       int fd;
-
-       fd = net_connect_unix(path);
-       if (fd == -1) {
-               i_error("connect(%s) failed: %m", path);
-               return NULL;
-       }
-
-       cmd = t_strconcat(daemon_name, "\n", NULL);
-       ret = fd_send(fd, client_fd, cmd, strlen(cmd));
-       if (ret != (ssize_t)strlen(cmd)) {
-               if (ret < 0)
-                       i_error("fd_send(%s) failed: %m", path);
-               else
-                       i_error("fd_send(%s) didn't write enough bytes", path);
-               i_close_fd(&fd);
-               return NULL;
-       }
-
-       lookup = i_new(struct access_lookup, 1);
-       lookup->refcount = 1;
-       lookup->fd = fd;
-       lookup->path = i_strdup(path);
-       lookup->io = io_add(fd, IO_READ, access_lookup_input, lookup);
-       lookup->to = timeout_add(ACCESS_LOOKUP_TIMEOUT_MSECS,
-                                access_lookup_timeout, lookup);
-       lookup->callback = callback;
-       lookup->context = context;
-       return lookup;
-}
-
-void access_lookup_destroy(struct access_lookup **_lookup)
-{
-       struct access_lookup *lookup = *_lookup;
-
-       i_assert(lookup->refcount > 0);
-       if (--lookup->refcount > 0)
-               return;
-
-       *_lookup = NULL;
-
-       timeout_remove(&lookup->to);
-       io_remove(&lookup->io);
-       if (close(lookup->fd) < 0)
-               i_error("close(%s) failed: %m", lookup->path);
-
-       i_free(lookup->path);
-       i_free(lookup);
-}
diff --git a/src/login-common/access-lookup.h b/src/login-common/access-lookup.h
deleted file mode 100644 (file)
index 6ebb582..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef ACCESS_LOOKUP_H
-#define ACCESS_LOOKUP_H
-
-typedef void access_lookup_callback_t(bool success, void *context);
-
-struct access_lookup *
-access_lookup(const char *path, int client_fd, const char *daemon_name,
-             access_lookup_callback_t *callback, void *context);
-void access_lookup_destroy(struct access_lookup **lookup);
-
-#endif
index 61e99c974edab3135f4beac118d770310fa58e38..7dd2f7bfc6a564f4ae05105abfa0a15882d3cd9c 100644 (file)
@@ -15,7 +15,6 @@
 #include "master-interface.h"
 #include "iostream-ssl.h"
 #include "client-common.h"
-#include "access-lookup.h"
 #include "master-admin-client.h"
 #include "anvil-client.h"
 #include "auth-client.h"