xref: /illumos-gate/usr/src/man/man9f/drv_priv.9f (revision 4f364e7c95ee7fd9d5bbeddc1940e92405bb0e72)
te
Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
Copyright 1989 AT&T
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
DRV_PRIV 9F "Jan 16, 2006"
NAME
drv_priv - determine driver privilege
SYNOPSIS

#include <sys/types.h>
#include <sys/cred.h>
#include <sys/ddi.h>



int drv_priv(cred_t *cr);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

PARAMETERS
cr

Pointer to the user credential structure.

DESCRIPTION

The drv_priv() function provides a general interface to the system privilege policy. It determines whether the credentials supplied by the user credential structure pointed to by cr identify a process that has the {PRIV_SYS_DEVICES} privilege asserted in its effective set. This function should be used only when file access modes, special minor device numbers, and the device policy (see privileges(5), add_drv(1M)) are insufficient to provide protection for the requested driver function. It is intended to replace all calls to suser() and any explicit checks for effective user ID = 0 in driver code.

RETURN VALUES

This routine returns 0 if it succeeds, EPERM if it fails.

CONTEXT

The drv_priv() function can be called from user, interrupt, or kernel context.

SEE ALSO

add_drv(1M), update_drv(1M), privileges(5)

Writing Device Drivers