You are not logged in.

#1 2010-10-24 23:43:21

arkay
Member
Registered: 2008-05-23
Posts: 79

ntlmaps not running after recent update. (FIXED)

FIXED - Ended up re-writing MAKEPKG, depends, modified patches file and new MD5 sums to build on Python 2.7.  Instructions below for anyone who needs them. Cheers - Arkay.


Hi All,

I use ntlmaps in conjunction with corkscrew to create ssh tunnels out through my work proxy to my home network.  It's always worked perfectly fine until a recent pacman -Syu.

From looking into it as much as I can it appears that Python 3 has been pulled into the mix where ntlmaps appears only to work with python 2.

In the original effort to fix it I updated to the latest MAKEPKG in the AUR which also doesn't seem to work with either version of Python.

I've attempted to debug the issues in Python though my knowledge of the language is sorely lacking.

The initial error I get is:

  File "/usr/bin/ntlmaps", line 31
    print 'NTLM authorization Proxy Server v%s' % conf['GENERAL']['VERSION']
                                              ^
SyntaxError: invalid syntax

But the code block above appears ok to me.  On further investigation (running it line by line in interactive mode), it appeared to be the includes causing the issue at which point I found dos line endings on all the code in the site-python ntlmaps code.  After removing all of them and converting back to unix eol's (didn't seem to really make a difference), I still get the same syntax errors.  Further looking finds includes to libraries which possibly no longer exist or are depreciated in python 3. "threads" seems to be the main offender, according to the doco it is depreciated but should still work (tm).

I'm pretty much at a loss as to what to do next.  I've tried swapping to cntlm but for some reason our proxy won't allow the connections through the way ntlmaps does.

I also just tried to re-install it with aurget.  The makepkg worked but the install script failed with:

Byte compiling python modules...
error: command failed to execute correctly

Looking into that now too...

Any help would be much appreciated.  Perhaps someone else can attempt to install and run it on their system.

Cheers,

Arkay.

P.S.  My system is i686, recently updated.

P.P.S.  Apologies to the mods.  This should most likely be in the PKGBUILD forms... Please move and remove this P.P.S wink

Last edited by arkay (2010-10-26 01:00:09)

Offline

#2 2010-10-25 00:02:40

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: ntlmaps not running after recent update. (FIXED)

Did you try editing the first line and replacing this

#!/usr/bin/python

with this

#!/usr/bin/python2

Last edited by skunktrader (2010-10-25 00:03:59)

Offline

#3 2010-10-25 00:04:16

arkay
Member
Registered: 2008-05-23
Posts: 79

Re: ntlmaps not running after recent update. (FIXED)

skunktrader,

Thanks for the suggestion.  I got it sorted out, not long after posting (apparently it helps sometimes!).

Turned out that I needed to backlevel my version of Python2 from 2.7 to 2.6 then re-run the PKGBUILD so the python byte compiler would properly generate the package.  After that it's running fine again.

Cheers,

Arkay.

Offline

#4 2010-10-25 00:26:29

arkay
Member
Registered: 2008-05-23
Posts: 79

Re: ntlmaps not running after recent update. (FIXED)

Ok.  This isn't the greatest of fixes.  It'll get you going, but many packages depend on Python2.7... So it's ugly at best.  Still trying to find a way to make it work with current 2.7.

Cheers,

Arkay.

Offline

#5 2010-10-25 02:16:57

arkay
Member
Registered: 2008-05-23
Posts: 79

Re: ntlmaps not running after recent update. (FIXED)

Ok.  For some reason I haven't (yet) been able to get the PKGBUILD working with python 3.

I have however updated everything to work as expected with python 2.7 (specifically ntlmaps-0.9.9.0.1 under python2 2.7-2).

Here's the relevant bits for anyone who would like to build against 2.7 instead (if you have problems with 3).

Filename: PKGBUILD

# Contributor: Graziano <graziano.giuliani@poste.it>
# Maintainer: John Gerritse <reaphsharc@gmail.com>

pkgname=ntlmaps
pkgver=0.9.9.0.1
pkgrel=5
pkgdesc="'NTLM Authorization Proxy Server' (APS) is a proxy software that allows you to authenticate via an MS Proxy Server using the proprietary NTLM protocol."
url="http://ntlmaps.sourceforge.net/"
license="GPL"
arch=('i686' 'x86_64')
depends=('python2')
backup=('etc/conf.d/ntlmaps')
install=$pkgname.install
source=(http://downloads.sourceforge.net/sourceforge/$pkgname/${pkgname}-${pkgver}.tar.gz patches ntlmaps.install ntlmaps.rc)
md5sums=('7ee0a00d5446f39ebbe5f0f90465986e'
         '0ba42ac958b124b8e635c1524b26138e'
         'a78770387e22c14a37bfdaee25c6594a'
         '602132fda99e27efdd636a946e034d6b')

build() {
  PYTHONVER=`python2 -c 'import sys;print(sys.version[0:3])'`
  cd $srcdir/$pkgname-$pkgver/
  patch -Np1 -i ../patches
  install -D -m 600 server.cfg $pkgdir/etc/conf.d/$pkgname
  PYDEST_SITE=$pkgdir/usr/lib/python$PYTHONVER/site-packages
  mkdir -p $PYDEST_SITE/$pkgname
  cp -a lib/* $PYDEST_SITE/$pkgname
  install -m 644 __init__.py $PYDEST_SITE/$pkgname/__init__.py
  install -D -m 755 main.py $pkgdir/usr/bin/$pkgname
  install -D -m 755 ../ntlmaps.rc $pkgdir/etc/rc.d/ntlmaps
  echo $pkgname > $PYDEST_SITE/$pkgname.pth
  echo "echo $pkgname > $PYDEST_SITE/$pkgname.pth"
}

Filename: ntlmaps.install

# This is a default template for a post-install scriptlet.  You can
# remove any functions you don't need (and this header).

# arg 1:  the new package version
pre_install() {
  /bin/true
}

# arg 1:  the new package version
post_install() {
  echo "Byte compiling python modules..."
  python2 /usr/lib/python2.7/compileall.py >/dev/null 2>&1
  python2 -O /usr/lib/python2.7/compileall.py >/dev/null 2>&1
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  echo "Byte compiling python modules..."
  python2 /usr/lib/python2.7/compileall.py >/dev/null 2>&1
  python2 -O /usr/lib/python2.7/compileall.py >/dev/null 2>&1
}

# arg 1:  the old package version
pre_remove() {
  /bin/true
}

# arg 1:  the old package version
post_remove() {
  /bin/true
}

op=$1
shift
$op $*

Filename: ntlmaps.rc

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    PID=`pidof -o %PPID /usr/bin/ntlmaps`
    stat_busy "Starting ntlmaps"
    if [ -z "$PID" ]; then 
       /usr/bin/ntlmaps > /var/log/ntlmaps.log 2>&1 &
    fi
    if [ ! -z "$PID" -o $? -gt 0 ]; then
      stat_fail
    else
      add_daemon ntlmaps
      stat_done
    fi
    ;;
  stop)
    PID=`pidof -o %PPID /usr/bin/python2 /usr/bin/ntlmaps`
    stat_busy "Stopping ntlmaps"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon ntlmaps
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac

Filename: patches

diff -Naur ntlmaps-0.9.9.0.1/__init__.py ntlmaps-0.9.9.0.1_new//__init__.py
--- ntlmaps-0.9.9.0.1/__init__.py       2005-06-10 13:49:35.000000000 +1000
+++ ntlmaps-0.9.9.0.1_new//__init__.py  2010-10-25 12:49:03.820614080 +1100
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
 
 # This file is Copyright 2004 Darryl A. Dixon <esrever_otua@pythonhacker.is-a-geek.net>
 # and is part of 'NTLM Authorization Proxy Server',
@@ -20,10 +20,10 @@
 # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 #
 
-import os, sys
+#import os, sys
 
-ntlmaps_dir = os.path.dirname(os.path.abspath(__file__))
-ntlmaps_libdir = ntlmaps_dir + '/lib'
-sys.path.append(ntlmaps_libdir)
+#ntlmaps_dir = os.path.dirname(os.path.abspath(__file__))
+#ntlmaps_libdir = ntlmaps_dir + '/lib'
+#sys.path.append(ntlmaps_libdir)
 
-del os, sys
+#del os, sys
diff -Naur ntlmaps-0.9.9.0.1/lib/config.py ntlmaps-0.9.9.0.1_new//lib/config.py
--- ntlmaps-0.9.9.0.1/lib/config.py     2005-06-10 13:46:43.000000000 +1000
+++ ntlmaps-0.9.9.0.1_new//lib/config.py        2010-10-25 12:51:35.847799575 +1100
@@ -52,7 +52,7 @@
     the config file. Otherwise the function falls back to
     'server.cfg' in the current directory. """
 
-    configFileName = configFileDir+'server.cfg'
+    configFileName = configFileDir+'ntlmaps'
 
     optionsList, notUsedArguments = getopt.getopt(argv[1:], 'c:')
 
diff -Naur ntlmaps-0.9.9.0.1/main.py ntlmaps-0.9.9.0.1_new//main.py
--- ntlmaps-0.9.9.0.1/main.py   2006-01-27 12:35:00.000000000 +1100
+++ ntlmaps-0.9.9.0.1_new//main.py      2010-10-25 12:58:02.445983916 +1100
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
 
 # This file is part of 'NTLM Authorization Proxy Server'
 # Copyright 2001 Dmitry A. Rozmanov <dima@xenon.spb.ru>
@@ -18,17 +18,16 @@
 # Free Software Foundation, Inc.,
 # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 #
-import __init__
 
 import sys
 
-import server, config, config_affairs
+from ntlmaps import server, config, config_affairs
 
 
 #--------------------------------------------------------------
 # config affairs
 # look for default config name in lib/config.py
-conf = config.read_config(config.findConfigFileNameInArgv(sys.argv, __init__.ntlmaps_dir+'/'))
+conf = config.read_config(config.findConfigFileNameInArgv(sys.argv, '/etc/conf.d/'))
 
 conf['GENERAL']['VERSION'] = '0.9.9.0.1'

Save each of the code blocks (cut/paste into an editor) with the filenames given into a directory.  Update/check the md5sums in the PKGBUILD for each (dunno how to upload files into a thread so you'll have to check the sums match after pasting/saving and I don't yet have AUR access).  Then run makepkg.  You should end up with a working ntlmaps for python2.7.

Cheers,

Arkay.

Last edited by arkay (2010-10-26 03:40:20)

Offline

Board footer

Powered by FluxBB