ninja: Running install target with root privilages breaks subsequent invocations
A “common pattern” for a library is to run make and then sudo make install. This works nicely with CMake. However, when using Ninja as the underlying build system, sudo ninja install changes the owner of .ninja_log to root. Subsequent invocations of ninja than fail with
ninja: error: opening build log: Permission denied
Just deleting the file afterwards seems fine, but this is not the way to go, right? When I raised this issue on CMake, one suggestion was for Ninja to try and write the log file with the original owner if it is run as root. What do you think?
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 8
- Comments: 18 (5 by maintainers)
Commits related to this issue
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
- build_log: make sure to carry the old uid and gid see #1302 as a normal workflow you do things like "ninja all && sudo ninja install" for the case that the install target executes a build target then... — committed to marcelhollerbach/ninja by marcelhollerbach 7 years ago
I faced the same issue while building the sources. The issue is some folders are built with root permission and some other folder with other username permission. To get rid of this, change the complete permission of the source code to a single user. sudo chown -R username:username <android_source_code>
Hello,
How about checking if there is already a log file, if there is, ensure the permissions stay the same, if not, just rename it (and take the uid and gid of the running user)?
I created PR https://github.com/ninja-build/ninja/pull/1362 to see how it looks in code.