質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Q&A

解決済

1回答

1782閲覧

/tmp 直下ファイルの Permission 無視挙動の解決

Bivi

総合スコア1

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

1グッド

0クリップ

投稿2022/01/06 03:54

前提・実現したいこと

/tmp/hogehoge というファイルを
Permission 777, Sticky Bit無, 所有ユーザ na, 所有グループ na
で作成、その後、
root ユーザでそのファイルに対し追記したいです。

$ ls -l /tmp/hogehoge -rwxrwxrwx 1 na na 0 1月 6 12:48 /tmp/hogehoge

発生している問題・エラーメッセージ

# whoami root # echo hoge >> /tmp/hogehoge bash: /tmp/hogehoge: 許可がありません # echo hoge | tee -a /tmp/hogehoge tee: /tmp/hogehoge: 許可がありません hoge # echo hoge | LANG=C tee -a /tmp/hogehoge tee: /tmp/hogehoge: Permission denied hoge # ls -l /tmp/hogehoge -rwxrwxrwx 1 na na 0 1月 6 12:48 /tmp/hogehoge # ls -ld /tmp/ drwxrwxrwt 20 root root 212992 1月 6 12:52 /tmp/

補足情報(FW/ツールのバージョンなど)

本事象発生環境

# cat /etc/os-release NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.3 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal # uname -a Linux XXX 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

なお、Ubuntu16.04 (Linux 4.4.0-66-generic) では実証は発生しませんでした。

melian👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

以下の変更が原因の様です。

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. This protection can be turned on and off separately for FIFOs and regular files via sysctl, just like the symlinks/hardlinks protection.

パッチの内容を見ますと、以下を実行することで Ubuntu16.04 の挙動と同じになる様です。

bash

1$ sudo sysctl fs.protected_regular=0

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.

投稿2022/01/06 04:15

melian

総合スコア19865

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Bivi

2022/01/06 04:19

ご回答ありがとうございます! 検索でも原因がわからず困っておりましたが、変更チケット・解決策までご提供いただき、大変助かりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問