Dummy out close function if there is no end_session for the auth

method and the front-end can handle a NULL close function.  Avoids
the extra sudo process when we don't actually need it.
This commit is contained in:
Todd C. Miller
2013-02-24 05:54:57 -05:00
parent 2b8cb98987
commit d3ff0f31ee
3 changed files with 31 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2008-2010 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1999-2005, 2008-2013 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -302,6 +302,22 @@ sudo_auth_begin_session(struct passwd *pw, char **user_env[])
debug_return_int(status == AUTH_FATAL ? -1 : 1);
}
bool
sudo_auth_needs_end_session(void)
{
sudo_auth *auth;
bool needed = false;
debug_decl(sudo_auth_needs_end_session, SUDO_DEBUG_AUTH)
for (auth = auth_switch; auth->name; auth++) {
if (auth->end_session && !IS_DISABLED(auth)) {
needed = true;
break;
}
}
debug_return_bool(needed);
}
/*
* Call authentication method end session hooks.
* Returns 1 on success and -1 on error.