Commit f7cc41d9 authored by Jon Bernard's avatar Jon Bernard

New upstream version 0.37.1

parent 59d32572
......@@ -245,7 +245,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2009-12-30'
timestamp='2009-11-20'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
......@@ -56,9 +56,8 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
......
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2010-01-22'
timestamp='2009-11-20'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
......@@ -75,9 +75,8 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
......@@ -381,8 +380,7 @@ case $basic_machine in
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile-* | tilegx-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
......@@ -1087,11 +1085,6 @@ case $basic_machine in
basic_machine=tic6x-unknown
os=-coff
;;
# This must be matched before tile*.
tilegx*)
basic_machine=tilegx-unknown
os=-linux-gnu
;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
......@@ -1442,8 +1435,6 @@ case $os in
-dicos*)
os=-dicos
;;
-nacl*)
;;
-none)
;;
*)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,8 +15,7 @@
AC_PREREQ(2.61)
# In following section update all occurences of version, including soname
AC_INIT([libcgroup], 0.37,
[http://sourceforge.net/tracker/?group_id=218421&atid=1043649])
AC_INIT([libcgroup], 0.37.1)
AM_INIT_AUTOMAKE([foreign dist-bzip2])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
......@@ -32,6 +31,19 @@ AC_DISABLE_STATIC
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADER([config.h])
AC_ARG_ENABLE([bindings],
[AC_HELP_STRING([--enable-bindings],
[enable python bindings [default=no]])],
[
if test "x$enableval" = xno; then
with_bindings=false
else
with_bindings=true
fi
],
[with_bindings = false])
AM_CONDITIONAL([WITH_BINDINGS], [test x$with_bindings = xtrue])
# Process command line options
AC_ARG_ENABLE([debug],
[AC_HELP_STRING([--enable-debug],
......@@ -181,6 +193,7 @@ AC_CONFIG_FILES([Makefile
src/daemon/Makefile
src/tools/Makefile
src/pam/Makefile
src/bindings/Makefile
scripts/Makefile
scripts/init.d/cgconfig
scripts/init.d/cgred
......
......@@ -163,7 +163,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......
......@@ -4,7 +4,7 @@
Name: libcgroup
Summary: Tools and libraries to control and monitor control groups
Group: System Environment/Libraries
Version: 0.37
Version: 0.37.1
Release: 1%{?dist}
License: LGPLv2+
URL: http://libcg.sourceforge.net/
......
......@@ -202,7 +202,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......
......@@ -190,7 +190,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......
......@@ -5,20 +5,18 @@ cgconfig.conf \- libcgroup configuration file
.\"***********************************
.SH DESCRIPTION
.B "cgconfig.conf"
is the configuration file used by
is a configuration file used by
.B libcgroup
to define control groups, their parameters and also mount points.
The file consists of
.I mount
and
.I group
sections.
These sections can be in arbitrary order.
Any line starting with '#' is considered as comment line and is
ignored.
sections. These sections can be in arbitrary order. Any line starting with
'#' is considered as a comment line and is ignored.
.LP
.I mount
section has the form:
section has this form:
.RS
.nf
.ft B
......@@ -53,7 +51,7 @@ automatically on cgconfig service startup if it does not exist and
is deleted on service shutdown.
.LP
.I group
section has the form:
section has this form:
.RS
.nf
.ft B
......
......@@ -8,12 +8,11 @@ cgrules.conf \- libcgroup configuration file
.B "cgrules.conf"
configuration file is used by
.B libcgroups
to define the control groups to which the process belongs to.
to define control groups to which a process belongs.
The file the contains list of rules which assign
to a defined group/user a control group in a subsystem
(or control groups in subsystems)
The file contains a list of rules which assign to a defined group/user a control
group in a subsystem (or control groups in subsystems).
Rules have two formats:
......@@ -31,8 +30,8 @@ Where:
.I user
can be:
.nf
- an user name
- a group name, with @group syntax
- a user name
- a group name with @group syntax
- the wildcard '*', for any user or group
- '%', which is equivalent to "ditto" (useful for
multi-line rules where different cgroups need to be
......@@ -57,10 +56,19 @@ can be:
can be:
.nf
- path relative to the controller hierarchy (ex. pgrp1/gid1/uid1)
- following strings will get expanded
%u username, uid if name resolving fails
%U uid
%g group name, gid if name resolving fails
%G gid
%p process name, pid if name not available
%P pid
'\\' can be used to escape '%'
.fi
First rule which matches the criteria will be executed.
First rule which matches the criteria will be executed.
Any text starting with '#' is considered as a start of comment line and is
......@@ -71,41 +79,36 @@ ignored.
.nf
student devices /usergroup/students
.fi
the processes of user
student
in the subsystem 'device' belong to the control group /usergroup/students.
Student's processes in the 'devices' subsystem belong to the control
group /usergroup/students.
.nf
student:cp devices /usergroup/students/cp
.fi
the 'cp' command processes of user
student
in the subsystem 'device' belong to the control group /usergroup/students/cp.
When student executes 'cp' command, the processes in the 'devices' subsystem
belong to the control group /usergroup/students/cp.
.nf
@admin * admingroup/
.fi
the processes which belong to group
admin
in all subsystems belongs to the control group /admingroup.
Processes started by anybody from admin group no matter in what subsystem belong
to the control group admingroup/.
.nf
peter cpu test1/
% memory test2/
.fi
First line says Peter's task for cpu controller
belongs to test1 control group
second line says put Peter's tasks for memory controller
belongs to test2/ control group
The first line says Peter's task for cpu controller belongs to test1 control
group. The second one says Peter's tasks for memory controller belong to test2/
control group.
.nf
* * default/
.fi
all processes belong in all subsystems
to the control group default/. Because there is applied the first task which is find -
it has a sense to have this row at the end of list to put the
tasks which was not mentioned in the previous rules
to the default/ control group.
All processes in any subsystem belong to the control group default/. Since
the earliest matched rule is applied, it makes sense to have this line
at the end of the list. It will put a task which was not mentioned in the
previous rules to default/ control group.
......
......@@ -189,7 +189,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......
......@@ -5,7 +5,9 @@
#error "Only <libcgroup.h> should be included directly."
#endif
#ifndef SWIG
#include <features.h>
#endif
__BEGIN_DECLS
......
......@@ -5,7 +5,9 @@
#error "Only <libcgroup.h> should be included directly."
#endif
#ifndef SWIG
#include <features.h>
#endif
__BEGIN_DECLS
......
......@@ -5,9 +5,11 @@
#error "Only <libcgroup.h> should be included directly."
#endif
#ifndef SWIG
#include <features.h>
#include <sys/types.h>
#include <stdbool.h>
#endif
__BEGIN_DECLS
......
......@@ -5,7 +5,9 @@
#error "Only <libcgroup.h> should be included directly."
#endif
#ifndef SWIG
#include <features.h>
#endif
__BEGIN_DECLS
......
......@@ -5,9 +5,11 @@
#error "Only <libcgroup.h> should be included directly."
#endif
#ifndef SWIG
#include <sys/types.h>
#include <stdio.h>
#include <features.h>
#endif
__BEGIN_DECLS
......
......@@ -7,8 +7,10 @@
#include <libcgroup/groups.h>
#ifndef SWIG
#include <features.h>
#include <stdbool.h>
#endif
__BEGIN_DECLS
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -162,7 +162,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......
......@@ -3,8 +3,8 @@ EXTRA_DIST = init.d/cgconfig.in init.d/cgred.in
if WITH_INITSCRIPT_INSTALL
INITSCRIPTDIR=$(DESTDIR)$(sysconfdir)/rc.d/init.d
install-exec-hook:
mkdir -p $(INITSCRIPTDIR)
cp init.d/cgconfig init.d/cgred $(INITSCRIPTDIR)
$(INSTALL) -d $(INITSCRIPTDIR)
$(INSTALL_SCRIPT) init.d/cgconfig init.d/cgred $(INITSCRIPTDIR)
uninstall-hook:
rm -f $(INITSCRIPTDIR)/cgconfig $(INITSCRIPTDIR)/cgred
......
......@@ -162,7 +162,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......@@ -371,8 +370,8 @@ uninstall-am:
uninstall uninstall-am uninstall-hook
@WITH_INITSCRIPT_INSTALL_TRUE@install-exec-hook:
@WITH_INITSCRIPT_INSTALL_TRUE@ mkdir -p $(INITSCRIPTDIR)
@WITH_INITSCRIPT_INSTALL_TRUE@ cp init.d/cgconfig init.d/cgred $(INITSCRIPTDIR)
@WITH_INITSCRIPT_INSTALL_TRUE@ $(INSTALL) -d $(INITSCRIPTDIR)
@WITH_INITSCRIPT_INSTALL_TRUE@ $(INSTALL_SCRIPT) init.d/cgconfig init.d/cgred $(INITSCRIPTDIR)
@WITH_INITSCRIPT_INSTALL_TRUE@uninstall-hook:
@WITH_INITSCRIPT_INSTALL_TRUE@ rm -f $(INITSCRIPTDIR)/cgconfig $(INITSCRIPTDIR)/cgred
......
......@@ -32,14 +32,9 @@
# get correct location of binaries from configure
prefix=@prefix@;exec_prefix=@exec_prefix@;sbindir=@sbindir@
CGCONFIGPARSER_BIN=$sbindir/cgconfigparser
CGROUP_FS=cgroup
CONFIG_FILE=/etc/cgconfig.conf
# support multiple mount points
declare -a MOUNTPOINT
declare -a MOUNTOPTS
maxindex=0
servicename=cgconfig
lockfile=/var/lock/subsys/$servicename
#
# Source LSB routines
......@@ -52,17 +47,13 @@ if [ -e /etc/sysconfig/cgconfig ]; then
. /etc/sysconfig/cgconfig
fi
RETVAL=0
create_default_groups() {
declare defaultcgroup
defaultcgroup=
if [ -f /etc/cgrules.conf ]
then
read user ctrl defaultcgroup <<< \
`grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf`
if [[ -n $defaultcgroup && $defaultcgroup = "*" ]]
then
if [ -f /etc/cgrules.conf ]; then
grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf | \
read user ctrl defaultcgroup
if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; then
log_warning_msg "/etc/cgrules.conf incorrect"
log_warning_msg "Overriding it"
defaultcgroup=
......@@ -106,38 +97,33 @@ create_default_groups() {
start() {
echo -n "Starting cgconfig service: "
if [ -f /var/lock/subsys/$servicename ]
then
if [ -f "$lockfile" ]; then
log_warning_msg "lock file already exists"
return 0
fi
if [ $? -eq 0 ]
then
if [ ! -s $CONFIG_FILE ]
then
if [ $? -eq 0 ]; then
if [ ! -s $CONFIG_FILE ]; then
log_failure_msg $CONFIG_FILE "is not configured"
return 6
fi
$CGCONFIGPARSER_BIN -l $CONFIG_FILE
retval=$?
if [ $retval -ne 0 ]
then
if [ $retval -ne 0 ]; then
log_failure_msg "Failed to parse " $CONFIG_FILE
return 1
fi
fi
if [ $CREATE_DEFAULT == "yes" ]; then
if [ $CREATE_DEFAULT = "yes" ]; then
create_default_groups
fi
touch /var/lock/subsys/$servicename
touch "$lockfile"
retval=$?
if [ $retval -ne 0 ]
then
log_failure_msg "Failed to touch " /var/lock/subsys/$servicename
if [ $retval -ne 0 ]; then
log_failure_msg "Failed to touch $lockfile"
return 1
fi
log_success_msg
......@@ -147,7 +133,7 @@ start() {
stop() {
echo -n "Stopping cgconfig service: "
cgclear
rm -f /var/lock/subsys/$servicename
rm -f "$lockfile"
log_success_msg
return 0
}
......@@ -174,38 +160,37 @@ common() {
trap "trapped INT" INT
}
restart() {
common
stop
start
}
RETVAL=0
case $1 in
'stop')
common
stop;
stop
RETVAL=$?
;;
'start')
common
start;
RETVAL=$?
;;
'restart')
common
stop
start
RETVAL=$?
;;
'reload')
common
stop
start
'restart'|'reload')
restart
RETVAL=$?
;;
'condrestart')
if [ -f /var/lock/subsys/$servicename ] ; then
stop
start
if [ -f "$lockfile" ]; then
restart
RETVAL=$?
fi
;;
'status')
if [ -f /var/lock/subsys/$servicename ] ; then
if [ -f "$lockfile" ]; then
echo "Running"
exit 0
else
......
......@@ -63,14 +63,13 @@ fi
# For convenience
processname=cgrulesengd
servicename=cgred
lockfile="/var/lock/subsys/$servicename"
pidfile=/var/run/cgred.pid
RETVAL=0
start()
{
echo -n $"Starting CGroup Rules Engine Daemon: "
if [ -f "/var/lock/subsys/$servicename" ] ; then
if [ -f "$lockfile" ]; then
log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
return 0
fi
......@@ -84,13 +83,17 @@ start()
return 1
fi
daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
RETVAL=$?
retval=$?
echo
if [ $RETVAL -ne 0 ]; then
if [ $retval -ne 0 ]; then
return 7
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
touch "$lockfile"
if [ $? -ne 0 ]; then
return 1
fi
echo "`pidof $processname`" > $pidfile
return 0
}
stop()
......@@ -100,15 +103,18 @@ stop()
log_success_msg
return 0
fi
killproc -p $pidfile $processname -TERM
RETVAL=$?
killproc -p $pidfile -TERM "$processname"
retval=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/$servicename
rm -f $pidfile
if [ $retval -ne 0 ]; then
return 1
fi
rm -f "$lockfile" "$pidfile"
return 0
}
RETVAL=0
# See how we are called
case "$1" in
start)
......@@ -126,15 +132,17 @@ case "$1" in
restart)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$servicename ] ; then
if [ -f "$lockfile" ]; then
stop
start
RETVAL=$?
fi
;;
reload|flash)
if [ -f /var/lock/subsys/$servicename ] ; then
if [ -f "$lockfile" ]; then
echo $"Reloading rules configuration..."
kill -s 12 `cat ${pidfile}`
RETVAL=$?
......
SUBDIRS = . daemon pam tools
if WITH_BINDINGS
BINDINGS_SUBDIR = bindings
endif
SUBDIRS = . daemon pam tools $(BINDINGS_SUBDIR)
# generate parse.h from parse.y
AM_YFLAGS = -d
......
......@@ -132,7 +132,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
distdir
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DIST_SUBDIRS = . daemon pam tools bindings
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
......@@ -269,7 +269,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
......@@ -286,7 +285,8 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = . daemon pam tools
@WITH_BINDINGS_TRUE@BINDINGS_SUBDIR = bindings
SUBDIRS = . daemon pam tools $(BINDINGS_SUBDIR)
# generate parse.h from parse.y
AM_YFLAGS = -d
......
......@@ -115,7 +115,7 @@ const char const *cgroup_strerror_codes[] = {
"Failed to parse config file",
"Have multiple paths for the same namespace",
"Controller in namespace does not exist",
"Cannot have mount and namespace keyword in the same configuration file",
"Either mount or namespace keyword has to be specified in the configuration file",
"This kernel does not support this feature",
"Value setting does not succeed",
};
......@@ -1991,6 +1991,8 @@ static int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
char *ctrl_file = NULL;
char *ctrl_value = NULL;
char *d_name = NULL;
char *tmp_path = NULL;
int tmp_len = 0;
char path[FILENAME_MAX+1];
char *buffer = NULL;
int error = 0;
......@@ -2019,8 +2021,33 @@ static int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
goto fill_error;
}
cgroup->control_uid = stat_buffer.st_uid;
cgroup->control_gid = stat_buffer.st_gid;
/*
* We have already stored the tasks_uid & tasks_gid.
* This check is to avoid the overwriting of the values
* stored in control_uid & cotrol_gid. tasks file will
* have the uid and gid of the user who is capable of
* putting a task to this cgroup. control_uid and control_gid
* is meant for the users who are capable of managing the
* cgroup shares.
*
* The strstr() function will return the pointer to the
* beginning of the sub string "/tasks".
*/
tmp_len = strlen(path) - strlen("/tasks");
/*
* tmp_path would be pointing to the last six characters
*/
tmp_path = (char *)path + tmp_len;
/*
* Checking to see, if this is actually a 'tasks' file
* We need to compare the last 6 bytes
*/
if (strcmp(tmp_path, "/tasks")){
cgroup->control_uid = stat_buffer.st_uid;
cgroup->control_gid = stat_buffer.st_gid;
}
ctrl_name = strtok_r(d_name, ".", &buffer);
......@@ -2366,6 +2393,14 @@ int cgroup_change_cgroup_flags(uid_t uid, gid_t gid,
/* Temporary pointer to a rule */
struct cgroup_rule *tmp = NULL;
/* Temporary variables for destination substitution */
char newdest[FILENAME_MAX];
int i, j;
int written;
int available;
struct passwd *user_info;
struct group *group_info;
/* Return codes */
int ret = 0;
......@@ -2418,7 +2453,92 @@ int cgroup_change_cgroup_flags(uid_t uid, gid_t gid,
do {
cgroup_dbg("Executing rule %s for PID %d... ", tmp->username,
pid);
ret = cgroup_change_cgroup_path(tmp->destination,
/* Destination substitutions */
for(j = i = 0; i < strlen(tmp->destination) &&
(j < FILENAME_MAX - 2); ++i, ++j) {
if(tmp->destination[i] == '%') {
/* How many bytes did we write / error check */
written = 0;
/* How many bytes can we write */
available = FILENAME_MAX - j - 2;