summaryrefslogtreecommitdiff
path: root/usr/src/lib/libproc
diff options
context:
space:
mode:
authorrd117015 <none@none>2007-02-20 10:39:20 -0800
committerrd117015 <none@none>2007-02-20 10:39:20 -0800
commit532877c46d04a2d0b254f9b5797720078adcea07 (patch)
tree6a099b60988ee5b9c2a654492f35be5dce1ffee8 /usr/src/lib/libproc
parent0a9f9c2a7d4d961e3ed3221accb2c04919531d23 (diff)
downloadillumos-joyent-532877c46d04a2d0b254f9b5797720078adcea07.tar.gz
PSARC 2006/554 setproject(3PROJECT) defining, and enhancing behaviour
6194864 simultaneous setproject()'s on the same project can fail to set rctl 6449567 setproject(3PROJECT) deletes resource controls set through prctl(1M) 6450539 projmod(1M) does not provide a mechanism to refresh "in-core" enforced resource controls 6491754 project.max-contracts should not allow basic privileges 6491804 task.final project property is not honoured if pools are not enabled
Diffstat (limited to 'usr/src/lib/libproc')
-rw-r--r--usr/src/lib/libproc/common/libproc.h4
-rw-r--r--usr/src/lib/libproc/common/llib-lproc9
-rw-r--r--usr/src/lib/libproc/common/mapfile-vers3
-rw-r--r--usr/src/lib/libproc/common/pr_getrctl.c85
4 files changed, 90 insertions, 11 deletions
diff --git a/usr/src/lib/libproc/common/libproc.h b/usr/src/lib/libproc/common/libproc.h
index 07e58fa05c..d12fda05e3 100644
--- a/usr/src/lib/libproc/common/libproc.h
+++ b/usr/src/lib/libproc/common/libproc.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -325,6 +325,8 @@ extern int pr_getrlimit(struct ps_prochandle *,
int, struct rlimit *);
extern int pr_setrlimit(struct ps_prochandle *,
int, const struct rlimit *);
+extern int pr_setprojrctl(struct ps_prochandle *, const char *,
+ rctlblk_t *, size_t, int);
#if defined(_LARGEFILE64_SOURCE)
extern int pr_getrlimit64(struct ps_prochandle *,
int, struct rlimit64 *);
diff --git a/usr/src/lib/libproc/common/llib-lproc b/usr/src/lib/libproc/common/llib-lproc
index 015de9ca0e..b9eff09617 100644
--- a/usr/src/lib/libproc/common/llib-lproc
+++ b/usr/src/lib/libproc/common/llib-lproc
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * 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.
@@ -23,7 +22,7 @@
/* PROTOLIB1 */
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -248,6 +247,8 @@ int pr_getrctl(struct ps_prochandle *Pr, const char *rname,
rctlblk_t *old_blk, rctlblk_t *new_blk, int rflag);
int pr_setrctl(struct ps_prochandle *Pr, const char *rname,
rctlblk_t *old_blk, rctlblk_t *new_blk, int rflag);
+int pr_setprojrctl(struct ps_prochandle *Pr, const char *rname,
+ rctlblk_t *new_blk, size_t size, int rflag);
/* pr_getrlimit.c */
int pr_getrlimit(struct ps_prochandle *Pr,
diff --git a/usr/src/lib/libproc/common/mapfile-vers b/usr/src/lib/libproc/common/mapfile-vers
index ef256570ce..758f43d99f 100644
--- a/usr/src/lib/libproc/common/mapfile-vers
+++ b/usr/src/lib/libproc/common/mapfile-vers
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -208,6 +208,7 @@ SUNWprivate_1.1 {
pr_pset_bind;
pr_rename;
pr_setitimer;
+ pr_setprojrctl;
pr_setrctl;
pr_setrlimit;
pr_setrlimit64;
diff --git a/usr/src/lib/libproc/common/pr_getrctl.c b/usr/src/lib/libproc/common/pr_getrctl.c
index d54fc228a6..9cbf7dfa0c 100644
--- a/usr/src/lib/libproc/common/pr_getrctl.c
+++ b/usr/src/lib/libproc/common/pr_getrctl.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * 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.
@@ -20,8 +19,8 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -33,6 +32,7 @@
#include <errno.h>
#include <strings.h>
#include "libproc.h"
+#include <sys/rctl_impl.h>
/*
* getrctl() system call -- executed by subject process
@@ -197,3 +197,78 @@ pr_setrctl(struct ps_prochandle *Pr, const char *rname,
}
return (rval.sys_rval1);
}
+
+/*
+ * setprojrctl() system call -- executed by subject process
+ */
+int
+pr_setprojrctl(struct ps_prochandle *Pr, const char *rname,
+ rctlblk_t *new_blk, size_t size, int rflag)
+{
+ sysret_t rval;
+ argdes_t argd[6];
+ argdes_t *adp;
+ int error;
+
+ if (Pr == NULL) /* no subject process */
+ return (setprojrctl(rname, new_blk, size, rflag));
+
+ adp = &argd[0];
+ adp->arg_value = 4; /* switch for setprojrctls in rctlsys */
+ adp->arg_object = NULL;
+ adp->arg_type = AT_BYVAL;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = 0;
+
+ adp++;
+ adp->arg_value = 0;
+ adp->arg_object = (void *)rname;
+ adp->arg_type = AT_BYREF;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = strlen(rname) + 1;
+
+ adp++;
+ adp->arg_value = 0; /* old_blk is not used by setprojrctls() */
+ adp->arg_object = NULL;
+ adp->arg_type = AT_BYVAL;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = 0;
+
+
+ adp++;
+ if (new_blk == NULL) {
+ adp->arg_value = 0;
+ adp->arg_object = NULL;
+ adp->arg_type = AT_BYVAL;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = 0;
+ } else {
+ adp->arg_value = 0;
+ adp->arg_object = new_blk;
+ adp->arg_type = AT_BYREF;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = rctlblk_size() * size;
+ }
+
+ adp++;
+ adp->arg_value = size; /* obufsz is used by setrctls() */
+ adp->arg_object = NULL;
+ adp->arg_type = AT_BYVAL;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = 0;
+
+ adp++;
+ adp->arg_value = rflag;
+ adp->arg_object = NULL;
+ adp->arg_type = AT_BYVAL;
+ adp->arg_inout = AI_INPUT;
+ adp->arg_size = 0;
+
+ error = Psyscall(Pr, &rval, SYS_rctlsys, 6, &argd[0]);
+
+ if (error) {
+ errno = (error > 0) ? error : ENOSYS;
+ return (-1);
+ }
+ return (rval.sys_rval1);
+}