From 70b63cddd088f84c774f5e47b9e6fcc52f4dc90d Mon Sep 17 00:00:00 2001 From: sthen Date: Thu, 8 Oct 2009 19:13:09 +0000 Subject: [PATCH] import www/cntlm, from maintainer David Coppa 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. --- www/cntlm/Makefile | 22 +++++++++++ www/cntlm/distinfo | 5 +++ www/cntlm/patches/patch-Makefile | 46 +++++++++++++++++++++++ www/cntlm/patches/patch-acl_c | 11 ++++++ www/cntlm/patches/patch-ntlm_c | 20 ++++++++++ www/cntlm/patches/patch-proxy_c | 64 ++++++++++++++++++++++++++++++++ www/cntlm/patches/patch-socket_c | 11 ++++++ www/cntlm/patches/patch-utils_h | 18 +++++++++ www/cntlm/pkg/DESCR | 3 ++ www/cntlm/pkg/PLIST | 7 ++++ 10 files changed, 207 insertions(+) create mode 100644 www/cntlm/Makefile create mode 100644 www/cntlm/distinfo create mode 100644 www/cntlm/patches/patch-Makefile create mode 100644 www/cntlm/patches/patch-acl_c create mode 100644 www/cntlm/patches/patch-ntlm_c create mode 100644 www/cntlm/patches/patch-proxy_c create mode 100644 www/cntlm/patches/patch-socket_c create mode 100644 www/cntlm/patches/patch-utils_h create mode 100644 www/cntlm/pkg/DESCR create mode 100644 www/cntlm/pkg/PLIST diff --git a/www/cntlm/Makefile b/www/cntlm/Makefile new file mode 100644 index 00000000000..19cccf8afed --- /dev/null +++ b/www/cntlm/Makefile @@ -0,0 +1,22 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $ + +COMMENT = fast NTLM/NTLMv2 authenticating HTTP proxy +DISTNAME = cntlm-0.35.1 +CATEGORIES = www +MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=cntlm/} +HOMEPAGE = http://cntlm.sourceforge.net/ +MAINTAINER = David Coppa + +# GPLv2+ +PERMIT_PACKAGE_CDROM = Yes +PERMIT_PACKAGE_FTP = Yes +PERMIT_DISTFILES_CDROM =Yes +PERMIT_DISTFILES_FTP = Yes + +WANTLIB = c pthread + +CONFIGURE_STYLE = simple +ALL_TARGET = cntlm +NO_REGRESS = Yes + +.include diff --git a/www/cntlm/distinfo b/www/cntlm/distinfo new file mode 100644 index 00000000000..d85586c5bd0 --- /dev/null +++ b/www/cntlm/distinfo @@ -0,0 +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 diff --git a/www/cntlm/patches/patch-Makefile b/www/cntlm/patches/patch-Makefile new file mode 100644 index 00000000000..46b47b87078 --- /dev/null +++ b/www/cntlm/patches/patch-Makefile @@ -0,0 +1,46 @@ +$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 @@ + # 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 ++MANDIR=${PREFIX}/man + + # + # Careful now... +@@ -13,8 +13,8 @@ MANDIR=/usr/local/man + # + 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; \ + 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; \ +- [ -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; \ + fi +- @echo; echo "Cntlm will look for configuration in $(SYSCONFDIR)/$(NAME).conf" + + rpm: + if [ `id -u` = 0 ]; then \ diff --git a/www/cntlm/patches/patch-acl_c b/www/cntlm/patches/patch-acl_c new file mode 100644 index 00000000000..9483d12b468 --- /dev/null +++ b/www/cntlm/patches/patch-acl_c @@ -0,0 +1,11 @@ +$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 + #include + #include ++#include + #include + #include + #include diff --git a/www/cntlm/patches/patch-ntlm_c b/www/cntlm/patches/patch-ntlm_c new file mode 100644 index 00000000000..26b9539b74c --- /dev/null +++ b/www/cntlm/patches/patch-ntlm_c @@ -0,0 +1,20 @@ +$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 @@ + #include + #include + #include ++#include + + #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); + } + diff --git a/www/cntlm/patches/patch-proxy_c b/www/cntlm/patches/patch-proxy_c new file mode 100644 index 00000000000..6b02b92a95c --- /dev/null +++ b/www/cntlm/patches/patch-proxy_c @@ -0,0 +1,64 @@ +$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; diff --git a/www/cntlm/patches/patch-socket_c b/www/cntlm/patches/patch-socket_c new file mode 100644 index 00000000000..521676ac4fc --- /dev/null +++ b/www/cntlm/patches/patch-socket_c @@ -0,0 +1,11 @@ +$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 + #include + #include + #include diff --git a/www/cntlm/patches/patch-utils_h b/www/cntlm/patches/patch-utils_h new file mode 100644 index 00000000000..c5e6a46776a --- /dev/null +++ b/www/cntlm/patches/patch-utils_h @@ -0,0 +1,18 @@ +$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 ++#include + #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, diff --git a/www/cntlm/pkg/DESCR b/www/cntlm/pkg/DESCR new file mode 100644 index 00000000000..60a086dea04 --- /dev/null +++ b/www/cntlm/pkg/DESCR @@ -0,0 +1,3 @@ +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. diff --git a/www/cntlm/pkg/PLIST b/www/cntlm/pkg/PLIST new file mode 100644 index 00000000000..3ff0887e1db --- /dev/null +++ b/www/cntlm/pkg/PLIST @@ -0,0 +1,7 @@ +@comment $OpenBSD: PLIST,v 1.1.1.1 2009/10/08 19:13:09 sthen Exp $ +@bin bin/cntlm +@man man/man1/cntlm.1 +share/examples/cntlm/ +@sample ${SYSCONFDIR}/cntlm/ +share/examples/cntlm/cntlm.conf +@sample ${SYSCONFDIR}/cntlm/cntlm.conf