- 浏览: 3500043 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 10651http://support.micr ... -
当您尝试登录到 Telnet 服务器正在运行 Windows Server 2003,与 Service Pack 1 或 Service Pack 2 时出现
2011-08-06 13:41 3088http://support.microsoft.com/kb ... -
collectd
2011-08-03 14:27 2278collectd是一个守护(daemon)进程,用来收集系 ... -
rhel5的xen内核无法使用串口的原因和解决方法
2011-03-20 19:10 2482公司有一台服务器安装的了rhel5系统,默认的内核是带 ... -
RDM与VMFS 对比与解释
2010-12-25 17:53 2432在一个存储区域网络 ... -
通过VMWare的Webservice API连接ESX|ESXi主机的JAVA源码
2010-12-25 17:52 5574参考VMWare的Webservice API的文档,连接到E ... -
修改 ESX Server IP 地址
2010-12-25 17:51 11401修改 ESX Server IP 地址 ... -
Debian Linux下如何以root账号登录桌面
2010-12-22 12:51 6251I Debian Linux 方法有两种,一是图 ... -
coLinux
2010-11-02 22:11 9107coLinux是我极其喜爱的一款虚拟机。它快速而灵巧,最为方便 ... -
Linux操作下的进程管理利器 Supervise
2010-10-19 21:02 2823[摘要] Supervise是daemontoo ... -
andLinux介绍:
2010-08-22 20:51 39671:来自linuxtoy:是一个基 ... -
andlinux root 密码修改
2010-08-21 09:54 3167安装andlinux后发现root密码不知道,后发现,输入当前 ... -
RHEL
2010-08-02 17:46 2776Red Hat Enterprise Linux Advan ... -
coLinux ExpandingRootedit
2010-03-18 01:45 2688Contents 1 First backu ... -
AndLinux
2010-03-18 01:05 4075AndLinux (http://andlinux.org ... -
andLinux 在系统重装后手工修复
2010-03-15 22:21 2827话说“家有一老,如有一宝”,而手边有一个linux,也可以 ... -
寻找最快的 ubuntu / debian 源 及 建立局域网deb 更新服务器和安装初步
2010-03-15 01:51 4674寻找最快的 ubuntu / debian 源 寻找最快的 ... -
colinux的安装与网络配置
2010-03-15 00:37 9382在windows上模拟linux ... -
使用colinux在windows上虚拟linux
2010-03-12 13:44 5305Cooperative Linux is th ... -
Linux发行版大全
2010-03-06 03:20 3407基于Debian Adamantix: ...
相关推荐
电子商务之价格优化算法:梯度下降:机器学习在价格优化中的角色.docx
ToadforOracle与Oracle数据库版本兼容性教程.docx
360浏览器银河麒麟版 for X86 适配兆芯 / 海光 / intel / AMD CPU
使用React.js构建,提供多种主题可供选择,并且易于定制。该项目旨在帮助开发者和自由职业者创建自己的个性化投资组合。 主要功能点 多种主题可供选择,包括绿色、黑白、蓝色、红色、橙色、紫色、粉色和黄色 易于定制,可以在src/data文件夹中更新个人信息 包含主页、关于、简历、教育、技能、经验、项目、成就、服务、推荐信、博客和联系等多个部分 支持通过Google表单收集联系信息 提供SEO优化建议 支持多种部署方式,如Netlify、Firebase、Heroku和GitHub Pages 技术栈主要 React.js Material-UI Axios React-fast-marquee React-helmet React-icons React-reveal React-router-dom React-router-hash-link React-slick Slick-carousel Validator
中小型企业财务管理系统 SSM毕业设计 附带论文 启动教程:https://www.bilibili.com/video/BV1GK1iYyE2B
python whl离线安装包 pip安装失败可以尝试使用whl离线安装包安装 第一步 下载whl文件,注意需要与python版本配套 python版本号、32位64位、arm或amd64均有区别 第二步 使用pip install XXXXX.whl 命令安装,如果whl路径不在cmd窗口当前目录下,需要带上路径 WHL文件是以Wheel格式保存的Python安装包, Wheel是Python发行版的标准内置包格式。 在本质上是一个压缩包,WHL文件中包含了Python安装的py文件和元数据,以及经过编译的pyd文件, 这样就使得它可以在不具备编译环境的条件下,安装适合自己python版本的库文件。 如果要查看WHL文件的内容,可以把.whl后缀名改成.zip,使用解压软件(如WinRAR、WinZIP)解压打开即可查看。 为什么会用到whl文件来安装python库文件呢? 在python的使用过程中,我们免不了要经常通过pip来安装自己所需要的包, 大部分的包基本都能正常安装,但是总会遇到有那么一些包因为各种各样的问题导致安装不了的。 这时我们就可以通过尝试去Python安装包大全中(whl包下载)下载whl包来安装解决问题。
电子商务之价格优化算法:线性回归:价格优化策略实施.docx
内容概要:报告详细介绍了企业数字化转型的驱动因素、数字化转型方案分类及其应用场景,重点关注了云计算、超连接、数字孪生、人工智能、分布式账本、增材制造、人机接口、数据共享、工业物联网等关键技术。这些技术不仅支持了企业的运营效率提升和业务模式创新,也为实现更快、更开放、更高效的数字化转型提供了支撑。报告最后提出了企业实施数字化转型的六个步骤。 适合人群:企业高级管理人员、技术人员、咨询顾问,以及对工业数字化转型感兴趣的读者。 使用场景及目标:帮助企业制定和实施数字化转型策略,优化运营模式,提升业务效率,增强市场竞争力。同时,也可作为政府部门、研究机构和行业协会的参考文献。 其他说明:报告中提到的关键技术及其应用场景对企业数字化转型具有重要的指导意义,特别是对于那些希望通过数字化转型实现业务创新和升级的企业。
基于java的线上选课系统的设计与实现答辩PPT.pptx
安装前的准备 1、安装Python:确保你的计算机上已经安装了Python。你可以在命令行中输入python --version或python3 --version来检查是否已安装以及安装的版本。 个人建议:在anaconda中自建不同python版本的环境,方法如下(其他版本照葫芦画瓢): 比如创建python3.8环境,anaconda命令终端输入:conda create -n py38 python==3.8 2、安装pip:pip是Python的包管理工具,用于安装和管理Python包。你可以通过输入pip --version或pip3 --version来检查pip是否已安装。 安装WHL安装包 1、打开命令行(或打开anaconda命令行终端): 在Windows上,你可以搜索“cmd”或“命令提示符”并打开它。 在macOS或Linux上,你可以打开“终端”。 2、cd到whl文件所在目录安装: 使用cd命令导航到你下载的whl文件所在的文件夹。 终端输入:pip install xxx.whl安装即可(xxx.whl指的是csdn下载解压出来的whl) 3、等待安装完成: 命令行会显示安装进度,并在安装完成后返回提示符。 以上是简单安装介绍,小白也能会,简单好用,从此再也不怕下载安装超时问题。 使用过程遇到问题可以私信,我可以帮你解决! 收起
电子商务之价格优化算法:贝叶斯定价:贝叶斯网络在电子商务定价中的应用.docx
IMG_20241105_235746.jpg
基于java的毕业设计选题系统答辩PPT.pptx
专升本考试资料全套.7z
Trustwave DbProtect:数据库活动监控策略制定.docx
基于VB的程序实例,可供参考学习使用
本压缩包资源说明,你现在往下拉可以看到压缩包内容目录 我是批量上传的基于SpringBoot+Vue的项目,所以描述都一样;有源码有数据库脚本,系统都是测试过可运行的,看文件名即可区分项目~ |Java|SpringBoot|Vue|前后端分离| 开发语言:Java 框架:SpringBoot,Vue JDK版本:JDK1.8 数据库:MySQL 5.7+(推荐5.7,8.0也可以) 数据库工具:Navicat 开发软件: idea/eclipse(推荐idea) Maven包:Maven3.3.9+ 系统环境:Windows/Mac
该源码项目是一款基于Thinkphp5框架的Java插件设计,包含114个文件,其中Java源文件60个,PNG图片32个,XML配置文件7个,GIF图片7个,Git忽略文件1个,LICENSE文件1个,Markdown文件1个,Xmind文件1个,Idea项目文件1个,以及JAR文件1个。
数据库开发和管理最佳实践.pdf
本压缩包资源说明,你现在往下拉可以看到压缩包内容目录 我是批量上传的基于SpringBoot+Vue的项目,所以描述都一样;有源码有数据库脚本,系统都是测试过可运行的,看文件名即可区分项目~ |Java|SpringBoot|Vue|前后端分离| 开发语言:Java 框架:SpringBoot,Vue JDK版本:JDK1.8 数据库:MySQL 5.7+(推荐5.7,8.0也可以) 数据库工具:Navicat 开发软件: idea/eclipse(推荐idea) Maven包:Maven3.3.9+ 系统环境:Windows/Mac