[SSSD] [PATCHES] PAM: authenticate agains cache

Jakub Hrozek jhrozek at redhat.com
Mon Jun 29 15:23:16 UTC 2015


On Mon, Jun 29, 2015 at 11:56:01AM +0200, Lukas Slebodnik wrote:
> On (26/06/15 17:31), Pavel Reichl wrote:
> >
> So it seems you still do not understand what's wrong from desing point of view.
> If you do not understand something please ask it before. We would save your
> time with preparing patches and time of other developers reviewing unnecessary
> round of patches.
> 
> I would like to repeat what was not right from design point of view in previous
> version. You used totally different approach for functions. They weren't wrong
> they just did not fit among other sysdb functions.
> 
> Let's imagine pure object oriented library and someone decides to create new
> class with just static functions. He wrote this class because he wanted to
> emulate procedural paradigm. It wouldn't be a problem if other classes
> were written in such way. But mixing them together make a stinky code.
> 
> It's the same as let chimpanzee sit in an auditorium. it is not dangerous and
> can clap as well but it doesn't fit among other people. It would be fine
> if auditorious contained just chimpanzees.
> 
> And now why is current version even worse then previous one from design point
> of view. You renamed public functions and moved them to tottaly unrelated part
> of code. It is an equivalent of get dressed chimpanzee to different clothes and
> let it sit in city council. It still does not fit there.
> 
> 
> 
> >From 38dc66b619d6838610940f23ef84e0851a003319 Mon Sep 17 00:00:00 2001
> >From: Pavel Reichl <preichl at redhat.com>
> >Date: Wed, 24 Jun 2015 09:07:55 -0400
> >Subject: [PATCH 1/3] sysdb: new attribute lastOnlineAuthWithCurrentToken
> >
> >Introduce new user attribute lastOnlineAuthWithCurrentToken.
> >
> >Resolves:
> >https://fedorahosted.org/sssd/ticket/1807
> >---
> > src/db/sysdb.h                  |  1 +
> > src/responder/pam/pam_helpers.c | 98 ++++++++++++++++++++++++++++++++++++++++-
> > src/responder/pam/pam_helpers.h | 15 +++++++
> > src/tests/cmocka/test_pam_srv.c | 37 ++++++++++++++++
> > 4 files changed, 150 insertions(+), 1 deletion(-)
> >
> >diff --git a/src/db/sysdb.h b/src/db/sysdb.h
> >index 4dc382f6fb3f1b6bd084312463edf1b6189ebba9..f309c9e0c542f8b9c02e48f74a9cefdb1e0a1752 100644
> >--- a/src/db/sysdb.h
> >+++ b/src/db/sysdb.h
> >@@ -87,6 +87,7 @@
> > #define SYSDB_LAST_ONLINE_AUTH "lastOnlineAuth"
> > #define SYSDB_LAST_FAILED_LOGIN "lastFailedLogin"
> > #define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
> >+#define SYSDB_LAST_ONLINE_AUTH_WITH_CURR_TOKEN "lastOnlineAuthWithCurrentToken"
> > 
> > #define SYSDB_LAST_UPDATE "lastUpdate"
> > #define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
> >diff --git a/src/responder/pam/pam_helpers.h b/src/responder/pam/pam_helpers.h
> >index 1e1d914dfe3cd358972cc1ba6deb683a49b68235..b23713c2b51185ca11369b17f1ca30e295d1cb21 100644
> >--- a/src/responder/pam/pam_helpers.h
> >+++ b/src/responder/pam/pam_helpers.h
> >@@ -23,6 +23,8 @@
> > #ifndef PAM_HELPERS_H_
> > #define PAM_HELPERS_H_
> > 
> >+#include "util/util.h"
> >+
> > errno_t pam_initgr_cache_set(struct tevent_context *ev,
> >                              hash_table_t *id_table,
> >                              char *name,
> >@@ -35,4 +37,17 @@ errno_t pam_initgr_cache_set(struct tevent_context *ev,
> > errno_t pam_initgr_check_timeout(hash_table_t *id_table,
> >                               char *name);
> > 
> >+errno_t
> >+pam_null_last_online_auth_with_curr_token(struct sss_domain_info *domain,
> >+                                          const char *username);
> >+
> >+errno_t
> >+pam_get_last_online_auth_with_curr_token(struct sss_domain_info *domain,
> >+                                         const char *name,
> >+                                         uint64_t *_value);
> >+errno_t
> >+pam_set_last_online_auth_with_curr_token(struct sss_domain_info *domain,
> >+                                         const char *username,
> >+                                         uint64_t value);
> >+
> > #endif /* PAM_HELPERS_H_ */
> 
> Here are three proposal which you can use.
> a) create reusable public functions in sysdb and not a single purpose
>    functions. Reusable public functions would fit to current sysdb API.
> b) create internal helper functions in pam_responder. They should be internal
>    (static) and they purpose should be to improve readalibity of code; avoid
>    long functions. If you want them in separate module then create a new file
>    for fast pam authentication with public pam functions.

I don't think it's such a big deal at this point because the getsetters
are in the PAM tree and don't pullute the sysdb API. It's just a helper
now.

Yes, I guess even more structured approach would be to have a PAM responder
module that handles the cached authentication, but then the question
is whether this refactoring wouldn't be too invasive.

On the other hand, the tests for the utilities are not too critical, so
if you feel strongly about these three helpers, then making them static
would be less invasive than creating the module, unless there are tests.

I'm totally fine with refactoring code that is well covered with tests,
but I don't think we're there yet with PAM responder.

>    Helper functions (wrappers) must be internal in this module. So compiler can
>    inline them and readability is not decreased.
>    If you warry about code coverage of static functions then you needn't.
>    They already use tested public functions from sysdb and it's recommended to
>    write tests for new functionality. So they will be indirectly tested.
> c) Relace all SYSDB_* constants with setters and getters. So internal sysdb
>    library will be consistent.



More information about the sssd-devel mailing list