/*
* CDDL HEADER START
*
* 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
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lint.h"
#include <string.h>
#include <limits.h>
#include <sys/resource.h>
#include <sys/priocntl.h>
#include <limits.h>
#include <errno.h>
#include <priv.h>
static idtype_t
{
switch (which) {
case PRIO_PROCESS:
return (P_PID);
case PRIO_PGRP:
return (P_PGID);
case PRIO_USER:
return (P_UID);
case PRIO_GROUP:
return (P_GID);
case PRIO_SESSION:
return (P_SID);
case PRIO_LWP:
return (P_LWPID);
case PRIO_TASK:
return (P_TASKID);
case PRIO_PROJECT:
return (P_PROJID);
case PRIO_ZONE:
return (P_ZONEID);
case PRIO_CONTRACT:
return (P_CTID);
default:
return (-1);
}
}
static int
{
switch (which) {
case PRIO_PROCESS:
case PRIO_PGRP:
case PRIO_USER:
return (1);
default:
return (0);
}
}
int
{
return (-1);
}
if (who < 0) {
if (old_idtype(which)) {
return (-1);
return (-1);
}
}
/*
* The POSIX standard requires that a 0 value for the who argument
* should specify the current process, process group, or user.
* For all other id types we can treat zero as normal id value.
*/
else
return (-1);
else
}
int
{
int ret;
return (-1);
}
if (who < 0) {
if (old_idtype(which)) {
return (-1);
return (-1);
}
}
else
/*
* The priocntl PC_DONICE subcommand returns EPERM if we lack
* sufficient privileges to carry out the operation, but
* setpriority(3C) may need to return EACCES. We can't just
* change EPERM to EACCES, because there are other conditions
* between the current process and the target.).
*
* setpriority(3C) must return EACCES if we lack the privilege
* checked for below and we are trying to increase the process
* priority (by lowering the numeric value of its priority).
*/
}
}
return (ret);
}