{"action":"created","issue":{"url":"https://api.github.com/repos/krb5/krb5/issues/425","repository_url":"https://api.github.com/repos/krb5/krb5","labels_url":"https://api.github.com/repos/krb5/krb5/issues/425/labels{/name}","comments_url":"https://api.github.com/repos/krb5/krb5/issues/425/comments","events_url":"https://api.github.com/repos/krb5/krb5/issues/425/events","html_url":"https://github.com/krb5/krb5/pull/425","id":140544216,"number":425,"title":"cc_file: always truncate, instead of relying on O_EXCL to guarantee creation","user":{"login":"danc86","id":398575,"avatar_url":"https://avatars.githubusercontent.com/u/398575?v=3","gravatar_id":"","url":"https://api.github.com/users/danc86","html_url":"https://github.com/danc86","followers_url":"https://api.github.com/users/danc86/followers","following_url":"https://api.github.com/users/danc86/following{/other_user}","gists_url":"https://api.github.com/users/danc86/gists{/gist_id}","starred_url":"https://api.github.com/users/danc86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danc86/subscriptions","organizations_url":"https://api.github.com/users/danc86/orgs","repos_url":"https://api.github.com/users/danc86/repos","events_url":"https://api.github.com/users/danc86/events{/privacy}","received_events_url":"https://api.github.com/users/danc86/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-13T23:47:49Z","updated_at":"2016-03-14T01:10:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/krb5/krb5/pulls/425","html_url":"https://github.com/krb5/krb5/pull/425","diff_url":"https://github.com/krb5/krb5/pull/425.diff","patch_url":"https://github.com/krb5/krb5/pull/425.patch"},"body":"The problem with unlink() followed by open() with O_CREAT|O_EXCL is that\r\nthere is a race window where another process initializing the same\r\nccache filename could have already re-created the file by the time we\r\nreach open(). In that case open() will return EEXIST, which\r\nfcc_initialize() makes no attempt to recover from and just returns\r\nKRB5_FCC_INTERNAL.\r\n\r\nWe can instead drop O_EXCL, meaning that the file might already exist at\r\nthe time of the open() call, but then call ftruncate() on it *after*\r\nacquiring the write lock, ensuring that the file is written safely even\r\nwhen multiple concurrent processes are initializing the ccache."},"comment":{"url":"https://api.github.com/repos/krb5/krb5/issues/comments/196093505","html_url":"https://github.com/krb5/krb5/pull/425#issuecomment-196093505","issue_url":"https://api.github.com/repos/krb5/krb5/issues/425","id":196093505,"user":{"login":"danc86","id":398575,"avatar_url":"https://avatars.githubusercontent.com/u/398575?v=3","gravatar_id":"","url":"https://api.github.com/users/danc86","html_url":"https://github.com/danc86","followers_url":"https://api.github.com/users/danc86/followers","following_url":"https://api.github.com/users/danc86/following{/other_user}","gists_url":"https://api.github.com/users/danc86/gists{/gist_id}","starred_url":"https://api.github.com/users/danc86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danc86/subscriptions","organizations_url":"https://api.github.com/users/danc86/orgs","repos_url":"https://api.github.com/users/danc86/repos","events_url":"https://api.github.com/users/danc86/events{/privacy}","received_events_url":"https://api.github.com/users/danc86/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T01:10:31Z","updated_at":"2016-03-14T01:10:31Z","body":"BTW there is a Fedora bug about the unlink()/open() race window, I meant to link it here but forgot when I was filing the PR:\r\n\r\nhttps://bugzilla.redhat.com/show_bug.cgi?id=1316798"}}