我想链接到一个共享库,该共享库的所有者更改为root并设置了setuid:
$ ls -la
total 3616
drwxrwxr-x 2 chiron chiron 4096 Mai 29 21:59 .
drwxrwxr-x 4 chiron chiron 4096 Mai 29 23:16 ..
-rwsr-xr-x 1 root chiron 3692440 Mai 29 21:59 chiron_lowlevel_controller_node
启动可执行文件时,出现以下错误:
$ ./chiron_lowlevel_controller_node
./chiron_lowlevel_controller_node: error while loading shared libraries: libxmlrpcpp.so: cannot open shared object file: No such file or directory
这使我感到困惑,因为ldd返回:
$ ldd chiron_lowlevel_controller_node | grep xml
libxmlrpcpp.so => /opt/ros/melodic/lib/libxmlrpcpp.so (0x00007effe8c86000)
libxmlrpcpp.so确实存在:
$ ls -la | grep xml
-rw-r--r-- 1 root root 122608 Mär 18 19:03 libxmlrpcpp.so
我还知道libxmlrpcpp.so并没有损坏,因为当我删除setuid并将所有者更改为chiron时,不会发生错误。
其他问题:
$ readelf -d chiron_lowlevel_controller
返回RUNPATH中的许多目录:
0x000000000000001d (RUNPATH) Library runpath: [Many:Directories:Separated:By:Double:Dots]
但是如果我将libxmlrpcpp.so移到其中一个目录中,
$ ldd chiron_lowlevel_controller_node | grep xml
libxmlrpcpp.so => not found
此article声称ldd在runpath的所有目录中搜索共享库,那么为什么在移动共享库时它不起作用?还是那篇文章不对?
系统信息:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic