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

Exception when invoking as root using udp port 161 #61

Open
cacarroll opened this issue Feb 27, 2019 · 7 comments
Open

Exception when invoking as root using udp port 161 #61

cacarroll opened this issue Feb 27, 2019 · 7 comments

Comments

@cacarroll
Copy link

cacarroll commented Feb 27, 2019

snmpsim loads but then fails when queried. This only happens when invoking as root on port 161. When running on a non privileged port as a user it works great.

(py36-venv) [root@vSNMP pydev]# snmpsimd.py --agent-udpv4-endpoint=192.0.0.5:161 --process-user=user1 --process-group=group1
Scanning "/root/.snmpsim/variation" directory for variation modules...
Directory "/root/.snmpsim/variation" does not exist
Scanning "/root/pydev/py36-venv/snmpsim/variation" directory for variation modules...
A total of 9 modules found in /root/pydev/py36-venv/snmpsim/variation
Scanning "/root/pydev/py36-venv/share/snmpsim/variation" directory for variation modules...
Directory "/root/pydev/py36-venv/share/snmpsim/variation" does not exist
Scanning "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/variation" directory for variation modules...
Directory "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/variation" does not exist
Initializing variation modules...
Variation module "delay" from "/root/pydev/py36-venv/snmpsim/variation/delay.py" loaded OK
Variation module "error" from "/root/pydev/py36-venv/snmpsim/variation/error.py" loaded OK
Variation module "multiplex" from "/root/pydev/py36-venv/snmpsim/variation/multiplex.py" loaded OK
Variation module "notification" from "/root/pydev/py36-venv/snmpsim/variation/notification.py" loaded OK
Variation module "numeric" from "/root/pydev/py36-venv/snmpsim/variation/numeric.py" loaded OK
ERROR Variation module "redis" from "/root/pydev/py36-venv/snmpsim/variation/redis.py" load FAILED: Redis connect parameters not specified
ERROR Variation module "sql" from "/root/pydev/py36-venv/snmpsim/variation/sql.py" load FAILED: database type not specified
Variation module "subprocess" from "/root/pydev/py36-venv/snmpsim/variation/subprocess.py" loaded OK
Variation module "writecache" from "/root/pydev/py36-venv/snmpsim/variation/writecache.py" loaded OK
--- SNMP Engine configuration
SNMPv3 EngineID: 0x80004fb80576534e4d502bb0ba48
  --- Data directories configuration
  SNMPv3 Context Engine ID: 0x80004fb80576534e4d502bb0ba48
  Scanning "/root/.snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
  Directory "/root/.snmpsim/data" does not exist
  Scanning "/root/pydev/py36-venv/snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
    Configuring /root/pydev/py36-venv/snmpsim/data/bgp.snmprec controller
    SNMPv1/2c community name: bgp
    SNMPv3 Context Name: ec50a8f4d28bcb39103379379ddc5185 or bgp
    Configuring /root/pydev/py36-venv/snmpsim/data/cisco_16_switch.snmprec controller
    SNMPv1/2c community name: cisco_16_switch
    SNMPv3 Context Name: 906aed851a6090332cfcf762181810af or cisco_16_switch
    Configuring /root/pydev/py36-venv/snmpsim/data/hp_perf.snmprec controller
    SNMPv1/2c community name: hp_perf
    SNMPv3 Context Name: 2711b75cd6dea2b25c6d9db79dff3abd or hp_perf
    Configuring /root/pydev/py36-venv/snmpsim/data/hp_perf2.snmprec controller
    SNMPv1/2c community name: hp_perf2
    SNMPv3 Context Name: c030cd1687fce01f8b29682f28f91d6d or hp_perf2
    Configuring /root/pydev/py36-venv/snmpsim/data/public.snmprec controller
    SNMPv1/2c community name: public
    SNMPv3 Context Name: 4c9184f37cff01bcdc32dc486ec36961 or public
    Configuring /root/pydev/py36-venv/snmpsim/data/1.3.6.1.6.1.1.0/127.0.0.1.snmprec controller
    SNMPv1/2c community name: 1.3.6.1.6.1.1.0/127.0.0.1
    SNMPv3 Context Name: b00e7c4780fffc4ca0a74e262dd116bc or 1.3.6.1.6.1.1.0/127.0.0.1
    Configuring /root/pydev/py36-venv/snmpsim/data/foreignformats/linux.snmpwalk controller
    SNMPv1/2c community name: foreignformats/linux
    SNMPv3 Context Name: bd63505107ebbd71e0046f4f30ce9c74 or foreignformats/linux
    Configuring /root/pydev/py36-venv/snmpsim/data/foreignformats/winxp1.snmpwalk controller
    SNMPv1/2c community name: foreignformats/winxp1
    SNMPv3 Context Name: 80212f5c9cbc92e175293565ef100834 or foreignformats/winxp1
    Configuring /root/pydev/py36-venv/snmpsim/data/foreignformats/winxp2.sapwalk controller
    SNMPv1/2c community name: foreignformats/winxp2
    SNMPv3 Context Name: da761cfc8c94d3aceef4f60f049105ba or foreignformats/winxp2
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/host-resources-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/host-resources-mib
    SNMPv3 Context Name: e15efa7fd2910fcd23721edfe04d6f12 or mib2dev/host-resources-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/ip-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/ip-mib
    SNMPv3 Context Name: b545e61d091faca8a69f426b2bc5285d or mib2dev/ip-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/tcp-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/tcp-mib
    SNMPv3 Context Name: ce7ca72c4091055613e6f9a22279bbcc or mib2dev/tcp-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/udp-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/udp-mib
    SNMPv3 Context Name: 2193fe4afb8daee928db9dcbf9ace768 or mib2dev/udp-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/public/1.3.6.1.2.1.100.1.13.0.snmprec controller
    SNMPv1/2c community name: public/1.3.6.1.2.1.100.1.13.0
    SNMPv3 Context Name: 1099b06180350d8b30b977aef5a79faa or public/1.3.6.1.2.1.100.1.13.0
    Configuring /root/pydev/py36-venv/snmpsim/data/public/1.3.6.1.2.1.100.1.2.0/__1.snmprec controller
    SNMPv1/2c community name: public/1.3.6.1.2.1.100.1.2.0/__1
    SNMPv3 Context Name: 99d7c3808c1c0725693315846b8d42ae or public/1.3.6.1.2.1.100.1.2.0/__1
    Configuring /root/pydev/py36-venv/snmpsim/data/public/1.3.6.1.6.1.1.0/127.0.0.1.snmprec controller
    SNMPv1/2c community name: public/1.3.6.1.6.1.1.0/127.0.0.1
    SNMPv3 Context Name: d4c09769d12b4ec404a0a31386bd42f6 or public/1.3.6.1.6.1.1.0/127.0.0.1
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/linksys-system.snmprec controller
    SNMPv1/2c community name: recorded/linksys-system
    SNMPv3 Context Name: 1a764f7fd0e7b0bf98bada8fe723e488 or recorded/linksys-system
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/linux-full-walk.snmprec controller
    SNMPv1/2c community name: recorded/linux-full-walk
    SNMPv3 Context Name: a172334d7d97871b72241397f713fa12 or recorded/linux-full-walk
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/solaris-system.snmprec controller
    SNMPv1/2c community name: recorded/solaris-system
    SNMPv3 Context Name: 21dd004374d17d03e3dfa074cf39d03c or recorded/solaris-system
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/udp-endpoint-table-walk.snmprec controller
    SNMPv1/2c community name: recorded/udp-endpoint-table-walk
    SNMPv3 Context Name: 441ae36bd8c97e17421768a049541373 or recorded/udp-endpoint-table-walk
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/winxp-full-walk.snmprec controller
    SNMPv1/2c community name: recorded/winxp-full-walk
    SNMPv3 Context Name: d55520dd841a3fcd0a7618889301f4ad or recorded/winxp-full-walk
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/delay.snmprec controller
    SNMPv1/2c community name: variation/delay
    SNMPv3 Context Name: 6334719eb92fc00f20e7df14ffc8f6d2 or variation/delay
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/error.snmprec controller
    SNMPv1/2c community name: variation/error
    SNMPv3 Context Name: 83e5bd723f8095e1a27fb2b404e50404 or variation/error
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex.snmprec controller
    SNMPv1/2c community name: variation/multiplex
    SNMPv3 Context Name: 1016117d6836664ee15b9b2af5642c3c or variation/multiplex
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/notification.snmprec controller
    SNMPv1/2c community name: variation/notification
    SNMPv3 Context Name: fb800ce0bec7d161fcbf0249793a2b69 or variation/notification
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/sql.snmprec controller
    SNMPv1/2c community name: variation/sql
    SNMPv3 Context Name: 3fe8eeff6b172158b39f89ca150c8b0a or variation/sql
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/subprocess.snmprec controller
    SNMPv1/2c community name: variation/subprocess
    SNMPv3 Context Name: b399244b6b33799beedc357f453a0119 or variation/subprocess
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/virtualtable.snmprec controller
    SNMPv1/2c community name: variation/virtualtable
    SNMPv3 Context Name: 329a935947144eb87ad0cdc5e08927b1 or variation/virtualtable
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/writecache.snmprec controller
    SNMPv1/2c community name: variation/writecache
    SNMPv3 Context Name: 0886e1397d572377c17c15036a1e6c66 or variation/writecache
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00000.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00000
    SNMPv3 Context Name: 14de4d7a19be68c2a09429578218d80a or variation/multiplex/00000
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00001.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00001
    SNMPv3 Context Name: 78ed3493c53f1b7769901ad4eba77a6f or variation/multiplex/00001
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00002.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00002
    SNMPv3 Context Name: a98f363190bae0bb6eb215069e4e0694 or variation/multiplex/00002
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00003.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00003
    SNMPv3 Context Name: e2846ec4e4e23399ae1bea52c3cc3f25 or variation/multiplex/00003
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00004.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00004
    SNMPv3 Context Name: f816184db84e89f16bf1a3f0f798ce6e or variation/multiplex/00004
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00005.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00005
    SNMPv3 Context Name: 3b19457c6530b5c4d41a04107aed2cdc or variation/multiplex/00005
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00006.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00006
    SNMPv3 Context Name: 4d5ef03b64553186ccb161418552d1df or variation/multiplex/00006
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00007.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00007
    SNMPv3 Context Name: db2a4a17f7826b121cd6baaf830ad714 or variation/multiplex/00007
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00008.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00008
    SNMPv3 Context Name: 2fe88e4455aa806f0e05cf234df01c89 or variation/multiplex/00008
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00009.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00009
    SNMPv3 Context Name: 6e0f5ddb1317240d8451de240210a611 or variation/multiplex/00009
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00010.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00010
    SNMPv3 Context Name: d9439360a67b45f63b56ef60b6245f54 or variation/multiplex/00010
  Scanning "/root/pydev/py36-venv/share/snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
  Directory "/root/pydev/py36-venv/share/snmpsim/data" does not exist
  Scanning "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
  Directory "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/data" does not exist
  --- SNMPv3 USM configuration
  SNMPv3 USM SecurityName: simulator
  SNMPv3 USM authentication key: auctoritas, authentication protocol: MD5
  SNMPv3 USM encryption (privacy) key: privatus, encryption protocol: DES
  Maximum number of variable bindings in SNMP response: 64
  --- Transport configuration
  Listening at UDP/IPv4 endpoint 192.0.0.5:161, transport ID 1.3.6.1.6.1.1.0
Shutting down variation modules:
Variation module "delay" shutdown OK
Variation module "error" shutdown OK
Variation module "multiplex" shutdown OK
Variation module "notification" shutdown OK
Variation module "numeric" shutdown OK
Variation module "redis" shutdown OK
Variation module "sql" shutdown OK
Variation module "subprocess" shutdown OK
Variation module "writecache" shutdown OK
Process terminated
ERROR Traceback (most recent call last):;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher;
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 207, in loop;    poll_fun(timeout, map);
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 188, in poll2;    readwrite(obj, flags);
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 123, in readwrite;    obj.handle_error();
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 108, in readwrite;    obj.handle_read_event();
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 423, in handle_read_event;    self.handle_read();
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/proto/rfc3412.py", line 284, in receiveMessage;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/smi/builder.py", line 426, in importSymbols;
ERROR pysnmp.smi.error.MibNotFoundError: No module __SNMPv2-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fea663117f0>;
ERROR ;During handling of the above exception, another exception occurred:;;
ERROR Traceback (most recent call last):;
ERROR   File "/root/pydev/py36-venv/bin/snmpsimd.py", line 1466, in <module>;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher;
ERROR pysnmp.error.PySnmpError: poll error: Traceback (most recent call last):;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher;;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 207, in loop;    poll_fun(timeout, map);;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 188, in poll2;    readwrite(obj, flags);;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 123, in readwrite;    obj.handle_error();;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 108, in readwrite;    obj.handle_read_event();;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 423, in handle_read_event;    self.handle_read();;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/proto/rfc3412.py", line 284, in receiveMessage;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/smi/builder.py", line 426, in importSymbols;;pysnmp.smi.error.MibNotFoundError: No module __SNMPv2-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fea663117f0>;caused by <class 'pysnmp.smi.error.MibNotFoundError'>: No module __SNMPv2-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fea663117f0>;
@etingof
Copy link
Owner

etingof commented Feb 27, 2019

Could you please share your pip freeze output? Thanks!

@cacarroll
Copy link
Author

cacarroll commented Feb 28, 2019 via email

@etingof
Copy link
Owner

etingof commented Mar 1, 2019

Actually, I think that's not exactly a bug...

I suspect that when you switch into a non-privileged user, you lose access to root's virtual environment. So may be the solution would be to have snmpsim installed into non-privileged user's virtual environment, then run it as root from there?

WDYT?

@etingof
Copy link
Owner

etingof commented Mar 1, 2019

Alternatively, commit f0505c1 should fix this issue. Let's see if it works for you so I could cut next release?

@cacarroll
Copy link
Author

cacarroll commented Mar 13, 2019 via email

@cacarroll
Copy link
Author

cacarroll commented Mar 13, 2019 via email

@cacarroll
Copy link
Author

cacarroll commented Mar 18, 2019 via email

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