ldap_backend.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /*
10  * AUTHOR: Flavio Pescuma, MARA Systems AB <flavio@marasystems.com>
11  */
12 #include "squid.h"
13 
14 #include <cstdio>
15 
16 #define LDAP_DEPRECATED 1
17 
19 
20 #if _SQUID_WINDOWS_ && !_SQUID_CYGWIN_
21 
22 #include <windows.h>
23 #include <winldap.h>
24 #ifndef LDAPAPI
25 #define LDAPAPI __cdecl
26 #endif
27 #ifdef LDAP_VERSION3
28 #ifndef LDAP_OPT_X_TLS
29 #define LDAP_OPT_X_TLS 0x6000
30 #endif
31 /* Some tricks to allow dynamic bind with ldap_start_tls_s entry point at
32  * run time.
33  */
34 #undef ldap_start_tls_s
35 #if LDAP_UNICODE
36 #define LDAP_START_TLS_S "ldap_start_tls_sW"
37 typedef WINLDAPAPI ULONG(LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlW *, IN PLDAPControlW *);
38 #else
39 #define LDAP_START_TLS_S "ldap_start_tls_sA"
40 typedef WINLDAPAPI ULONG(LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *);
41 #endif /* LDAP_UNICODE */
42 PFldap_start_tls_s Win32_ldap_start_tls_s;
43 #define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l, nullptr, nullptr,s,c)
44 #endif /* LDAP_VERSION3 */
45 
46 #else
47 
48 #include <lber.h>
49 #include <ldap.h>
50 
51 #endif
53 #define PROGRAM_NAME "digest_pw_auth(LDAP_backend)"
54 
55 /* Globals */
56 
57 static LDAP *ld = nullptr;
58 static const char *passattr = nullptr;
59 static char *ldapServer = nullptr;
60 static const char *userbasedn = nullptr;
61 static const char *userdnattr = nullptr;
62 static const char *usersearchfilter = nullptr;
63 static const char *binddn = nullptr;
64 static const char *bindpasswd = nullptr;
65 static const char *delimiter = ":";
66 static int encrpass = 0;
67 static int searchscope = LDAP_SCOPE_SUBTREE;
68 static int persistent = 0;
69 static int noreferrals = 0;
70 static int port = LDAP_PORT;
71 static int strip_nt_domain = 0;
72 static int edir_universal_passwd = 0;
73 static int aliasderef = LDAP_DEREF_NEVER;
74 #if defined(NETSCAPE_SSL)
75 static char *sslpath = nullptr;
76 static int sslinit = 0;
77 #endif
78 static int connect_timeout = 0;
79 static int timelimit = LDAP_NO_LIMIT;
80 
81 #ifdef LDAP_VERSION3
82 /* Added for TLS support and version 3 */
83 static int use_tls = 0;
84 static int version = -1;
85 #endif
86 
87 static void ldapconnect(void);
88 static int readSecret(const char *filename);
89 
90 /* Yuck.. we need to glue to different versions of the API */
91 
92 #if defined(LDAP_API_VERSION) && LDAP_API_VERSION > 1823
93 static void
95 {
96  ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
97 }
98 static void
99 squid_ldap_set_referrals(int referrals)
100 {
101  int *value = static_cast<int*>(referrals ? LDAP_OPT_ON :LDAP_OPT_OFF);
102  ldap_set_option(ld, LDAP_OPT_REFERRALS, value);
103 }
104 static void
105 squid_ldap_set_timelimit(int aTimeLimit)
106 {
107  ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &aTimeLimit);
108 }
109 static void
110 squid_ldap_set_connect_timeout(int aTimeLimit)
111 {
112 #if defined(LDAP_OPT_NETWORK_TIMEOUT)
113  struct timeval tv;
114  tv.tv_sec = aTimeLimit;
115  tv.tv_usec = 0;
116  ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &tv);
117 #elif defined(LDAP_X_OPT_CONNECT_TIMEOUT)
118  aTimeLimit *= 1000;
119  ldap_set_option(ld, LDAP_X_OPT_CONNECT_TIMEOUT, &aTimeLimit);
120 #endif
121 }
122 
123 #else
124 static int
126 {
127  return ld->ld_errno;
128 }
129 static void
131 {
132  ld->ld_deref = deref;
133 }
134 static void
136 {
137  if (referrals)
138  ld->ld_options |= ~LDAP_OPT_REFERRALS;
139  else
140  ld->ld_options &= ~LDAP_OPT_REFERRALS;
141 }
142 static void
144 {
145  ld->ld_timelimit = aTimeLimit;
146 }
147 static void
149 {
150  fprintf(stderr, "ERROR: Connect timeouts not supported in your LDAP library\n");
151 }
152 static void
154 {
155  free(p);
156 }
157 
158 #endif
159 
160 #ifdef LDAP_API_FEATURE_X_OPENLDAP
161 #if LDAP_VENDOR_VERSION > 194
162 #define HAS_URI_SUPPORT 1
163 #endif
164 #endif
165 
166 static int
167 ldap_escape_value(char *escaped, int size, const char *src)
168 {
169  int n = 0;
170  while (size > 4 && *src) {
171  switch (*src) {
172  case '*':
173  case '(':
174  case ')':
175  case '\\':
176  n += 3;
177  size -= 3;
178  if (size > 0) {
179  *escaped = '\\';
180  ++escaped;
181  std::snprintf(escaped, 3, "%02x", (int) *src);
182  ++src;
183  escaped += 2;
184  }
185  break;
186  default:
187  *escaped = *src;
188  ++escaped;
189  ++src;
190  ++n;
191  --size;
192  }
193  }
194  *escaped = '\0';
195  return n;
196 }
197 
198 static char *
199 getpassword(char *login, char *realm)
200 {
201  LDAPMessage *res = nullptr;
202  LDAPMessage *entry;
203  char **values = nullptr;
204  char **value = nullptr;
205  char *password = nullptr;
206  int retry = 0;
207  char filter[8192];
208  *filter = '\0';
209  char searchbase[8192];
210  *searchbase = '\0';
211  char *universal_password = nullptr;
212  size_t universal_password_len = 256;
213  int nmas_res = 0;
214  int rc = -1;
215  if (ld) {
216  if (usersearchfilter) {
217  char escaped_login[1024];
218  std::snprintf(searchbase, sizeof(searchbase), "%s", userbasedn);
219  ldap_escape_value(escaped_login, sizeof(escaped_login), login);
220  std::snprintf(filter, sizeof(filter), usersearchfilter, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login, escaped_login);
221 
222 retrysrch:
223  debug("user filter '%s', searchbase '%s'\n", filter, searchbase);
224 
225  rc = ldap_search_s(ld, searchbase, searchscope, filter, nullptr, 0, &res);
226  if (rc != LDAP_SUCCESS) {
227  if (noreferrals && rc == LDAP_PARTIAL_RESULTS) {
228  /* Everything is fine. This is expected when referrals
229  * are disabled.
230  */
231  rc = LDAP_SUCCESS;
232  } else {
233  fprintf(stderr, PROGRAM_NAME " WARNING, LDAP search error '%s'\n", ldap_err2string(rc));
234 #if defined(NETSCAPE_SSL)
235  if (sslpath && ((rc == LDAP_SERVER_DOWN) || (rc == LDAP_CONNECT_ERROR))) {
236  int sslerr = PORT_GetError();
237  fprintf(stderr, PROGRAM_NAME ": WARNING, SSL error %d (%s)\n", sslerr, ldapssl_err2string(sslerr));
238  }
239 #endif
240  fprintf(stderr, PROGRAM_NAME " WARNING, LDAP search error, trying to recover'%s'\n", ldap_err2string(rc));
241  ldap_msgfree(res);
242  /* try to connect to the LDAP server again, maybe my persistent conexion failed. */
243  if (!retry) {
244  ++retry;
245  ldap_unbind(ld);
246  ld = nullptr;
247  ldapconnect();
248  goto retrysrch;
249  }
250  return nullptr;
251 
252  }
253  }
254  } else if (userdnattr) {
255  std::snprintf(searchbase, 8192, "%s=%s, %s", userdnattr, login, userbasedn);
256 
257 retrydnattr:
258  debug("searchbase '%s'\n", searchbase);
259  rc = ldap_search_s(ld, searchbase, searchscope, nullptr, nullptr, 0, &res);
260  }
261  if (rc == LDAP_SUCCESS) {
262  entry = ldap_first_entry(ld, res);
263  if (entry) {
264  debug("ldap dn: %s\n", ldap_get_dn(ld, entry));
265  if (edir_universal_passwd) {
266 
267  /* allocate some memory for the universal password returned by NMAS */
268  universal_password = (char*)calloc(1, universal_password_len);
269  values = (char**)calloc(2, sizeof(char *));
270 
271  /* actually talk to NMAS to get a password */
272  nmas_res = nds_get_password(ld, ldap_get_dn(ld, entry), &universal_password_len, universal_password);
273  if (nmas_res == LDAP_SUCCESS && universal_password) {
274  debug("NMAS returned value %s\n", universal_password);
275  values[0] = universal_password;
276  values[1] = nullptr;
277  } else {
278  debug("Error reading Universal Password: %d = %s\n", nmas_res, ldap_err2string(nmas_res));
279  }
280  } else {
281  values = ldap_get_values(ld, entry, passattr);
282  }
283  } else {
284  ldap_msgfree(res);
285  return nullptr;
286  }
287  if (!values) {
288  debug("No attribute value found\n");
290  free(universal_password);
291  ldap_msgfree(res);
292  return nullptr;
293  }
294  value = values;
295  while (*value) {
296  if (encrpass) {
297  const char *t = strtok(*value, delimiter);
298  if (t && strcmp(t, realm) == 0) {
299  password = strtok(nullptr, delimiter);
300  break;
301  }
302  } else {
303  password = *value;
304  break;
305  }
306  ++value;
307  }
308  debug("password: %s\n", password);
309  if (password)
310  password = xstrdup(password);
311  if (edir_universal_passwd) {
312  free(values);
313  free(universal_password);
314  } else {
315  ldap_value_free(values);
316  }
317  ldap_msgfree(res);
318  return password;
319  } else {
320  fprintf(stderr, PROGRAM_NAME " WARNING, LDAP error '%s'\n", ldap_err2string(rc));
321  /* try to connect to the LDAP server again, maybe my persistent conexion failed. */
322  if (!retry) {
323  ++retry;
324  ldap_unbind(ld);
325  ld = nullptr;
326  ldapconnect();
327  goto retrydnattr;
328  }
329  return nullptr;
330  }
331  }
332  return nullptr;
333 }
334 
335 static void
337 {
338  int rc;
339 
340  /* On Windows ldap_start_tls_s is available starting from Windows XP,
341  * so we need to bind at run-time with the function entry point
342  */
343 #if _SQUID_WINDOWS_
344  if (use_tls) {
345 
346  HMODULE WLDAP32Handle;
347 
348  WLDAP32Handle = GetModuleHandle("wldap32");
349  if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) {
350  fprintf(stderr, PROGRAM_NAME ": ERROR: TLS (-Z) not supported on this platform.\n");
351  exit(EXIT_FAILURE);
352  }
353  }
354 #endif
355 
356  if (ld == nullptr) {
357 #if HAS_URI_SUPPORT
358  if (strstr(ldapServer, "://") != nullptr) {
359  rc = ldap_initialize(&ld, ldapServer);
360  if (rc != LDAP_SUCCESS) {
361  fprintf(stderr, "\nUnable to connect to LDAPURI:%s\n", ldapServer);
362  }
363  } else
364 #endif
365 #if NETSCAPE_SSL
366  if (sslpath) {
367  if (!sslinit && (ldapssl_client_init(sslpath, nullptr) != LDAP_SUCCESS)) {
368  fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n",
369  sslpath);
370  exit(EXIT_FAILURE);
371  } else {
372  ++sslinit;
373  }
374  if ((ld = ldapssl_init(ldapServer, port, 1)) == NULL) {
375  fprintf(stderr, "\nUnable to connect to SSL LDAP server: %s port:%d\n",
376  ldapServer, port);
377  exit(EXIT_FAILURE);
378  }
379  } else
380 #endif
381  if ((ld = ldap_init(ldapServer, port)) == nullptr) {
382  fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n", ldapServer, port);
383  }
384  if (connect_timeout)
386 
387 #ifdef LDAP_VERSION3
388  if (version == -1) {
389  version = LDAP_VERSION2;
390  }
391  if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version)
392  != LDAP_SUCCESS) {
393  fprintf(stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
394  version);
395  ldap_unbind(ld);
396  ld = nullptr;
397  }
398  if (use_tls) {
399 #ifdef LDAP_OPT_X_TLS
400  if ((version == LDAP_VERSION3) && (ldap_start_tls_s(ld, nullptr, nullptr) == LDAP_SUCCESS)) {
401  fprintf(stderr, "Could not Activate TLS connection\n");
402  ldap_unbind(ld);
403  ld = nullptr;
404  }
405 #else
406  fprintf(stderr, "TLS not supported with your LDAP library\n");
407  ldap_unbind(ld);
408  ld = nullptr;
409 #endif
410  }
411 #endif
415  if (binddn && bindpasswd && *binddn && *bindpasswd) {
416  rc = ldap_simple_bind_s(ld, binddn, bindpasswd);
417  if (rc != LDAP_SUCCESS) {
418  fprintf(stderr, PROGRAM_NAME " WARNING, could not bind to binddn '%s'\n", ldap_err2string(rc));
419  ldap_unbind(ld);
420  ld = nullptr;
421  }
422  }
423  debug("Connected OK\n");
424  }
425 }
426 int
427 LDAPArguments(int argc, char **argv)
428 {
429  setbuf(stdout, nullptr);
430 
431  while (argc > 1 && argv[1][0] == '-') {
432  const char *value = "";
433  char option = argv[1][1];
434  switch (option) {
435  case 'P':
436  case 'R':
437  case 'z':
438  case 'Z':
439  case 'g':
440  case 'e':
441  case 'S':
442  case 'n':
443  case 'd':
444  break;
445  default:
446  if (strlen(argv[1]) > 2) {
447  value = argv[1] + 2;
448  } else if (argc > 2) {
449  value = argv[2];
450  ++argv;
451  --argc;
452  } else
453  value = "";
454  break;
455  }
456  ++argv;
457  --argc;
458  switch (option) {
459  case 'H':
460 #if !HAS_URI_SUPPORT
461  fprintf(stderr, "ERROR: Your LDAP library does not have URI support\n");
462  return 1;
463 #endif
464  /* Fall thru to -h */
465  case 'h':
466  if (ldapServer) {
467  int len = strlen(ldapServer) + 1 + strlen(value) + 1;
468  char *newhost = static_cast<char*>(xmalloc(len));
469  std::snprintf(newhost, len, "%s %s", ldapServer, value);
470  free(ldapServer);
471  ldapServer = newhost;
472  } else {
473  ldapServer = xstrdup(value);
474  }
475  break;
476  case 'A':
477  passattr = value;
478  break;
479  case 'e':
480  encrpass = 1;
481  break;
482  case 'l':
483  delimiter = value;
484  break;
485  case 'b':
486  userbasedn = value;
487  break;
488  case 'F':
489  usersearchfilter = value;
490  break;
491  case 'u':
492  userdnattr = value;
493  break;
494  case 's':
495  if (strcmp(value, "base") == 0)
496  searchscope = LDAP_SCOPE_BASE;
497  else if (strcmp(value, "one") == 0)
498  searchscope = LDAP_SCOPE_ONELEVEL;
499  else if (strcmp(value, "sub") == 0)
500  searchscope = LDAP_SCOPE_SUBTREE;
501  else {
502  fprintf(stderr, PROGRAM_NAME " ERROR: Unknown search scope '%s'\n", value);
503  return 1;
504  }
505  break;
506  case 'S':
507 #if defined(NETSCAPE_SSL)
508  sslpath = value;
509  if (port == LDAP_PORT)
510  port = LDAPS_PORT;
511 #else
512  fprintf(stderr, PROGRAM_NAME " ERROR: -E unsupported with this LDAP library\n");
513  return 1;
514 #endif
515  break;
516  case 'c':
517  connect_timeout = atoi(value);
518  break;
519  case 't':
520  timelimit = atoi(value);
521  break;
522  case 'a':
523  if (strcmp(value, "never") == 0)
524  aliasderef = LDAP_DEREF_NEVER;
525  else if (strcmp(value, "always") == 0)
526  aliasderef = LDAP_DEREF_ALWAYS;
527  else if (strcmp(value, "search") == 0)
528  aliasderef = LDAP_DEREF_SEARCHING;
529  else if (strcmp(value, "find") == 0)
530  aliasderef = LDAP_DEREF_FINDING;
531  else {
532  fprintf(stderr, PROGRAM_NAME " ERROR: Unknown alias dereference method '%s'\n", value);
533  return 1;
534  }
535  break;
536  case 'D':
537  binddn = value;
538  break;
539  case 'w':
540  bindpasswd = value;
541  break;
542  case 'W':
543  readSecret(value);
544  break;
545  case 'P':
547  break;
548  case 'p':
549  port = atoi(value);
550  break;
551  case 'R':
553  break;
554 #ifdef LDAP_VERSION3
555  case 'v':
556  switch (atoi(value)) {
557  case 2:
558  version = LDAP_VERSION2;
559  break;
560  case 3:
561  version = LDAP_VERSION3;
562  break;
563  default:
564  fprintf(stderr, "Protocol version should be 2 or 3\n");
565  return 1;
566  }
567  break;
568  case 'Z':
569  if (version == LDAP_VERSION2) {
570  fprintf(stderr, "TLS (-Z) is incompatible with version %d\n",
571  version);
572  return 1;
573  }
574  version = LDAP_VERSION3;
575  use_tls = 1;
576  break;
577 #endif
578  case 'd':
579  debug_enabled = 1;
580  break;
581  case 'E':
582  strip_nt_domain = 1;
583  break;
584  case 'n':
586  break;
587  default:
588  fprintf(stderr, PROGRAM_NAME " ERROR: Unknown command line option '%c'\n", option);
589  return 1;
590  }
591  }
592 
593  while (argc > 1) {
594  char *value = argv[1];
595  if (ldapServer) {
596  int len = strlen(ldapServer) + 1 + strlen(value) + 1;
597  char *newhost = static_cast<char*>(xmalloc(len));
598  std::snprintf(newhost, len, "%s %s", ldapServer, value);
599  free(ldapServer);
600  ldapServer = newhost;
601  } else {
602  ldapServer = xstrdup(value);
603  }
604  --argc;
605  ++argv;
606  }
607 
608  if (!ldapServer)
609  ldapServer = (char *) "localhost";
610 
611  if (!userbasedn || !((passattr != nullptr) || (edir_universal_passwd && usersearchfilter && version == LDAP_VERSION3 && use_tls))) {
612  fprintf(stderr, "Usage: " PROGRAM_NAME " -b basedn -f filter [options] ldap_server_name\n\n");
613  fprintf(stderr, "\t-A password attribute(REQUIRED)\t\tUser attribute that contains the password\n");
614  fprintf(stderr, "\t-l password realm delimiter(REQUIRED)\tCharater(s) that divides the password attribute\n\t\t\t\t\t\tin realm and password tokens, default ':' realm:password\n");
615  fprintf(stderr, "\t-b basedn (REQUIRED)\t\t\tbase dn under where to search for users\n");
616  fprintf(stderr, "\t-e Encrypted passwords(REQUIRED)\tPassword are stored encrypted using HHA1\n");
617  fprintf(stderr, "\t-F filter\t\t\t\tuser search filter pattern. %%s = login\n");
618  fprintf(stderr, "\t-u attribute\t\t\t\tattribute to use in combination with the basedn to create the user DN\n");
619  fprintf(stderr, "\t-s base|one|sub\t\t\t\tsearch scope\n");
620  fprintf(stderr, "\t-D binddn\t\t\t\tDN to bind as to perform searches\n");
621  fprintf(stderr, "\t-w bindpasswd\t\t\t\tpassword for binddn\n");
622  fprintf(stderr, "\t-W secretfile\t\t\t\tread password for binddn from file secretfile\n");
623 #if HAS_URI_SUPPORT
624  fprintf(stderr, "\t-H URI\t\t\t\t\tLDAPURI (defaults to ldap://localhost)\n");
625 #endif
626  fprintf(stderr, "\t-h server\t\t\t\tLDAP server (defaults to localhost)\n");
627  fprintf(stderr, "\t-p port\t\t\t\t\tLDAP server port (defaults to %d)\n", LDAP_PORT);
628  fprintf(stderr, "\t-P\t\t\t\t\tpersistent LDAP connection\n");
629 #if defined(NETSCAPE_SSL)
630  fprintf(stderr, "\t-E sslcertpath\t\t\t\tenable LDAP over SSL\n");
631 #endif
632  fprintf(stderr, "\t-c timeout\t\t\t\tconnect timeout\n");
633  fprintf(stderr, "\t-t timelimit\t\t\t\tsearch time limit\n");
634  fprintf(stderr, "\t-R\t\t\t\t\tdo not follow referrals\n");
635  fprintf(stderr, "\t-a never|always|search|find\t\twhen to dereference aliases\n");
636 #ifdef LDAP_VERSION3
637  fprintf(stderr, "\t-v 2|3\t\t\t\t\tLDAP version\n");
638  fprintf(stderr, "\t-Z\t\t\t\t\tTLS encrypt the LDAP connection, requires\n\t\t\t\tLDAP version 3\n");
639 #endif
640  fprintf(stderr, "\t-S\t\t\t\t\tStrip NT domain from usernames\n");
641  fprintf(stderr, "\t-n\t\t\t\t\tGet an eDirectory Universal Password from Novell NMAS\n\t\t\t\t\t\t(requires bind credentials, version 3, TLS, and a search filter)\n");
642  fprintf(stderr, "\n");
643  fprintf(stderr, "\tIf you need to bind as a user to perform searches then use the\n\t-D binddn -w bindpasswd or -D binddn -W secretfile options\n\n");
644  return -1;
645  }
646  return 0;
647 }
648 static int
649 readSecret(const char *filename)
650 {
651  char buf[BUFSIZ];
652  char *e = nullptr;
653  FILE *f;
654 
655  if (!(f = fopen(filename, "r"))) {
656  fprintf(stderr, PROGRAM_NAME " ERROR: Can not read secret file %s\n", filename);
657  return 1;
658  }
659  if (!fgets(buf, sizeof(buf) - 1, f)) {
660  fprintf(stderr, PROGRAM_NAME " ERROR: Secret file %s is empty\n", filename);
661  fclose(f);
662  return 1;
663  }
664  /* strip whitespaces on end */
665  if ((e = strrchr(buf, '\n')))
666  *e = 0;
667  if ((e = strrchr(buf, '\r')))
668  *e = 0;
669 
670  bindpasswd = xstrdup(buf);
671  if (!bindpasswd) {
672  fprintf(stderr, PROGRAM_NAME " ERROR: can not allocate memory\n");
673  }
674  fclose(f);
675 
676  return 0;
677 }
678 
679 void
680 LDAPHHA1(RequestData * requestData)
681 {
682  char *password;
683  ldapconnect();
684  password = getpassword(requestData->user, requestData->realm);
685  if (password != nullptr) {
686  if (encrpass)
687  xstrncpy(requestData->HHA1, password, sizeof(requestData->HHA1));
688  else {
689  HASH HA1;
690  DigestCalcHA1("md5", requestData->user, requestData->realm, password, nullptr, nullptr, HA1, requestData->HHA1);
691  }
692  free(password);
693  } else {
694  requestData->error = -1;
695  }
696 
697 }
698 
static int readSecret(const char *filename)
#define BUFSIZ
Definition: defines.h:20
static void squid_ldap_memfree(char *p)
#define xmalloc
static const char * binddn
Definition: ldap_backend.cc:63
static void squid_ldap_set_referrals(int referrals)
void debug(const char *format,...)
Definition: debug.cc:19
static int squid_ldap_errno(LDAP *ld)
#define xstrdup
static int use_tls
char * xstrncpy(char *dst, const char *src, size_t n)
Definition: xstring.cc:37
static const char * delimiter
Definition: ldap_backend.cc:65
static void squid_ldap_set_timelimit(int aTimeLimit)
static int timelimit
Definition: ldap_backend.cc:79
static const char * userdnattr
Definition: ldap_backend.cc:61
static int port
Definition: ldap_backend.cc:70
static int noreferrals
Definition: ldap_backend.cc:69
static void ldapconnect(void)
static int searchscope
Definition: ldap_backend.cc:67
int size
Definition: ModDevPoll.cc:70
static int encrpass
Definition: ldap_backend.cc:66
#define NULL
Definition: types.h:145
static const char * userbasedn
Definition: ldap_backend.cc:60
#define PROGRAM_NAME
Definition: ldap_backend.cc:53
int debug_enabled
Definition: debug.cc:13
static const char * passattr
Definition: ldap_backend.cc:58
static char * ldapServer
Definition: ldap_backend.cc:59
static char * getpassword(char *login, char *realm)
static int version
static int strip_nt_domain
Definition: ldap_backend.cc:71
static int ldap_escape_value(char *escaped, int size, const char *src)
int nds_get_password(LDAP *ld, char *object_dn, size_t *pwd_len, char *pwd)
void LDAPHHA1(RequestData *requestData)
static const char * usersearchfilter
Definition: ldap_backend.cc:62
static void squid_ldap_set_aliasderef(int deref)
static int persistent
Definition: ldap_backend.cc:68
static const char * bindpasswd
Definition: ldap_backend.cc:64
static int aliasderef
Definition: ldap_backend.cc:73
static int connect_timeout
Definition: ldap_backend.cc:78
int LDAPArguments(int argc, char **argv)
static void squid_ldap_set_connect_timeout(int aTimeLimit)
static LDAP * ld
Definition: ldap_backend.cc:57
char HASH[HASHLEN]
Definition: rfc2617.h:31
void DigestCalcHA1(const char *pszAlg, const char *pszUserName, const char *pszRealm, const char *pszPassword, const char *pszNonce, const char *pszCNonce, HASH HA1, HASHHEX SessionKey)
Definition: rfc2617.c:88
static int edir_universal_passwd
Definition: ldap_backend.cc:72

 

Introduction

Documentation

Support

Miscellaneous