#3940 sss_cache: Fail if unknown domain is passed in parameter
Merged 5 years ago by jhrozek. Opened 5 years ago by lslebodn.
SSSD/ lslebodn/sssd sss_cache_domain_param  into  master

@@ -57,5 +57,11 @@ 

      ret = subprocess.call(["sss_cache", "-u", "non-existing"])

      assert ret == 2

  

+     ret = subprocess.call(["sss_cache", "-d", "non-existing", "-u", "dummy"])

+     assert ret == 2

+ 

      ret = subprocess.call(["sss_cache", "-g", "non-existing"])

      assert ret == 2

+ 

+     ret = subprocess.call(["sss_cache", "-d", "non-existing", "-g", "dummy"])

+     assert ret == 2

file modified
+8 -1
@@ -152,6 +152,12 @@ 

          /* nothing to invalidate; no reason to fail */

          ret = EOK;

          goto done;

+     } else if (ret == ERR_DOMAIN_NOT_FOUND) {

+         /* Cannot find domain specified in the parameter --domain.

+          * It might be a typo and therefore we will fail.

+          */

+         ret = ENOENT;

+         goto done;

      } else if (ret != EOK) {

          DEBUG(SSSDBG_CRIT_FAILURE,

                "Error initializing context for the application\n");
@@ -858,7 +864,7 @@ 

      }

  

      ret = init_domains(ctx, values.domain);

-     if (ret == ENOENT) {

+     if (ret == ENOENT && values.domain == NULL) {

          /* Nothing to invalidate; do not log confusing messages. */

          goto fini;

      } else if (ret != EOK) {
@@ -866,6 +872,7 @@ 

              ERROR("Could not open domain %1$s. If the domain is a subdomain "

                    "(trusted domain), use fully qualified name instead of "

                    "--domain/-d parameter.\n", values.domain);

+             ret = ERR_DOMAIN_NOT_FOUND;

          } else {

              ERROR("Could not open available domains\n");

          }

If sss_cache is called with --domain parameter we should fail
in case of unknown domain. It might be a typo and user should know
about such case.

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

@jhrozek
sorry that I did not notice such case in previous PR.

rebased onto 8baf23b

5 years ago

2 new commits added

  • test_sss_cache: Add test case for wrong domain in parameter
  • sss_cache: Fail if unknown domain is passed in parameter
5 years ago

Oops, I also didn't consider this case in my testing. The code LGTM and there is a test, let me just run it through CI..

ACK, will push later in the evening to not disrupt any development CI runs

Commit 159a231 fixes this pull-request

Pull-Request has been merged by jhrozek

5 years ago

Commit 2de3c5f fixes this pull-request

Pull-Request has been merged by jhrozek

5 years ago