add support for negative authorizations
authorDavid Zeuthen <davidz@redhat.com>
Tue, 20 Nov 2007 04:25:30 +0000 (23:25 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Tue, 20 Nov 2007 04:25:30 +0000 (23:25 -0500)
commit45f52acbfd1d898e37f4ccaa830d6425fa4bc2da
treeb005ece85a7e7232fc4166ec69a1d72aaecfef59
parent8dd9f25b9aec6756bc87806fe6482ef0211ef132
add support for negative authorizations

Negative authorizations is a way to block an entity; previously the
algorithm was something like (ignoring the config file for now)

  Result is_authorized() {
    res = has_implicit_auth();
    if (res == YES) {
      return YES;
    } else if (has_explicit_auth()) {
      return YES;
    }
    return res;
  }

Now it's

  Result is_authorized() {
    res = has_implicit_auth();
    expl = has_explicit_auth();
    is_blocked = has_negative_explicit_auth();

    if (is_blocked)
      return NO;

    if (res == YES) {
      return YES;
    } else if (has_explicit_auth()) {
      return YES;
    }
    return res;
  }

E.g. just a single negative auth will force NO to be returned. I
really, really need to write into the spec how this works; my mental
L1 cache can't contain it anymore. Once it's formally defined we need
to craft a test suite to verify that the code works according to
spec...
12 files changed:
doc/man/polkit-auth.xml
src/polkit-dbus/polkit-simple.c
src/polkit-grant/polkit-authorization-db-write.c
src/polkit-grant/polkit-explicit-grant-helper.c
src/polkit-grant/polkit-revoke-helper.c
src/polkit/polkit-authorization-db.c
src/polkit/polkit-authorization-db.h
src/polkit/polkit-authorization.c
src/polkit/polkit-authorization.h
src/polkit/polkit-context.c
tools/polkit-auth.c
tools/polkit-bash-completion.sh