]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceFormat Enforcement
authorAutomatic source maintenance <squidadm@squid-cache.org>
Sat, 12 Jun 2010 00:12:55 +0000 (18:12 -0600)
committerAutomatic source maintenance <squidadm@squid-cache.org>
Sat, 12 Jun 2010 00:12:55 +0000 (18:12 -0600)
helpers/ntlm_auth/smb_lm/libntlmssp.c
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c
include/ntlmauth.h
lib/ntlmauth.c
src/tools.cc

index c8d6b550cde6b0e971825ec8099e68aa843e6d4e..1f4f892710f4715ecb43df6716986849a8357f52 100644 (file)
@@ -154,11 +154,11 @@ make_challenge(char *domain, char *domain_controller)
     }
     ntlm_challenge chal;
     u_int32_t flags = REQUEST_NON_NT_SESSION_KEY |
-                   CHALLENGE_TARGET_IS_DOMAIN |
-                   NEGOTIATE_ALWAYS_SIGN |
-                   NEGOTIATE_USE_NTLM |
-                   NEGOTIATE_USE_LM |
-                   NEGOTIATE_ASCII;
+                      CHALLENGE_TARGET_IS_DOMAIN |
+                      NEGOTIATE_ALWAYS_SIGN |
+                      NEGOTIATE_USE_NTLM |
+                      NEGOTIATE_USE_LM |
+                      NEGOTIATE_ASCII;
     ntlm_make_challenge(&chal, my_domain, my_domain_controller, (char *)challenge, NTLM_NONCE_LEN, flags);
     int len = sizeof(chal) - sizeof(chal.payload) + le16toh(chal.target.maxlen);
     return base64_encode_bin((char *)&chal, len);
@@ -268,8 +268,8 @@ ntlm_check_auth(ntlm_authenticate * auth, int auth_length)
 
 #if 1
     debug("Empty LM pass detection: user: '%s', ours:'%s', his: '%s'"
-                "(length: %d)\n",
-                user,lmencoded_empty_pass,tmp.str,tmp.l);
+          "(length: %d)\n",
+          user,lmencoded_empty_pass,tmp.str,tmp.l);
     if (memcmp(tmp.str,lmencoded_empty_pass,ENCODED_PASS_LEN)==0) {
         fprintf(stderr,"Empty LM password supplied for user %s\\%s. "
                 "No-auth\n",domain,user);
@@ -280,8 +280,8 @@ ntlm_check_auth(ntlm_authenticate * auth, int auth_length)
     tmp = ntlm_fetch_string(&(auth->hdr), auth_length, &auth->ntresponse, auth->flags);
     if (tmp.str != NULL && tmp.l != 0) {
         debug("Empty NT pass detection: user: '%s', ours:'%s', his: '%s'"
-                    "(length: %d)\n",
-                    user,ntencoded_empty_pass,tmp.str,tmp.l);
+              "(length: %d)\n",
+              user,ntencoded_empty_pass,tmp.str,tmp.l);
         if (memcmp(tmp.str,lmencoded_empty_pass,ENCODED_PASS_LEN)==0) {
             fprintf(stderr,"Empty NT password supplied for user %s\\%s. "
                     "No-auth\n",domain,user);
index 4f16a61fc94837eb4fa371bcee3e0bc7cb286a01..89379611c922c1159ffd6db7b8fb50392bcfebf2 100644 (file)
@@ -248,7 +248,7 @@ obtain_challenge()
     const char *ch = NULL;
     for (j = 0; j < numcontrollers; j++) {
         debug("obtain_challenge: selecting %s\\%s (attempt #%d)\n",
-                    current_dc->domain, current_dc->controller, j + 1);
+              current_dc->domain, current_dc->controller, j + 1);
         if (current_dc->dead != 0) {
             if (time(NULL) - current_dc->dead >= DEAD_DC_RETRY_INTERVAL) {
                 /* mark helper as retry-worthy if it's so. */
index 525ff93d921bbfc8bb8fb5206be986bdde81ad34..371ae9c2e364b8696576e74618ee92975a7cd9c3 100644 (file)
 extern "C" {
 #endif
 
-/* Used internally. Microsoft seems to think this is right, I believe them.
- * Right. */
+    /* Used internally. Microsoft seems to think this is right, I believe them.
    * Right. */
 #define NTLM_MAX_FIELD_LENGTH 300      /* max length of an NTLMSSP field */
 
 
-/* Here start the NTLMSSP definitions */
+    /* Here start the NTLMSSP definitions */
 
-/* these are marked as "extra" fields */
+    /* these are marked as "extra" fields */
 #define REQUEST_INIT_RESPONSE          0x100000
 #define REQUEST_ACCEPT_RESPONSE        0x200000
 #define REQUEST_NON_NT_SESSION_KEY     0x400000
 
 
-/** String header. String data resides at the end of the request */
-typedef struct _strhdr {
-    int16_t len;               /**< Length in bytes */
-    int16_t maxlen;            /**< Allocated space in bytes */
-    int32_t offset;            /**< Offset from start of request */
-} strhdr;
+    /** String header. String data resides at the end of the request */
+    typedef struct _strhdr {
+        int16_t len;           /**< Length in bytes */
+        int16_t maxlen;                /**< Allocated space in bytes */
+        int32_t offset;                /**< Offset from start of request */
+    } strhdr;
 
-/** We use this to keep data/length couples. */
-typedef struct _lstring {
-    int32_t l;                 /**< length, -1 if empty */
-    char *str;                 /**< the string. NULL if not initialized */
-} lstring;
+    /** We use this to keep data/length couples. */
+    typedef struct _lstring {
+        int32_t l;                     /**< length, -1 if empty */
+        char *str;                     /**< the string. NULL if not initialized */
+    } lstring;
 
-/** Debug dump the given flags field to stderr */
-void ntlm_dump_ntlmssp_flags(const u_int32_t flags);
+    /** Debug dump the given flags field to stderr */
+    void ntlm_dump_ntlmssp_flags(const u_int32_t flags);
 
 
-/* ************************************************************************* */
-/* Packet and Payload structures and handling functions */
-/* ************************************************************************* */
+    /* ************************************************************************* */
+    /* Packet and Payload structures and handling functions */
+    /* ************************************************************************* */
 
-/* NTLM request types that we know about */
+    /* NTLM request types that we know about */
 #define NTLM_ANY                       0
 #define NTLM_NEGOTIATE                 1
 #define NTLM_CHALLENGE                 2
 #define NTLM_AUTHENTICATE              3
 
-/** This is an header common to all packets, it's used to discriminate
- * among the different packet signature types.
- */
-typedef struct _ntlmhdr {
-    char signature[8];         /**< "NTLMSSP" */
-    int32_t type;              /**< One of the NTLM_* types above. */
-} ntlmhdr;
-
-/** Validate the packet type matches one we want. */
-int ntlm_validate_packet(const ntlmhdr *packet, const int type);
-
-/** Retrieve a string from the NTLM packet payload. */
-lstring ntlm_fetch_string(const ntlmhdr *packet,
-                          const int32_t packet_length,
-                          const strhdr *str,
-                          const u_int32_t flags);
-
-/** Append a string to the NTLM packet payload. */
-void ntlm_add_to_payload(const ntlmhdr *packet_hdr,
-                         char *payload,
-                         int *payload_length,
-                         strhdr * hdr,
-                         const char *toadd,
-                         const int toadd_length);
-
-
-/* ************************************************************************* */
-/* Negotiate Packet structures and functions */
-/* ************************************************************************* */
-
-/* negotiate request flags */
+    /** This is an header common to all packets, it's used to discriminate
    * among the different packet signature types.
    */
+    typedef struct _ntlmhdr {
+        char signature[8];             /**< "NTLMSSP" */
+        int32_t type;          /**< One of the NTLM_* types above. */
+    } ntlmhdr;
+
+    /** Validate the packet type matches one we want. */
+    int ntlm_validate_packet(const ntlmhdr *packet, const int type);
+
+    /** Retrieve a string from the NTLM packet payload. */
+    lstring ntlm_fetch_string(const ntlmhdr *packet,
+                              const int32_t packet_length,
+                              const strhdr *str,
+                              const u_int32_t flags);
+
+    /** Append a string to the NTLM packet payload. */
+    void ntlm_add_to_payload(const ntlmhdr *packet_hdr,
+                             char *payload,
+                             int *payload_length,
+                             strhdr * hdr,
+                             const char *toadd,
+                             const int toadd_length);
+
+
+    /* ************************************************************************* */
+    /* Negotiate Packet structures and functions */
+    /* ************************************************************************* */
+
+    /* negotiate request flags */
 #define NEGOTIATE_UNICODE              0x0001
 #define NEGOTIATE_ASCII                0x0002
 #define NEGOTIATE_REQUEST_TARGET       0x0004
@@ -148,75 +148,75 @@ void ntlm_add_to_payload(const ntlmhdr *packet_hdr,
 #define NEGOTIATE_THIS_IS_LOCAL_CALL   0x4000
 #define NEGOTIATE_ALWAYS_SIGN          0x8000
 
-/** Negotiation request sent by client */
-typedef struct _ntlm_negotiate {
-    ntlmhdr hdr;               /**< "NTLMSSP" , LSWAP(0x1) */
-    u_int32_t flags;           /**< Request flags */
-    strhdr domain;             /**< Domain we wish to authenticate in */
-    strhdr workstation;                /**< Client workstation name */
-    char payload[256];         /**< String data */
-} ntlm_negotiate;
+    /** Negotiation request sent by client */
+    typedef struct _ntlm_negotiate {
+        ntlmhdr hdr;           /**< "NTLMSSP" , LSWAP(0x1) */
+        u_int32_t flags;               /**< Request flags */
+        strhdr domain;         /**< Domain we wish to authenticate in */
+        strhdr workstation;            /**< Client workstation name */
+        char payload[256];             /**< String data */
+    } ntlm_negotiate;
 
 
-/* ************************************************************************* */
-/* Challenge Packet structures and functions */
-/* ************************************************************************* */
+    /* ************************************************************************* */
+    /* Challenge Packet structures and functions */
+    /* ************************************************************************* */
 
 #define NTLM_NONCE_LEN 8
 
-/* challenge request flags */
+    /* challenge request flags */
 #define CHALLENGE_TARGET_IS_DOMAIN     0x10000
 #define CHALLENGE_TARGET_IS_SERVER     0x20000
 #define CHALLENGE_TARGET_IS_SHARE      0x40000
 
-/** Challenge request sent by server. */
-typedef struct _ntlm_challenge {
-    ntlmhdr hdr;               /**< "NTLMSSP" , LSWAP(0x2) */
-    strhdr target;             /**< Authentication target (domain/server ...) */
-    u_int32_t flags;           /**< Request flags */
-    u_char challenge[NTLM_NONCE_LEN];  /**< Challenge string */
-    u_int32_t context_low;     /**< LS part of the server context handle */
-    u_int32_t context_high;    /**< MS part of the server context handle */
-    char payload[256];         /**< String data */
-} ntlm_challenge;
-
-/* Size of the ntlm_challenge structures formatted fields (excluding payload) */
+    /** Challenge request sent by server. */
+    typedef struct _ntlm_challenge {
+        ntlmhdr hdr;           /**< "NTLMSSP" , LSWAP(0x2) */
+        strhdr target;         /**< Authentication target (domain/server ...) */
+        u_int32_t flags;               /**< Request flags */
+        u_char challenge[NTLM_NONCE_LEN];      /**< Challenge string */
+        u_int32_t context_low; /**< LS part of the server context handle */
+        u_int32_t context_high;        /**< MS part of the server context handle */
+        char payload[256];             /**< String data */
+    } ntlm_challenge;
+
+    /* Size of the ntlm_challenge structures formatted fields (excluding payload) */
 #define NTLM_CHALLENGE_HEADER_OFFSET   (sizeof(ntlm_challenge)-256)
 
-/** Generate a challenge request nonce. */
-void ntlm_make_nonce(char *nonce);
-
-/** Generate a challenge request Blob to be sent to the client. */
-void ntlm_make_challenge(ntlm_challenge *ch,
-                         const char *domain,
-                         const char *domain_controller,
-                         const char *challenge_nonce,
-                         const int challenge_nonce_len,
-                         const u_int32_t flags);
-
-
-/* ************************************************************************* */
-/* Authenticate Packet structures and functions */
-/* ************************************************************************* */
-
-/** Authentication request sent by client in response to challenge */
-typedef struct _ntlm_authenticate {
-    ntlmhdr hdr;               /**< "NTLMSSP" , LSWAP(0x3) */
-    strhdr lmresponse;         /**< LANMAN challenge response */
-    strhdr ntresponse;         /**< NT challenge response */
-    strhdr domain;             /**< Domain to authenticate against */
-    strhdr user;               /**< Username */
-    strhdr workstation;                /**< Workstation name */
-    strhdr sessionkey;         /**< Session key for server's use */
-    int32_t flags;             /**< Request flags */
-    char payload[256 * 6];     /**< String data */
-} ntlm_authenticate;
-
-/** Unpack username and domain out of a packet payload. */
-int ntlm_unpack_auth(const ntlm_authenticate *auth,
-                     char *user,
-                     char *domain,
-                     const int32_t size);
+    /** Generate a challenge request nonce. */
+    void ntlm_make_nonce(char *nonce);
+
+    /** Generate a challenge request Blob to be sent to the client. */
+    void ntlm_make_challenge(ntlm_challenge *ch,
+                             const char *domain,
+                             const char *domain_controller,
+                             const char *challenge_nonce,
+                             const int challenge_nonce_len,
+                             const u_int32_t flags);
+
+
+    /* ************************************************************************* */
+    /* Authenticate Packet structures and functions */
+    /* ************************************************************************* */
+
+    /** Authentication request sent by client in response to challenge */
+    typedef struct _ntlm_authenticate {
+        ntlmhdr hdr;           /**< "NTLMSSP" , LSWAP(0x3) */
+        strhdr lmresponse;             /**< LANMAN challenge response */
+        strhdr ntresponse;             /**< NT challenge response */
+        strhdr domain;         /**< Domain to authenticate against */
+        strhdr user;           /**< Username */
+        strhdr workstation;            /**< Workstation name */
+        strhdr sessionkey;             /**< Session key for server's use */
+        int32_t flags;         /**< Request flags */
+        char payload[256 * 6]; /**< String data */
+    } ntlm_authenticate;
+
+    /** Unpack username and domain out of a packet payload. */
+    int ntlm_unpack_auth(const ntlm_authenticate *auth,
+                         char *user,
+                         char *domain,
+                         const int32_t size);
 
 
 #if __cplusplus
index 1469e4d29b591b1f211b4e041a10998a16e37f4b..75c963d2d079b4a558975d03a6b8dd52d910db77 100644 (file)
@@ -194,7 +194,7 @@ ntlm_add_to_payload(const ntlmhdr *packet_hdr,
 /* Challenge Packet functions */
 /* ************************************************************************* */
 
-/* 
+/*
  * Generates a challenge request nonce. The randomness of the 8 byte
  * challenge strings can be guarenteed to be poor at best.
  */
@@ -239,9 +239,9 @@ ntlm_make_challenge(const char *domain, const char *dc_UNUSED,
 
     ntlm_make_challenge(&chal, domain, dc_UNUSED, cn, cnl, flags);
 
-/*  ORIGINAL handling of ntlm_challenge object was to encode it like this:
-    TODO: find all old callers and have them do teh decode themselves now.
-*/
+    /*  ORIGINAL handling of ntlm_challenge object was to encode it like this:
+        TODO: find all old callers and have them do teh decode themselves now.
+    */
     return base64_encode_bin((char *)&chal, NTLM_CHALLENGE_HEADER_OFFSET + pl);
 }
 #endif
index cd4b71fbeb7662cbf661027ef89984377d3668c0..c88ee054f7056cffc0da54fd91b69eec6f3b6c5e 100644 (file)
@@ -901,7 +901,7 @@ setMaxFD(void)
         }
     }
     if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
-         debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror());
+        debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror());
     } else {
         Squid_MaxFD = rl.rlim_cur;
     }