-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
snmpsim import error while running with root #53
Comments
I tried to run this on Fedora with python3 and 2, and on Centos7 with python 2. In both distros it works with normal user but doesn't with root. The Here is pip freeze
|
I can't reproduce this issue so far. Is there any traceback revealing line number? Or may be you could run |
I can get a stack trace for you, I track it down to the |
ImportError here https://github.com/etingof/pysnmp/blob/master/pysnmp/smi/builder.py#L161 I was trying to get something alike with normal user but it seems to take totally different path. I notice that |
Here it is:
|
This may be useful too:
|
Thank you for the thorough report! This reminds me that we've had similar problem in OpenStack... Commit etingof/pysnmp@fd7f6a7 in the release-4.4.9 branch should have fixed this problem. I wonder if you could give it a try before I make a release? |
For sure! I will ask you some patience since my Fedora died at the last update, I still have the VMs, as soon as I have my desk up to date I check it out for you. Regards! |
No worries, take your time! |
I have another problem right now, the release-4.4.9. (snmpsim-env) [root@localhost ~]# python
Python 3.7.2 (default, Jan 3 2019, 09:14:01)
[GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysnmp.entity.engine import SnmpEngine
>>> from snmpsim.daemon import dropPrivileges
>>>
>>> SnmpEngine()
SnmpEngine(snmpEngineID=<SnmpEngineID value object at 0x7fd6ac757198 tagSet <TagSet object at 0x7fd6af2dcc88 tags 0:0:4> subtypeSpec <ConstraintsIntersection object at 0x7fd6ac757358 consts <ValueSizeConstraint object at 0x7fd6af2b8080 consts 0, 65535>, <ValueSizeConstraint object at 0x7fd6ac757320 consts 5, 32>> encoding iso-8859-1 payload [0x80004fb8056c6f...63616c6413be2f88]>)
>>>
>>>
>>> dropPrivileges('nobody', 'nobody')
>>> SnmpEngine()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/snmpsim-env/lib64/python3.7/site-packages/pysnmp/entity/engine.py", line 91, in __init__
File "/root/snmpsim-env/lib64/python3.7/site-packages/pysnmp/smi/builder.py", line 426, in importSymbols
pysnmp.smi.error.MibNotFoundError: No module __SNMP-FRAMEWORK-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fd6ac770be0>
>>> |
This is a better way of running the test: from unittest import TestCase, main
from snmpsim.daemon import dropPrivileges
from pysnmp.entity.engine import SnmpEngine
class DropPrivileges(TestCase):
def test_dropPrivileges(self):
'SnmpEngine should work after dropping privileges'
dropPrivileges('nobody', 'nobody')
SnmpEngine()
if __name__ == '__main__':
main(verbosity=2) |
I just created a pull request, for this. I move the privileges drop to the end of file, just before starting the server (and opening the ports), is this okay? Is there any tests for validating the rest? Regards!!! |
Just a little comment, There is still a little bug at https://github.com/etingof/pysnmp/blob/master/pysnmp/smi/builder.py#L241. If user hasn't permission to read This would only happen if you pass a user at |
Hmm, is not that |
Yeah you're right, I was using an old revision, sorry! Regards! |
Hi
I'm trying to use snmpsim to simulate response from a switch. I need to open 161 port to get the management end fooled by snmpsim. I ran it as normal user without problems but when I ran it as root it gives-me an error.
Regards
The text was updated successfully, but these errors were encountered: