我有 centos 7 webserser,其中所有站点的文件都\www\sitename\htdocs\
属于用户“apache”。
有时我需要git pull
作为 apache 用户,这就是为什么我以 apache 身份编写简单的 sudo 脚本的原因:
[ansible@vm123123 ~]$ cat ~/suwu.sh
#!/bin/sh
sudo setfacl -m apache:x $(dirname "$SSH_AUTH_SOCK")
sudo setfacl -m apache:rwx "$SSH_AUTH_SOCK"
sudo -E su -s /bin/sh apache
[ansible@vm123123 ~]$
它运行良好,我可以以 apache 用户身份登录,更改文件并将我的 SSH 密钥转发到 git 服务器。
但无法mc
以 apache 启动:
sh-4.2$ mc
(mc:36339): GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: Cannot create "/usr/share/httpd/.cache/mc"
(mc:36339): GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: Cannot create "/usr/share/httpd/.local/share/mc"
Сбой запуска:
Cannot create "/usr/share/httpd/.config/mc"
sh-4.2$
这就是我这样运行 mc 的原因:
sh-4.2$ MC_HOME=/tmp/MCHOME mc
这可行,但是有没有办法MC_HOME
在我的脚本或其他地方设置 apache 一次?