Cannot create share links with passwords

Hi all,

i’ve searched the topics but could not find anything with the problem in question in the subject of this topic.

  • When i try to create a share link with a password all i get is a small message on top “Error” (screenshot bellow).

  • In the seahub.log i see this after each try:

[ERROR] django.request:224 log_response Internal Server Error: /api/v2.1/share-links/
Traceback (most recent call last):
File “/srv/seafile/seahub/thirdpart/django/core/handlers/exception.py”, line 47, in inner
response = get_response(request)
File “/srv/seafile/seahub/thirdpart/django/core/handlers/base.py”, line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/srv/seafile/seahub/thirdpart/django/views/decorators/csrf.py”, line 54, in wrapped_view
return view_func(*args, **kwargs)
File “/srv/seafile/seahub/thirdpart/django/views/generic/base.py”, line 70, in view
return self.dispatch(request, *args, **kwargs)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 505, in dispatch
response = self.handle_exception(exc)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 465, in handle_exception
self.raise_uncaught_exception(exc)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 476, in raise_uncaught_exception
raise exc
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 502, in dispatch
response = handler(request, *args, **kwargs)
File “/srv/seafile/seahub/seahub/api2/endpoints/share_links.py”, line 410, in post
fs = FileShare.objects.create_file_link(username, repo_id, path,
File “/srv/seafile/seahub/seahub/share/models.py”, line 157, in create_file_link
return self._add_file_share(username, repo_id, path, ‘f’, password,
File “/srv/seafile/seahub/seahub/share/models.py”, line 110, in _add_file_share
password_enc = make_password(password)
File “/srv/seafile/seahub/seahub/share/models.py”, line 31, in make_password
aes = AESPasswordHasher()
File “/srv/seafile/seahub/seahub/utils/hasher.py”, line 39, in init
self.cipher = AES.new(secret.encode(‘utf-8’), AES.MODE_ECB)
AttributeError: ‘NoneType’ object has no attribute ‘new’

Everything else on the seafile installation works as designed.

Seafile “version”: “9.0.2” is running on Ubuntu 20.04.3 LTS

I could use some help :slight_smile:

1 Like

Hi guys!

I have the same issue, also in a freshly created test-environment. I’m running Ubuntu 22.04 LTS and Seafile 9.0.5 with nginx.

Poduction:

2022-05-25 06:09:46,311 [ERROR] django.request:224 log_response Internal Server Error: /api/v2.1/share-links/
Traceback (most recent call last):
  File "/srv/seafile/seahub/thirdpart/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
  File "/srv/seafile/seahub/thirdpart/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/srv/seafile/seahub/thirdpart/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "/srv/seafile/seahub/thirdpart/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
  File "/srv/seafile/seahub/seahub/api2/endpoints/share_links.py", line 410, in post
fs = FileShare.objects.create_file_link(username, repo_id, path,
  File "/srv/seafile/seahub/seahub/share/models.py", line 157, in create_file_link
return self._add_file_share(username, repo_id, path, 'f', password,
  File "/srv/seafile/seahub/seahub/share/models.py", line 110, in _add_file_share
password_enc = make_password(password)
  File "/srv/seafile/seahub/seahub/share/models.py", line 31, in make_password
aes = AESPasswordHasher()
  File "/srv/seafile/seahub/seahub/utils/hasher.py", line 39, in __init__
self.cipher = AES.new(secret.encode('utf-8'), AES.MODE_ECB)
AttributeError: 'NoneType' object has no attribute 'new'

Test:

2022-05-25 12:35:08,903 [ERROR] django.request:224 log_response Internal Server Error: /api/v2.1/share-links/
Traceback (most recent call last):
File “/srv/seafile/seahub/thirdpart/django/core/handlers/exception.py”, line 47, in inner
response = get_response(request)
File “/srv/seafile/seahub/thirdpart/django/core/handlers/base.py”, line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/srv/seafile/seahub/thirdpart/django/views/decorators/csrf.py”, line 54, in wrapped_view
return view_func(*args, **kwargs)
File “/srv/seafile/seahub/thirdpart/django/views/generic/base.py”, line 70, in view
return self.dispatch(request, *args, **kwargs)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 505, in dispatch
response = self.handle_exception(exc)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 465, in handle_exception
self.raise_uncaught_exception(exc)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 476, in raise_uncaught_exception
raise exc
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 502, in dispatch
response = handler(request, *args, **kwargs)
File “/srv/seafile/seahub/seahub/api2/endpoints/share_links.py”, line 413, in post
fs = FileShare.objects.create_file_link(username, repo_id, path,
File “/srv/seafile/seahub/seahub/share/models.py”, line 157, in create_file_link
return self._add_file_share(username, repo_id, path, ‘f’, password,
File “/srv/seafile/seahub/seahub/share/models.py”, line 110, in _add_file_share
password_enc = make_password(password)
File “/srv/seafile/seahub/seahub/share/models.py”, line 31, in make_password
aes = AESPasswordHasher()
File “/srv/seafile/seahub/seahub/utils/hasher.py”, line 39, in init
self.cipher = AES.new(secret.encode(‘utf-8’), AES.MODE_ECB)
AttributeError: ‘NoneType’ object has no attribute ‘new’

Does someone have an idea where we should look or maybe try some things?

Thank you very much in advance!

1 Like

While playing around with the Test system i found out that it may be related with dependencies.

Can you check what Django and cffi version you’re running?

For django:

pip list | grep Django

and for cffi i just checked in the filesystem under

/“YourCustomPath”/seafile/seahub/thirdpart

there should be a cffi folder with a version.

With installing the correct versions I was able to fix it in the Test environment.

For the django installation i used:

pip3 install django==3.2.* Pillow pylibmc captcha jinja2 sqlalchemy==1.4.3 django-pylibmc django-simple-captcha python3-ldap mysqlclient pycryptodome==3.12.0

and for cffi:

pip3 install --force-reinstall --upgrade --target /srv/seafile/seahub/thirdpart cffi==1.14.6

as mentioned in another thread by @Barolo - Thank you!

Hope this helps - i’ll also update when I was able to do the productive environment.

1 Like

@gi4ouR did my details help you in any way or are you still stuck with the error?

Thanks for your writeup. I had the sample problem (current server 9.0.6) and pip3 list was missing pycryptodome. So I just did

pip3 install pycryptodome

and restarted seahub and then sharing links with passwords worked again.

1 Like

I have exactly the same issue.
I tried all solutions provided so far, but it doesn’t work.
I am under version 9.0.7.

$ pip list | grep Django
Django                 4.1
pip list | grep cff
cffi                   1.15.1

 [ERROR] django.request:224 log_response Internal Server Error: /api/v2.1/share-links/
Traceback (most recent call last):
  File "/srv/seafile/seahub/thirdpart/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/srv/seafile/seahub/thirdpart/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/srv/seafile/seahub/thirdpart/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/srv/seafile/seahub/thirdpart/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/srv/seafile/seahub/thirdpart/rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "/srv/seafile/seahub/seahub/api2/endpoints/share_links.py", line 422, in post
    fs = FileShare.objects.create_dir_link(username, repo_id, path,
  File "/srv/seafile/seahub/seahub/share/models.py", line 173, in create_dir_link
    return self._add_file_share(username, repo_id, path, 'd', password,
  File "/srv/seafile/seahub/seahub/share/models.py", line 110, in _add_file_share
    password_enc = make_password(password)
  File "/srv/seafile/seahub/seahub/share/models.py", line 31, in make_password
    aes = AESPasswordHasher()
  File "/srv/seafile/seahub/seahub/utils/hasher.py", line 39, in __init__
    self.cipher = AES.new(secret.encode('utf-8'), AES.MODE_ECB)
AttributeError: 'NoneType' object has no attribute 'new'

Thanks

Hi Jess

You did run these commands and still have Django 4.x and cffi 1.15.x installed? As far as I know Seafile does not run (yet) with Django 4, so you need to downgrade to the 3.2.14 Version of Django. And check that you really have installed the cffi version mentioned above (1.14.6). I don’t know exactly if there is maybe a more recent version of cffi available (and supported by Seafile).

Here you can see the requirement for Django on the Announcement for Seafile 9.0.7: Seafile community edition 9.0.7 is ready! - Announcement - Seafile Community Forum

I am pretty sure with a downgrade of those versions it will work again.

I did a downgrade of Django and cffi.
$ pip list | grep Django
Django 3.2.14
$ pip list | grep cff
cffi 1.14.6

I restarted the server and no change at all,
The exact same logs.

Any idea ?

Also, in the folder seafile/seahub/thirdpart, I have several cffi folders.
one called “cffi”, and three called “cffi-1.14.0.dist-info”, “cffi-1.14.6.dist-info” and “cffi-1.15.1.dist-info”
all with this content.

content of cffi
-rw-r–r-- 1 debian debian 42064 Aug 26 12:24 api.py
-rw-r–r-- 1 debian debian 42454 Aug 26 12:24 backend_ctypes.py
-rw-r–r-- 1 debian debian 3908 Aug 26 12:24 _cffi_errors.h
-rw-r–r-- 1 debian debian 14800 Aug 26 12:24 _cffi_include.h
-rw-r–r-- 1 debian debian 5724 Aug 26 12:24 cffi_opcode.py
-rw-r–r-- 1 debian debian 2689 Aug 26 12:24 commontypes.py
-rw-r–r-- 1 debian debian 44231 Aug 26 12:24 cparser.py
-rw-r–r-- 1 debian debian 17581 Aug 26 12:24 _embedding.h
-rw-r–r-- 1 debian debian 877 Aug 26 12:24 error.py
-rw-r–r-- 1 debian debian 4046 Aug 26 12:24 ffiplatform.py
-rw-r–r-- 1 debian debian 513 Aug 26 12:24 init.py
-rw-r–r-- 1 debian debian 747 Aug 26 12:24 lock.py
-rw-r–r-- 1 debian debian 21768 Aug 26 12:24 model.py
-rw-r–r-- 1 debian debian 5976 Aug 26 12:24 parse_c_type.h
-rw-r–r-- 1 debian debian 4374 Aug 26 12:24 pkgconfig.py
drwxr-xr-x 2 debian debian 4096 Aug 26 12:24 pycache
-rw-r–r-- 1 debian debian 64568 Aug 26 12:24 recompiler.py
-rw-r–r-- 1 debian debian 8931 Aug 26 12:24 setuptools_ext.py
-rw-r–r-- 1 debian debian 43320 Aug 26 12:24 vengine_cpy.py
-rw-r–r-- 1 debian debian 26684 Aug 26 12:24 vengine_gen.py
-rw-r–r-- 1 debian debian 11253 Aug 26 12:24 verifier.py

content of cffi-1.14.0.dist-info
-rw-r–r-- 1 debian debian 76 Aug 9 03:10 entry_points.txt
-rw-r–r-- 1 debian debian 4 Aug 9 03:10 INSTALLER
-rw-r–r-- 1 debian debian 1294 Aug 9 03:10 LICENSE.txt
-rw-r–r-- 1 debian debian 1191 Aug 9 03:10 METADATA
-rw-r–r-- 1 debian debian 3089 Aug 9 03:10 RECORD
-rw-r–r-- 1 debian debian 0 Aug 9 03:10 REQUESTED
-rw-r–r-- 1 debian debian 19 Aug 9 03:10 top_level.txt
-rw-r–r-- 1 debian debian 109 Aug 9 03:10 WHEEL

Maybe I should clean a bit by removing some folders ?

ok, the one that gets listed with the pip command will be the active one, so this looks fine now.

But i am a bit confused that the cffi folder of 1.15 is still there, mine was removed with the installation of 1.14.6. What distro are you running?

Please try to create another link and post the corresponding messages from the ‘seahub.log’ file located in the /logs directory. This is the place where you need to see that something has changed, maybe the error is now not the same anymore inside the log?

I am running the following Debian version : Debian GNU/Linux 11 (bullseye)

I have created a new link, then try to put a password.
Same logs
2022-08-31 10:10:10,222 [ERROR] django.request:224 log_response Internal Server Error: /api/v2.1/share-links/
Traceback (most recent call last):
File “/srv/seafile/seahub/thirdpart/django/core/handlers/exception.py”, line 47, in inner
response = get_response(request)
File “/srv/seafile/seahub/thirdpart/django/core/handlers/base.py”, line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/srv/seafile/seahub/thirdpart/django/views/decorators/csrf.py”, line 54, in wrapped_view
return view_func(*args, **kwargs)
File “/srv/seafile/seahub/thirdpart/django/views/generic/base.py”, line 70, in view
return self.dispatch(request, *args, **kwargs)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 505, in dispatch
response = self.handle_exception(exc)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 465, in handle_exception
self.raise_uncaught_exception(exc)
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 476, in raise_uncaught_exception
raise exc
File “/srv/seafile/seahub/thirdpart/rest_framework/views.py”, line 502, in dispatch
response = handler(request, *args, **kwargs)
File “/srv/seafile/seahub/seahub/api2/endpoints/share_links.py”, line 422, in post
fs = FileShare.objects.create_dir_link(username, repo_id, path,
File “/srv/seafile/seahub/seahub/share/models.py”, line 173, in create_dir_link
return self._add_file_share(username, repo_id, path, ‘d’, password,
File “/srv/seafile/seahub/seahub/share/models.py”, line 110, in _add_file_share
password_enc = make_password(password)
File “/srv/seafile/seahub/seahub/share/models.py”, line 31, in make_password
aes = AESPasswordHasher()
File “/srv/seafile/seahub/seahub/utils/hasher.py”, line 39, in init
self.cipher = AES.new(secret.encode(‘utf-8’), AES.MODE_ECB)

I am going to reinstall everything, directly with the correct package version

I am not sure, but is this line still appearing in your latest logs? It was not mentioned in the last log you posted. If you do not have any data to migrate or done a lot of configuration a fresh installation is worth a try. But as far as I understood this error messages, there is still something missing (or in an unsupported version) which prevents the password generation to be running smoothly. So if you do the reinstallation the same way, you probably have the error again after doing it. (unless there was a confusion about f.e. the installed cffi version, so the server still wanted to work with a wrong version). What pycryptodome do you have installed? You can read it out the same way as the other packages:

pip list | grep crypto

And you did restart the server / seahub service after doing these changes, right? Sorry for the question, but I’ve seen a lot of things :wink:

I had not seen that the method recommended by the Seafile team is Docker.
So, after restarting from scratch and installed through Docker.
Now everything is working :slight_smile:

Thank you for your help.