Skip to content

Bug #42560 Empty directory argument to tempnam yields open_basedir problems #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sj-i opened this issue Dec 19, 2020 · 6 comments
Closed

Comments

@sj-i
Copy link
Owner

sj-i commented Dec 19, 2020

@sj-i
Copy link
Owner Author

sj-i commented Dec 19, 2020

sji@sji-IdeaPad-Flex-5-14ARE05:~/work/php-dev/bugs/42560$ cat 42560.php 
<?php
var_dump(tempnam('', 'test'));
sji@sji-IdeaPad-Flex-5-14ARE05:~/work/php-dev/bugs/42560$ php 42560.php 
string(15) "/tmp/testx7Q771"
sji@sji-IdeaPad-Flex-5-14ARE05:~/work/php-dev/bugs/42560$ php -dopen_basedir='/tmp/' 42560.php 
PHP Warning:  tempnam(): open_basedir restriction in effect. File() is not within the allowed path(s): (/tmp/) in /home/sji/work/php-dev/bugs/42560/42560.php on line 2
bool(false)

確認とれた

@sj-i
Copy link
Owner Author

sj-i commented Dec 20, 2020

ふつうにフォールバックのコードが open_basedir チェックより後に動いているもよう
フォールバック時の open_basedir チェックはすでに行われており、テストを足して open_basedir チェックを移動するだけでよさそう

@sj-i
Copy link
Owner Author

sj-i commented Dec 20, 2020

php/php-src#6526

@sj-i
Copy link
Owner Author

sj-i commented Dec 20, 2020

ファイルアップロード時のコードと共用の部分で、見るとなぜか upload_tmp_dir がセットされてなくてシステムの一時フォルダへのフォールバックが起きた時だけ open_basedir チェックが行われている……
open_basedir の趣旨的には upload_tmp_dir 設定時もチェックしてくれないとダメそうな気する、が、ユーザが自分で設定したディレクトリなら信頼できる筈だという意味で敢えてスキップしてる可能性もゼロではない。ので、PR のコメントで一応言及しておいた。

@sj-i
Copy link
Owner Author

sj-i commented Jan 5, 2021

やっぱ upload_tmp_dir の明示的指定時も効くのは(マイナーバージョンアップでは)びみょいかな、というので、元の挙動を維持できるよう修正した

@sj-i
Copy link
Owner Author

sj-i commented Jan 19, 2021

マージされたのでクローズ

@sj-i sj-i closed this as completed Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant