Compilation Winexe avec le support SMB2 sur el6
Nov 19
2020
2020
Comments Off
(fonctionne le 2020-11-19 pour une Redhat/Centos 6.10 64bits)
Je viens de passer 2 jours à trouver une solution, donc je partage (et garde pour plus tard).
Préparation de l’environnement :
Créer une VM en centos 6
Activer le repo EPEL et installer quelques packages :
yum install patch git gcc perl mingw-binutils-generic mingw-filesystem-base mingw32-binutils mingw32-cpp mingw32-crt mingw32-filesystem mingw32-gcc mingw32-headers mingw64-binutils mingw64-cpp mingw64-crt mingw64-filesystem mingw64-gcc mingw64-headers libcom_err-devel libacl-devel gnutls-devel openldap-devel popt-devel zlib-devel zlib-static glibc-devel glibc-static python-devel
Préparation des sources et Compilation :
git clone https://bitbucket.org/reevertcode/reevert-winexe-waf.git
cd reevert-winexe-waf/
git clone git://git.samba.org/samba.git samba
cd samba/
git reset --hard a6bda1f2bc85779feb9680bc74821da5ccd401c5
cd ..
rm -rf source/smb_static
cat patches/fix_smb_static.patch | patch -p1
cat patches/smb2_nognutls_noaddc.patch | patch -p1
cat patches/smb2_add_public_includes_samba_4.3.patch | patch -p1
cat source/wscript_build
sed -i "s/lib='dl'$/lib='dl gnutls'/" source/wscript_build
cd source && ln -s ../samba/bin/default/smb_static
./waf --samba-dir=../samba configure build
WorkAround :
Le winexe resultat n’est pas parfait. Workaround pour le faire fonctionner à peu près comme il faut : Encapsuler le binaire dans un script tel ci-après.
#!/bin/sh
# 2020-11-19 Baptiste Gagneux
MaxRetries=30
Tempo=2
iRetry=1
BinWinexe=/usr/local/bin/winexe-1.1-reevert-2020-11-19
# First attempt without reinstalling the Winexe service
Resultat=$(echo ' ' | timeout -s9 180s ${BinWinexe} --kerberos=yes "$@" 2>/dev/null)
CR=$?
# Then Retries will cleaning.
while [ "${Resultat}" == "" ] ; do
Resultat=$(echo ' ' | timeout -s9 180s ${BinWinexe} --uninstall --kerberos=yes "$@" 2>/dev/null)
CR=$?
if [ ${iRetry} -eq ${MaxRetries} ] ; then
Resultat="winexe connection error (with ${MaxRetries} retries and ${Tempo} tempo)"
CR=99
fi
iRetry=$((${iRetry}+1))
sleep ${Tempo}
done
# Exiting with the results
echo ${Resultat}
exit ${CR}
Sources :
https://bitbucket.org/reevertcode/reevert-winexe-waf/src/master/
https://github.com/opinkerfi/winexe-waf
https://sourceforge.net/p/winexe/bugs/77/?limit=25&page=2