Skip to content
Snippets Groups Projects
  • Isaiah's avatar
    4f9fb9aa
    SystemTools: Fix Touch to avoid requiring file ownership · 4f9fb9aa
    Isaiah authored and Brad King's avatar Brad King committed
    SystemTools::Touch should only require +w file permissions. The previous
    implementation used `stat` to get the current time, and then passed that
    time to one of utimensat/utimes/utime. However, utimes/utimensat only
    permit an arbitrary-time argument to be passed by the file owner.
    
    Therefore, per the docs, we pass NULL for the `times` argument to utimes
    and utimensat, to indicate using the current time. This is permitted for
    any UID with +w on the file.
    
    Remove plain `utime` fallback that is no longer necessary.
    4f9fb9aa
    History
    SystemTools: Fix Touch to avoid requiring file ownership
    Isaiah authored and Brad King's avatar Brad King committed
    SystemTools::Touch should only require +w file permissions. The previous
    implementation used `stat` to get the current time, and then passed that
    time to one of utimensat/utimes/utime. However, utimes/utimensat only
    permit an arbitrary-time argument to be passed by the file owner.
    
    Therefore, per the docs, we pass NULL for the `times` argument to utimes
    and utimensat, to indicate using the current time. This is permitted for
    any UID with +w on the file.
    
    Remove plain `utime` fallback that is no longer necessary.