Update to cntlm-0.92.1 and add a rc script.

ok ajacoutot@
This commit is contained in:
dcoppa 2012-01-25 22:00:15 +00:00
parent bc9324b36a
commit f3722359d3
12 changed files with 112 additions and 163 deletions

View File

@ -1,11 +1,10 @@
# $OpenBSD: Makefile,v 1.5 2010/11/22 08:36:47 espie Exp $
# $OpenBSD: Makefile,v 1.6 2012/01/25 22:00:15 dcoppa Exp $
COMMENT = fast NTLM/NTLMv2 authenticating HTTP proxy
DISTNAME = cntlm-0.35.1
REVISION = 0
DISTNAME = cntlm-0.92.1
CATEGORIES = www
MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=cntlm/}
HOMEPAGE = http://cntlm.sourceforge.net/
HOMEPAGE = http://awk.cz/cntlm/
MAINTAINER = David Coppa <dcoppa@openbsd.org>
# GPLv2+
@ -16,6 +15,11 @@ PERMIT_DISTFILES_FTP = Yes
WANTLIB = c pthread
FAKE_FLAGS = INSTALL_DATA="${INSTALL_DATA}" \
INSTALL_DATA_DIR="${INSTALL_DATA_DIR}" \
INSTALL_MAN="${INSTALL_MAN}" \
INSTALL_PROGRAM="${INSTALL_PROGRAM}"
CONFIGURE_STYLE = simple
ALL_TARGET = cntlm
USE_GROFF = Yes

View File

@ -1,5 +1,5 @@
MD5 (cntlm-0.35.1.tar.gz) = JUfHOhFZBi/aoYd8wDoi9g==
RMD160 (cntlm-0.35.1.tar.gz) = ZaK5em7INAtBrL0PKdwQlhSKAqw=
SHA1 (cntlm-0.35.1.tar.gz) = S/n3Ww9f20RptegQE8QKwWbJ0jU=
SHA256 (cntlm-0.35.1.tar.gz) = ez+3GE5yzD8XQ7uOUDpTBelkWLxjCn4ev8nzwH/6bF4=
SIZE (cntlm-0.35.1.tar.gz) = 74188
MD5 (cntlm-0.92.1.tar.gz) = Fr6KIo19ugqwaVikf5Y2Fw==
RMD160 (cntlm-0.92.1.tar.gz) = vKR4bkvlJXvf7aP2a+eeIVfE4bc=
SHA1 (cntlm-0.92.1.tar.gz) = OQuTE5dj9zE49PdLvrG5WEA3s4Y=
SHA256 (cntlm-0.92.1.tar.gz) = bUra0zcMn0uj9uGiMvEtt7ZtLUawMogn58akL8YwcbU=
SIZE (cntlm-0.92.1.tar.gz) = 94229

View File

@ -1,46 +1,67 @@
$OpenBSD: patch-Makefile,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
--- Makefile.orig Tue Nov 20 17:18:24 2007
+++ Makefile Thu Oct 8 05:03:34 2009
@@ -2,9 +2,9 @@
$OpenBSD: patch-Makefile,v 1.2 2012/01/25 22:00:15 dcoppa Exp $
--- Makefile.orig Tue Nov 29 23:18:41 2011
+++ Makefile Wed Jan 25 15:59:32 2012
@@ -2,10 +2,10 @@
# You can tweak these three variables to make things install where you
# like, but do not touch more unless you know what you are doing. ;)
#
-SYSCONFDIR=/usr/local/etc
-BINDIR=/usr/local/bin
-MANDIR=/usr/local/man
+SYSCONFDIR=${DESTDIR}/etc/${NAME}
+BINDIR=${PREFIX}/bin
-DESTDIR=
-SYSCONFDIR=$(DESTDIR)/etc
-BINDIR=$(DESTDIR)/usr/sbin
-MANDIR=$(DESTDIR)/usr/share/man
+DESTDIR?=
+SYSCONFDIR=$(DESTDIR)/etc/${NAME}
+BINDIR=${PREFIX}/sbin
+MANDIR=${PREFIX}/man
#
# Careful now...
@@ -13,8 +13,8 @@ MANDIR=/usr/local/man
#
@@ -16,26 +16,23 @@ NAME=cntlm
CC=gcc
OBJS=utils.o ntlm.o xcrypt.o config.o socket.o acl.o auth.o http.o proxy.o
-CFLAGS=$(FLAGS) -std=c99 -Wall -pedantic -O3 -D__BSD_VISIBLE -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112 -D_ISOC99_SOURCE -D_REENTRANT -DVERSION=\"`cat VERSION`\"
-LDFLAGS=-lpthread
+CFLAGS=$(FLAGS) -std=c99 -Wall -pedantic -D__BSD_VISIBLE -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112 -D_ISOC99_SOURCE -D_REENTRANT -DVERSION=\"`cat VERSION`\"
+LDFLAGS=-pthread
NAME=cntlm
VER=`cat VERSION`
DIR=`pwd`
@@ -42,12 +42,13 @@ install: $(NAME)
install -O root -G system -M 644 -f $(MANDIR)/man1 doc/$(NAME).1; \
install -O root -G system -M 600 -c $(SYSCONFDIR) doc/$(NAME).conf; \
OBJS=utils.o ntlm.o xcrypt.o config.o socket.o acl.o auth.o http.o forward.o direct.o scanner.o pages.o main.o
-CFLAGS+=$(FLAGS) -std=c99 -Wall -pedantic -O3 -D__BSD_VISIBLE -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112 -D_ISOC99_SOURCE -D_REENTRANT -D_BSD_SOURCE -DVERSION=\"`cat VERSION`\"
+CFLAGS+=$(FLAGS) -std=c99 -Wall -pedantic -D__BSD_VISIBLE -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112 -D_ISOC99_SOURCE -D_REENTRANT -D_BSD_SOURCE -DVERSION=\"`cat VERSION`\"
OS=$(shell uname -s)
OSLDFLAGS=$(shell [ $(OS) = "SunOS" ] && echo "-lrt -lsocket -lnsl")
-LDFLAGS:=-lpthread $(OSLDFLAGS)
+LDFLAGS:=-pthread $(OSLDFLAGS)
$(NAME): configure-stamp $(OBJS)
- @echo "Linking $@"
- @$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
main.o: main.c
- @echo "Compiling $<"
- @if [ -z "$(SYSCONFDIR)" ]; then \
+ if [ -z "$(SYSCONFDIR)" ]; then \
$(CC) $(CFLAGS) -c main.c -o $@; \
else \
- install -D -o root -g root -m 755 -s $(NAME) $(BINDIR)/$(NAME); \
- install -D -o root -g root -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
$(CC) $(CFLAGS) -DSYSCONFDIR=\"$(SYSCONFDIR)\" -c main.c -o $@; \
fi
.c.o:
- @echo "Compiling $<"
- @$(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CFLAGS) -c -o $@ $<
install: $(NAME)
# Special handling for install(1)
@@ -49,12 +46,11 @@ install: $(NAME)
[ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
|| install -d -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
else \
- install -D -m 755 -s $(NAME) $(BINDIR)/$(NAME); \
- install -D -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
- [ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
- || install -D -o root -g root -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
+ install -d -m 0755 ${BINDIR}; \
+ install -o root -g bin -m 0555 -s ${NAME} ${BINDIR}/${NAME}; \
+ install -d -m 0755 ${MANDIR}/man1; \
+ install -o root -g bin -m 0444 doc/${NAME}.1 ${MANDIR}/man1/${NAME}.1; \
+ install -d -m 0755 ${PREFIX}/share/examples/${NAME}; \
+ install -o root -g bin -m 0444 doc/${NAME}.conf ${PREFIX}/share/examples/${NAME}/${NAME}.conf; \
- || install -D -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
+ ${INSTALL_PROGRAM} $(NAME) $(BINDIR)/$(NAME); \
+ ${INSTALL_MAN} doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
+ ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/${NAME}; \
+ ${INSTALL_DATA} doc/$(NAME).conf ${PREFIX}/share/examples/${NAME}/${NAME}.conf; \
fi
- @echo; echo "Cntlm will look for configuration in $(SYSCONFDIR)/$(NAME).conf"
rpm:
if [ `id -u` = 0 ]; then \
tgz:
mkdir -p tmp

View File

@ -1,11 +0,0 @@
$OpenBSD: patch-acl_c,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
--- acl.c.orig Thu Oct 8 03:32:08 2009
+++ acl.c Thu Oct 8 03:32:21 2009
@@ -22,6 +22,7 @@
#include <syslog.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-ntlm_c,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
--- ntlm.c.orig Thu Oct 8 08:04:39 2009
+++ ntlm.c Thu Oct 8 08:05:27 2009
@@ -22,6 +22,7 @@
$OpenBSD: patch-ntlm_c,v 1.2 2012/01/25 22:00:15 dcoppa Exp $
--- ntlm.c.orig Mon Nov 28 14:55:15 2011
+++ ntlm.c Wed Jan 25 15:27:49 2012
@@ -23,6 +23,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
@ -9,12 +9,3 @@ $OpenBSD: patch-ntlm_c,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
#include "ntlm.h"
#include "swap.h"
@@ -75,7 +76,7 @@ static void ntlm2_calc_resp(char **nthash, int *ntlen,
if (0 && debug) {
tmp = printmem(nonce, 8, 7);
- printf("NTLMv2:\n\t Nonce: %s\n\tTimestamp: %lld\n", tmp, tw);
+ printf("NTLMv2:\n\t Nonce: %s\n\tTimestamp: %"PRId64"\n", tmp, tw);
free(tmp);
}

View File

@ -1,64 +0,0 @@
$OpenBSD: patch-proxy_c,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
--- proxy.c.orig Thu Nov 15 18:08:06 2007
+++ proxy.c Thu Oct 8 08:08:07 2009
@@ -530,6 +530,7 @@ bailout:
int make_connect(int sd, const char *thost) {
rr_data_t data1, data2;
int ret, closed;
+ hlist_t tl;
if (!sd || !thost || !strlen(thost))
return -1;
@@ -540,9 +541,18 @@ int make_connect(int sd, const char *thost) {
data1->req = 1;
data1->method = strdup("CONNECT");
data1->url = strdup(thost);
- data1->http = strdup("0");
+ data1->http = strdup("1");
data1->headers = hlist_mod(data1->headers, "Proxy-Connection", "Keep-Alive", 1);
+ /*
+ * Header replacement
+ */
+ tl = header_list;
+ while (tl) {
+ data1->headers = hlist_mod(data1->headers, tl->key, tl->value, 1);
+ tl = tl->next;
+ }
+
if (debug)
printf("Starting authentication...\n");
@@ -916,7 +926,7 @@ void *proxy_thread(void *client) {
char *tmp, *buf, *pos, *dom;
struct auth_s *tcreds; /* Per-thread credentials; for NTLM-to-basic */
- int cd = (int)client;
+ int cd = (int)(uintptr_t)client;
int authok = 0;
int sd = 0;
@@ -1387,7 +1397,7 @@ void *tunnel_thread(void *client) {
}
void *socks5_thread(void *client) {
- int cd = (int)client;
+ int cd = (int)(uintptr_t)client;
char *tmp, *thost, *tport, *uname, *upass;
unsigned char *bs, *auths, *addr;
unsigned short port;
@@ -2618,11 +2628,11 @@ int main(int argc, char **argv) {
if (plist_in(proxyd_list, i)) {
if (!serialize)
- tid = pthread_create(&pthr, &pattr, proxy_thread, (void *)cd);
+ tid = pthread_create(&pthr, &pattr, proxy_thread, (void *)(uintptr_t)cd);
else
- proxy_thread((void *)cd);
+ proxy_thread((void *)(uintptr_t)cd);
} else if (plist_in(socksd_list, i)) {
- tid = pthread_create(&pthr, &pattr, socks5_thread, (void *)cd);
+ tid = pthread_create(&pthr, &pattr, socks5_thread, (void *)(uintptr_t)cd);
} else {
data = (struct thread_arg_s *)new(sizeof(struct thread_arg_s));
data->fd = cd;

View File

@ -1,11 +0,0 @@
$OpenBSD: patch-socket_c,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
--- socket.c.orig Thu Oct 8 03:31:49 2009
+++ socket.c Thu Oct 8 03:32:04 2009
@@ -19,6 +19,7 @@
*
*/
+#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-swap_h,v 1.1 2012/01/25 22:00:15 dcoppa Exp $
--- swap.h.orig Mon Mar 29 01:58:51 2010
+++ swap.h Wed Jan 25 15:56:26 2012
@@ -26,6 +26,7 @@
#include "config/config.h"
+#if !defined(__OpenBSD__)
#define swap16(x) \
((uint16_t)( \
(((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
@@ -48,6 +49,7 @@
(((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
(((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
(((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) ))
+#endif
#if config_endian == 0
# define U16LE(x) swap16(x)

View File

@ -1,18 +0,0 @@
$OpenBSD: patch-utils_h,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
--- utils.h.orig Thu Oct 8 03:31:13 2009
+++ utils.h Thu Oct 8 03:31:43 2009
@@ -23,13 +23,13 @@
#define _UTILS_H
#include <pthread.h>
+#include <sys/param.h>
#include "config/config.h"
#define BUFSIZE 1024
#define MINIBUF_SIZE 50
#define VAL(var, type, offset) *((type *)(var+offset))
#define MEM(var, type, offset) (type *)(var+offset)
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
/*
* Two single-linked list types. First is for storing headers,

View File

@ -1,3 +1,5 @@
Cntlm is an http proxy server, written in pure C, that allows you to
authenticate via the proprietary NTLM protocol, so you can use web
sites and web proxies that require NTLM/NTLMv2 authorization.
Cntlm is an NTLM, NTLM2SR, and NTLMv2 authenticating HTTP proxy.
It stands between user's applications and the corporate proxy,
adding NTLM authentication on-the-fly. Cntlm supports multiple
parent proxies and all authenticated connections are cached and
reused to achieve high efficiency.

View File

@ -1,7 +1,10 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $
@bin bin/cntlm
@comment $OpenBSD: PLIST,v 1.2 2012/01/25 22:00:15 dcoppa Exp $
@newgroup _cntlm:692
@newuser _cntlm:692:_cntlm:daemon:Cntlm Daemon:/var/empty:/sbin/nologin
@man man/man1/cntlm.1
@bin sbin/cntlm
share/examples/cntlm/
@sample ${SYSCONFDIR}/cntlm/
share/examples/cntlm/cntlm.conf
@sample ${SYSCONFDIR}/cntlm/cntlm.conf
@rcscript ${RCDIR}/cntlm

13
www/cntlm/pkg/cntlm.rc Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
#
# $OpenBSD: cntlm.rc,v 1.1 2012/01/25 22:00:15 dcoppa Exp $
daemon="${TRUEPREFIX}/sbin/cntlm"
daemon_flags="-c ${SYSCONFDIR}/cntlm/cntlm.conf"
daemon_user="_cntlm"
. /etc/rc.d/rc.subr
rc_reload=NO
rc_cmd $1