当我想要vimdiff根文件时,我按照这一建议使用以下别名。
alias sudovimdiff='SUDO_EDITOR=vimdiff sudoedit'然后,我可以使用以下命令。
$ sudovimdiff /root/a /root/b但是,如果我的用户可以写其中一个文件,则命令将失败。
$ sudovimdiff /root/a /tmp/b
sudoedit: /tmp/b: editing files in a writable directory is not permitted是否有办法使用我的用户的环境设置(即sudoedit)来区分一个根文件和一个非根文件?
发布于 2018-07-05 10:38:39
可能与sudo编辑错误消息相关:
编辑:.。不允许在可写目录中编辑文件。
请尝试使用sudo visudo修改sudoers文件,添加一行:
Defaults !sudoedit_checkdir更多的这里。
发布于 2018-01-10 06:13:37
来自man sudo,在描述-e (又名sudoedit)的部分:
To help prevent the editing of unauthorized files, the
following restrictions are enforced unless explicitly allowed
by the security policy:
· Symbolic links may not be edited (version 1.8.15 and
higher).
· Symbolic links along the path to be edited are not
followed when the parent directory is writable by the
invoking user unless that user is root (version 1.8.16
and higher).
· Files located in a directory that is writable by the
invoking user may not be edited unless that user is root
(version 1.8.16 and higher).因此,要么:
sudoedit作为根,这将违背目的或sudoedit处理所有非sudo参数文件名,所以您可以使用一个包装脚本:$ cat foo.sh #!/bin/sh exec vimdiff "$@“"$DIFF_FILE”$ SUDO_EDITOR ="$PWD/foo.sh“DIFF_FILE=$PWD/.zshrc”sudoedit /etc/zsh/zshrc密码“用于编辑sudo编辑: /etc/zsh/zshrchttps://unix.stackexchange.com/questions/415978
复制相似问题