libroscpp.so: cannot open shared object file: No such file or directory
I ran roscore
after setcap cap_net_admin,cap_net_raw+eip /usr/bin/python3.8
operation and below is the error I got. But the pyhton code below works properly.
opt/ros/noetic/lib/rosout/rosout: error while loading shared libraries: libroscpp.so: cannot open shared object file: No such file or directory process[rosout-1]: started with pid [10399] started core service [/rosout] [rosout-1] process has died [pid 10399, exit code 127, cmd /opt/ros/noetic/lib/rosout/rosout
__name:=rosout __log:=/home/bee/.ros/log/430043e8-0177-11ee-b48f-df7e4d4418d2/rosout-1.log]. log file: /home/bee/.ros/log/430043e8-0177-11ee-b48f-df7e4d4418d2/rosout-1*.log [rosout-1] restarting process
After running the setcap -r /usr/bin/python3
process, roscore
works fine, but the python code below does not work properly, giving an authorization error.
import pysoem
def test_pysoem():
master = pysoem.Master()
result = master.open("enp1s0")
master.close()
Error (without setuid privileges in python3.8):
$ python3.8 pysoem_test.py
> Traceback (most recent call last):
> File "ethercat_test.py", line 19, in
> <module>
> master.open('enp1s0') File "pysoem/pysoem.pyx", line 201, in pysoem.pysoem.CdefMaster.open
> ConnectionError: could not open interface enp1s0
I am using ubuntu 20.04.6 and ros noetic. I've run it this way with the melodic before.
$printenv | grep ROS
ROS_VERSION=1
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/opt/ros/noetic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROS_MASTER_URI=http://localhost:11311
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_DISTRO=noetic
$ echo $LD_LIBRARY_PATH
/home/bee/catkin_ws/devel/lib:/opt/ros/noetic/lib
Why does roscore give an error when giving setuid permissions to python3.8?
Asked by miksi on 2023-06-02 14:33:19 UTC
Answers
setcap cap_net_admin,cap_net_raw+eip /usr/bin/python3.8
It is an extremely bad practice to run all python programs with root privilege, even on your personal laptop. DO NOT DO THIS!
There are a number of better ways to give one ros node extra permissions. The launch-prefix="sudo -E"
is discussed in #q165246; it assumes that you configure sudo
to not require a password for your user account.
Asked by Mike Scheutzow on 2023-06-04 07:51:30 UTC
Comments
I added the following lines to the sudoers file.
bee ALL=(ALL) NOPASSWD: /usr/bin/python3
bee ALL=(ALL) NOPASSWD: /opt/ros/noetic/bin/roslaunch
I tried the following commands one by one
launch-prefix="sudo -HE env PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} PYTHONPATH=${PYTHONPATH}"
launch-prefix="sudo -S -HE env PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} PYTHONPATH=${PYTHONPATH}"
the error I got:
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
i couldn't solve this error
Asked by miksi on 2023-06-15 08:24:55 UTC
We are getting way off-topic for ros, but I will give a short answer. Assuming your username is bee
, then the syntax for new file /etc/sudoers.d/bee
is this single line:
bee ALL=(ALL:ALL) NOPASSWD: ALL
As explained in the link I provided, the launch file syntax is launch-prefix="sudo -E"
. That's it. Do not use -H. Do not use -S. Do not override existing environment variables.
Asked by Mike Scheutzow on 2023-06-16 07:57:49 UTC
Comments
If your library does not work outside of ros, then you'll need to resolve that issue first. After removing the suid change, have you tried:
If it doesn't work, your code is probably wrong. Frankly, when I look at the description for this pysoem library, it does not look like a function that belongs inside a ros node.
Asked by Mike Scheutzow on 2023-06-04 08:03:56 UTC