Skip to content

Commit

Permalink
WIN32/Cygwin fixes by Guido
Browse files Browse the repository at this point in the history
- Better GetOSVersion function, more squid "aware", added support for
Windows XP and future Windows versions.
- Added trap in WIN32_Subsystem_Init() for unknown or unsupported (WIN32s)
Windows version.
- Fixed compile warning in comm.c
- Changed exit() WIN32 hook, now less intrusive

And some ident fixes
  • Loading branch information
hno committed Aug 16, 2001
1 parent 57e470e commit abc6aaf
Show file tree
Hide file tree
Showing 21 changed files with 377 additions and 356 deletions.
116 changes: 62 additions & 54 deletions helpers/basic_auth/LDAP/squid_ldap_auth.c
Expand Up @@ -11,7 +11,7 @@
* National Research Council
*
* Usage: squid_ldap_auth -b basedn [-s searchscope]
* [-f searchfilter] [-D binddn -w bindpasswd]
* [-f searchfilter] [-D binddn -w bindpasswd]
* [-u attr] [-p] [-R] <ldap_server_name>
*
* Dependencies: You need to get the OpenLDAP libraries
Expand All @@ -25,7 +25,7 @@
* Changes:
* 2001-05-02: Henrik Nordstrom <hno@squid-cache.org>
* - Support newer OpenLDAP 2.x libraries using the
* revised Internet Draft API which unfortunately
* revised Internet Draft API which unfortunately
* is not backwards compatible with RFC1823..
* 2001-04-15: Henrik Nordstrom <hno@squid-cache.org>
* - Added command line option for basedn
Expand Down Expand Up @@ -64,31 +64,38 @@ static int checkLDAP(LDAP * ld, char *userid, char *password);
/* Yuck.. we need to glue to different versions of the API */

#if defined(LDAP_API_VERSION) && LDAP_API_VERSION > 1823
static int squid_ldap_errno(LDAP *ld)
static int
squid_ldap_errno(LDAP * ld)
{
int err = 0;
ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &err);
return err;
}
static void squid_ldap_set_aliasderef(LDAP *ld, int deref)
static void
squid_ldap_set_aliasderef(LDAP * ld, int deref)
{
ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
}
static void squid_ldap_set_referrals(LDAP *ld, int referrals)
static void
squid_ldap_set_referrals(LDAP * ld, int referrals)
{
int *value = referrals ? LDAP_OPT_ON : LDAP_OPT_OFF;
ldap_set_option(ld, LDAP_OPT_REFERRALS, value);
}

#else
static int squid_ldap_errno(LDAP *ld)
static int
squid_ldap_errno(LDAP * ld)
{
return ld->ld_errno;
}
static void squid_ldap_set_aliasderef(LDAP *ld, int deref)
static void
squid_ldap_set_aliasderef(LDAP * ld, int deref)
{
ld->ld_deref = deref;
}
static void squid_ldap_set_referrals(LDAP *ld, int referrals)
static void
squid_ldap_set_referrals(LDAP * ld, int referrals)
{
if (referrals)
ld->ld_options |= ~LDAP_OPT_REFERRALS;
Expand All @@ -111,13 +118,13 @@ main(int argc, char **argv)
while (argc > 2 && argv[1][0] == '-') {
char *value = "";
char option = argv[1][1];
switch(option) {
switch (option) {
case 'p':
case 'R':
break;
default:
if (strlen(argv[1]) > 2) {
value = argv[1]+2;
value = argv[1] + 2;
} else {
value = argv[2];
argv++;
Expand All @@ -127,57 +134,57 @@ main(int argc, char **argv)
}
argv++;
argc--;
switch(option) {
switch (option) {
case 'b':
basedn = value;
break;
basedn = value;
break;
case 'f':
searchfilter = value;
break;
searchfilter = value;
break;
case 'u':
userattr = value;
break;
userattr = value;
break;
case 's':
if (strcmp(value, "base") == 0)
searchscope = LDAP_SCOPE_BASE;
else if (strcmp(value, "one") == 0)
searchscope = LDAP_SCOPE_ONELEVEL;
else if (strcmp(value, "sub") == 0)
searchscope = LDAP_SCOPE_SUBTREE;
else {
fprintf(stderr, "squid_ldap_auth: ERROR: Unknown search scope '%s'\n", value);
exit(1);
}
break;
if (strcmp(value, "base") == 0)
searchscope = LDAP_SCOPE_BASE;
else if (strcmp(value, "one") == 0)
searchscope = LDAP_SCOPE_ONELEVEL;
else if (strcmp(value, "sub") == 0)
searchscope = LDAP_SCOPE_SUBTREE;
else {
fprintf(stderr, "squid_ldap_auth: ERROR: Unknown search scope '%s'\n", value);
exit(1);
}
break;
case 'a':
if (strcmp(value, "never") == 0)
aliasderef = LDAP_DEREF_NEVER;
else if (strcmp(value, "always") == 0)
aliasderef = LDAP_DEREF_ALWAYS;
else if (strcmp(value, "search") == 0)
aliasderef = LDAP_DEREF_SEARCHING;
else if (strcmp(value, "find") == 0)
aliasderef = LDAP_DEREF_FINDING;
else {
fprintf(stderr, "squid_ldap_auth: ERROR: Unknown alias dereference method '%s'\n", value);
exit(1);
}
break;
if (strcmp(value, "never") == 0)
aliasderef = LDAP_DEREF_NEVER;
else if (strcmp(value, "always") == 0)
aliasderef = LDAP_DEREF_ALWAYS;
else if (strcmp(value, "search") == 0)
aliasderef = LDAP_DEREF_SEARCHING;
else if (strcmp(value, "find") == 0)
aliasderef = LDAP_DEREF_FINDING;
else {
fprintf(stderr, "squid_ldap_auth: ERROR: Unknown alias dereference method '%s'\n", value);
exit(1);
}
break;
case 'D':
binddn = value;
break;
binddn = value;
break;
case 'w':
bindpasswd = value;
break;
bindpasswd = value;
break;
case 'p':
persistent = !persistent;
break;
persistent = !persistent;
break;
case 'R':
noreferrals = !noreferrals;
break;
noreferrals = !noreferrals;
break;
default:
fprintf(stderr, "squid_ldap_auth: ERROR: Unknown command line option '%c'\n", option);
exit(1);
fprintf(stderr, "squid_ldap_auth: ERROR: Unknown command line option '%c'\n", option);
exit(1);
}
}

Expand Down Expand Up @@ -212,7 +219,7 @@ main(int argc, char **argv)
}
*passwd++ = '\0'; /* Cut in username,password */
tryagain = 1;
recover:
recover:
if (ld == NULL) {
if ((ld = ldap_init(ldapServer, LDAP_PORT)) == NULL) {
fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n",
Expand Down Expand Up @@ -258,7 +265,8 @@ checkLDAP(LDAP * ld, char *userid, char *password)
char filter[256];
LDAPMessage *res = NULL;
LDAPMessage *entry;
char *searchattr[] = {NULL};
char *searchattr[] =
{NULL};
char *userdn;
int rc;

Expand Down Expand Up @@ -300,6 +308,6 @@ checkLDAP(LDAP * ld, char *userid, char *password)

if (ldap_simple_bind_s(ld, dn, password) != LDAP_SUCCESS)
return 1;

return 0;
}
2 changes: 1 addition & 1 deletion helpers/ntlm_auth/SMB/ntlm.h
Expand Up @@ -57,7 +57,7 @@ static char *__foo;
#define debug(X...) /* */
#endif /* DEBUG */
#else /* __GNUC__ */
static void
static void
debug(char *format,...)
{
}
Expand Down
6 changes: 3 additions & 3 deletions src/HttpReply.c
Expand Up @@ -469,7 +469,7 @@ httpReplyBodySize(method_t method, HttpReply * reply)
* Calculates the maximum size allowed for an HTTP response
*/
void
httpReplyBodyBuildSize(request_t *request, HttpReply * reply, dlink_list *bodylist)
httpReplyBodyBuildSize(request_t * request, HttpReply * reply, dlink_list * bodylist)
{
body_size *bs;
aclCheck_t *checklist;
Expand All @@ -484,8 +484,8 @@ httpReplyBodyBuildSize(request_t *request, HttpReply * reply, dlink_list *bodyli
/* Allow - use this entry */
reply->maxBodySize = bs->maxsize;
bs = NULL;
debug (58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %d\n", reply->maxBodySize);
debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %d\n", reply->maxBodySize);
}
aclChecklistFree(checklist);
aclChecklistFree(checklist);
}
}

0 comments on commit abc6aaf

Please sign in to comment.