#3720 SYSDB: Return ENOENT for mpg with local provider
Merged 5 years ago by jhrozek. Opened 5 years ago by lslebodn.
SSSD/ lslebodn/sssd loc_prov_fix  into  master

file modified
+1 -1
@@ -494,7 +494,7 @@ 

          break;

      case SYSDB_GROUP:

          def_attrs[1] = SYSDB_GIDNUM;

-         if (domain->mpg) {

+         if (domain->mpg && strcasecmp(domain->provider, "local") != 0) {

              /* When searching a group by name in a MPG domain, we also

               * need to search the user space in order to be able to match

               * a user private group/

file modified
+32
@@ -1091,6 +1091,11 @@ 

          return;

      }

  

+     /* setup_sysdb_tests creates local provider and we need to handle

+      * ldap provider differently with auto_private_groups.

+      */

+     test_ctx->domain->provider = discard_const_p(char, "ldap");

+ 

      data = test_data_new_user(test_ctx, _i);

      fail_if(data == NULL);

  
@@ -1107,6 +1112,32 @@ 

  }

  END_TEST

  

+ START_TEST(test_user_group_by_name_local)

+ {

+     struct sysdb_test_ctx *test_ctx;

+     struct test_data *data;

+     struct ldb_message *msg;

+     int ret;

+ 

+     /* Setup */

+     ret = setup_sysdb_tests(&test_ctx);

+     if (ret != EOK) {

+         fail("Could not set up the test");

+         return;

+     }

+ 

+     data = test_data_new_user(test_ctx, _i);

+     fail_if(data == NULL);

+ 

+     ret = sysdb_search_group_by_name(data,

+                                      data->ctx->domain,

+                                      data->username, /* we're searching for the private group */

+                                      NULL,

+                                      &msg);

+     fail_if(ret != ENOENT);

+ }

+ END_TEST

+ 

  START_TEST (test_sysdb_getgrnam)

  {

      struct sysdb_test_ctx *test_ctx;
@@ -7092,6 +7123,7 @@ 

       * can be found. Regression test for ticket #3615

       */

      tcase_add_loop_test(tc_sysdb, test_user_group_by_name, 27000, 27010);

+     tcase_add_loop_test(tc_sysdb, test_user_group_by_name_local, 27000, 27010);

  

      /* Create a new group */

      tcase_add_loop_test(tc_sysdb, test_sysdb_add_group, 28000, 28010);

We need to return ENOENT for local provider if user have
just magic private group. Otherwise we would not be able
to detect such situation in sss_groupshow

/* The search itself */
ret = group_show(tctx, tctx->sysdb,
                 tctx->local, pc_recursive,
                  tctx->octx->name, &root);
/* Also show MPGs */
if (ret == ENOENT) {
    ret = group_show_mpg(tctx, tctx->local,
                         tctx->octx->name, &root);
}

Resolves:
https://pagure.io/SSSD/sssd/issue/3644

rebased onto 570fa6f079157dcae767baa160900694b4256d02

5 years ago

rebased onto 7af89f7

5 years ago

ACK, thank you for the patch and sorry the review took so long.

Commit b0aa567 fixes this pull-request

Pull-Request has been merged by jhrozek

5 years ago

Commit afe7060 fixes this pull-request

Pull-Request has been merged by jhrozek

5 years ago