GitHub PullRequestReviewCommentEvent at 2014-06-25 15:10:06
Repository: C
Actor: rmascarenhas
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/bernardoamc/C/pulls/comments/14191557","id":14191557,"diff_hunk":"@@ -0,0 +1,239 @@\n+/* display_acl.c\n+ *\n+ * Displays the permissions from the ACL entry that corresponds to a particular\n+ * user or group. If the ACL entry that corresponds to the given user or group\n+ * falls into the group class, then the program should additionally display the\n+ * permissions that would apply after the ACL entry has been modified by the ACL\n+ * mask entry.\n+ *\n+ * Usage: ./display_acl <u,g> <name, id> <file>\n+**/\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <pwd.h>\n+#include <grp.h>\n+#include <errno.h>\n+#include <string.h>\n+#include <sys/acl.h>\n+#include <acl/libacl.h>\n+\n+typedef enum { USER, GROUP } chtype;\n+\n+void helpAndLeave(const char *progname, int status);\n+void pexit(const char *fCall);\n+uid_t userIdFromName(const char *name);\n+gid_t groupIdFromName(const char *name);\n+void printPermissions(acl_entry_t, acl_entry_t, int);\n+\n+int main(int argc, char *argv[])\n+{\n+  acl_t acl;\n+  acl_entry_t entry = NULL, selectedEntry = NULL, maskEntry = NULL, otherEntry = NULL;\n+  acl_tag_t tag_type, selectedTagType;\n+  int type, entryId, moreEntries;\n+  unsigned int id, entryOwnerId;\n+\n+  if (argc != 4) {\n+    helpAndLeave(argv[0], EXIT_FAILURE);\n+  }\n+\n+  switch (*argv[1]) {\n+    case 'u': type = USER;  break;\n+    case 'g': type = GROUP; break;\n+    default:  helpAndLeave(argv[0], EXIT_FAILURE);\n+  }\n+\n+  if (type == USER) {\n+    id = userIdFromName(argv[2]);\n+  } else {\n+    id = groupIdFromName(argv[2]);\n+  }\n+\n+  if (id == -1) {\n+    fprintf(stderr, \"Invalid user or group identifier: %s\", argv[2]);\n+    exit(EXIT_FAILURE);\n+  }\n+\n+  acl = acl_get_file(argv[3], ACL_TYPE_ACCESS);\n+\n+  if (acl == NULL) {\n+    pexit(\"acl_get_file\");\n+  }\n+\n+  for (entryId = ACL_FIRST_ENTRY; ; entryId = ACL_NEXT_ENTRY) {\n+    moreEntries = acl_get_entry(acl, entryId, &entry);\n+\n+    if (moreEntries == -1) {\n+      pexit(\"acl_get_entry\");\n+    } else if (moreEntries == 0) {\n+      break;\n+    }\n+\n+    if (acl_get_tag_type(entry, &tag_type) == -1) {\n+      pexit(\"acl_get_tag_type\");\n+    }\n+\n+    if (tag_type == ACL_MASK) {\n+      maskEntry = entry;\n+    } else if (tag_type == ACL_OTHER) {\n+      otherEntry = entry;\n+    } else {\n+      if (tag_type == ACL_USER_OBJ || tag_type == ACL_USER) {\n+        entryOwnerId = userIdFromName(acl_get_qualifier(entry));\n+      } else {\n+        entryOwnerId = groupIdFromName(acl_get_qualifier(entry));","path":"c17/display_acl.c","position":85,"original_position":85,"commit_id":"52c5cf377b911979c2888e962abb51e7a428df66","original_commit_id":"52c5cf377b911979c2888e962abb51e7a428df66","user":{"login":"rmascarenhas","id":613784,"avatar_url":"https://avatars.githubusercontent.com/u/613784?","gravatar_id":"8cb8eb3d2467ad15bb6b4d6eeac21cf3","url":"https://api.github.com/users/rmascarenhas","html_url":"https://github.com/rmascarenhas","followers_url":"https://api.github.com/users/rmascarenhas/followers","following_url":"https://api.github.com/users/rmascarenhas/following{/other_user}","gists_url":"https://api.github.com/users/rmascarenhas/gists{/gist_id}","starred_url":"https://api.github.com/users/rmascarenhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmascarenhas/subscriptions","organizations_url":"https://api.github.com/users/rmascarenhas/orgs","repos_url":"https://api.github.com/users/rmascarenhas/repos","events_url":"https://api.github.com/users/rmascarenhas/events{/privacy}","received_events_url":"https://api.github.com/users/rmascarenhas/received_events","type":"User","site_admin":false},"body":"Have you tested these `acl_get_qualifier` calls? `ACL_USER` and `ACL_GROUP` entries do not have qualifiers set (since the id is already on the file's i-node) and the call will probably error out.","created_at":"2014-06-25T15:10:06Z","updated_at":"2014-06-25T15:10:06Z","html_url":"https://github.com/bernardoamc/C/pull/10#discussion_r14191557","pull_request_url":"https://api.github.com/repos/bernardoamc/C/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/bernardoamc/C/pulls/comments/14191557"},"html":{"href":"https://github.com/bernardoamc/C/pull/10#discussion_r14191557"},"pull_request":{"href":"https://api.github.com/repos/bernardoamc/C/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/bernardoamc/C/pulls/10","id":17262796,"html_url":"https://github.com/bernardoamc/C/pull/10","diff_url":"https://github.com/bernardoamc/C/pull/10.diff","patch_url":"https://github.com/bernardoamc/C/pull/10.patch","issue_url":"https://api.github.com/repos/bernardoamc/C/issues/10","number":10,"state":"open","title":"Add chapter 17 exercises","user":{"login":"bernardoamc","id":428984,"avatar_url":"https://avatars.githubusercontent.com/u/428984?","gravatar_id":"a7859f6e07d3b2bc6ba92acb6617ee2b","url":"https://api.github.com/users/bernardoamc","html_url":"https://github.com/bernardoamc","followers_url":"https://api.github.com/users/bernardoamc/followers","following_url":"https://api.github.com/users/bernardoamc/following{/other_user}","gists_url":"https://api.github.com/users/bernardoamc/gists{/gist_id}","starred_url":"https://api.github.com/users/bernardoamc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernardoamc/subscriptions","organizations_url":"https://api.github.com/users/bernardoamc/orgs","repos_url":"https://api.github.com/users/bernardoamc/repos","events_url":"https://api.github.com/users/bernardoamc/events{/privacy}","received_events_url":"https://api.github.com/users/bernardoamc/received_events","type":"User","site_admin":false},"body":"@rmascarenhas It works, without any style. :smile: ","created_at":"2014-06-17T21:30:27Z","updated_at":"2014-06-25T15:10:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ea05de91a7dd8ef51df1683606a13b88289d399","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bernardoamc/C/pulls/10/commits","review_comments_url":"https://api.github.com/repos/bernardoamc/C/pulls/10/comments","review_comment_url":"https://api.github.com/repos/bernardoamc/C/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bernardoamc/C/issues/10/comments","statuses_url":"https://api.github.com/repos/bernardoamc/C/statuses/52c5cf377b911979c2888e962abb51e7a428df66","head":{"label":"bernardoamc:c17","ref":"c17","sha":"52c5cf377b911979c2888e962abb51e7a428df66","user":{"login":"bernardoamc","id":428984,"avatar_url":"https://avatars.githubusercontent.com/u/428984?","gravatar_id":"a7859f6e07d3b2bc6ba92acb6617ee2b","url":"https://api.github.com/users/bernardoamc","html_url":"https://github.com/bernardoamc","followers_url":"https://api.github.com/users/bernardoamc/followers","following_url":"https://api.github.com/users/bernardoamc/following{/other_user}","gists_url":"https://api.github.com/users/bernardoamc/gists{/gist_id}","starred_url":"https://api.github.com/users/bernardoamc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernardoamc/subscriptions","organizations_url":"https://api.github.com/users/bernardoamc/orgs","repos_url":"https://api.github.com/users/bernardoamc/repos","events_url":"https://api.github.com/users/bernardoamc/events{/privacy}","received_events_url":"https://api.github.com/users/bernardoamc/received_events","type":"User","site_admin":false},"repo":{"id":17547296,"name":"C","full_name":"bernardoamc/C","owner":{"login":"bernardoamc","id":428984,"avatar_url":"https://avatars.githubusercontent.com/u/428984?","gravatar_id":"a7859f6e07d3b2bc6ba92acb6617ee2b","url":"https://api.github.com/users/bernardoamc","html_url":"https://github.com/bernardoamc","followers_url":"https://api.github.com/users/bernardoamc/followers","following_url":"https://api.github.com/users/bernardoamc/following{/other_user}","gists_url":"https://api.github.com/users/bernardoamc/gists{/gist_id}","starred_url":"https://api.github.com/users/bernardoamc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernardoamc/subscriptions","organizations_url":"https://api.github.com/users/bernardoamc/orgs","repos_url":"https://api.github.com/users/bernardoamc/repos","events_url":"https://api.github.com/users/bernardoamc/events{/privacy}","received_events_url":"https://api.github.com/users/bernardoamc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bernardoamc/C","description":"C files","fork":false,"url":"https://api.github.com/repos/bernardoamc/C","forks_url":"https://api.github.com/repos/bernardoamc/C/forks","keys_url":"https://api.github.com/repos/bernardoamc/C/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bernardoamc/C/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bernardoamc/C/teams","hooks_url":"https://api.github.com/repos/bernardoamc/C/hooks","issue_events_url":"https://api.github.com/repos/bernardoamc/C/issues/events{/number}","events_url":"https://api.github.com/repos/bernardoamc/C/events","assignees_url":"https://api.github.com/repos/bernardoamc/C/assignees{/user}","branches_url":"https://api.github.com/repos/bernardoamc/C/branches{/branch}","tags_url":"https://api.github.com/repos/bernardoamc/C/tags","blobs_url":"https://api.github.com/repos/bernardoamc/C/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bernardoamc/C/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bernardoamc/C/git/refs{/sha}","trees_url":"https://api.github.com/repos/bernardoamc/C/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bernardoamc/C/statuses/{sha}","languages_url":"https://api.github.com/repos/bernardoamc/C/languages","stargazers_url":"https://api.github.com/repos/bernardoamc/C/stargazers","contributors_url":"https://api.github.com/repos/bernardoamc/C/contributors","subscribers_url":"https://api.github.com/repos/bernardoamc/C/subscribers","subscription_url":"https://api.github.com/repos/bernardoamc/C/subscription","commits_url":"https://api.github.com/repos/bernardoamc/C/commits{/sha}","git_commits_url":"https://api.github.com/repos/bernardoamc/C/git/commits{/sha}","comments_url":"https://api.github.com/repos/bernardoamc/C/comments{/number}","issue_comment_url":"https://api.github.com/repos/bernardoamc/C/issues/comments/{number}","contents_url":"https://api.github.com/repos/bernardoamc/C/contents/{+path}","compare_url":"https://api.github.com/repos/bernardoamc/C/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bernardoamc/C/merges","archive_url":"https://api.github.com/repos/bernardoamc/C/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bernardoamc/C/downloads","issues_url":"https://api.github.com/repos/bernardoamc/C/issues{/number}","pulls_url":"https://api.github.com/repos/bernardoamc/C/pulls{/number}","milestones_url":"https://api.github.com/repos/bernardoamc/C/milestones{/number}","notifications_url":"https://api.github.com/repos/bernardoamc/C/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bernardoamc/C/labels{/name}","releases_url":"https://api.github.com/repos/bernardoamc/C/releases{/id}","created_at":"2014-03-08T17:45:16Z","updated_at":"2014-06-17T21:30:27Z","pushed_at":"2014-06-17T21:29:25Z","git_url":"git://github.com/bernardoamc/C.git","ssh_url":"git@github.com:bernardoamc/C.git","clone_url":"https://github.com/bernardoamc/C.git","svn_url":"https://github.com/bernardoamc/C","homepage":null,"size":752,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"bernardoamc:master","ref":"master","sha":"73bea5973a18e9ca700c77112182496cef6a1d8a","user":{"login":"bernardoamc","id":428984,"avatar_url":"https://avatars.githubusercontent.com/u/428984?","gravatar_id":"a7859f6e07d3b2bc6ba92acb6617ee2b","url":"https://api.github.com/users/bernardoamc","html_url":"https://github.com/bernardoamc","followers_url":"https://api.github.com/users/bernardoamc/followers","following_url":"https://api.github.com/users/bernardoamc/following{/other_user}","gists_url":"https://api.github.com/users/bernardoamc/gists{/gist_id}","starred_url":"https://api.github.com/users/bernardoamc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernardoamc/subscriptions","organizations_url":"https://api.github.com/users/bernardoamc/orgs","repos_url":"https://api.github.com/users/bernardoamc/repos","events_url":"https://api.github.com/users/bernardoamc/events{/privacy}","received_events_url":"https://api.github.com/users/bernardoamc/received_events","type":"User","site_admin":false},"repo":{"id":17547296,"name":"C","full_name":"bernardoamc/C","owner":{"login":"bernardoamc","id":428984,"avatar_url":"https://avatars.githubusercontent.com/u/428984?","gravatar_id":"a7859f6e07d3b2bc6ba92acb6617ee2b","url":"https://api.github.com/users/bernardoamc","html_url":"https://github.com/bernardoamc","followers_url":"https://api.github.com/users/bernardoamc/followers","following_url":"https://api.github.com/users/bernardoamc/following{/other_user}","gists_url":"https://api.github.com/users/bernardoamc/gists{/gist_id}","starred_url":"https://api.github.com/users/bernardoamc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bernardoamc/subscriptions","organizations_url":"https://api.github.com/users/bernardoamc/orgs","repos_url":"https://api.github.com/users/bernardoamc/repos","events_url":"https://api.github.com/users/bernardoamc/events{/privacy}","received_events_url":"https://api.github.com/users/bernardoamc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bernardoamc/C","description":"C files","fork":false,"url":"https://api.github.com/repos/bernardoamc/C","forks_url":"https://api.github.com/repos/bernardoamc/C/forks","keys_url":"https://api.github.com/repos/bernardoamc/C/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bernardoamc/C/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bernardoamc/C/teams","hooks_url":"https://api.github.com/repos/bernardoamc/C/hooks","issue_events_url":"https://api.github.com/repos/bernardoamc/C/issues/events{/number}","events_url":"https://api.github.com/repos/bernardoamc/C/events","assignees_url":"https://api.github.com/repos/bernardoamc/C/assignees{/user}","branches_url":"https://api.github.com/repos/bernardoamc/C/branches{/branch}","tags_url":"https://api.github.com/repos/bernardoamc/C/tags","blobs_url":"https://api.github.com/repos/bernardoamc/C/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bernardoamc/C/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bernardoamc/C/git/refs{/sha}","trees_url":"https://api.github.com/repos/bernardoamc/C/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bernardoamc/C/statuses/{sha}","languages_url":"https://api.github.com/repos/bernardoamc/C/languages","stargazers_url":"https://api.github.com/repos/bernardoamc/C/stargazers","contributors_url":"https://api.github.com/repos/bernardoamc/C/contributors","subscribers_url":"https://api.github.com/repos/bernardoamc/C/subscribers","subscription_url":"https://api.github.com/repos/bernardoamc/C/subscription","commits_url":"https://api.github.com/repos/bernardoamc/C/commits{/sha}","git_commits_url":"https://api.github.com/repos/bernardoamc/C/git/commits{/sha}","comments_url":"https://api.github.com/repos/bernardoamc/C/comments{/number}","issue_comment_url":"https://api.github.com/repos/bernardoamc/C/issues/comments/{number}","contents_url":"https://api.github.com/repos/bernardoamc/C/contents/{+path}","compare_url":"https://api.github.com/repos/bernardoamc/C/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bernardoamc/C/merges","archive_url":"https://api.github.com/repos/bernardoamc/C/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bernardoamc/C/downloads","issues_url":"https://api.github.com/repos/bernardoamc/C/issues{/number}","pulls_url":"https://api.github.com/repos/bernardoamc/C/pulls{/number}","milestones_url":"https://api.github.com/repos/bernardoamc/C/milestones{/number}","notifications_url":"https://api.github.com/repos/bernardoamc/C/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bernardoamc/C/labels{/name}","releases_url":"https://api.github.com/repos/bernardoamc/C/releases{/id}","created_at":"2014-03-08T17:45:16Z","updated_at":"2014-06-17T21:30:27Z","pushed_at":"2014-06-17T21:29:25Z","git_url":"git://github.com/bernardoamc/C.git","ssh_url":"git@github.com:bernardoamc/C.git","clone_url":"https://github.com/bernardoamc/C.git","svn_url":"https://github.com/bernardoamc/C","homepage":null,"size":752,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bernardoamc/C/pulls/10"},"html":{"href":"https://github.com/bernardoamc/C/pull/10"},"issue":{"href":"https://api.github.com/repos/bernardoamc/C/issues/10"},"comments":{"href":"https://api.github.com/repos/bernardoamc/C/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/bernardoamc/C/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/bernardoamc/C/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bernardoamc/C/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/bernardoamc/C/statuses/52c5cf377b911979c2888e962abb51e7a428df66"}}}}