~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to helpers/ntlm_auth/fakeauth/ntlm.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: ntlm.h,v 1.9 2006/08/28 09:06:41 serassio Exp $
 
3
 *
 
4
 * AUTHOR: Andrew Doran <ad@interlude.eu.org>
 
5
 *
 
6
 * SQUID Web Proxy Cache          http://www.squid-cache.org/
 
7
 * ----------------------------------------------------------
 
8
 *
 
9
 *  Squid is the result of efforts by numerous individuals from
 
10
 *  the Internet community; see the CONTRIBUTORS file for full
 
11
 *  details.   Many organizations have provided support for Squid's
 
12
 *  development; see the SPONSORS file for full details.  Squid is
 
13
 *  Copyrighted (C) 2001 by the Regents of the University of
 
14
 *  California; see the COPYRIGHT file for full details.  Squid
 
15
 *  incorporates software developed and/or copyrighted by other
 
16
 *  sources; see the CREDITS file for full details.
 
17
 *
 
18
 *  This program is free software; you can redistribute it and/or modify
 
19
 *  it under the terms of the GNU General Public License as published by
 
20
 *  the Free Software Foundation; either version 2 of the License, or
 
21
 *  (at your option) any later version.
 
22
 *  
 
23
 *  This program is distributed in the hope that it will be useful,
 
24
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
25
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
26
 *  GNU General Public License for more details.
 
27
 *  
 
28
 *  You should have received a copy of the GNU General Public License
 
29
 *  along with this program; if not, write to the Free Software
 
30
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
 
31
 *  
 
32
 */
 
33
 
 
34
#ifndef _NTLM_H_
 
35
#define _NTLM_H_
 
36
 
 
37
/* undefine this to have strict protocol adherence. You don't really need
 
38
 * that though */
 
39
#define IGNORANCE_IS_BLISS
 
40
 
 
41
#include <sys/types.h>
 
42
 
 
43
/* All of this cruft is little endian */
 
44
#include "squid_endian.h"
 
45
 
 
46
/* NTLM request types that we know about */
 
47
#define NTLM_ANY          0
 
48
 
 
49
/* Negotiation request sent by client */
 
50
struct ntlm_negotiate {
 
51
    ntlmhdr hdr;                /* NTLM header */
 
52
    int32_t flags;              /* Request flags */
 
53
    strhdr domain;              /* Domain we wish to authenticate in */
 
54
    strhdr workstation;         /* Client workstation name */
 
55
    char pad[256];              /* String data */
 
56
};
 
57
 
 
58
/* Challenge request sent by server. */
 
59
struct ntlm_challenge {
 
60
    ntlmhdr hdr;                /* NTLM header */
 
61
    strhdr target;              /* Authentication target (domain/server ...) */
 
62
    int32_t flags;              /* Request flags */
 
63
    u_char challenge[8];        /* Challenge string */
 
64
    int16_t unknown[8];         /* Some sort of context data */
 
65
    char pad[256];              /* String data */
 
66
};
 
67
 
 
68
/* Authentication request sent by client in response to challenge */
 
69
struct ntlm_authenticate {
 
70
    ntlmhdr hdr;                /* NTLM header */
 
71
    strhdr lmresponse;          /* LANMAN challenge response */
 
72
    strhdr ntresponse;          /* NT challenge response */
 
73
    strhdr domain;              /* Domain to authenticate against */
 
74
    strhdr user;                /* Username */
 
75
    strhdr workstation;         /* Workstation name */
 
76
    strhdr sessionkey;          /* Session key for server's use */
 
77
    int32_t flags;              /* Request flags */
 
78
    char pad[256 * 6];          /* String data */
 
79
};
 
80
 
 
81
char *ntlmGetString(ntlmhdr * hdr, strhdr * str, int flags);
 
82
void ntlmMakeChallenge(struct ntlm_challenge *chal, int32_t flags);
 
83
int ntlmCheckHeader(ntlmhdr * hdr, int type);
 
84
int ntlmCheckNegotiation(struct ntlm_negotiate *neg);
 
85
int ntlmAuthenticate(struct ntlm_authenticate *neg);
 
86
 
 
87
#define safe_free(x)    if (x) { free(x); x = NULL; }
 
88
 
 
89
#undef debug
 
90
 
 
91
/************* CONFIGURATION ***************/
 
92
/*
 
93
 * define this if you want debugging
 
94
 */
 
95
#ifndef DEBUG
 
96
#define DEBUG
 
97
#endif
 
98
 
 
99
#define FAIL_DEBUG 0
 
100
 
 
101
/************* END CONFIGURATION ***************/
 
102
 
 
103
#include <sys/types.h>
 
104
 
 
105
extern int debug_enabled;
 
106
#if FAIL_DEBUG
 
107
extern int fail_debug_enabled;
 
108
#endif
 
109
 
 
110
/* Debugging stuff */
 
111
 
 
112
#ifdef __GNUC__                 /* this is really a gcc-ism */
 
113
#ifdef DEBUG
 
114
#include <stdio.h>
 
115
#include <unistd.h>
 
116
static const char *__foo;
 
117
#define debug(X...) if (debug_enabled) { \
 
118
                    fprintf(stderr,"ntlm-auth[%ld](%s:%d): ", (long)getpid(), \
 
119
                    ((__foo=strrchr(__FILE__,'/'))==NULL?__FILE__:__foo+1),\
 
120
                    __LINE__);\
 
121
                    fprintf(stderr,X); }
 
122
#else /* DEBUG */
 
123
#define debug(X...)             /* */
 
124
#endif /* DEBUG */
 
125
#else /* __GNUC__ */
 
126
static void
 
127
debug(char *format,...)
 
128
{
 
129
#ifdef DEBUG
 
130
#ifdef _SQUID_MSWIN_
 
131
#if FAIL_DEBUG
 
132
    if (debug_enabled || fail_debug_enabled) {
 
133
#else
 
134
    if (debug_enabled) {
 
135
#endif
 
136
        va_list args;
 
137
 
 
138
        va_start(args, format);
 
139
        fprintf(stderr, "ntlm-auth[%ld]: ", (long)getpid());
 
140
        vfprintf(stderr, format, args);
 
141
        va_end(args);
 
142
#if FAIL_DEBUG
 
143
        fail_debug_enabled = 0;
 
144
#endif
 
145
    }
 
146
#endif /* _SQUID_MSWIN_ */
 
147
#endif /* DEBUG */
 
148
}
 
149
#endif /* __GNUC__ */
 
150
 
 
151
 
 
152
/* A couple of harmless helper macros */
 
153
#define SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n");
 
154
#ifdef __GNUC__
 
155
#define SEND2(X,Y...) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
 
156
#else
 
157
/* no gcc, no debugging. varargs macros are a gcc extension */
 
158
#define SEND2(X,Y) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
 
159
#endif
 
160
 
 
161
#endif /* _NTLM_H_ */