From dba5f85e8f1943863b4cbab1ab52913c62365ce1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 29 Nov 2014 02:20:13 -0500 Subject: fix errors: the only erroring files left are db_pam.c and nslcd.c --- nslcd/Makefile.am | 2 +- nslcd/cfg.c | 226 -------------------------------------------------- nslcd/common.c | 67 --------------- nslcd/common.h | 18 ---- nslcd/db_passwd.c | 6 +- nslcd/hackers_watch.c | 2 +- 6 files changed, 4 insertions(+), 317 deletions(-) diff --git a/nslcd/Makefile.am b/nslcd/Makefile.am index ab50a9f..8e501da 100644 --- a/nslcd/Makefile.am +++ b/nslcd/Makefile.am @@ -21,7 +21,7 @@ sbin_PROGRAMS = nslcd AM_CPPFLAGS=-I$(top_srcdir) -AM_CFLAGS = $(PTHREAD_CFLAGS) +AM_CFLAGS = -std=c99 $(PTHREAD_CFLAGS) nslcd_SOURCES = nslcd.c ../nslcd.h ../common/nslcd-prot.h \ ../common/inotify_helpers.h \ diff --git a/nslcd/cfg.c b/nslcd/cfg.c index 9a90003..d62cf80 100644 --- a/nslcd/cfg.c +++ b/nslcd/cfg.c @@ -975,232 +975,6 @@ static void cfg_read(const char *filename, struct ldap_config *cfg) { handle_log(filename, lnr, keyword, line); } - /* general connection options */ - else if (strcasecmp(keyword, "uri") == 0) - { - check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != '\0')); - while (get_token(&line, token, sizeof(token)) != NULL) - { - if (strcasecmp(token, "dns") == 0) - { -#ifdef HAVE_LDAP_DOMAIN2HOSTLIST - add_uris_from_dns(filename, lnr, cfg, - cfg_getdomainname(filename, lnr)); -#else /* not HAVE_LDAP_DOMAIN2HOSTLIST */ - log_log(LOG_ERR, "%s:%d: value %s not supported on platform", - filename, lnr, token); - exit(EXIT_FAILURE); -#endif /* not HAVE_LDAP_DOMAIN2HOSTLIST */ - } - else if (strncasecmp(token, "dns:", 4) == 0) - { -#ifdef HAVE_LDAP_DOMAIN2HOSTLIST - add_uris_from_dns(filename, lnr, cfg, strdup(token + 4)); -#else /* not HAVE_LDAP_DOMAIN2HOSTLIST */ - log_log(LOG_ERR, "%s:%d: value %s not supported on platform", - filename, lnr, token); - exit(EXIT_FAILURE); -#endif /* not HAVE_LDAP_DOMAIN2HOSTLIST */ - } - else - add_uri(filename, lnr, cfg, token); - } - } - else if (strcasecmp(keyword, "ldap_version") == 0) - { - cfg->ldap_version = get_int(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "binddn") == 0) - { - cfg->binddn = get_linedup(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "bindpw") == 0) - { - check_permissions(filename, keyword); - cfg->bindpw = get_linedup(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "rootpwmoddn") == 0) - { - cfg->rootpwmoddn = get_linedup(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "rootpwmodpw") == 0) - { - check_permissions(filename, keyword); - cfg->rootpwmodpw = get_linedup(filename, lnr, keyword, &line); - } - /* SASL authentication options */ - else if (strcasecmp(keyword, "sasl_mech") == 0) - { - cfg->sasl_mech = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "sasl_realm") == 0) - { - cfg->sasl_realm = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "sasl_authcid") == 0) - { - cfg->sasl_authcid = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "sasl_authzid") == 0) - { - cfg->sasl_authzid = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "sasl_secprops") == 0) - { - cfg->sasl_secprops = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } -#ifdef LDAP_OPT_X_SASL_NOCANON - else if ((strcasecmp(keyword, "sasl_canonicalize") == 0) || - (strcasecmp(keyword, "sasl_canonicalise") == 0) || - (strcasecmp(keyword, "ldap_sasl_canonicalize") == 0) || - (strcasecmp(keyword, "sasl_canon") == 0)) - { - cfg->sasl_canonicalize = get_boolean(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "sasl_nocanon") == 0) - { - cfg->sasl_canonicalize = get_boolean(filename, lnr, keyword, &line); - cfg->sasl_canonicalize = !cfg->sasl_canonicalize; - get_eol(filename, lnr, keyword, &line); - } -#endif /* LDAP_OPT_X_SASL_NOCANON */ - /* Kerberos authentication options */ - else if (strcasecmp(keyword, "krb5_ccname") == 0) - { - handle_krb5_ccname(filename, lnr, keyword, line); - } - /* search/mapping options */ - else if (strcasecmp(keyword, "base") == 0) - { - handle_base(filename, lnr, keyword, line, cfg); - } - else if (strcasecmp(keyword, "scope") == 0) - { - handle_scope(filename, lnr, keyword, line, cfg); - } - else if (strcasecmp(keyword, "deref") == 0) - { - handle_deref(filename, lnr, keyword, line, cfg); - } - else if (strcasecmp(keyword, "referrals") == 0) - { - cfg->referrals = get_boolean(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "filter") == 0) - { - handle_filter(filename, lnr, keyword, line); - } - /* timing/reconnect options */ - else if (strcasecmp(keyword, "bind_timelimit") == 0) - { - cfg->bind_timelimit = get_int(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "timelimit") == 0) - { - cfg->timelimit = get_int(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "idle_timelimit") == 0) - { - cfg->idle_timelimit = get_int(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (!strcasecmp(keyword, "reconnect_sleeptime")) - { - cfg->reconnect_sleeptime = get_int(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "reconnect_retrytime") == 0) - { - cfg->reconnect_retrytime = get_int(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - } -#ifdef LDAP_OPT_X_TLS - /* SSL/TLS options */ - else if (strcasecmp(keyword, "ssl") == 0) - { - check_argumentcount(filename, lnr, keyword, - (get_token(&line, token, sizeof(token)) != NULL)); - if ((strcasecmp(token, "start_tls") == 0) || - (strcasecmp(token, "starttls") == 0)) - cfg->ssl = SSL_START_TLS; - else if (parse_boolean(filename, lnr, token)) - cfg->ssl = SSL_LDAPS; - get_eol(filename, lnr, keyword, &line); - } - else if (strcasecmp(keyword, "tls_reqcert") == 0) - { - handle_tls_reqcert(filename, lnr, keyword, line); - } - else if (strcasecmp(keyword, "tls_cacertdir") == 0) - { - value = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - /* TODO: check that the path is valid */ - log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CACERTDIR,\"%s\")", - value); - LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CACERTDIR, value); - free(value); - } - else if ((strcasecmp(keyword, "tls_cacertfile") == 0) || - (strcasecmp(keyword, "tls_cacert") == 0)) - { - value = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - /* TODO: check that the path is valid */ - log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CACERTFILE,\"%s\")", - value); - LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CACERTFILE, value); - free(value); - } - else if (strcasecmp(keyword, "tls_randfile") == 0) - { - value = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - /* TODO: check that the path is valid */ - log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_RANDOM_FILE,\"%s\")", - value); - LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_RANDOM_FILE, value); - free(value); - } - else if (strcasecmp(keyword, "tls_ciphers") == 0) - { - value = get_linedup(filename, lnr, keyword, &line); - log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CIPHER_SUITE,\"%s\")", - value); - LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CIPHER_SUITE, value); - free(value); - } - else if (strcasecmp(keyword, "tls_cert") == 0) - { - value = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - /* TODO: check that the path is valid */ - log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CERTFILE,\"%s\")", - value); - LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CERTFILE, value); - free(value); - } - else if (strcasecmp(keyword, "tls_key") == 0) - { - value = get_strdup(filename, lnr, keyword, &line); - get_eol(filename, lnr, keyword, &line); - /* TODO: check that the path is valid */ - log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_KEYFILE,\"%s\")", - value); - LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_KEYFILE, value); - free(value); - } -#endif /* LDAP_OPT_X_TLS */ /* other options */ else if (strcasecmp(keyword, "pagesize") == 0) { diff --git a/nslcd/common.c b/nslcd/common.c index 421e8a5..3c82d71 100644 --- a/nslcd/common.c +++ b/nslcd/common.c @@ -185,73 +185,6 @@ int isvalidname(const char *name) return regexec(&nslcd_cfg->validnames, name, 0, NULL, 0) == 0; } -/* this writes a single address to the stream */ -int write_address(TFILE *fp, MYLDAP_ENTRY *entry, const char *attr, - const char *addr) -{ - int32_t tmpint32; - struct in_addr ipv4addr; - struct in6_addr ipv6addr; - /* try to parse the address as IPv4 first, fall back to IPv6 */ - if (inet_pton(AF_INET, addr, &ipv4addr) > 0) - { - /* write address type */ - WRITE_INT32(fp, AF_INET); - /* write the address length */ - WRITE_INT32(fp, sizeof(struct in_addr)); - /* write the address itself (in network byte order) */ - WRITE(fp, &ipv4addr, sizeof(struct in_addr)); - } - else if (inet_pton(AF_INET6, addr, &ipv6addr) > 0) - { - /* write address type */ - WRITE_INT32(fp, AF_INET6); - /* write the address length */ - WRITE_INT32(fp, sizeof(struct in6_addr)); - /* write the address itself (in network byte order) */ - WRITE(fp, &ipv6addr, sizeof(struct in6_addr)); - } - else - { - /* failure, log but write simple invalid address - (otherwise the address list is messed up) */ - /* TODO: have error message in correct format */ - log_log(LOG_WARNING, "%s: %s: \"%s\" unparsable", - myldap_get_dn(entry), attr, addr); - /* write an illegal address type */ - WRITE_INT32(fp, -1); - /* write an emtpy address */ - WRITE_INT32(fp, 0); - } - /* we're done */ - return 0; -} - -int read_address(TFILE *fp, char *addr, int *addrlen, int *af) -{ - int32_t tmpint32; - int len; - /* read address family */ - READ_INT32(fp, *af); - if ((*af != AF_INET) && (*af != AF_INET6)) - { - log_log(LOG_WARNING, "incorrect address family specified: %d", *af); - return -1; - } - /* read address length */ - READ_INT32(fp, len); - if ((len > *addrlen) || (len <= 0)) - { - log_log(LOG_WARNING, "address length incorrect: %d", len); - return -1; - } - *addrlen = len; - /* read address */ - READ(fp, addr, len); - /* we're done */ - return 0; -} - /* convert the provided string representation of a sid (e.g. S-1-5-21-1936905831-823966427-12391542-23578) to a format that can be used to search the objectSid property with */ diff --git a/nslcd/common.h b/nslcd/common.h index ac0fb71..9d9a29e 100644 --- a/nslcd/common.h +++ b/nslcd/common.h @@ -83,24 +83,6 @@ MUST_USE const char *getfqdn(void); const char *get_userpassword(MYLDAP_ENTRY *entry, const char *attr, char *buffer, size_t buflen); -/* write out an address, parsing the addr value */ -int write_address(TFILE *fp, MYLDAP_ENTRY *entry, const char *attr, - const char *addr); - -/* a helper macro to write out addresses and bail out on errors */ -#define WRITE_ADDRESS(fp, entry, attr, addr) \ - if (write_address(fp, entry, attr, addr)) \ - return -1; - -/* read an address from the stream */ -int read_address(TFILE *fp, char *addr, int *addrlen, int *af); - -/* helper macro to read an address from the stream */ -#define READ_ADDRESS(fp, addr, len, af) \ - len = (int)sizeof(addr); \ - if (read_address(fp, addr, &(len), &(af))) \ - return -1; - /* convert the provided string representation of a sid (e.g. S-1-5-21-1936905831-823966427-12391542-23578) to a format that can be used to search the objectSid property with */ diff --git a/nslcd/db_passwd.c b/nslcd/db_passwd.c index b72d869..2dad2da 100644 --- a/nslcd/db_passwd.c +++ b/nslcd/db_passwd.c @@ -35,9 +35,7 @@ #include "common.h" #include "log.h" -#include "myldap.h" #include "cfg.h" -#include "attmap.h" #include "common/dict.h" #include "compat/strndup.h" @@ -112,7 +110,7 @@ NSLCD_HANDLE_UID( } return NULL; ,/* write */ - write_passwd(fp, entry, calleruid) + write_passwd(fp, entry, calleruid); ,/* cleanup */ ) @@ -146,7 +144,7 @@ NSLCD_HANDLE_UID( } return NULL; ,/* write */ - write_passwd(fp, entry, calleruid) + write_passwd(fp, entry, calleruid); ,/* cleanup */ ) diff --git a/nslcd/hackers_watch.c b/nslcd/hackers_watch.c index 6687675..b6295a9 100644 --- a/nslcd/hackers_watch.c +++ b/nslcd/hackers_watch.c @@ -21,7 +21,7 @@ #include /* for asprintf(3) */ #include /* for chdir(3) */ -#include "inotify_helpers.h" +#include "common/inotify_helpers.h" #include "hackers_parse.h" #include "hackers_watch.h" -- cgit v1.2.3