我想在recursilvely中更改AIX中目录的所有权。 我用
<osexec commandbase="su" dir="/bin" mode="osexec">
<args>
<arg line="chown -R ${broker_admin_name}:${broker_admin_name} ${broker_installation_directory}/dcx"/>
</osexec>
这段代码是否正确? 我想在dcx(包括dcx)下更改所有目录和文件的所有权,但我无法通过执行此操作来更改所有权。我也尝试:
<chown owner="${broker_admin_name}">
<fileset dir="${broker_installation_directory}/dcx" includes="**/*">
</fileset>
<dirset dir="${broker_installation_directory}/dcx" includes="**/*">
</dirset>
</chown>
但是只有dcx下的目录才能更改所有权而不是文件。
另外,我可以通过build.xml中的普通shell命令执行此操作吗?
ie chown -R abc:abc xyz
如何直接在build.xml中执行此操作?
答案 0 :(得分:1)
您是否收到“不允许操作”错误消息?
在Ubuntu上,chown任务受操作系统的限制:
$ ant
build:
[chown] chown: changing ownership of `/home/mark/tmp/build/one/test.txt': Operation not permitted
[chown] chown: changing ownership of `/home/mark/tmp/build/three/test.txt': Operation not permitted
[chown] chown: changing ownership of `/home/mark/tmp/build/two/test.txt': Operation not permitted
[chown] chown: changing ownership of `/home/mark/tmp/build': Operation not permitted
[chown] chown: changing ownership of `/home/mark/tmp/build/one': Operation not permitted
[chown] chown: changing ownership of `/home/mark/tmp/build/three': Operation not permitted
[chown] chown: changing ownership of `/home/mark/tmp/build/two': Operation not permitted
[chown] Result: 1
[chown] Applied chown to 3 files and 4 directories.
运行“chown”命令演示了相同的限制
$ chown -R an_other_user build
chown: changing ownership of `build/one/test.txt': Operation not permitted
chown: changing ownership of `build/one': Operation not permitted
chown: changing ownership of `build/two/test.txt': Operation not permitted
chown: changing ownership of `build/two': Operation not permitted
chown: changing ownership of `build': Operation not permitted
最佳解决方案是以root用户身份运行ANT:
$ sudo ant
<project name="demo" default="build">
<target name="init">
<mkdir dir="build/one"/>
<mkdir dir="build/two"/>
<echo file="build/one/test.txt" message="helloworld"/>
<echo file="build/two/test.txt" message="helloworld"/>
</target>
<target name="build" depends="init">
<chown owner="an_other_user" verbose="true">
<fileset dir="build"/>
<dirset dir="build"/>
</chown>
</target>
<target name="clean">
<delete dir="build"/>
</target>
</project>