¿Cómo puedo saber cuál es mi entorno de escritorio o administrador de ventanas desde un comando de línea de comandos?

Поведение, которое вы показываете, похоже, зависит от fs.protected_regularпараметра ядра Linux, введенного вместе с fs.protected_fifosэтой фиксацией (, объединенной в версии 4.19, я полагаю ), с целью исправить уязвимости безопасности.

Выдержка из сообщения фиксации (выделение мое):

namei: allow restricted O_CREAT of FIFOs and regular files

Disallows open of FIFOs or regular files not owned by the user in world writable sticky directories, unless the owner is the same as that of the directory or the file is opened without the O_CREAT flag. The purpose is to make data spoofing attacks harder....

В том же сообщении фиксации также содержится список связанных общих уязвимостей и рисков (CVE ).

Таким образом, при условии, что userXявляется rootили иным образом предоставлен доступ на запись к /tmp/file, и что /tmpявляется доступным для записи каталогом с установленным липким битом, они могут открыть fileтолько для записи. если:

  • userXявляется владельцем file; или
  • и file, и каталог /tmpпринадлежат одному и тому же пользователю.

В вашем тесте rootимеет права на запись на /tmp/test.txt,но не является владельцем файла, и /tmp/test.txtи /tmpне имеют одного и того же владельца (соответственно maxиroot).

Проблема совершенно не связана со способом крепления /tmp.

Соответствующая документация находится в Documentation/sysctl/fs.txt:

protected_fifos:

The intent of this protection is to avoid unintentional writes to an attacker-controlled FIFO, where a program expected to create a regular file.

...

protected_regular:

This protection is similar to protected_fifos, but it avoids writes to an attacker-controlled regular file, where a program expected to create one.

When set to "0", writing to regular files is unrestricted.

When set to "1" don't allow O_CREAT open on regular files that we don't own in world writable sticky directories, unless they are owned by the owner of the directory.

When set to "2" it also applies to group writable sticky directories.

То есть описанную выше защиту можно отключить командой:

sysctl fs.protected_regular=0

Небольшое тестирование в подтверждение нашей гипотезы:

$ su - root
# sysctl fs.protected_regular
fs.protected_regular = 1
# cd /
# mkdir test
# chmod 1777 test
# su - otheruser
$ echo hello >/test/somefile
$ exit
logout
# cat /test/somefile
hello
# ls -lah test/somefile
-rw-r--r-- 1 otheruser otheruser 6 Feb 26 17:21 test/somefile
# echo root >>test/somefile
-bash: test/somefile: Permission denied
# sysctl fs.protected_regular=0
fs.protected_regular = 0
# echo root >>test/somefile
# cat /test/somefile
hello
root
# sysctl fs.protected_regular=1
fs.protected_regular = 1
# echo root >>test/somefile
-bash: test/somefile: Permission denied
# chmod 0777 /test/
# echo root >>test/somefile
# cat test/somefile 
hello
root
root

В отличие от fs.protected_hardlinksи fs.protected_symlinks, fs.protected_regularи fs.protected_fifosне включены по умолчанию в коде ядра.
Включение их является изменением, несовместимым с предыдущими версиями (, как показано в примере, который вы предоставили в , этот комментарий указывает ), и, насколько я могу судить, systemdсделал это в версии 241 с . ] этот недавний коммит .

Кредиты :благодаря JdeBP за указание в правильном направлении с комментарием к вопросу.

-1
15.09.2021, 12:53
1 ответ

по крайней мере, в системе на основе Debian вы можете просто запустить
echo $XDG_CURRENT_DESKTOP
чтобы определить окружение рабочего стола. Для диспетчера окон запустите
wmctrl -m
(sudo apt -получить установку wmctrl)

1
23.09.2021, 16:08

Теги

Похожие вопросы