Hello,

am I the only one?  If I don't configure
CFG_APACHE_{PASSWORD,GROUP}_FILE, I'm getting this error:


$ ~/invenio/bin/inveniocfg  --create-tables
>>> Going to create and fill tables...
Testing DB connection... ok
Testing Python/MySQL/MySQLdb UTF-8 chain... ok
>>> Going to reset CFG_SITE_NAME and CFG_SITE_NAME_INTL...
You may want to restart Apache now.
>>> CFG_SITE_NAME and CFG_SITE_NAME_INTL* reset successfully.
>>> Going to reset CFG_SITE_ADMIN_EMAIL...
You may want to restart Apache now.
>>> CFG_SITE_ADMIN_EMAIL reset successfully.
>>> Going to reset I18N field names...
>>> I18N field names reset successfully.
Traceback (most recent call last):
  File "/home/invenio/invenio/bin/webaccessadmin", line 28, in <module>
    from invenio.webaccessadmin_lib import main
  File "/usr/local/lib/python2.5/site-packages/invenio/webaccessadmin_lib.py", l
ine 48, in <module>
    import invenio.access_control_engine as acce
  File "/usr/local/lib/python2.5/site-packages/invenio/access_control_engine.py"
, line 31, in <module>
    from invenio import webuser
  File "/usr/local/lib/python2.5/site-packages/invenio/webuser.py", line 1049, i
n <module>
    _apache_passwords = _load_apache_password_file()
  File "/usr/local/lib/python2.5/site-packages/invenio/webuser.py", line 1044, i
n _load_apache_password_file
    for row in open(os.path.join(CFG_TMPDIR, apache_password_file)):
IOError: [Errno 21] Is a directory


I attach a trivial and obvious solution, unless I'm missing something.
(BTW, it is relative to 0.99.1)

Best regards,

Ferran
WebUser: allow no apache password and group files

* Check whether apache password and group file exists before trying to
  open the file to prevent an error when creating tables.

---
 lib/python/traces/webuser.py |   30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

Index: invenio/lib/python/traces/webuser.py
===================================================================
--- invenio.orig/lib/python/traces/webuser.py	2009-05-20 16:21:34.000000000 +0200
+++ invenio/lib/python/traces/webuser.py	2009-05-20 16:29:03.000000000 +0200
@@ -1041,10 +1041,11 @@
 
 def _load_apache_password_file(apache_password_file=CFG_APACHE_PASSWORD_FILE):
     ret = {}
-    for row in open(os.path.join(CFG_TMPDIR, apache_password_file)):
-        row = row.split(':')
-        if len(row) == 2:
-            ret[row[0].strip()] = row[1].strip()
+    if apache_password_file:
+        for row in open(os.path.join(CFG_TMPDIR, apache_password_file)):
+            row = row.split(':')
+            if len(row) == 2:
+                ret[row[0].strip()] = row[1].strip()
     return ret
 _apache_passwords = _load_apache_password_file()
 
@@ -1060,16 +1061,17 @@
 
 def _load_apache_group_file(apache_group_file=CFG_APACHE_GROUP_FILE):
     ret = {}
-    for row in open(os.path.join(CFG_TMPDIR, apache_group_file)):
-        row = row.split(':')
-        if len(row) == 2:
-            group = row[0].strip()
-            users = row[1].strip().split(' ')
-            for user in users:
-                user = user.strip()
-                if user not in ret:
-                    ret[user] = []
-                ret[user].append(group)
+    if apache_group_file:
+        for row in open(os.path.join(CFG_TMPDIR, apache_group_file)):
+            row = row.split(':')
+            if len(row) == 2:
+                group = row[0].strip()
+                users = row[1].strip().split(' ')
+                for user in users:
+                    user = user.strip()
+                    if user not in ret:
+                        ret[user] = []
+                    ret[user].append(group)
     return ret
 _apache_groups = _load_apache_group_file()
 

Reply via email to