Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Filesystem::touch() not working with different owners (utime/atime issue)#7752

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
fabpot wants to merge2 commits intosymfony:masterfromfabpot:moved_filesystem_3

Conversation

fabpot
Copy link
Member

This PR was submitted on the symfony/Filesystem read-only repository and moved automatically to the main Symfony repository (closessymfony/filesystem#3).

Case: I have 2 users, www-data and myself. I have a command script that makes a lock file in /var/lock/.../ something. This command is called from a post request by FOS and ran in the background. Whever one of the 2 methods (web/cli manually) is used, the other user won't have permissions to use the Filesystem::touch(). The reason this won't work is the second parameter.

What touch() does:
$touch param: The touch time. If time is not supplied, the current system time is used.
$atime param: If present, the access time of the given filename is set to the value of atime. Otherwise, it is set to the value passed to the time parameter. If neither are present, the current system time is used.

So the current code is basically copying this. However, if the second parameter is null it is still present and will cause the same problem. Note that all files and folders related are set to 0777 and have the owner of www-data. I'm accessing them under my own account here:

Interactive shell

php > var_dump(touch('/var/lock/tripolis/ontw/dev/2140191804.lock', null));
PHP Warning: touch(): Utime failed: Operation not permitted in php shell code on line 1

Warning: touch(): Utime failed: Operation not permitted in php shell code on line 1
bool(false)
php > var_dump(touch('/var/lock/tripolis/ontw/dev/2140191804.lock'));
bool(true)

If I were to pass it without second parameter, let it be time() or null (Filesystem uses time() by default if not present), it DOES work. However, Filesystem::touch() ALWAYS gives a parameter to touch. This parameter is exactly the same value as what the function itself would do in php. Let it be that in my case there is an issue with the atime. I'm not exactly sure how it works but it's not tracked or usable in my case. Because parameter 2 exists, parameter 3 is set. Parameter 3 is not allowed and therefore causes Filesystem::touch() to throw an exception.

fabpot added a commit that referenced this pull requestApr 21, 2013
This PR was submitted for the master branch but it was merged into the 2.1 branch instead (closes#7752).Discussion----------Filesystem::touch() not working with different owners (utime/atime issue)This PR was submitted on the symfony/Filesystem read-only repository and moved automatically to the main Symfony repository (closessymfony/filesystem#3).Case: I have 2 users, www-data and myself. I have a command script that makes a lock file in /var/lock/.../ something. This command is called from a post request by FOS and ran in the background.  Whever one of the 2 methods (web/cli manually) is used, the other user won't have permissions to use the Filesystem::touch(). The reason this won't work is the second parameter.What touch() does:$touch param: The touch time. If time is not supplied, the current system time is used.$atime param: If present, the access time of the given filename is set to the value of atime. Otherwise, it is set to the value passed to the time parameter. If neither are present, the current system time is used.So the current code is basically copying this. However, if the second parameter is null it is still present and will cause the same problem. Note that all files and folders related are set to 0777 and have the owner of www-data. I'm accessing them under my own account here:Interactive shellphp > var_dump(touch('/var/lock/tripolis/ontw/dev/2140191804.lock', null));PHP Warning:  touch(): Utime failed: Operation not permitted in php shell code on line 1Warning: touch(): Utime failed: Operation not permitted in php shell code on line 1bool(false)php > var_dump(touch('/var/lock/tripolis/ontw/dev/2140191804.lock'));bool(true)If I were to pass it without second parameter, let it be time() or null (Filesystem uses time() by default if not present), it DOES work. However, Filesystem::touch() ALWAYS gives a parameter to touch. This parameter is exactly the same value as what the function itself would do in php. Let it be that in my case there is an issue with the atime. I'm not exactly sure how it works but it's not tracked or usable in my case. Because parameter 2 exists, parameter 3 is set. Parameter 3 is not allowed and therefore causes Filesystem::touch() to throw an exception.Commits-------e3a0fe6 Filesystem::touch() not working with different owners (utime/atime issue)
@fabpotfabpot closed thisApr 21, 2013
fabpot added a commit that referenced this pull requestApr 24, 2013
This PR was merged into the master branch.Discussion----------[Filesystem] Made sure Filesystem::dumpFile() overwrites an existing file#7753 introduced a change in behaviour. Before, ConfigCache simply used the ``rename()`` function to save a file. It was replaced by ``Filesystem::dumpFile()`` which internally uses ``Filesystem::rename()``. The later checks if file already exists and throws an exception if it exists.This PR makes sure that ``Filesystem::dumpFile()`` removes the file before creating a new one.Alternatively, we could introduce a third parameter to the ``Filesystem::rename()`` which would allow to overwrite the target file.Before#7752:* [CompilerDebugDumpPass](https://github.com/symfony/symfony/blob/d100ffaf761b46acdb2440c04602378b87b0d610/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php#L23) uses ConfigCache* [ConfigCache](https://github.com/symfony/symfony/blob/d100ffaf761b46acdb2440c04602378b87b0d610/src/Symfony/Component/Config/ConfigCache.php#L103) uses the [rename()](http://uk1.php.net/rename) function (which overwrites a file if it exists)After#7752:* [CompilerDebugDumpPass](https://github.com/symfony/symfony/blob/ad47bc47380188041b7889f40e380ad3766a0110/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php#L23) uses the ``Filesystem::dumpFile()``* [Filesystem::dumpFile()](https://github.com/webfactory/symfony/blob/ad47bc47380188041b7889f40e380ad3766a0110/src/Symfony/Component/Filesystem/Filesystem.php#L458) uses the [Filesystem::rename()](https://github.com/webfactory/symfony/blob/ad47bc47380188041b7889f40e380ad3766a0110/src/Symfony/Component/Filesystem/Filesystem.php#L239) (which throws an exception if file exists)| Q | A| ------------- | ---| Bug fix?| yes| New feature?| no| BC breaks?| no| Deprecations?| no| Tests pass?| yes| Fixed tickets|#7816| License | MIT| Doc PR| ~Commits-------4f4ec76 [Filesystem] Made sure Filesystem::dumpFile() overwrites an existing file.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp