<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[php通过sudo执行root权限的程序]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Thu, 18 Apr 2013 03:47:45 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	最近公司需要通过web界面修改squid.conf，然后保存配置文件的同时重启动squid，web服务器是nginx+php，文件用户和组都是www。<br/>首先编辑 /etc/sudoers 使用 visudo来编辑<br/>/etc/sudoers的权限是440：<br/>-r–r—– 1 root root 3248 Oct 18 23:47 /etc/sudoers<br/>需要chmod u+w /etc/sudoers<br/>修改完毕之后再chmod -w /etc/sudoers<br/>因为如果/etc/sudoers的权限不是440，那么sudo会报错：<br/>[root@hn ~]# sudo<br/>sudo: /etc/sudoers is mode 0640, should be 0440<br/>sudo: no valid sudoers sources found, quitting<br/><br/>在最下面添加一行<br/><br/>nobody ALL=NOPASSWD:/usr/local/squid/sbin/squid -k reconfigure<br/><br/>然后注释掉文件中的Defaults requiretty这行<br/>否则会出现sudo: sorry, you must have a tty to run sudo的错误<br/>保存退出即可<br/>测试<br/>写一个php文件，内容如下<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
$output = shell_exec(&quot;/usr/bin/sudo /usr/local/squid/sbin/squid -k reconfigure&quot;);
echo $output;
?&gt;
</textarea><br/><br/>来自：http://tunps.com/php-sudo-root-privilege-program
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] php通过sudo执行root权限的程序]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>