{"action":"created","comment":{"url":"https://api.github.com/repos/karkhaz/red/pulls/comments/71285917","id":71285917,"diff_hunk":"@@ -459,6 +477,132 @@ static int call_posix_spawnp(pid_t *restrict pid, const char *restrict file,\n }\n #endif\n \n+\n+#define redirect_hardcoded(path, replacement)                         \\\n+  patterns[0] = \"^/usr/bin/\" path \"$\";                                \\\n+  patterns[1] = \"^/bin/\" path \"$\";                                    \\\n+  patterns[2] = \"^/usr/sbin/\" path \"$\";                               \\\n+  for(int i = 0; i < 3; ++i){                                         \\\n+    compiled = pcre_compile(patterns[i], 0, &err_ptr,                 \\\n+                            &err_offset, NULL);                       \\\n+                                                                      \\\n+    if (!compiled) {                                                  \\\n+      fprintf(stderr, \"Could not compile '%s'\\n\", path);              \\\n+      exit(1);                                                        \\\n+    }                                                                 \\\n+                                                                      \\\n+    match = pcre_exec(compiled, NULL, original, strlen(original), 0,  \\\n+                          0, vector, 3);                              \\\n+                                                                      \\\n+    if (match >= 0) {                                                 \\\n+      int fd = mkstemp(error_template);                               \\\n+      if (fd == -1) {                                                 \\\n+        perror(\"tuscan: mkstemp\");                                    \\\n+        exit(1);                                                      \\\n+      }                                                               \\\n+      dprintf(fd, \"hardcoded path\\n%ld\\n%s\\n\",                        \\\n+          (long)getpid(), path);                                      \\\n+      if (close(fd) == -1) {                                          \\\n+        perror(\"tuscan: close\");                                      \\\n+        exit(1);                                                      \\\n+      }                                                               \\\n+      return xstr(replacement);                                       \\\n+    }                                                                 \\\n+  }\n+\n+\n+static const char *transform_path(const char *original){\n+  const char *err_ptr;\n+  int err_offset;\n+  pcre *compiled;\n+  int vector[3] = {0};\n+  int match;\n+  char *patterns[4];\n+  for(int i = 0; i < 4; i++){","path":"libred/red.c","position":105,"original_position":105,"commit_id":"3d7aabf50ac087f4c18101399b8995493230df0e","original_commit_id":"3d7aabf50ac087f4c18101399b8995493230df0e","user":{"login":"petrhosek","id":283696,"avatar_url":"https://avatars.githubusercontent.com/u/283696?v=3","gravatar_id":"","url":"https://api.github.com/users/petrhosek","html_url":"https://github.com/petrhosek","followers_url":"https://api.github.com/users/petrhosek/followers","following_url":"https://api.github.com/users/petrhosek/following{/other_user}","gists_url":"https://api.github.com/users/petrhosek/gists{/gist_id}","starred_url":"https://api.github.com/users/petrhosek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrhosek/subscriptions","organizations_url":"https://api.github.com/users/petrhosek/orgs","repos_url":"https://api.github.com/users/petrhosek/repos","events_url":"https://api.github.com/users/petrhosek/events{/privacy}","received_events_url":"https://api.github.com/users/petrhosek/received_events","type":"User","site_admin":false},"body":"Either use `sizeof(patterns) / sizeof(patterns[0])` for the size of array or define this as macro.","created_at":"2016-07-19T07:41:43Z","updated_at":"2016-07-19T07:41:43Z","html_url":"https://github.com/karkhaz/red/pull/1#discussion_r71285917","pull_request_url":"https://api.github.com/repos/karkhaz/red/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/karkhaz/red/pulls/comments/71285917"},"html":{"href":"https://github.com/karkhaz/red/pull/1#discussion_r71285917"},"pull_request":{"href":"https://api.github.com/repos/karkhaz/red/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/karkhaz/red/pulls/1","id":77832253,"html_url":"https://github.com/karkhaz/red/pull/1","diff_url":"https://github.com/karkhaz/red/pull/1.diff","patch_url":"https://github.com/karkhaz/red/pull/1.patch","issue_url":"https://api.github.com/repos/karkhaz/red/issues/1","number":1,"state":"open","locked":false,"title":"Redirecting invocations with hardcoded paths","user":{"login":"karkhaz","id":2887605,"avatar_url":"https://avatars.githubusercontent.com/u/2887605?v=3","gravatar_id":"","url":"https://api.github.com/users/karkhaz","html_url":"https://github.com/karkhaz","followers_url":"https://api.github.com/users/karkhaz/followers","following_url":"https://api.github.com/users/karkhaz/following{/other_user}","gists_url":"https://api.github.com/users/karkhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/karkhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karkhaz/subscriptions","organizations_url":"https://api.github.com/users/karkhaz/orgs","repos_url":"https://api.github.com/users/karkhaz/repos","events_url":"https://api.github.com/users/karkhaz/events{/privacy}","received_events_url":"https://api.github.com/users/karkhaz/received_events","type":"User","site_admin":false},"body":"red can now be configured to redirect the invocation of certain tools.\r\nBy specifying an alternative path for `tool`, red will redirect any\r\ninvocation of `/usr/bin/tool` or `/usr/sbin/tool` or `/bin/tool` to that\r\npath.\r\n\r\nSpecifying which tools to redirect, and alternate paths, is done at\r\ncompile time for efficiency. Users can pass the flag\r\n-DBEAR_TOOL=/new/path to redirect absolute-path invocations of TOOL to\r\n/new/path. The list of supported tools is in libred/CMakeLists.txt.\r\n\r\nThis commit does NOT deal with the situation where a build script\r\ninvokes a tool without a relative path, but clobbers the PATH variable\r\nso that an invocation of `ar` resolves to `/usr/bin/ar` anyway.\r\n\r\nThe PID of the execing process and the name of the tool whose absolute\r\npath was invoked is written out to a temporary file.","created_at":"2016-07-18T15:54:20Z","updated_at":"2016-07-19T07:41:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3c8443e32a84a34f9b2fe78c12846521185daf18","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/karkhaz/red/pulls/1/commits","review_comments_url":"https://api.github.com/repos/karkhaz/red/pulls/1/comments","review_comment_url":"https://api.github.com/repos/karkhaz/red/pulls/comments{/number}","comments_url":"https://api.github.com/repos/karkhaz/red/issues/1/comments","statuses_url":"https://api.github.com/repos/karkhaz/red/statuses/3d7aabf50ac087f4c18101399b8995493230df0e","head":{"label":"karkhaz:redirect-hardcoded-paths","ref":"redirect-hardcoded-paths","sha":"3d7aabf50ac087f4c18101399b8995493230df0e","user":{"login":"karkhaz","id":2887605,"avatar_url":"https://avatars.githubusercontent.com/u/2887605?v=3","gravatar_id":"","url":"https://api.github.com/users/karkhaz","html_url":"https://github.com/karkhaz","followers_url":"https://api.github.com/users/karkhaz/followers","following_url":"https://api.github.com/users/karkhaz/following{/other_user}","gists_url":"https://api.github.com/users/karkhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/karkhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karkhaz/subscriptions","organizations_url":"https://api.github.com/users/karkhaz/orgs","repos_url":"https://api.github.com/users/karkhaz/repos","events_url":"https://api.github.com/users/karkhaz/events{/privacy}","received_events_url":"https://api.github.com/users/karkhaz/received_events","type":"User","site_admin":false},"repo":{"id":63201635,"name":"red","full_name":"karkhaz/red","owner":{"login":"karkhaz","id":2887605,"avatar_url":"https://avatars.githubusercontent.com/u/2887605?v=3","gravatar_id":"","url":"https://api.github.com/users/karkhaz","html_url":"https://github.com/karkhaz","followers_url":"https://api.github.com/users/karkhaz/followers","following_url":"https://api.github.com/users/karkhaz/following{/other_user}","gists_url":"https://api.github.com/users/karkhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/karkhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karkhaz/subscriptions","organizations_url":"https://api.github.com/users/karkhaz/orgs","repos_url":"https://api.github.com/users/karkhaz/repos","events_url":"https://api.github.com/users/karkhaz/events{/privacy}","received_events_url":"https://api.github.com/users/karkhaz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/karkhaz/red","description":"redirected exception daemon","fork":false,"url":"https://api.github.com/repos/karkhaz/red","forks_url":"https://api.github.com/repos/karkhaz/red/forks","keys_url":"https://api.github.com/repos/karkhaz/red/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karkhaz/red/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karkhaz/red/teams","hooks_url":"https://api.github.com/repos/karkhaz/red/hooks","issue_events_url":"https://api.github.com/repos/karkhaz/red/issues/events{/number}","events_url":"https://api.github.com/repos/karkhaz/red/events","assignees_url":"https://api.github.com/repos/karkhaz/red/assignees{/user}","branches_url":"https://api.github.com/repos/karkhaz/red/branches{/branch}","tags_url":"https://api.github.com/repos/karkhaz/red/tags","blobs_url":"https://api.github.com/repos/karkhaz/red/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karkhaz/red/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karkhaz/red/git/refs{/sha}","trees_url":"https://api.github.com/repos/karkhaz/red/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karkhaz/red/statuses/{sha}","languages_url":"https://api.github.com/repos/karkhaz/red/languages","stargazers_url":"https://api.github.com/repos/karkhaz/red/stargazers","contributors_url":"https://api.github.com/repos/karkhaz/red/contributors","subscribers_url":"https://api.github.com/repos/karkhaz/red/subscribers","subscription_url":"https://api.github.com/repos/karkhaz/red/subscription","commits_url":"https://api.github.com/repos/karkhaz/red/commits{/sha}","git_commits_url":"https://api.github.com/repos/karkhaz/red/git/commits{/sha}","comments_url":"https://api.github.com/repos/karkhaz/red/comments{/number}","issue_comment_url":"https://api.github.com/repos/karkhaz/red/issues/comments{/number}","contents_url":"https://api.github.com/repos/karkhaz/red/contents/{+path}","compare_url":"https://api.github.com/repos/karkhaz/red/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karkhaz/red/merges","archive_url":"https://api.github.com/repos/karkhaz/red/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karkhaz/red/downloads","issues_url":"https://api.github.com/repos/karkhaz/red/issues{/number}","pulls_url":"https://api.github.com/repos/karkhaz/red/pulls{/number}","milestones_url":"https://api.github.com/repos/karkhaz/red/milestones{/number}","notifications_url":"https://api.github.com/repos/karkhaz/red/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karkhaz/red/labels{/name}","releases_url":"https://api.github.com/repos/karkhaz/red/releases{/id}","deployments_url":"https://api.github.com/repos/karkhaz/red/deployments","created_at":"2016-07-13T00:31:28Z","updated_at":"2016-07-13T00:32:22Z","pushed_at":"2016-07-18T15:54:20Z","git_url":"git://github.com/karkhaz/red.git","ssh_url":"git@github.com:karkhaz/red.git","clone_url":"https://github.com/karkhaz/red.git","svn_url":"https://github.com/karkhaz/red","homepage":null,"size":526,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"karkhaz:master","ref":"master","sha":"1da24b6df469db1522d974ded9f1245aa0b0e3ca","user":{"login":"karkhaz","id":2887605,"avatar_url":"https://avatars.githubusercontent.com/u/2887605?v=3","gravatar_id":"","url":"https://api.github.com/users/karkhaz","html_url":"https://github.com/karkhaz","followers_url":"https://api.github.com/users/karkhaz/followers","following_url":"https://api.github.com/users/karkhaz/following{/other_user}","gists_url":"https://api.github.com/users/karkhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/karkhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karkhaz/subscriptions","organizations_url":"https://api.github.com/users/karkhaz/orgs","repos_url":"https://api.github.com/users/karkhaz/repos","events_url":"https://api.github.com/users/karkhaz/events{/privacy}","received_events_url":"https://api.github.com/users/karkhaz/received_events","type":"User","site_admin":false},"repo":{"id":63201635,"name":"red","full_name":"karkhaz/red","owner":{"login":"karkhaz","id":2887605,"avatar_url":"https://avatars.githubusercontent.com/u/2887605?v=3","gravatar_id":"","url":"https://api.github.com/users/karkhaz","html_url":"https://github.com/karkhaz","followers_url":"https://api.github.com/users/karkhaz/followers","following_url":"https://api.github.com/users/karkhaz/following{/other_user}","gists_url":"https://api.github.com/users/karkhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/karkhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karkhaz/subscriptions","organizations_url":"https://api.github.com/users/karkhaz/orgs","repos_url":"https://api.github.com/users/karkhaz/repos","events_url":"https://api.github.com/users/karkhaz/events{/privacy}","received_events_url":"https://api.github.com/users/karkhaz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/karkhaz/red","description":"redirected exception daemon","fork":false,"url":"https://api.github.com/repos/karkhaz/red","forks_url":"https://api.github.com/repos/karkhaz/red/forks","keys_url":"https://api.github.com/repos/karkhaz/red/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karkhaz/red/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karkhaz/red/teams","hooks_url":"https://api.github.com/repos/karkhaz/red/hooks","issue_events_url":"https://api.github.com/repos/karkhaz/red/issues/events{/number}","events_url":"https://api.github.com/repos/karkhaz/red/events","assignees_url":"https://api.github.com/repos/karkhaz/red/assignees{/user}","branches_url":"https://api.github.com/repos/karkhaz/red/branches{/branch}","tags_url":"https://api.github.com/repos/karkhaz/red/tags","blobs_url":"https://api.github.com/repos/karkhaz/red/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karkhaz/red/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karkhaz/red/git/refs{/sha}","trees_url":"https://api.github.com/repos/karkhaz/red/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karkhaz/red/statuses/{sha}","languages_url":"https://api.github.com/repos/karkhaz/red/languages","stargazers_url":"https://api.github.com/repos/karkhaz/red/stargazers","contributors_url":"https://api.github.com/repos/karkhaz/red/contributors","subscribers_url":"https://api.github.com/repos/karkhaz/red/subscribers","subscription_url":"https://api.github.com/repos/karkhaz/red/subscription","commits_url":"https://api.github.com/repos/karkhaz/red/commits{/sha}","git_commits_url":"https://api.github.com/repos/karkhaz/red/git/commits{/sha}","comments_url":"https://api.github.com/repos/karkhaz/red/comments{/number}","issue_comment_url":"https://api.github.com/repos/karkhaz/red/issues/comments{/number}","contents_url":"https://api.github.com/repos/karkhaz/red/contents/{+path}","compare_url":"https://api.github.com/repos/karkhaz/red/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karkhaz/red/merges","archive_url":"https://api.github.com/repos/karkhaz/red/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karkhaz/red/downloads","issues_url":"https://api.github.com/repos/karkhaz/red/issues{/number}","pulls_url":"https://api.github.com/repos/karkhaz/red/pulls{/number}","milestones_url":"https://api.github.com/repos/karkhaz/red/milestones{/number}","notifications_url":"https://api.github.com/repos/karkhaz/red/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karkhaz/red/labels{/name}","releases_url":"https://api.github.com/repos/karkhaz/red/releases{/id}","deployments_url":"https://api.github.com/repos/karkhaz/red/deployments","created_at":"2016-07-13T00:31:28Z","updated_at":"2016-07-13T00:32:22Z","pushed_at":"2016-07-18T15:54:20Z","git_url":"git://github.com/karkhaz/red.git","ssh_url":"git@github.com:karkhaz/red.git","clone_url":"https://github.com/karkhaz/red.git","svn_url":"https://github.com/karkhaz/red","homepage":null,"size":526,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/karkhaz/red/pulls/1"},"html":{"href":"https://github.com/karkhaz/red/pull/1"},"issue":{"href":"https://api.github.com/repos/karkhaz/red/issues/1"},"comments":{"href":"https://api.github.com/repos/karkhaz/red/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/karkhaz/red/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/karkhaz/red/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/karkhaz/red/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/karkhaz/red/statuses/3d7aabf50ac087f4c18101399b8995493230df0e"}}}}
{"actor":{"display_login":"petrhosek"}}