{"action":"created","issue":{"url":"https://api.github.com/repos/Yubico/pam-u2f/issues/89","repository_url":"https://api.github.com/repos/Yubico/pam-u2f","labels_url":"https://api.github.com/repos/Yubico/pam-u2f/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/Yubico/pam-u2f/issues/89/comments","events_url":"https://api.github.com/repos/Yubico/pam-u2f/issues/89/events","html_url":"https://github.com/Yubico/pam-u2f/pull/89","id":315976941,"number":89,"title":"Signify that pam-u2f is waiting for a touch","user":{"login":"maximbaz","id":1177900,"avatar_url":"https://avatars2.githubusercontent.com/u/1177900?v=4","gravatar_id":"","url":"https://api.github.com/users/maximbaz","html_url":"https://github.com/maximbaz","followers_url":"https://api.github.com/users/maximbaz/followers","following_url":"https://api.github.com/users/maximbaz/following{/other_user}","gists_url":"https://api.github.com/users/maximbaz/gists{/gist_id}","starred_url":"https://api.github.com/users/maximbaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maximbaz/subscriptions","organizations_url":"https://api.github.com/users/maximbaz/orgs","repos_url":"https://api.github.com/users/maximbaz/repos","events_url":"https://api.github.com/users/maximbaz/events{/privacy}","received_events_url":"https://api.github.com/users/maximbaz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-04-19T17:49:04Z","updated_at":"2018-04-23T11:54:07Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/Yubico/pam-u2f/pulls/89","html_url":"https://github.com/Yubico/pam-u2f/pull/89","diff_url":"https://github.com/Yubico/pam-u2f/pull/89.diff","patch_url":"https://github.com/Yubico/pam-u2f/pull/89.patch"},"body":"Feedback on the code is very welcome!\r\n\r\nThis code has one functional issue where I hope you could give me a hint. I'll explain the scenario:\r\n\r\n1. Open terminal 1, type `sudo -s`, do not touch the device.\r\n    * \"Please touch the device\" appears and stays on the screen as expected.\r\n    * The marker file is created as expected.\r\n2. Open terminal 2, type `sudo -s`, do not touch the device.\r\n    * \"Please touch the device\" appears and stays on the screen as expected.\r\n    * On the terminal 1, the wait for touch is cancelled, I see a password prompt there - as expected.\r\n    * The marker file does not exist - **not expected**.\r\n\r\nThis is a race condition, in two terminals the code has reached the line where I create a marker file, but as soon as the first terminal aborts its waiting, it removes the file without accounting for the fact that there is a second terminal that is also waiting for a touch.\r\n\r\nI tried to play with `flock()` with a hope that if a process locks a file, another process would not be able to remove it... but that doesn't seem to be the case.\r\n\r\nMy other ideas include:\r\n- Store a counter in the lock file.\r\n- Create files with random suffix and put them in `/var/run/user/1000/pam-u2f-lock/` folder, in which case the presence of _at least one file_ indicates that pam-u2f is waiting for a touch.\r\n\r\nYour suggestions?\r\n\r\n**UPDATE:**\r\n\r\nOne more idea: \r\n\r\n- Keep the file exist forever, only \"touch\" it before and after authentication (just open and close) - this will be enough for me when using inotify, but may not be as nice for others.\r\n\r\nAnd one more problem: I am unable to setup a file system event watcher on a file that doesn't exist yet, I have to set it on something that exists... We could have used something like `/var/run/user/1000/pam-u2f/lock` and only create/remove the `lock` file while keeping the folder available, but how can we ensure that the folder exists after installation of pam-u2f?"},"comment":{"url":"https://api.github.com/repos/Yubico/pam-u2f/issues/comments/383548850","html_url":"https://github.com/Yubico/pam-u2f/pull/89#issuecomment-383548850","issue_url":"https://api.github.com/repos/Yubico/pam-u2f/issues/89","id":383548850,"user":{"login":"a-dma","id":711165,"avatar_url":"https://avatars2.githubusercontent.com/u/711165?v=4","gravatar_id":"","url":"https://api.github.com/users/a-dma","html_url":"https://github.com/a-dma","followers_url":"https://api.github.com/users/a-dma/followers","following_url":"https://api.github.com/users/a-dma/following{/other_user}","gists_url":"https://api.github.com/users/a-dma/gists{/gist_id}","starred_url":"https://api.github.com/users/a-dma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-dma/subscriptions","organizations_url":"https://api.github.com/users/a-dma/orgs","repos_url":"https://api.github.com/users/a-dma/repos","events_url":"https://api.github.com/users/a-dma/events{/privacy}","received_events_url":"https://api.github.com/users/a-dma/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T11:54:07Z","updated_at":"2018-04-23T11:54:07Z","author_association":"OWNER","body":"Also the `auth_file` not being free'd is a leak. Not earth-shattering, but it should be cleaned up. I'll fix it once this is merged. Please don't do the same with `lock_file`."}}
{"actor":{"display_login":"a-dma"}}