为什么ubuntu触摸终端无法执行应用程序
我的buntu手机是nexus 4.以下代码未执行。
码
#include #include int main() { printf("Hello world!\n"); return 0; }
编
$ arm-linux-gnueabihf-g++ -static -o hello main.c
- 我将文件复制到
/home/phablet/Downloads
目录 - 打开ubuntu手机终端,
- 修改文件属性(
chmod a+x ./hello
) - 执行
./hello
但是ubuntu手机提示出现以下错误
./hello permission denied
为什么?
我想出了什么。 您无法从主目录运行二进制文件的原因是终端的apparmor配置文件阻止了它。 如果你在尝试运行二进制文件后查看dmesg输出,你应该看到如下内容:
[140792.471956] type=1400 audit(1431182253.050:175): apparmor="DENIED" operation="exec" profile="com.ubuntu.terminal_terminal_0.7.70" name="/home/phablet/apps/git/usr/bin/git" pid=28134 comm="bash" requested_mask="x" denied_mask="x" fsuid=32011 ouid=32011
这只是告诉你apparmor拒绝终端运行你的程序,其中它告诉你终端的apparmor配置文件名称(com.ubuntu.terminal_terminal_0.7.70)。 要允许运行任意二进制文件,我们需要更改该配置文件。
现在通常你会在/etc/apparmor.d下找到apparmor配置文件,但在ubuntu手机上并不总是如此。 似乎特别是点击包(终端是其中之一)做自己的事情并将文件放在不同的地方。 我找到了终端apparmor配置文件的多个位置,正确编辑的位置似乎是:
sudo vi /var/lib/apparmor/profiles/click_com.ubuntu.terminal_terminal_0.7.70
应该有这样的部分:
# autopilot runs things in out of ~/autopilot/fakeenv, so lets allow running # things pretty much everywhere but avoid exec conflicts with the autopilot # include file which has this rule: # owner @{HOMEDIRS}/autopilot/fakeenv/*/.local/share/@{APP_PKGNAME}/** mrwklix, /[^h]** pix, /[^h][^o][^m][^e]** pix, @{HOMEDIRS}/*/autopilot/[^f][^a][^k][^e]*/** pix,
哪个应该已经允许在/ home下执行几乎所有内容,如果我理解它是正确的。 评论似乎意味着相同。 但是,由于逃避我的原因,它不起作用。 因此,要使其工作,您可以删除(或注释掉)整个部分并将其替换为:
/** pix,
这应该允许终端应用程序始终运行所有内容。 然后重启apparmor:
sudo service apparmor restart
你应该好好去。