Make kauth_deregister_scope() and kauth_unlisten_scope() free the

passed kauth_scope_t and kauth_listener_t objects, respectively.

Okay yamt@.
This commit is contained in:
elad 2007-01-01 23:33:03 +00:00
parent ab88ea8145
commit c6e8423fec
2 changed files with 19 additions and 14 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: kauth.9,v 1.43 2006/12/26 10:43:43 elad Exp $
.\" $NetBSD: kauth.9,v 1.44 2007/01/01 23:33:03 elad Exp $
.\"
.\" Copyright (c) 2005, 2006 Elad Efrat <elad@NetBSD.org>
.\" All rights reserved.
@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 26, 2006
.Dd January 1, 2007
.Dt KAUTH 9
.Os
.Sh NAME
@ -944,7 +944,10 @@ during authorization on the scope.
.It Ft void Fn kauth_deregister_scope "kauth_scope_t scope"
Deregister
.Ar scope
from the scopes available on the system.
from the scopes available on the system, and free the
.Ft kauth_scope_t
object
.Ar scope .
.El
.Ss Listener Management
Listeners in
@ -970,17 +973,17 @@ Create a new listener on the scope with the id
.Ar id ,
setting the default listener to
.Ar cb .
.\".Ar cookie
.\"is optional user-data that will be passed to the listener when called
.\"during an authorization request.
.Ar cookie
is optional user-data that will be passed to the listener when called
during an authorization request.
.It Ft void Fn kauth_unlisten_scope "kauth_listener_t listener"
Remove
Removes
.Ar listener
from the scope which it belongs to.
.Pp
Effectively what this does is is remove the callback from the chain of
functions to be called when an authorization request is made, preventing
from the listener from being entered in the future.
from the scope which it belongs to, ensuring it won't be called again,
and frees the
.Ft kauth_listener_t
object
.Ar listener .
.El
.Pp
.Nm

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_auth.c,v 1.35 2006/12/26 10:43:44 elad Exp $ */
/* $NetBSD: kern_auth.c,v 1.36 2007/01/01 23:33:03 elad Exp $ */
/*-
* Copyright (c) 2005, 2006 Elad Efrat <elad@NetBSD.org>
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.35 2006/12/26 10:43:44 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.36 2007/01/01 23:33:03 elad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -655,6 +655,7 @@ kauth_deregister_scope(kauth_scope_t scope)
if (scope != NULL) {
/* Remove scope from list */
SIMPLEQ_REMOVE(&scope_list, scope, kauth_scope, next_scope);
kmem_free(scope, sizeof(*scope));
}
}
@ -716,6 +717,7 @@ kauth_unlisten_scope(kauth_listener_t listener)
SIMPLEQ_REMOVE(&listener->scope->listenq, listener,
kauth_listener, listener_next);
listener->scope->nlisteners--;
kmem_free(listener, sizeof(*listener));
}
}