summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmaël Bouya2017-06-15 23:24:03 +0200
committerIsmaël Bouya2017-06-15 23:24:50 +0200
commit5590d09e5f532c070fed25a9c0ac6f175a163aa7 (patch)
treee2ba92b54fe3eb81763fc4f3612f35c083695dc8
parentc1fb85aa2221b7946fa598735d986cc2c1f3b606 (diff)
downloadaur-5590d09e5f532c070fed25a9c0ac6f175a163aa7.tar.gz
Fix build for python3.6
Also fix ldap and theme for python3
-rw-r--r--PKGBUILD17
-rw-r--r--ldap_fix.py93
2 files changed, 104 insertions, 6 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 0b70f4132f82..a326f4ea2403 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,8 +1,8 @@
# Maintainer : Immae <ismael.bouya@normalesup.org>
pkgname=mediagoblin-git
-pkgver=0.9.0.r8.gc4d3293
-pkgrel=3
+pkgver=0.9.0.r11.gcfb80ab0
+pkgrel=4
pkgdesc='A free software media publishing platform'
arch=('i686' 'x86_64')
url='http://mediagoblin.org'
@@ -30,13 +30,15 @@ source=(
'paste_local.ini'
'mediagoblin_local.ini'
'mediagoblin-tmpfiles.conf'
+ 'ldap_fix.py'
)
sha256sums=('SKIP'
'2a02c90dcc8f69ac2a072044d3e4281347ed048c2610cb2e11295e4876cfb409'
'f636d02f86d2dab5ecc901be5b0f7c42366500393f22dfdc7e354ca299fca65a'
'ac914d60886d9bf53d3f40b8b00a60d46ada1cac9130210e045a4776d898e884'
'9adf338f5dbfb94ee7ae29433091b6991a1fa39a6135a8295f9f1cc1fde0edc1'
- 'abb6c4c4e54d4372adfe67ab22371ad625505098311955e5ae8e34102b059d47')
+ 'abb6c4c4e54d4372adfe67ab22371ad625505098311955e5ae8e34102b059d47'
+ 'a57ce62645cdcc6dc752d5af18350be492df02128e54deac088f4d77874f91e9')
pkgver() {
cd "$srcdir/mediagoblin"
@@ -54,21 +56,24 @@ build() {
./bootstrap.sh
./configure --with-python3
- make || make
- ./bin/easy_install flup
+ make
+ ./bin/easy_install flup typing
+ sed -i "s/registry.has_key(current_theme_name)/current_theme_name in registry/" mediagoblin/tools/theme.py
}
package() {
cd "$srcdir/mediagoblin"
- rm -rf .git .gitignore
install -dm755 "$pkgdir"/usr/share/webapps/mediagoblin/
cp -a . "$pkgdir"/usr/share/webapps/mediagoblin
cd "$pkgdir"/usr/share/webapps/mediagoblin
+
+ rm -rf .git .gitignore
find . -name '*.pyc' -delete
find . -type f -exec sed -i "s|$srcdir/mediagoblin|/usr/share/webapps/mediagoblin|g" {} \;
+ install -Dm644 "$srcdir/ldap_fix.py" "$pkgdir"/usr/share/webapps/mediagoblin/mediagoblin/plugins/ldap/tools.py
install -dm755 "$pkgdir"/var/lib/mediagoblin
install -dm755 "$pkgdir"/etc/webapps/mediagoblin
diff --git a/ldap_fix.py b/ldap_fix.py
new file mode 100644
index 000000000000..10cc375cf31a
--- /dev/null
+++ b/ldap_fix.py
@@ -0,0 +1,93 @@
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from ldap3 import Server, Connection, SUBTREE
+from ldap3.core.exceptions import LDAPException
+import logging
+
+import six
+
+from mediagoblin.tools import pluginapi
+
+_log = logging.getLogger(__name__)
+
+
+class LDAP(object):
+ def __init__(self):
+ self.ldap_settings = pluginapi.get_config('mediagoblin.plugins.ldap')
+
+ def _connect(self, server):
+ _log.info('Connecting to {0}.'.format(server['LDAP_SERVER_URI']))
+ self.server = Server(server['LDAP_SERVER_URI'])
+
+ if 'LDAP_START_TLS' in server and server['LDAP_START_TLS'] == 'true':
+ _log.info('Initiating TLS')
+ self.server.start_tls()
+
+ def _manager_auth(self, settings, username, password):
+ conn = Connection(self.server,
+ settings['LDAP_BIND_DN'],
+ settings['LDAP_BIND_PW'],
+ auto_bind=True)
+ found = conn.search(
+ search_base=settings['LDAP_SEARCH_BASE'],
+ search_filter=settings['LDAP_SEARCH_FILTER'].format(username=username),
+ search_scope=SUBTREE,
+ attributes=[settings['EMAIL_SEARCH_FIELD']])
+ if (not found) or len(conn.entries) > 1:
+ return False, None
+
+ user = conn.entries[0]
+ user_dn = user.entry_dn
+ try:
+ email = user.entry_attributes_as_dict[settings['EMAIL_SEARCH_FIELD']][0]
+ except KeyError:
+ email = None
+
+ Connection(self.server, user_dn, password, auto_bind=True)
+
+ return username, email
+
+ def _direct_auth(self, settings, username, password):
+ user_dn = settings['LDAP_USER_DN_TEMPLATE'].format(username=username)
+ conn = Connection(self.server, user_dn, password, auto_bind=True)
+ email_found = conn.search(
+ search_base=settings['LDAP_SEARCH_BASE'],
+ search_filter='uid={0}'.format(username),
+ search_scope=SUBTREE,
+ attributes=[settings['EMAIL_SEARCH_FIELD']])
+
+ if email_found:
+ try:
+ email = conn.entries[0].entry_attributes_as_dict[settings['EMAIL_SEARCH_FIELD']][0]
+ except KeyError:
+ email = None
+
+ return username, email
+
+ def login(self, username, password):
+ for k, v in six.iteritems(self.ldap_settings):
+ try:
+ self._connect(v)
+
+ if 'LDAP_BIND_DN' in v:
+ return self._manager_auth(v, username, password)
+ else:
+ return self._direct_auth(v, username, password)
+
+ except LDAPException as e:
+ _log.info(e)
+
+ return False, None