Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error creating user with sqlite db #98

Open
MenschLink opened this issue Jul 20, 2022 · 2 comments
Open

error creating user with sqlite db #98

MenschLink opened this issue Jul 20, 2022 · 2 comments
Assignees

Comments

@MenschLink
Copy link

errors creating user with sqlite

after initializing my sqlite-db, I want to start creating users. These two errors occurr when I attempt to execute opensips-cli -x user add

ERROR: cannot execute query: SELECT table_version FROM version WHERE table_name = 'subscriber'
ERROR: (sqlite3.OperationalError) no such table: version [SQL: "SELECT table_version FROM version WHERE table_name = 'subscriber'"]
ERROR: cannot execute query: SELECT count(*) FROM subscriber WHERE username = 'example' AND domain = 'example.tldf'
ERROR: (sqlite3.OperationalError) no such table: subscriber [SQL: "SELECT count(*) FROM subscriber WHERE username = 'examplel' AND domain = 'example.tld'"]

and after supplying passwords:

ValueError: unsupported hash type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/bin/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/lib/python3/dist-packages/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/lib/python3/dist-packages/opensipscli/cli.py", line 242, in cmdloop
    ret = self.run_command(module, command, modifiers, params)
  File "/usr/lib/python3/dist-packages/opensipscli/cli.py", line 404, in run_command
    return mod[0].__invoke__(cmd, params, modifiers)
  File "/usr/lib/python3/dist-packages/opensipscli/module.py", line 36, in __invoke__
    return f(params, modifiers)
  File "/usr/lib/python3/dist-packages/opensipscli/modules/user.py", line 168, in do_add
    self.user_get_ha1_sha512t256(username, domain, password)
  File "/usr/lib/python3/dist-packages/opensipscli/modules/user.py", line 119, in user_get_ha1_sha512t256
    o = hashlib.new("sha512_256")
  File "/usr/lib/python3.6/hashlib.py", line 156, in __hash_new
    return __get_builtin_constructor(name)(data)
  File "/usr/lib/python3.6/hashlib.py", line 113, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512_256
@liviuchircu liviuchircu self-assigned this Jul 20, 2022
@liviuchircu
Copy link
Member

liviuchircu commented Jul 20, 2022

Hi, @MenschLink and thanks for the report! Indeed... it seems the SHA-512-256 hash is only available on higher Python 3 releases. I get the same error when I use Python 3.6, however it works on 3.8:

~ 16:46:35$ python3.6 -c 'import hashlib; o = hashlib.new("sha512_256"); print(o)'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/hashlib.py", line 150, in __hash_new
    return _hashlib.new(name, data)
ValueError: unsupported hash type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/hashlib.py", line 156, in __hash_new
    return __get_builtin_constructor(name)(data)
  File "/usr/local/lib/python3.6/hashlib.py", line 113, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512_256
~ 16:46:36$
~ 16:46:36$
~ 16:46:58$ python3.8 -c 'import hashlib; o = hashlib.new("sha512_256"); print(o)'
<sha512_256 HASH object @ 0x7f3899398f90>

I will add some handling for this exception, maybe print out an error & keep the sha_512t256 column empty, so the user at least knows to upgrade to a more modern Python environment, if they need that hash. Thanks!

@MenschLink
Copy link
Author

@liviuchircu thanks, I actually solved it in python 3.7, by replacing sha512_256 with sha512-256. I sort of also figured out how to fix the subscriber SQL error, but it doesn't feel quite right because I also get a 500 error when I try to register with the newly added user... maybe I'm not deploying the sqlite database setup correctly? Is there an example how that should work with the config?

[default]
#database_modules: acc clusterer dialog dialplan dispatcher domain rtpproxy usr>
database_modules: ALL

#database_admin_url: postgres://root@localhost
database_admin_url: sqlite:////opt/opensips.sqlite

database_url: sqlite:////opt/opensips.sqlite




this is what my /etc/opensips-cli.cfg currently looks like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants