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

Supress python traceback in normal operation #45

Open
protegh opened this issue Oct 7, 2020 · 0 comments
Open

Supress python traceback in normal operation #45

protegh opened this issue Oct 7, 2020 · 0 comments

Comments

@protegh
Copy link

protegh commented Oct 7, 2020

When e.g. calling ssh-ldap-pubkey add for an user that is still missing the sshPublicKey attribute there naturally is an error message. But the ldap errors are covered by all the lines of the python traceback:

# ssh-ldap-pubkey add -H ldaps://<ldap-server>/ .ssh/id_ed25519.pub
Enter login (LDAP) password for user '<username>': 
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/ssh_ldap_pubkey/__init__.py", line 159, in add_pubkey
    self._conn.modify_s(dn, modlist)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 631, in modify_s
    return self.modify_ext_s(dn,modlist,None,None)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 604, in modify_ext_s
    resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 751, in result3
    resp_ctrl_classes=resp_ctrl_classes
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 758, in result4
    ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 331, in _ldap_call
    reraise(exc_type, exc_value, exc_traceback)
  File "/usr/lib/python3.7/site-packages/ldap/compat.py", line 44, in reraise
    raise exc_value
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 315, in _ldap_call
    result = func(*args,**kwargs)
ldap.OBJECT_CLASS_VIOLATION: {'desc': 'Object class violation', 'info': "attribute 'sshPublicKey' not allowed"}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.7/ssh-ldap-pubkey", line 147, in <module>
    main(**kwargs)
  File "/usr/lib/python-exec/python3.7/ssh-ldap-pubkey", line 117, in main
    ldapssh.add_pubkey(login, passw, pubkey)
  File "/usr/lib/python3.7/site-packages/ssh_ldap_pubkey/__init__.py", line 163, in add_pubkey
    self._conn.modify_s(dn, modlist)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 631, in modify_s
    return self.modify_ext_s(dn,modlist,None,None)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 604, in modify_ext_s
    resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 751, in result3
    resp_ctrl_classes=resp_ctrl_classes
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 758, in result4
    ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 331, in _ldap_call
    reraise(exc_type, exc_value, exc_traceback)
  File "/usr/lib/python3.7/site-packages/ldap/compat.py", line 44, in reraise
    raise exc_value
  File "/usr/lib/python3.7/site-packages/ldap/ldapobject.py", line 315, in _ldap_call
    result = func(*args,**kwargs)
ldap.INSUFFICIENT_ACCESS: {'desc': 'Insufficient access'}

I'd like to have only the lines:

# ssh-ldap-pubkey add -H ldaps://<ldap-server>/ --quiet .ssh/id_ed25519.pub
Enter login (LDAP) password for user '<username>': 
ldap.OBJECT_CLASS_VIOLATION: {'desc': 'Object class violation', 'info': "attribute 'sshPublicKey' not allowed"}

During handling of the above exception, another exception occurred:

ldap.INSUFFICIENT_ACCESS: {'desc': 'Insufficient access'}

here.

I'd suggest adding a new option -d --debug and printing the python traceback only when this option is supplied.

@protegh protegh changed the title Supress tpython raceback in normal operation Supress python traceback in normal operation Oct 7, 2020
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

1 participant