[vim/vim] Sudo vi/vim read-only files can be edited and forcibly saved! How to disable forced savings. (Issue #15126)

25 views
Skip to first unread message

wangchao732

unread,
Jun 29, 2024, 5:24:17 AMJun 29
to vim/vim, Subscribed

Steps to reproduce

sudo vim /etc/sudoers
wq!

Expected behaviour

sudo cat /etc/sudoers|grep prometheus
prometheus ALL=(ALL) NOPASSWD: ALL,!//su,!//bash,!/usr/sbin/visudo
[prometheus@cdh6-slave3 ~]$ cat /etc/sudoers
cat: /etc/sudoers: 权限不够

sudo vim /etc/sudoers save: wq!

Version of Vim

7.4

Environment

CentOS Linux release 7.9.2009 (Core)

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15126@github.com>

Christian Robinson

unread,
Jun 29, 2024, 11:41:06 AMJun 29
to vim...@googlegroups.com, vim/vim, Subscribed
You can’t lock down Vim if you give it super user permissions, which you’re doing here. Use sudoedit instead. 

-- 
Christian J. Robinson

On Jun 29, 2024, at 3:24 AM, wangchao732 <vim-dev...@256bit.org> wrote:


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/15126%40github.com.

Restorer

unread,
Jun 29, 2024, 1:36:44 PMJun 29
to vim/vim, Subscribed

I don't know how much this will help you, but check out the documentation on -R and -M, and -m command line parameters.
Also, don't forget that whoever has more rights may pay less attention to conventions.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15126/2198271392@github.com>

Aliaksei Budavei

unread,
Jun 29, 2024, 1:41:34 PMJun 29
to vim/vim, Subscribed

sudo head -8 /etc/sudoers

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15126/2198272805@github.com>

Restorer

unread,
Jun 29, 2024, 1:53:53 PMJun 29
to vim/vim, Subscribed

And here, however, is the answer.
At the very top it says that you don't need to edit this file manually, you need to use the visudo utility to edit it.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15126/2198276090@github.com>

wangchao732

unread,
Jul 2, 2024, 10:33:25 PMJul 2
to vim/vim, Subscribed

Closed #15126 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/15126/issue_event/13373872293@github.com>

wangchao732

unread,
Jul 2, 2024, 10:34:13 PMJul 2
to vim/vim, Subscribed

And here, however, is the answer. At the very top it says that you don't need to edit this file manually, you need to use the visudo utility to edit it.

Tks, I found a new way to solve the problem, thank you for your help and have fun.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15126/2204936982@github.com>

Reply all
Reply to author
Forward
0 new messages