Page MenuHomePhabricator

Python environment lacks definition of vyos_libexec_dir when calling os.system()
Open, LowPublicBUG

Description

Rewriting the SNMP configuration as XML/Python requires that the running VyOS configuration is altered by the python script. This is aweful.

The reason is that if a user specifies a plaintext password it will be converted to an encrypted one during SNMP startup. Later this encrypted pasword is re-read and set as encrypted-key in the running config whereas the plaintext-key node is deleted.

Calling

os.system('/opt/vyatta/sbin/my_delete service snmp v3 user "nms" auth plaintext-key')

Resulted in:

sh: /validate-value.py: No such file or directory

The available environment has been extracted using os.system('env')

The current workaround in https://github.com/vyos/vyos-1x/commit/0d38d4f13c24450aaa7b1a0a748e5f007b73ba8f is more than ugly (definition of the environment variable before calling the script)

Details

Difficulty level
Unknown (require assessment)
Version
1.2.0-rolling+201806050337
Why the issue appeared?
Will be filled on close
c-po created this task.Jun 5 2018, 7:43 PM
c-po updated the task description. (Show Details)Jun 5 2018, 7:49 PM
syncer triaged this task as Low priority.Jun 10 2018, 2:24 AM
dmbaturin added a subscriber: dmbaturin.

@c-po You've found a workaround, right?

c-po added a comment.Sep 3 2018, 5:07 AM

Yes, just pass the variable on calls to os.system()

c-po added a comment.Sep 3 2018, 12:53 PM

@dmbaturin the "workaround" and implementation is IMHO super bad (https://github.com/vyos/vyos-1x/blob/current/src/conf_mode/snmp.py#L808-L813) as it uses /opt/vyatta/sbin/my_set or /opt/vyatta/sbin/my_delete.

Can't we use vyos.configtree in a Python script to replace those bad shell calls? I think this would be the best solution!

In other words, does vyos.configtree support the effective configuration?