- 浏览: 3506860 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
wanglf1207:
EJB的确是个不错的产品,只是因为用起来有点门槛,招来太多人吐 ...
weblogic-ejb-jar.xml的元素解析 -
qwfys200:
总结的不错。
Spring Web Flow 2.0 入门 -
u011577913:
u011577913 写道也能给我发一份翻译文档? 邮件437 ...
Hazelcast 参考文档-4 -
u011577913:
也能给我发一份翻译文档?
Hazelcast 参考文档-4 -
songzj001:
DbUnit入门实战
本人在/etc/environment中设置了环境变量:
JAVA_HOME=/opt/java ORACLE_HOME=/home/user2/ LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
正常情况下执行没有问题,但使用sudo XXXXXXX的时候,其他变量都好使,除了LD_LIBRARY_PATH;
经探索,找到原因:
据说因为安全原因,Linux系统做了限制。 LD_LIBRARY_PATH not loading from .profile nor /etc/environment
Ubuntu 不能在 profile, environment,.bashrc中设置 LD_LIBRARY_PATH;
解决办法:
编辑 /etc/ld.so.conf 文件,将指定的路径加上,或者在 /etc/ld.so.conf.d/ 目录中添加一个新的配置文件。
评论
1 楼
yangzb
2010-02-18
另一个办法:
The problem is simple: how to preserve PATH and LD_LIBRARY_PATH when running a program via sudo. But when I tried to find a workaround, I was totally confused by related stuff. So I keep a record as clear as possible to help myself.
1.
Topic: How to set environment variables
Source: man sudo, section OPTIONS
Details:
Environment variables to be set for the command may also be passed on the command line in the form of VAR=value,
e.g. LD_LIBRARY_PATH=/usr/local/pkg/lib. Variables passed on the command line are subject to the same restric‐
tions as normal environment variables with one important exception. If the setenv option is set in sudoers, the
command to be run has the SETENV tag set or the command matched is ALL, the user may set variables that would
overwise be forbidden. See sudoers(5) for more information.
2.
Topic: About LD_LIBRARY_PATH
Source: man sudo, section SECURITY NOTES
Details:
Note that the dynamic linker on most operating systems will remove variables that can control dynamic linking from
the environment of setuid executables, including sudo. Depending on the operating system this may include _RLD*,
DYLD_*, LD_*, LDR_*, LIBPATH, SHLIB_PATH, and others. These type of variables are removed from the environment
before sudo even begins execution and, as such, it is not possible for sudo to preserve them.
3.
Topic: env_reset
Source: man sudo, section SUDOERS OPTIONS
Details:
env_reset If set, sudo will reset the environment to only contain the LOGNAME, SHELL, USER, USERNAME and the
SUDO_* variables. Any variables in the caller’s environment that match the env_keep and env_check
lists are then added. The default contents of the env_keep and env_check lists are displayed when
sudo is run by root with the -V option. If sudo was compiled with the SECURE_PATH option, its
value will be used for the PATH environment variable. This flag is on by default.
4.
Topic: Handling environment variables against env_reset
Source: man sudo, section SECURITY NOTES
Details:
There are two distinct ways to deal with environment variables. By default, the env_reset sudoers option is
enabled. This causes commands to be executed with a minimal environment containing TERM, PATH, HOME, SHELL, LOG‐
NAME, USER and USERNAME in addition to variables from the invoking process permitted by the env_check and env_keep
sudoers options. There is effectively a whitelist for environment variables.
If, however, the env_reset option is disabled in sudoers, any variables not explicitly denied by the env_check and
env_delete options are inherited from the invoking process. In this case, env_check and env_delete behave like a
blacklist. Since it is not possible to blacklist all potentially dangerous environment variables, use of the
default env_reset behavior is encouraged.
My workaround is as follows:
cd /usr/local/bin; sudo ln -s <path_to_my_executable>
sudo LD_LIBRARY_PATH=<path_to_shared_libraries> my_executable
The problem is simple: how to preserve PATH and LD_LIBRARY_PATH when running a program via sudo. But when I tried to find a workaround, I was totally confused by related stuff. So I keep a record as clear as possible to help myself.
1.
Topic: How to set environment variables
Source: man sudo, section OPTIONS
Details:
Environment variables to be set for the command may also be passed on the command line in the form of VAR=value,
e.g. LD_LIBRARY_PATH=/usr/local/pkg/lib. Variables passed on the command line are subject to the same restric‐
tions as normal environment variables with one important exception. If the setenv option is set in sudoers, the
command to be run has the SETENV tag set or the command matched is ALL, the user may set variables that would
overwise be forbidden. See sudoers(5) for more information.
2.
Topic: About LD_LIBRARY_PATH
Source: man sudo, section SECURITY NOTES
Details:
Note that the dynamic linker on most operating systems will remove variables that can control dynamic linking from
the environment of setuid executables, including sudo. Depending on the operating system this may include _RLD*,
DYLD_*, LD_*, LDR_*, LIBPATH, SHLIB_PATH, and others. These type of variables are removed from the environment
before sudo even begins execution and, as such, it is not possible for sudo to preserve them.
3.
Topic: env_reset
Source: man sudo, section SUDOERS OPTIONS
Details:
env_reset If set, sudo will reset the environment to only contain the LOGNAME, SHELL, USER, USERNAME and the
SUDO_* variables. Any variables in the caller’s environment that match the env_keep and env_check
lists are then added. The default contents of the env_keep and env_check lists are displayed when
sudo is run by root with the -V option. If sudo was compiled with the SECURE_PATH option, its
value will be used for the PATH environment variable. This flag is on by default.
4.
Topic: Handling environment variables against env_reset
Source: man sudo, section SECURITY NOTES
Details:
There are two distinct ways to deal with environment variables. By default, the env_reset sudoers option is
enabled. This causes commands to be executed with a minimal environment containing TERM, PATH, HOME, SHELL, LOG‐
NAME, USER and USERNAME in addition to variables from the invoking process permitted by the env_check and env_keep
sudoers options. There is effectively a whitelist for environment variables.
If, however, the env_reset option is disabled in sudoers, any variables not explicitly denied by the env_check and
env_delete options are inherited from the invoking process. In this case, env_check and env_delete behave like a
blacklist. Since it is not possible to blacklist all potentially dangerous environment variables, use of the
default env_reset behavior is encouraged.
My workaround is as follows:
cd /usr/local/bin; sudo ln -s <path_to_my_executable>
sudo LD_LIBRARY_PATH=<path_to_shared_libraries> my_executable
发表评论
-
微软内部补丁(非正式发布)之取得方式(20110713)
2011-08-06 13:58 10689http://support.micr ... -
当您尝试登录到 Telnet 服务器正在运行 Windows Server 2003,与 Service Pack 1 或 Service Pack 2 时出现
2011-08-06 13:41 3095http://support.microsoft.com/kb ... -
collectd
2011-08-03 14:27 2284collectd是一个守护(daemon)进程,用来收集系 ... -
rhel5的xen内核无法使用串口的原因和解决方法
2011-03-20 19:10 2495公司有一台服务器安装的了rhel5系统,默认的内核是带 ... -
RDM与VMFS 对比与解释
2010-12-25 17:53 2444在一个存储区域网络 ... -
通过VMWare的Webservice API连接ESX|ESXi主机的JAVA源码
2010-12-25 17:52 5582参考VMWare的Webservice API的文档,连接到E ... -
修改 ESX Server IP 地址
2010-12-25 17:51 11408修改 ESX Server IP 地址 ... -
Debian Linux下如何以root账号登录桌面
2010-12-22 12:51 6259I Debian Linux 方法有两种,一是图 ... -
coLinux
2010-11-02 22:11 9119coLinux是我极其喜爱的一款虚拟机。它快速而灵巧,最为方便 ... -
Linux操作下的进程管理利器 Supervise
2010-10-19 21:02 2834[摘要] Supervise是daemontoo ... -
andLinux介绍:
2010-08-22 20:51 39771:来自linuxtoy:是一个基 ... -
andlinux root 密码修改
2010-08-21 09:54 3172安装andlinux后发现root密码不知道,后发现,输入当前 ... -
RHEL
2010-08-02 17:46 2780Red Hat Enterprise Linux Advan ... -
coLinux ExpandingRootedit
2010-03-18 01:45 2702Contents 1 First backu ... -
AndLinux
2010-03-18 01:05 4084AndLinux (http://andlinux.org ... -
andLinux 在系统重装后手工修复
2010-03-15 22:21 2836话说“家有一老,如有一宝”,而手边有一个linux,也可以 ... -
寻找最快的 ubuntu / debian 源 及 建立局域网deb 更新服务器和安装初步
2010-03-15 01:51 4684寻找最快的 ubuntu / debian 源 寻找最快的 ... -
colinux的安装与网络配置
2010-03-15 00:37 9390在windows上模拟linux ... -
使用colinux在windows上虚拟linux
2010-03-12 13:44 5318Cooperative Linux is th ... -
Linux发行版大全
2010-03-06 03:20 3414基于Debian Adamantix: ...
相关推荐
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} export CUDA_HOME=/usr/local/cuda export PATH=$PATH:$CUDA_HOME/bin export LD_LIBRARY_PATH=/usr/local/cuda-...
ubuntu9.1随手笔记,GRUB引导修复,GRUB命令行启动,字体安装,flash 乱码,切换用户,eclipse安装,LD_LIBRARY_PATH变量的设置,修改系统启动选项菜单的背景图片,remastersys工具包安装
为了解决这个问题,我们需要将这个路径添加到`LD_LIBRARY_PATH`中。有几种方法可以实现这一目标: 1. **编辑`.bashrc`文件**:在个人主目录`~`(通常是`/home/your_username`)下的`.bashrc`文件中添加环境变量。...
export LD_LIBRARY_PATH=your_path/install/third_party/onnxruntime/lib:$LD_LIBRARY_PATH ``` 注意:上述命令中的your_path需要改为第1步得到的“install”所在的父目录! ## 3. 编写Demo示例
boa开源代码解决cgi依赖库加载失败的问题 int complete_env(request * req) ... char *env = getenv("LD_LIBRARY_PATH"); if (NULL != env) my_add_cgi_env(req, "LD_LIBRARY_PATH", env); ...... }
pyenv-archshell pyenv shell命令的扩展,允许在必要时设置 LD_LIBRARY_PATH。 这个插件添加了pyenv archshell命令,它是标准pyenv shell命令的包装器。 目前这个插件只对linux有影响。 如果指定了版本, archshell...
export LD_LIBRARY_PATH=$HOME/gst_1.6.0/out/lib/:$LD_LIBRARY_PATH ``` - **`WORK_DIR`** 变量记录当前的工作目录。 - **`LD_LIBRARY_PATH`** 环境变量被设置为包含自定义库路径 `$HOME/gst_1.6.0/out/lib/` 的值...
1 、确定数据库的sid 和db_name \u3000sid='hsj' ... LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH 3、设置登录方法
1.将sapjco3.jar 文件复制至 $JAVA_HOME/lib/sapjco3.jar 2.将 libsapjco3.so 文件复制至 $JAVA_...LD_LIBRARY_PATH=dir:$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/amd64/server export CLASSPATH LD_LIBRARY_PATH PATH
java_Path环境变量的配置
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/boost/lib export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/boost/lib export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/boost/include export CPLUS_...
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH export LD_LIBRARY_PATH ``` 这将将当前目录添加到LD_LIBRARY_PATH环境变量中,从而使Java程序可以找到动态链接库。 五、java.library.path环境变量 java.library.path环境...
解决这个问题的一个关键方法是设置或调整系统的环境变量,特别是`LD_LIBRARY_PATH`。本文将详细介绍如何在Ubuntu系统中设置环境变量来解决此类问题。 首先,我们需要理解`LD_LIBRARY_PATH`这个环境变量的作用。它是...
gdal-2.0.1.tar.gz安装包,大家可以根据需要下载。 1.tar -xzvf gdal-2.0.0.tar.gz 2. 编译源码。 cd gdal-2.0.0 ./configure ...添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH export ORACLE_OWNER=oracle export ORACLE_SID=fzwang export ORACLE_TERM=xterm export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data...
虽然使用`LD_LIBRARY_PATH`是一种快速解决问题的方法,但也有不少声音认为应尽量避免使用此变量,尤其是作为全局变量。主要原因包括: - **安全性问题**:全局设置可能导致意外加载恶意或不兼容的库。 - **维护复杂...
写了点Qt界面程序,然而发现很难移植到其他没有安装Qt环境的电脑上运行。查资料了解到,在windows上有...export LD_LIBRARY_PATH=/home/xl/Qt5.9.2/5.9.2/gcc_64/lib:$LD_LIBRARY_PATH export QT_PLUGIN_PATH=/home/x
通常情况下,这一顺序为:LD_PRELOAD环境变量中指定的库,LD_LIBRARY_PATH指定的目录,ld.so.cache文件,系统的标准库目录/lib以及/usr/lib。通过LD_PRELOAD指定的库将优先加载,因此可以实现对程序行为的控制和修改...
export LD_LIBRARY_PATH=/path/to/library:$LD_LIBRARY_PATH ``` 这行命令会在原有值的基础上添加一个新的搜索路径。需要注意的是,这种方式只对当前用户的当前会话有效。 #### 五、配置文件/etc/ld.so.conf 管理...
SATA硬盘仿真模型。The xilinx GTP is configured as SATA PHY,and 256MB DDR2 memory(Xilinx XAPP859) is HDD storge space....setenv LD_LIBRARY_PATH $LMC_HOME/lib/linux.lib:$LD_LIBRARY_PATH