{"action":"created","comment":{"url":"https://api.github.com/repos/SSSD/sssd/pulls/comments/78175619","id":78175619,"diff_hunk":"@@ -372,14 +372,43 @@ int local_db_delete(TALLOC_CTX *mem_ctx,\n                     struct local_context *lctx,\n                     const char *req_path)\n {\n+    TALLOC_CTX *tmp_ctx;\n     struct ldb_dn *dn;\n+    static const char *attrs[] = { NULL };\n+    struct ldb_result *res;\n     int ret;\n \n+    tmp_ctx = talloc_new(mem_ctx);\n+    if (!tmp_ctx) return ENOMEM;\n+\n     ret = local_db_dn(mem_ctx, lctx->ldb, req_path, &dn);\n-    if (ret != EOK) return ret;\n+    if (ret != EOK) goto done;\n+\n+    ret = ldb_search(lctx->ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE,\n+                    attrs, LOCAL_CONTAINER_FILTER);\n+    if (ret != EOK) goto done;\n+\n+    if (res->count == 1) {\n+        ret = ldb_search(lctx->ldb, tmp_ctx, &res, dn, LDB_SCOPE_ONELEVEL,\n+                         attrs, NULL);\n+        if (ret != EOK) goto done;\n+\n+        if (res->count > 0) {\n+            ret = EINVAL;","path":"src/responder/secrets/local.c","position":44,"original_position":27,"commit_id":"5d2e880115143e9f1d742cd8600e4bdc074c8d6c","original_commit_id":"5d2e880115143e9f1d742cd8600e4bdc074c8d6c","user":{"login":"simo5","id":8332609,"avatar_url":"https://avatars.githubusercontent.com/u/8332609?v=3","gravatar_id":"","url":"https://api.github.com/users/simo5","html_url":"https://github.com/simo5","followers_url":"https://api.github.com/users/simo5/followers","following_url":"https://api.github.com/users/simo5/following{/other_user}","gists_url":"https://api.github.com/users/simo5/gists{/gist_id}","starred_url":"https://api.github.com/users/simo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simo5/subscriptions","organizations_url":"https://api.github.com/users/simo5/orgs","repos_url":"https://api.github.com/users/simo5/repos","events_url":"https://api.github.com/users/simo5/events{/privacy}","received_events_url":"https://api.github.com/users/simo5/received_events","type":"User","site_admin":false},"body":"maybe this should be something like EACCESS or EPERM ?","created_at":"2016-09-09T13:02:50Z","updated_at":"2016-09-09T13:02:50Z","html_url":"https://github.com/SSSD/sssd/pull/11#discussion_r78175619","pull_request_url":"https://api.github.com/repos/SSSD/sssd/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/SSSD/sssd/pulls/comments/78175619"},"html":{"href":"https://github.com/SSSD/sssd/pull/11#discussion_r78175619"},"pull_request":{"href":"https://api.github.com/repos/SSSD/sssd/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/SSSD/sssd/pulls/11","id":83635280,"html_url":"https://github.com/SSSD/sssd/pull/11","diff_url":"https://github.com/SSSD/sssd/pull/11.diff","patch_url":"https://github.com/SSSD/sssd/pull/11.patch","issue_url":"https://api.github.com/repos/SSSD/sssd/issues/11","number":11,"state":"open","locked":false,"title":"SECRETS: Don't remove a container when it has children","user":{"login":"fidencio","id":112762,"avatar_url":"https://avatars.githubusercontent.com/u/112762?v=3","gravatar_id":"","url":"https://api.github.com/users/fidencio","html_url":"https://github.com/fidencio","followers_url":"https://api.github.com/users/fidencio/followers","following_url":"https://api.github.com/users/fidencio/following{/other_user}","gists_url":"https://api.github.com/users/fidencio/gists{/gist_id}","starred_url":"https://api.github.com/users/fidencio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidencio/subscriptions","organizations_url":"https://api.github.com/users/fidencio/orgs","repos_url":"https://api.github.com/users/fidencio/repos","events_url":"https://api.github.com/users/fidencio/events{/privacy}","received_events_url":"https://api.github.com/users/fidencio/received_events","type":"User","site_admin":false},"body":"Let's return and log an error in case the container to be removed has\r\nchildren.\r\n\r\nThe approach taken introduced at least one new search in every delete\r\noperation. As far as I understand searching in the BASE scope is quite\r\ncheap and that's the reason I decided to just do the search in the\r\nONELEVEL scope when the deleted dn is for sure a container.\r\n\r\nWhile the first patch is not needed for solving this issue, it's needed for adding something to a container.\r\n\r\nThe easiest way to test would be:\r\n- Create a container: curl -H \"Content-Type: application/json\" --unix-socket /var/run/secrets.socket -XPOST http://localhost/secrets/bar/\r\n- Create a container inside the firstly created container: curl -H \"Content-Type: application/json\" --unix-socket /var/run/secrets.socket -XPOST http://localhost/secrets/bar/foo/\r\n- Add a secret to the container: curl -H \"Content-Type: application/json\" --unix-socket /var/run/secrets.socket -XPUT http://localhost/secrets/bar/foo/test -d'{\"type\":\"simple\",\"value\":\"foosecret\"}'\r\n- Try to remove the container bar: curl -H \"Content-Type: application/json\" --unix-socket /var/run/secrets.socket -XDELETE http://localhost/secrets/bar/\r\n\r\nWith the patch you won't be able to remove unless it has no children. Without, you will be able to remove the container.","created_at":"2016-09-01T13:46:08Z","updated_at":"2016-09-09T13:02:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c41139f5f341d822bec0f885db67da94cf1112e4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SSSD/sssd/pulls/11/commits","review_comments_url":"https://api.github.com/repos/SSSD/sssd/pulls/11/comments","review_comment_url":"https://api.github.com/repos/SSSD/sssd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SSSD/sssd/issues/11/comments","statuses_url":"https://api.github.com/repos/SSSD/sssd/statuses/5d2e880115143e9f1d742cd8600e4bdc074c8d6c","head":{"label":"fidencio:wip/#3167","ref":"wip/#3167","sha":"5d2e880115143e9f1d742cd8600e4bdc074c8d6c","user":{"login":"fidencio","id":112762,"avatar_url":"https://avatars.githubusercontent.com/u/112762?v=3","gravatar_id":"","url":"https://api.github.com/users/fidencio","html_url":"https://github.com/fidencio","followers_url":"https://api.github.com/users/fidencio/followers","following_url":"https://api.github.com/users/fidencio/following{/other_user}","gists_url":"https://api.github.com/users/fidencio/gists{/gist_id}","starred_url":"https://api.github.com/users/fidencio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidencio/subscriptions","organizations_url":"https://api.github.com/users/fidencio/orgs","repos_url":"https://api.github.com/users/fidencio/repos","events_url":"https://api.github.com/users/fidencio/events{/privacy}","received_events_url":"https://api.github.com/users/fidencio/received_events","type":"User","site_admin":false},"repo":{"id":67102888,"name":"sssd","full_name":"fidencio/sssd","owner":{"login":"fidencio","id":112762,"avatar_url":"https://avatars.githubusercontent.com/u/112762?v=3","gravatar_id":"","url":"https://api.github.com/users/fidencio","html_url":"https://github.com/fidencio","followers_url":"https://api.github.com/users/fidencio/followers","following_url":"https://api.github.com/users/fidencio/following{/other_user}","gists_url":"https://api.github.com/users/fidencio/gists{/gist_id}","starred_url":"https://api.github.com/users/fidencio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidencio/subscriptions","organizations_url":"https://api.github.com/users/fidencio/orgs","repos_url":"https://api.github.com/users/fidencio/repos","events_url":"https://api.github.com/users/fidencio/events{/privacy}","received_events_url":"https://api.github.com/users/fidencio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fidencio/sssd","description":"A daemon to manage identity, authentication and authorization for centrally-managed systems.","fork":true,"url":"https://api.github.com/repos/fidencio/sssd","forks_url":"https://api.github.com/repos/fidencio/sssd/forks","keys_url":"https://api.github.com/repos/fidencio/sssd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fidencio/sssd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fidencio/sssd/teams","hooks_url":"https://api.github.com/repos/fidencio/sssd/hooks","issue_events_url":"https://api.github.com/repos/fidencio/sssd/issues/events{/number}","events_url":"https://api.github.com/repos/fidencio/sssd/events","assignees_url":"https://api.github.com/repos/fidencio/sssd/assignees{/user}","branches_url":"https://api.github.com/repos/fidencio/sssd/branches{/branch}","tags_url":"https://api.github.com/repos/fidencio/sssd/tags","blobs_url":"https://api.github.com/repos/fidencio/sssd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fidencio/sssd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fidencio/sssd/git/refs{/sha}","trees_url":"https://api.github.com/repos/fidencio/sssd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fidencio/sssd/statuses/{sha}","languages_url":"https://api.github.com/repos/fidencio/sssd/languages","stargazers_url":"https://api.github.com/repos/fidencio/sssd/stargazers","contributors_url":"https://api.github.com/repos/fidencio/sssd/contributors","subscribers_url":"https://api.github.com/repos/fidencio/sssd/subscribers","subscription_url":"https://api.github.com/repos/fidencio/sssd/subscription","commits_url":"https://api.github.com/repos/fidencio/sssd/commits{/sha}","git_commits_url":"https://api.github.com/repos/fidencio/sssd/git/commits{/sha}","comments_url":"https://api.github.com/repos/fidencio/sssd/comments{/number}","issue_comment_url":"https://api.github.com/repos/fidencio/sssd/issues/comments{/number}","contents_url":"https://api.github.com/repos/fidencio/sssd/contents/{+path}","compare_url":"https://api.github.com/repos/fidencio/sssd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fidencio/sssd/merges","archive_url":"https://api.github.com/repos/fidencio/sssd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fidencio/sssd/downloads","issues_url":"https://api.github.com/repos/fidencio/sssd/issues{/number}","pulls_url":"https://api.github.com/repos/fidencio/sssd/pulls{/number}","milestones_url":"https://api.github.com/repos/fidencio/sssd/milestones{/number}","notifications_url":"https://api.github.com/repos/fidencio/sssd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fidencio/sssd/labels{/name}","releases_url":"https://api.github.com/repos/fidencio/sssd/releases{/id}","deployments_url":"https://api.github.com/repos/fidencio/sssd/deployments","created_at":"2016-09-01T06:05:21Z","updated_at":"2016-09-01T06:05:26Z","pushed_at":"2016-09-08T16:18:23Z","git_url":"git://github.com/fidencio/sssd.git","ssh_url":"git@github.com:fidencio/sssd.git","clone_url":"https://github.com/fidencio/sssd.git","svn_url":"https://github.com/fidencio/sssd","homepage":"https://fedorahosted.org/sssd","size":31861,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"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":"SSSD:master","ref":"master","sha":"f2d1d90a14267c01155eab7bb95b8eb34128acc9","user":{"login":"SSSD","id":12898906,"avatar_url":"https://avatars.githubusercontent.com/u/12898906?v=3","gravatar_id":"","url":"https://api.github.com/users/SSSD","html_url":"https://github.com/SSSD","followers_url":"https://api.github.com/users/SSSD/followers","following_url":"https://api.github.com/users/SSSD/following{/other_user}","gists_url":"https://api.github.com/users/SSSD/gists{/gist_id}","starred_url":"https://api.github.com/users/SSSD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SSSD/subscriptions","organizations_url":"https://api.github.com/users/SSSD/orgs","repos_url":"https://api.github.com/users/SSSD/repos","events_url":"https://api.github.com/users/SSSD/events{/privacy}","received_events_url":"https://api.github.com/users/SSSD/received_events","type":"Organization","site_admin":false},"repo":{"id":37479167,"name":"sssd","full_name":"SSSD/sssd","owner":{"login":"SSSD","id":12898906,"avatar_url":"https://avatars.githubusercontent.com/u/12898906?v=3","gravatar_id":"","url":"https://api.github.com/users/SSSD","html_url":"https://github.com/SSSD","followers_url":"https://api.github.com/users/SSSD/followers","following_url":"https://api.github.com/users/SSSD/following{/other_user}","gists_url":"https://api.github.com/users/SSSD/gists{/gist_id}","starred_url":"https://api.github.com/users/SSSD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SSSD/subscriptions","organizations_url":"https://api.github.com/users/SSSD/orgs","repos_url":"https://api.github.com/users/SSSD/repos","events_url":"https://api.github.com/users/SSSD/events{/privacy}","received_events_url":"https://api.github.com/users/SSSD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SSSD/sssd","description":"A daemon to manage identity, authentication and authorization for centrally-managed systems.","fork":false,"url":"https://api.github.com/repos/SSSD/sssd","forks_url":"https://api.github.com/repos/SSSD/sssd/forks","keys_url":"https://api.github.com/repos/SSSD/sssd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SSSD/sssd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SSSD/sssd/teams","hooks_url":"https://api.github.com/repos/SSSD/sssd/hooks","issue_events_url":"https://api.github.com/repos/SSSD/sssd/issues/events{/number}","events_url":"https://api.github.com/repos/SSSD/sssd/events","assignees_url":"https://api.github.com/repos/SSSD/sssd/assignees{/user}","branches_url":"https://api.github.com/repos/SSSD/sssd/branches{/branch}","tags_url":"https://api.github.com/repos/SSSD/sssd/tags","blobs_url":"https://api.github.com/repos/SSSD/sssd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SSSD/sssd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SSSD/sssd/git/refs{/sha}","trees_url":"https://api.github.com/repos/SSSD/sssd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SSSD/sssd/statuses/{sha}","languages_url":"https://api.github.com/repos/SSSD/sssd/languages","stargazers_url":"https://api.github.com/repos/SSSD/sssd/stargazers","contributors_url":"https://api.github.com/repos/SSSD/sssd/contributors","subscribers_url":"https://api.github.com/repos/SSSD/sssd/subscribers","subscription_url":"https://api.github.com/repos/SSSD/sssd/subscription","commits_url":"https://api.github.com/repos/SSSD/sssd/commits{/sha}","git_commits_url":"https://api.github.com/repos/SSSD/sssd/git/commits{/sha}","comments_url":"https://api.github.com/repos/SSSD/sssd/comments{/number}","issue_comment_url":"https://api.github.com/repos/SSSD/sssd/issues/comments{/number}","contents_url":"https://api.github.com/repos/SSSD/sssd/contents/{+path}","compare_url":"https://api.github.com/repos/SSSD/sssd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SSSD/sssd/merges","archive_url":"https://api.github.com/repos/SSSD/sssd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SSSD/sssd/downloads","issues_url":"https://api.github.com/repos/SSSD/sssd/issues{/number}","pulls_url":"https://api.github.com/repos/SSSD/sssd/pulls{/number}","milestones_url":"https://api.github.com/repos/SSSD/sssd/milestones{/number}","notifications_url":"https://api.github.com/repos/SSSD/sssd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SSSD/sssd/labels{/name}","releases_url":"https://api.github.com/repos/SSSD/sssd/releases{/id}","deployments_url":"https://api.github.com/repos/SSSD/sssd/deployments","created_at":"2015-06-15T17:09:48Z","updated_at":"2016-09-01T08:07:38Z","pushed_at":"2016-09-09T12:48:47Z","git_url":"git://github.com/SSSD/sssd.git","ssh_url":"git@github.com:SSSD/sssd.git","clone_url":"https://github.com/SSSD/sssd.git","svn_url":"https://github.com/SSSD/sssd","homepage":"https://fedorahosted.org/sssd","size":31894,"stargazers_count":5,"watchers_count":5,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":12,"forks":16,"open_issues":12,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SSSD/sssd/pulls/11"},"html":{"href":"https://github.com/SSSD/sssd/pull/11"},"issue":{"href":"https://api.github.com/repos/SSSD/sssd/issues/11"},"comments":{"href":"https://api.github.com/repos/SSSD/sssd/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/SSSD/sssd/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/SSSD/sssd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SSSD/sssd/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/SSSD/sssd/statuses/5d2e880115143e9f1d742cd8600e4bdc074c8d6c"}}}}
{"actor":{"display_login":"simo5"}}