{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/3358","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3358/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3358/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3358/events","html_url":"https://github.com/crystal-lang/crystal/pull/3358","id":179532799,"number":3358,"title":"Add File.chown and File.chmod","user":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-27T15:47:29Z","updated_at":"2016-09-27T17:10:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/3358","html_url":"https://github.com/crystal-lang/crystal/pull/3358","diff_url":"https://github.com/crystal-lang/crystal/pull/3358.diff","patch_url":"https://github.com/crystal-lang/crystal/pull/3358.patch"},"body":"Implements `File.chown(path, uid, gid)` as well as `File.chmod(path, mode)`.\r\n\r\nI followed the POSIX definitions which made more sense in the context of File, instead of following the Ruby definitions that behave like the UNIX CLI tools: `chown uid, gid, *paths` and `chmod mode, *paths`. These last forms would be better into FileUtils (which is expected to behave like a shell).\r\n\r\nI didn't:\r\n- implement the `File#chown` and `File#chmod` counterparts (targeting a file descriptor, not a path). I'm not sure they are that useful (I never needed `fchown` nor `fchmod`).\r\n- write specs for `chown` because it required special privileges or a particular computer setup. I manually tested it behaved as documented instead."},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/249931452","html_url":"https://github.com/crystal-lang/crystal/pull/3358#issuecomment-249931452","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3358","id":249931452,"user":{"login":"drosehn","id":16140513,"avatar_url":"https://avatars.githubusercontent.com/u/16140513?v=3","gravatar_id":"","url":"https://api.github.com/users/drosehn","html_url":"https://github.com/drosehn","followers_url":"https://api.github.com/users/drosehn/followers","following_url":"https://api.github.com/users/drosehn/following{/other_user}","gists_url":"https://api.github.com/users/drosehn/gists{/gist_id}","starred_url":"https://api.github.com/users/drosehn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drosehn/subscriptions","organizations_url":"https://api.github.com/users/drosehn/orgs","repos_url":"https://api.github.com/users/drosehn/repos","events_url":"https://api.github.com/users/drosehn/events{/privacy}","received_events_url":"https://api.github.com/users/drosehn/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T17:10:17Z","updated_at":"2016-09-27T17:10:17Z","body":"Aside:\r\n`fchown()` and `fchmod()` are important to use to avoid race conditions, especially when a program is running as root.  See, for instance, table 4-1 in the section **Working with Publicly Writable Files Using POSIX Calls** in this Apple documentation:\r\n\r\n[https://developer.apple.com/.../Articles/RaceConditions.html](https://developer.apple.com/library/content/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html)\r\n\r\nor google for:  `chown vs race conditions`\r\nor: `chmod vs race conditions`\r\n\r\nI work with several programs that run as root, so I'm pretty familiar with this detail !"}}
{"actor":{"display_login":"drosehn"}}