Skip to content

Commit

Permalink
Add code from 0.9.9.2 release
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/ntlmaps/code/trunk@142 4414eb6b-45f7-0310-abf5-9c8861e1d96f
  • Loading branch information
dixond committed Jun 10, 2005
1 parent 287ac05 commit 9ab8c7d
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 29 deletions.
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 0.9.9.2 Wednesday 23rd February 2005 Darryl Dixon <[email protected]>
- Added support for hostnames to FRIENDLY_IPS in server.cfg and config_affairs.py
- Include some preliminary (alpha) packaging stuff
- REQUEST sourceforge ID#1143827: Changed logic in config.py to make # work in passwords
- Add fix for Python 1.5.2 compatability to exception clause in config_affairs.py
- Fix Host check in self.determinemode() in proxy_client.py
- Fix self.monitor with no threadsToKill attribute in server.py

Version 0.9.9.1 Monday 14th February 2005 Darryl Dixon <[email protected]>
- Added HOSTS_TO_BYPASS_PARENT_PROXY configuration item in server.cfg
- Added processing of HOSTS_TO_BYPASS_PARENT_PROXY to config_affairs.py
Expand Down
35 changes: 15 additions & 20 deletions lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,33 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#

import string
import getopt
import string, getopt

#-------------------------------------------------------------------------------------------
def read_config(fname):
""
res = {}
section_name = 'DEFAULT'

buf = open(fname).readlines()
for i in range(len(buf)):
t = buf[i]
t = string.split(t, '#')[0]
t = string.strip(t)

if t:
if t[0] == '[' and t[-1] == ']':
section_name = string.strip(t[1:-1])
if section_name:
res[section_name] = {}
else:
parts = string.split(t, ':')
if len(parts) > 1:
res[section_name][string.strip(parts[0])] = string.strip(parts[1])

for line in buf:
workingLine = string.strip(line)
if workingLine:
if workingLine[0] != '#':
if workingLine[0] == '[' and workingLine[-1] == ']':
section_name = string.strip(workingLine[1:-1])
if section_name:
res[section_name] = {}
else:
parts = string.split(workingLine, ':')
if len(parts) > 1:
res[section_name][string.strip(parts[0])] = string.strip(parts[1])
return res

#-------------------------------------------------------------------------------------------
# Thanks Janek Schwarz <[email protected]> for this addition.

def findConfigFileNameInArgv(argv, configFileDir=''):
""" Resolves configuration file. Resolution goes as follows:
if the command switch '-c' is given it's argument is taken as
if the command switch '-c' is given its argument is taken as
the config file. Otherwise the function falls back to
'server.cfg' in the current directory. """

Expand Down
13 changes: 11 additions & 2 deletions lib/config_affairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#-------------------------------------------------------------------------
def arrange(conf):
""

#-----------------------------------------------
# GENERAL
Expand Down Expand Up @@ -50,13 +49,23 @@ def arrange(conf):
conf['GENERAL']['HOST'] = hostname
try:
externalIP = socket.gethostbyname_ex(hostname)[2]
except socket.gaierror:
except (socket.error): #socket.gaierror in Python 2.x
print "ERROR: Unable to get the IP address of this machine. This is not a fatal problem, but may cause problems for you using this proxy in some scenarios."
externalIP = []
conf['GENERAL']['HOST_IP_LIST'] = externalIP + ['127.0.0.1']

conf['GENERAL']['FRIENDLY_IPS'] = conf['GENERAL']['HOST_IP_LIST'] + string.split(conf['GENERAL']['FRIENDLY_IPS'])

# Idea contributed by Fernando M. Garcia Garcia:
saneList = []
for host in conf['GENERAL']['FRIENDLY_IPS']:
try:
saneList.append(socket.gethostbyname(host))
except (socket.error): #socket.gaierror on Python 2.x
print "ERROR: Could not get IP address for %s in list of FRIENDLY_IPS" % host
sys.exit(1)
conf['GENERAL']['FRIENDLY_IPS'] = saneList

conf['GENERAL']['URL_LOG'] = makeInt(conf['GENERAL']['URL_LOG'], 'URL_LOG')
url_logger = logger.Logger('url.log', conf['GENERAL']['URL_LOG'])
url_logger_lock = thread.allocate_lock()
Expand Down
7 changes: 5 additions & 2 deletions lib/proxy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,11 @@ def determine_mode(self):
if self.config['GENERAL']['HOSTS_TO_BYPASS_PARENT_PROXY']:
try:
host = self.client_head_obj.get_param_values('Host')
if host[0] in self.config['GENERAL']['HOSTS_TO_BYPASS_PARENT_PROXY']:
self.move_to_www_mode()
if host:
if host[0] in self.config['GENERAL']['HOSTS_TO_BYPASS_PARENT_PROXY']:
self.move_to_www_mode()
else:
self.move_to_proxy_mode()
else:
self.move_to_proxy_mode()
except KeyError:
Expand Down
5 changes: 4 additions & 1 deletion lib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def run(self):

#--------------------------------------------------------------
def client_run(self, conn, addr):
c = proxy_client.proxy_HTTP_Client(conn, addr, self.config, self.watchUpstream, self.monLock, self.monitor.threadsToKill)
if self.watchUpstream:
c = proxy_client.proxy_HTTP_Client(conn, addr, self.config, self.watchUpstream, self.monLock, self.monitor.threadsToKill)
else:
c = proxy_client.proxy_HTTP_Client(conn, addr, self.config, self.watchUpstream)
thread.start_new_thread(c.run, ())

#--------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# look for default config name in lib/config.py
conf = config.read_config(config.findConfigFileNameInArgv(sys.argv, __init__.ntlmaps_dir+'/'))

conf['GENERAL']['VERSION'] = '0.9.9.1'
conf['GENERAL']['VERSION'] = '0.9.9.2'

#--------------------------------------------------------------
print 'NTLM authorization Proxy Server v%s' % conf['GENERAL']['VERSION']
Expand Down
12 changes: 12 additions & 0 deletions packaging/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/python

"""
compile.py
Copyright (C) 2004 Darryl Dixon <[email protected]>
This program may be freely redistributed under the terms of the GNU GPL
"""

from compileall import compile_dir
import sys

compile_dir(sys.argv[1])
116 changes: 116 additions & 0 deletions packaging/ntlmaps.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
; This file is Copyright 2005 Mario Zoppetti, and was added by
; Darryl A. Dixon <[email protected]> to
; 'NTLM Authorization Proxy Server',
; Copyright 2001 Dmitry A. Rozmanov <[email protected]>
;
; NTLM APS is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; NTLM APS is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with the sofware; see the file COPYING. If not, write to the
; Free Software Foundation, Inc.,
; 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "ntlmaps"
!define PRODUCT_VERSION "0.9.9.2"
!define PRODUCT_PUBLISHER "MZ"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "ntlmaps-setup-${PRODUCT_VERSION}.exe"
SetCompressor lzma

LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
Icon "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
DirText "Setup will install $(^Name) in the following folder.$\r$\n$\r$\nTo install in a different folder, click Browse and select another folder."
LicenseText "If you accept all the terms of the agreement, choose I Agree to continue. You must accept the agreement to install $(^Name)."
LicenseData "COPYING"
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
ClearErrors
FileOpen $0 "${PRODUCT_NAME}.cmd" w
IfErrors done
FileWrite $0 "${PRODUCT_NAME}.exe -c server.cfg"
FileClose $0
done:

CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.cmd"
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.cmd"

File "dist\bz2.pyd"
File "dist\library.zip"
File /oname="${PRODUCT_NAME}.exe" "dist\main.exe"
File "dist\python24.dll"
File "dist\select.pyd"
File "dist\server.cfg"
File "dist\unicodedata.pyd"
File "dist\w9xpopen.exe"
File "dist\zlib.pyd"
File "dist\_socket.pyd"
File "dist\_ssl.pyd"
SectionEnd

Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\InstrumentationXSqlTunnel\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_VERSION}.cmd"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\_ssl.pyd"
Delete "$INSTDIR\_socket.pyd"
Delete "$INSTDIR\zlib.pyd"
Delete "$INSTDIR\w9xpopen.exe"
Delete "$INSTDIR\unicodedata.pyd"
Delete "$INSTDIR\server.cfg"
Delete "$INSTDIR\select.pyd"
Delete "$INSTDIR\python24.dll"
Delete "$INSTDIR\${PRODUCT_NAME}.exe"
Delete "$INSTDIR\library.zip"
Delete "$INSTDIR\bz2.pyd"
Delete "$INSTDIR\${PRODUCT_NAME}.cmd"

Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk"
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd
78 changes: 78 additions & 0 deletions packaging/ntlmaps.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ntlmaps.spec
# Copyright (C) 2004 Darryl Dixon <[email protected]>
# This program may be freely redistributed under the terms of the GNU GPL

%define name ntlmaps
%define ver 0.9.9.2
%define rel 1

Summary: NTLMAPS is a proxy server that authenticates requests to Microsoft proxies that require NTLM authentication.
Name: %{name}
Version: %{ver}
Release: %{rel}
License: GPL
Group: Applications/Internet
URL: http://ntlmaps.sourceforge.net
Vendor: Dmitry Rozmanov, Darryl Dixon, and others
Source: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Packager: Darryl Dixon <[email protected]>
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot

%description
NTLM Authorization Proxy Server (ntlmaps) is a proxy software that allows
you to authenticate via a Microsoft Proxy Server using the proprietary NTLM
protocol. NTLMAPS has the ability to behave as a standalone proxy server and
authenticate HTTP clients at Web servers using the NTLM protocol. It can
change arbitrary values in your client's request headers so that those
requests will look like they were created by Microsoft Internet Explorer. It
is written in Python 1.5.2.

%prep

%setup

%build

%install
if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
# This can be vastly improved, but it Works For Now!(tm) ;)
mkdir -p $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/opt/ntlmaps
mkdir -p $RPM_BUILD_ROOT/opt/ntlmaps/lib
mkdir -p $RPM_BUILD_ROOT/opt/ntlmaps/doc
mkdir -p $RPM_BUILD_ROOT/opt/ntlmaps/packaging
install --mode=0755 --group=root --owner=root changelog.txt \
Install.txt \
main.py \
readme.txt \
runserver.bat \
COPYING \
__init__.py \
research.txt \
server.cfg \
$RPM_BUILD_ROOT/opt/ntlmaps
install --mode=0755 --group=root --owner=root lib/* $RPM_BUILD_ROOT/opt/ntlmaps/lib
install --mode=0755 --group=root --owner=root doc/* $RPM_BUILD_ROOT/opt/ntlmaps/doc
install --mode=0755 --group=root --owner=root packaging/* $RPM_BUILD_ROOT/opt/ntlmaps/packaging
$RPM_BUILD_ROOT/opt/ntlmaps/packaging/compile.py $RPM_BUILD_ROOT/opt/ntlmaps
$RPM_BUILD_ROOT/opt/ntlmaps/packaging/compile.py $RPM_BUILD_ROOT/opt/ntlmaps/lib
mkdir -p $RPM_BUILD_ROOT%{_bindir}
ln -s $PYTHON_SITE/opt/ntlmaps/main.py $RPM_BUILD_ROOT%{_bindir}/ntlmaps
#mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
#install --mode=0644 --group=root --owner=root ntlmaps.1 $RPM_BUILD_ROOT%{_mandir}/man1
#gzip $RPM_BUILD_ROOT%{_mandir}/man1/ntlmaps.1

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
/opt/*
#%{_libdir}/*
%{_bindir}/*
#%{_mandir}/*

%changelog
* Wed Feb 23 2005 Darryl Dixon <[email protected]>
[ntlmaps-0.9.9.2]
- Initial release of .spec file
12 changes: 12 additions & 0 deletions packaging/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The files in this directory are included for the convenience of all packagers
of ntlmaps on any platform. Please feel free to contribute if you can see
enhancements or improvements to be made. Directory contents so far:
ntlmaps.spec -- Distribution-neutral RPM .spec file. Currently only
vaguely FHS compliant.
compile.py -- Basic wrapper of compileall.compile_dir() for convenience
of RPM builders.
setup.py -- Script for building standalone ntlmaps distributables with
py2exe on Windows.
ntlmaps.nsi -- NSIS (Nullsoft Scriptable Installer) configuration for
turning py2exe'ed ntlmaps into a pretty installer for
Windows.
Loading

0 comments on commit 9ab8c7d

Please sign in to comment.