{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/comments/112784111","pull_request_review_id":34131046,"id":112784111,"diff_hunk":"@@ -0,0 +1,83 @@\n+summary: Check file XAUTHORITY env variable points to is migrated into the snap environment\n+description: |\n+    The XAUTHORITY environment variable points to a file which is located\n+    in HOME, /run or /tmp depending on the distribution and desktop being\n+    used. If the file ends up in /tmp then it wont be visible inside the\n+    snap environment as each snap gets its private /tmp. To ensure the\n+    file XAUTHORITY points to is always available no matter where it is\n+    stored on the host system we migrate the file and copy it into\n+    /run/$USER/.Xauthority and set the XAUTHORITY environment variable\n+    accordingly.\n+\n+    This test verified the correct behaviour of the implemented logic\n+    inside `snap run`.\n+\n+execute: |\n+    snap install hello-world\n+\n+    ensure_xauth_path() {\n+        export XAUTHORITY=\"$1\"\n+        # Get rid of things to ensure a clean test bed\n+        rm -f /var/snap/hello-world/common/xauth-content /run/user/0/.Xauthority\n+        snap run --shell hello-world <<'EOF'\n+    echo $XAUTHORITY > /var/snap/hello-world/common/xauth-content\n+    exit\n+    EOF\n+        test \"$(cat /var/snap/hello-world/common/xauth-content)\" = \"$2\" || exit 1\n+        unset XAUTHORITY\n+    }\n+\n+    mock_xauthority() {\n+        # Generate valid Xauthority file which `snap run` will accept\n+        rm -f $1; touch $1\n+        for ((c=0; c<=$2; c++))\n+        do\n+            # Family\n+            echo -n -e \\\\x01\\\\x00 >> $1\n+            # Address\n+            echo -n -e \\\\x00\\\\x04\\\\x73\\\\x6e\\\\x61\\\\x70 >> $1\n+            # Number\n+            echo -n -e \\\\x00\\\\x01\\\\xff >> $1\n+            # Name\n+            echo -n -e \\\\x00\\\\x05\\\\x73\\\\x6e\\\\x61\\\\x70\\\\x64 >> $1\n+            # Data\n+            echo -n -e \\\\x00\\\\x01\\\\xff >> $1\n+        done\n+    }\n+\n+    if [ ! -d /run/user/0 ]; then\n+        mkdir -p /run/user/0\n+        chmod 700 /run/user/0\n+    fi\n+\n+    # An invalid Xauthority file should cause the XAUTHORITY\n+    # environment variable to stay untouched.\n+    echo \"foo bar\" > /tmp/invalid-xauthority\n+    ensure_xauth_path /tmp/invalid-xauthority /tmp/invalid-xauthority\n+    test ! -e /run/user/0/.Xauthority\n+\n+    echo > /tmp/invalid-xauthority\n+    ensure_xauth_path /tmp/invalid-xauthority /tmp/invalid-xauthority\n+    test ! -e /run/user/0/.Xauthority\n+\n+    # Generate valid Xauthority file which `snap run` will accept\n+    mock_xauthority /tmp/valid-xauthority 4\n+    chmod 600 /tmp/valid-xauthority","path":"tests/main/xauth-migration/task.yaml","position":65,"original_position":65,"commit_id":"c97fce06b70a54d089def2677c96aa85b4f880aa","original_commit_id":"c97fce06b70a54d089def2677c96aa85b4f880aa","user":{"login":"jdstrand","id":1663079,"avatar_url":"https://avatars3.githubusercontent.com/u/1663079?v=3","gravatar_id":"","url":"https://api.github.com/users/jdstrand","html_url":"https://github.com/jdstrand","followers_url":"https://api.github.com/users/jdstrand/followers","following_url":"https://api.github.com/users/jdstrand/following{/other_user}","gists_url":"https://api.github.com/users/jdstrand/gists{/gist_id}","starred_url":"https://api.github.com/users/jdstrand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdstrand/subscriptions","organizations_url":"https://api.github.com/users/jdstrand/orgs","repos_url":"https://api.github.com/users/jdstrand/repos","events_url":"https://api.github.com/users/jdstrand/events{/privacy}","received_events_url":"https://api.github.com/users/jdstrand/received_events","type":"User","site_admin":false},"body":"One more thing, doing a sha256sum on the xauth in /tmp against the one in XDG_RUNTIME_DIR would be great hear. I anecdotally checked exactly this on s390x (big endien), ppc64el, i386, amd64, armhf, and arm64 (all little endien) to blackbox test it, so it is good, but a spread test would ensure it stays good. :)","created_at":"2017-04-21T21:56:02Z","updated_at":"2017-04-21T21:56:02Z","html_url":"https://github.com/snapcore/snapd/pull/3177#discussion_r112784111","pull_request_url":"https://api.github.com/repos/snapcore/snapd/pulls/3177","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments/112784111"},"html":{"href":"https://github.com/snapcore/snapd/pull/3177#discussion_r112784111"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/3177"}}},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/3177","id":115311780,"html_url":"https://github.com/snapcore/snapd/pull/3177","diff_url":"https://github.com/snapcore/snapd/pull/3177.diff","patch_url":"https://github.com/snapcore/snapd/pull/3177.patch","issue_url":"https://api.github.com/repos/snapcore/snapd/issues/3177","number":3177,"state":"open","locked":false,"title":"cmd/snap: make users Xauthority file available in snap environment","user":{"login":"morphis","id":433752,"avatar_url":"https://avatars1.githubusercontent.com/u/433752?v=3","gravatar_id":"","url":"https://api.github.com/users/morphis","html_url":"https://github.com/morphis","followers_url":"https://api.github.com/users/morphis/followers","following_url":"https://api.github.com/users/morphis/following{/other_user}","gists_url":"https://api.github.com/users/morphis/gists{/gist_id}","starred_url":"https://api.github.com/users/morphis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morphis/subscriptions","organizations_url":"https://api.github.com/users/morphis/orgs","repos_url":"https://api.github.com/users/morphis/repos","events_url":"https://api.github.com/users/morphis/events{/privacy}","received_events_url":"https://api.github.com/users/morphis/received_events","type":"User","site_admin":false},"body":"Not all desktop environments set XAUTHORITY to something which is available\r\ninside the environment we create for snaps. Some place the authority file\r\ninside /tmp which a snap doesn't share with the host system. To workaround\r\nthis we copy the file XAUTHORITY points to when the snap is started into a\r\nsnap specific location in XDG_RUNTIME_DIR of the current user and allow\r\naccess via the x11 interface. This will work across all available desktop\r\nenvironments.","created_at":"2017-04-11T12:46:54Z","updated_at":"2017-04-21T21:56:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a90f25aa370cf207d1f84daf7ed1164ef48863f","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/snapcore/snapd/milestones/9","html_url":"https://github.com/snapcore/snapd/milestone/9","labels_url":"https://api.github.com/repos/snapcore/snapd/milestones/9/labels","id":2439897,"number":9,"title":"2.25","description":"","creator":{"login":"mvo5","id":914418,"avatar_url":"https://avatars0.githubusercontent.com/u/914418?v=3","gravatar_id":"","url":"https://api.github.com/users/mvo5","html_url":"https://github.com/mvo5","followers_url":"https://api.github.com/users/mvo5/followers","following_url":"https://api.github.com/users/mvo5/following{/other_user}","gists_url":"https://api.github.com/users/mvo5/gists{/gist_id}","starred_url":"https://api.github.com/users/mvo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvo5/subscriptions","organizations_url":"https://api.github.com/users/mvo5/orgs","repos_url":"https://api.github.com/users/mvo5/repos","events_url":"https://api.github.com/users/mvo5/events{/privacy}","received_events_url":"https://api.github.com/users/mvo5/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":7,"state":"open","created_at":"2017-04-06T15:23:14Z","updated_at":"2017-04-21T06:59:51Z","due_on":"2017-04-25T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/snapcore/snapd/pulls/3177/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapd/pulls/3177/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapd/issues/3177/comments","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/c97fce06b70a54d089def2677c96aa85b4f880aa","head":{"label":"morphis:f/copy-xauthority","ref":"f/copy-xauthority","sha":"c97fce06b70a54d089def2677c96aa85b4f880aa","user":{"login":"morphis","id":433752,"avatar_url":"https://avatars1.githubusercontent.com/u/433752?v=3","gravatar_id":"","url":"https://api.github.com/users/morphis","html_url":"https://github.com/morphis","followers_url":"https://api.github.com/users/morphis/followers","following_url":"https://api.github.com/users/morphis/following{/other_user}","gists_url":"https://api.github.com/users/morphis/gists{/gist_id}","starred_url":"https://api.github.com/users/morphis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morphis/subscriptions","organizations_url":"https://api.github.com/users/morphis/orgs","repos_url":"https://api.github.com/users/morphis/repos","events_url":"https://api.github.com/users/morphis/events{/privacy}","received_events_url":"https://api.github.com/users/morphis/received_events","type":"User","site_admin":false},"repo":{"id":56325721,"name":"snapd","full_name":"morphis/snapd","owner":{"login":"morphis","id":433752,"avatar_url":"https://avatars1.githubusercontent.com/u/433752?v=3","gravatar_id":"","url":"https://api.github.com/users/morphis","html_url":"https://github.com/morphis","followers_url":"https://api.github.com/users/morphis/followers","following_url":"https://api.github.com/users/morphis/following{/other_user}","gists_url":"https://api.github.com/users/morphis/gists{/gist_id}","starred_url":"https://api.github.com/users/morphis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morphis/subscriptions","organizations_url":"https://api.github.com/users/morphis/orgs","repos_url":"https://api.github.com/users/morphis/repos","events_url":"https://api.github.com/users/morphis/events{/privacy}","received_events_url":"https://api.github.com/users/morphis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/morphis/snapd","description":"Snappy is the software at the heart of Ubuntu Core.","fork":true,"url":"https://api.github.com/repos/morphis/snapd","forks_url":"https://api.github.com/repos/morphis/snapd/forks","keys_url":"https://api.github.com/repos/morphis/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/morphis/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/morphis/snapd/teams","hooks_url":"https://api.github.com/repos/morphis/snapd/hooks","issue_events_url":"https://api.github.com/repos/morphis/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/morphis/snapd/events","assignees_url":"https://api.github.com/repos/morphis/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/morphis/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/morphis/snapd/tags","blobs_url":"https://api.github.com/repos/morphis/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/morphis/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/morphis/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/morphis/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/morphis/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/morphis/snapd/languages","stargazers_url":"https://api.github.com/repos/morphis/snapd/stargazers","contributors_url":"https://api.github.com/repos/morphis/snapd/contributors","subscribers_url":"https://api.github.com/repos/morphis/snapd/subscribers","subscription_url":"https://api.github.com/repos/morphis/snapd/subscription","commits_url":"https://api.github.com/repos/morphis/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/morphis/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/morphis/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/morphis/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/morphis/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/morphis/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/morphis/snapd/merges","archive_url":"https://api.github.com/repos/morphis/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/morphis/snapd/downloads","issues_url":"https://api.github.com/repos/morphis/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/morphis/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/morphis/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/morphis/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/morphis/snapd/labels{/name}","releases_url":"https://api.github.com/repos/morphis/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/morphis/snapd/deployments","created_at":"2016-04-15T14:21:22Z","updated_at":"2016-07-19T15:18:36Z","pushed_at":"2017-04-21T10:39:26Z","git_url":"git://github.com/morphis/snapd.git","ssh_url":"git@github.com:morphis/snapd.git","clone_url":"https://github.com/morphis/snapd.git","svn_url":"https://github.com/morphis/snapd","homepage":null,"size":45991,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"fde02a538b9ed2caf3739fb4373de474af7fd646","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars2.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":44672744,"name":"snapd","full_name":"snapcore/snapd","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars2.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snapd","description":"The snapd and snap tools enable systems to work with .snap files.","fork":false,"url":"https://api.github.com/repos/snapcore/snapd","forks_url":"https://api.github.com/repos/snapcore/snapd/forks","keys_url":"https://api.github.com/repos/snapcore/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapd/teams","hooks_url":"https://api.github.com/repos/snapcore/snapd/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapd/events","assignees_url":"https://api.github.com/repos/snapcore/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapd/tags","blobs_url":"https://api.github.com/repos/snapcore/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapd/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapd/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapd/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapd/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapd/subscription","commits_url":"https://api.github.com/repos/snapcore/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapd/merges","archive_url":"https://api.github.com/repos/snapcore/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapd/downloads","issues_url":"https://api.github.com/repos/snapcore/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapd/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapd/deployments","created_at":"2015-10-21T11:51:46Z","updated_at":"2017-04-21T15:06:19Z","pushed_at":"2017-04-21T19:37:30Z","git_url":"git://github.com/snapcore/snapd.git","ssh_url":"git@github.com:snapcore/snapd.git","clone_url":"https://github.com/snapcore/snapd.git","svn_url":"https://github.com/snapcore/snapd","homepage":"","size":46071,"stargazers_count":696,"watchers_count":696,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":170,"mirror_url":null,"open_issues_count":41,"forks":170,"open_issues":41,"watchers":696,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/3177"},"html":{"href":"https://github.com/snapcore/snapd/pull/3177"},"issue":{"href":"https://api.github.com/repos/snapcore/snapd/issues/3177"},"comments":{"href":"https://api.github.com/repos/snapcore/snapd/issues/3177/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/3177/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/3177/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapd/statuses/c97fce06b70a54d089def2677c96aa85b4f880aa"}}}}
{"actor":{"display_login":"jdstrand"}}