X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/96f6312a0a827d2f90e7ab88d3a203c56eb82a9f..c645bbf04f3a2d814d029a3e6010b5622d0e9224:/lib/client.c diff --git a/lib/client.c b/lib/client.c index 80b4cd2..0fab347 100644 --- a/lib/client.c +++ b/lib/client.c @@ -41,9 +41,6 @@ #if HAVE_NETDB_H # include #endif -#if HAVE_PCRE_H -# include -#endif #include "log.h" #include "mem.h" @@ -85,6 +82,8 @@ struct disorder_client { int open; /** @brief Socket I/O context */ struct socketio sio; + /** @brief Whether to try to open a privileged connection */ + int trypriv; }; /** @brief Create a new client @@ -100,9 +99,21 @@ disorder_client *disorder_new(int verbose) { c->verbose = verbose; c->family = -1; + c->trypriv = 1; return c; } +/** @brief Don't try to make a privileged connection + * @param c Client + * + * You must call this before any of the connection functions (e.g., + * disorder_connect(), disorder_connect_user()), if at all. + */ +void disorder_force_unpriv(disorder_client *c) { + assert(!c->open); + c->trypriv = 0; +} + /** @brief Return the address family used by this client */ int disorder_client_af(disorder_client *c) { return c->family; @@ -432,7 +443,9 @@ int disorder_connect_generic(struct config *conf, socklen_t salen; char errbuf[1024]; - if((salen = find_server(conf, &sa, &c->ident)) == (socklen_t)-1) + if((salen = disorder_find_server(conf, + (c->trypriv ? 0 : DISORDER_FS_NOTPRIV), + &sa, &c->ident)) == (socklen_t)-1) return -1; c->input = 0; c->output = 0; @@ -749,6 +762,10 @@ static int pairlist(disorder_client *c, struct kvp **kp, const char *cmd, ...) { return 0; } +#if _WIN32 +# define boolean bodge_boolean +#endif + /** @brief Parse a boolean response * @param cmd Command for use in error messsage * @param value Result from server @@ -788,6 +805,7 @@ int disorder_log(disorder_client *c, struct sink *s) { byte_xasprintf((char **)&c->last, "input error: unexpected EOF"); return -1; } + return 0; }