basebuilder_pel7ppc64bebuilder0
6 years ago
22 changed files with 2351 additions and 0 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
[Unit] |
||||
Description=Control Group configuration service |
||||
|
||||
# The service should be able to start as soon as possible, |
||||
# before any 'normal' services: |
||||
DefaultDependencies=no |
||||
Conflicts=shutdown.target |
||||
Before=basic.target shutdown.target |
||||
|
||||
[Service] |
||||
Type=oneshot |
||||
RemainAfterExit=yes |
||||
Delegate=yes |
||||
ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -L /etc/cgconfig.d -s 1664 |
||||
ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -L /etc/cgconfig.d -e |
||||
|
||||
[Install] |
||||
WantedBy=sysinit.target |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
[Unit] |
||||
Description=CGroups Rules Engine Daemon |
||||
After=syslog.target nss-user-lookup.target |
||||
|
||||
[Service] |
||||
Type=forking |
||||
EnvironmentFile=-/etc/sysconfig/cgred |
||||
ExecStart=/usr/sbin/cgrulesengd $OPTIONS |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
||||
|
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
# cgrulesengd command line options. See cgrulesengd(8). |
||||
CGROUP_LOGLEVEL="WARNING" |
||||
OPTIONS="-s -g cgred" |
||||
|
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
Fedora specific configuration - we want to mount all controllers by default for libvirt. |
||||
|
||||
diff -up libcgroup-0.34/samples/cgconfig.conf.orig libcgroup-0.34/samples/cgconfig.conf |
||||
--- libcgroup-0.34/samples/cgconfig.conf.orig 2009-03-04 10:40:06.000000000 +0100 |
||||
+++ libcgroup-0.34/samples/cgconfig.conf 2009-10-19 10:17:37.000000000 +0200 |
||||
@@ -10,39 +10,8 @@ |
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
# |
||||
-#group daemons/www { |
||||
-# perm { |
||||
-# task { |
||||
-# uid = root; |
||||
-# gid = webmaster; |
||||
-# } |
||||
-# admin { |
||||
-# uid = root; |
||||
-# gid = root; |
||||
-# } |
||||
-# } |
||||
-# cpu { |
||||
-# cpu.shares = 1000; |
||||
-# } |
||||
-#} |
||||
# |
||||
-#group daemons/ftp { |
||||
-# perm { |
||||
-# task { |
||||
-# uid = root; |
||||
-# gid = ftpmaster; |
||||
-# } |
||||
-# admin { |
||||
-# uid = root; |
||||
-# gid = root; |
||||
-# } |
||||
-# } |
||||
-# cpu { |
||||
-# cpu.shares = 500; |
||||
-# } |
||||
-#} |
||||
-# |
||||
-#mount { |
||||
-# cpu = /mnt/cgroups/cpu; |
||||
-# cpuacct = /mnt/cgroups/cpuacct; |
||||
-#} |
||||
+# By default, we expect systemd mounts everything on boot, |
||||
+# so there is not much to do. |
||||
+# See man cgconfig.conf for further details, how to create groups |
||||
+# on system boot using this file. |
||||
+ |
||||
diff -up libcgroup-0.35.1/samples/cgconfig.sysconfig.orig libcgroup-0.35.1/samples/cgconfig.sysconfig |
||||
--- libcgroup-0.35.1/samples/cgconfig.sysconfig.orig 2010-03-09 14:56:34.000000000 +0100 |
||||
+++ libcgroup-0.35.1/samples/cgconfig.sysconfig 2010-03-09 16:30:12.000000000 +0100 |
||||
@@ -5,8 +5,6 @@ |
||||
# controller to limit cpu.shares of this default group and allowing some more |
||||
# important group take most of the CPU. |
||||
# |
||||
-# By default, create these groups: |
||||
-CREATE_DEFAULT=yes |
||||
- |
||||
-# Uncomment following line to disable creation of the default group on startup: |
||||
-# CREATE_DEFAULT=no |
||||
+# By default, do not create these groups: |
||||
+# CREATE_DEFAULT=yes |
||||
+CREATE_DEFAULT=no |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
diff -up libcgroup-0.41/src/api.c.chmod libcgroup-0.41/src/api.c |
||||
--- libcgroup-0.41/src/api.c.chmod 2014-01-13 15:05:56.000000000 +0100 |
||||
+++ libcgroup-0.41/src/api.c 2014-01-13 20:41:55.255577622 +0100 |
||||
@@ -153,6 +153,10 @@ static int cg_chown_file(FTS *fts, FTSEN |
||||
return ret; |
||||
} |
||||
|
||||
+int cg_chmod_file(FTS *fts, FTSENT *ent, mode_t dir_mode, |
||||
+ int dirm_change, mode_t file_mode, int filem_change, |
||||
+ int owner_is_umask); |
||||
+ |
||||
/* |
||||
* TODO: Need to decide a better place to put this function. |
||||
*/ |
||||
@@ -160,6 +164,8 @@ static int cg_chown_recursive(char **pat |
||||
{ |
||||
int ret = 0; |
||||
FTS *fts; |
||||
+ /* mode 664 */ |
||||
+ mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; |
||||
|
||||
cgroup_dbg("chown: path is %s\n", *path); |
||||
fts = fts_open(path, FTS_PHYSICAL | FTS_NOCHDIR | |
||||
@@ -177,6 +183,7 @@ static int cg_chown_recursive(char **pat |
||||
cgroup_warn("Warning: fts_read failed\n"); |
||||
break; |
||||
} |
||||
+ cg_chmod_file(fts, ent, mode, 0, mode, 1, 1); |
||||
ret = cg_chown_file(fts, ent, owner, group); |
||||
} |
||||
fts_close(fts); |
@ -0,0 +1,99 @@
@@ -0,0 +1,99 @@
|
||||
diff -up libcgroup-0.41/src/api.c.coverity libcgroup-0.41/src/api.c |
||||
--- libcgroup-0.41/src/api.c.coverity 2014-01-13 20:52:49.853838149 +0100 |
||||
+++ libcgroup-0.41/src/api.c 2014-01-13 20:52:49.854838142 +0100 |
||||
@@ -2791,7 +2791,6 @@ static int cgroup_create_template_group( |
||||
if (group_name == NULL) { |
||||
ret = ECGOTHER; |
||||
last_errno = errno; |
||||
- free(template_name); |
||||
goto end; |
||||
} |
||||
|
||||
diff -up libcgroup-0.41/src/config.c.coverity libcgroup-0.41/src/config.c |
||||
--- libcgroup-0.41/src/config.c.coverity 2014-01-13 15:05:56.000000000 +0100 |
||||
+++ libcgroup-0.41/src/config.c 2014-01-13 20:52:49.854838142 +0100 |
||||
@@ -323,7 +323,7 @@ int config_group_task_perm(char *perm_ty |
||||
long val = atoi(value); |
||||
char buffer[CGROUP_BUFFER_LEN]; |
||||
struct cgroup *config_cgroup; |
||||
- int table_index; |
||||
+ int table_index, ret; |
||||
|
||||
switch (flag) { |
||||
case CGROUP: |
||||
@@ -367,10 +367,10 @@ int config_group_task_perm(char *perm_ty |
||||
if (!group) |
||||
goto group_task_error; |
||||
|
||||
- getgrnam_r(value, group, buffer, |
||||
+ ret = getgrnam_r(value, group, buffer, |
||||
CGROUP_BUFFER_LEN, &group_buffer); |
||||
|
||||
- if (group_buffer == NULL) { |
||||
+ if (ret != 0 || group_buffer == NULL) { |
||||
free(group); |
||||
goto group_task_error; |
||||
} |
||||
@@ -436,7 +436,7 @@ int config_group_admin_perm(char *perm_t |
||||
struct cgroup *config_cgroup; |
||||
long val = atoi(value); |
||||
char buffer[CGROUP_BUFFER_LEN]; |
||||
- int table_index; |
||||
+ int table_index, ret; |
||||
|
||||
switch (flag) { |
||||
case CGROUP: |
||||
@@ -479,10 +479,10 @@ int config_group_admin_perm(char *perm_t |
||||
if (!group) |
||||
goto admin_error; |
||||
|
||||
- getgrnam_r(value, group, buffer, |
||||
+ ret = getgrnam_r(value, group, buffer, |
||||
CGROUP_BUFFER_LEN, &group_buffer); |
||||
|
||||
- if (group_buffer == NULL) { |
||||
+ if (ret != 0 || group_buffer == NULL) { |
||||
free(group); |
||||
goto admin_error; |
||||
} |
||||
diff -up libcgroup-0.41/src/daemon/cgrulesengd.c.coverity libcgroup-0.41/src/daemon/cgrulesengd.c |
||||
--- libcgroup-0.41/src/daemon/cgrulesengd.c.coverity 2014-01-13 15:05:56.000000000 +0100 |
||||
+++ libcgroup-0.41/src/daemon/cgrulesengd.c 2014-01-13 20:52:49.854838142 +0100 |
||||
@@ -646,7 +646,7 @@ close: |
||||
|
||||
static int cgre_create_netlink_socket_process_msg(void) |
||||
{ |
||||
- int sk_nl = 0, sk_unix = 0, sk_max; |
||||
+ int sk_nl = -1, sk_unix = -1, sk_max; |
||||
struct sockaddr_nl my_nla; |
||||
char buff[BUFF_SIZE]; |
||||
int rc = -1; |
||||
@@ -784,9 +784,9 @@ static int cgre_create_netlink_socket_pr |
||||
} |
||||
|
||||
close_and_exit: |
||||
- if (sk_nl > 0) |
||||
+ if (sk_nl > -1) |
||||
close(sk_nl); |
||||
- if (sk_unix > 0) |
||||
+ if (sk_unix > -1) |
||||
close(sk_unix); |
||||
return rc; |
||||
} |
||||
diff -upr libcgroup-0.40.rc1.orig/src/tools/lscgroup.c libcgroup-0.40.rc1/src/tools/lscgroup.c |
||||
--- libcgroup-0.40.rc1.orig/src/tools/lscgroup.c 2013-05-21 15:36:04.000000000 +0200 |
||||
+++ libcgroup-0.40.rc1/src/tools/lscgroup.c 2013-11-04 14:26:53.400473523 +0100 |
||||
@@ -97,11 +97,11 @@ static int display_controller_data(char |
||||
if (ret != 0) |
||||
return ret; |
||||
|
||||
- strncpy(cgroup_dir_path, info.full_path, FILENAME_MAX); |
||||
+ strncpy(cgroup_dir_path, info.full_path, FILENAME_MAX - 1); |
||||
/* remove problematic '/' characters from cgroup directory path*/ |
||||
trim_filepath(cgroup_dir_path); |
||||
|
||||
- strncpy(input_dir_path, input_path, FILENAME_MAX); |
||||
+ strncpy(input_dir_path, input_path, FILENAME_MAX - 1); |
||||
|
||||
/* remove problematic '/' characters from input directory path*/ |
||||
trim_filepath(input_dir_path); |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
diff -up libcgroup-0.41/src/api.c.fread libcgroup-0.41/src/api.c |
||||
--- libcgroup-0.41/src/api.c.fread 2014-01-13 21:01:32.067067615 +0100 |
||||
+++ libcgroup-0.41/src/api.c 2014-01-13 21:01:32.070067594 +0100 |
||||
@@ -2232,29 +2232,29 @@ static int cg_rd_ctrl_file(const char *s |
||||
const char *file, char **value) |
||||
{ |
||||
char path[FILENAME_MAX]; |
||||
- FILE *ctrl_file = NULL; |
||||
- int ret; |
||||
+ int ctrl_file = -1; |
||||
+ ssize_t ret; |
||||
|
||||
if (!cg_build_path_locked(cgroup, path, subsys)) |
||||
return ECGFAIL; |
||||
|
||||
strncat(path, file, sizeof(path) - strlen(path)); |
||||
- ctrl_file = fopen(path, "re"); |
||||
- if (!ctrl_file) |
||||
+ ctrl_file = open(path, O_RDONLY | O_CLOEXEC); |
||||
+ if (ctrl_file < 0) |
||||
return ECGROUPVALUENOTEXIST; |
||||
|
||||
*value = calloc(CG_VALUE_MAX, 1); |
||||
if (!*value) { |
||||
- fclose(ctrl_file); |
||||
+ close(ctrl_file); |
||||
last_errno = errno; |
||||
return ECGOTHER; |
||||
} |
||||
|
||||
/* |
||||
- * using %as crashes when we try to read from files like |
||||
+ * using %as or fread crashes when we try to read from files like |
||||
* memory.stat |
||||
*/ |
||||
- ret = fread(*value, 1, CG_VALUE_MAX-1, ctrl_file); |
||||
+ ret = read(ctrl_file, *value, CG_VALUE_MAX-1); |
||||
if (ret < 0) { |
||||
free(*value); |
||||
*value = NULL; |
||||
@@ -2264,7 +2264,7 @@ static int cg_rd_ctrl_file(const char *s |
||||
(*value)[ret-1] = '\0'; |
||||
} |
||||
|
||||
- fclose(ctrl_file); |
||||
+ close(ctrl_file); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
From c81248e53bd43a2132ce0b0a5aee4951c8618b6f Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Thu, 7 Aug 2014 07:17:23 +0200 |
||||
Subject: [PATCH] retry to set control file |
||||
|
||||
--- |
||||
src/api.c | 35 +++++++++++++++++++++++++++++++++++ |
||||
1 file changed, 35 insertions(+) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index ae8396e..03c8068 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -1432,6 +1432,8 @@ static int cg_set_control_value(char *path, const char *val) |
||||
return 0; |
||||
} |
||||
|
||||
+ |
||||
+ |
||||
/** cgroup_modify_cgroup modifies the cgroup control files. |
||||
* struct cgroup *cgroup: The name will be the cgroup to be modified. |
||||
* The values will be the values to be modified, those not mentioned |
||||
@@ -1449,6 +1451,9 @@ int cgroup_modify_cgroup(struct cgroup *cgroup) |
||||
int i; |
||||
int error = 0; |
||||
int ret; |
||||
+ int retry_list[CG_CONTROLLER_MAX]; |
||||
+ int retry_index; |
||||
+ struct control_value **cvalues; |
||||
|
||||
if (!cgroup_initialized) |
||||
return ECGROUPNOTINITIALIZED; |
||||
@@ -1469,6 +1474,8 @@ int cgroup_modify_cgroup(struct cgroup *cgroup) |
||||
if (!cg_build_path(cgroup->name, base, |
||||
cgroup->controller[i]->name)) |
||||
continue; |
||||
+ |
||||
+ retry_index = -1; |
||||
for (j = 0; j < cgroup->controller[i]->index; j++) { |
||||
ret = asprintf(&path, "%s%s", base, |
||||
cgroup->controller[i]->values[j]->name); |
||||
@@ -1485,12 +1492,40 @@ int cgroup_modify_cgroup(struct cgroup *cgroup) |
||||
* the user as fatal */ |
||||
if (error && !cgroup->controller[i]->values[j]->dirty) { |
||||
error = 0; |
||||
+ /* Let's retry to set it in the second round */ |
||||
+ ++retry_index; |
||||
+ retry_list[retry_index] = j; |
||||
continue; |
||||
} |
||||
if (error) |
||||
goto err; |
||||
cgroup->controller[i]->values[j]->dirty = false; |
||||
} |
||||
+ if (retry_index > -1) { |
||||
+ for (j = 0; j <= retry_index; j++) { |
||||
+ cvalues = cgroup->controller[i]->values; |
||||
+ ret = asprintf(&path, "%s%s", base, |
||||
+ cvalues[retry_list[j]]->name); |
||||
+ if (ret < 0) { |
||||
+ last_errno = errno; |
||||
+ error = ECGOTHER; |
||||
+ goto err; |
||||
+ } |
||||
+ error = cg_set_control_value(path, |
||||
+ cvalues[retry_list[j]]->value); |
||||
+ free(path); |
||||
+ path = NULL; |
||||
+ /* don't consider error in files directly |
||||
+ * written by the user as fatal */ |
||||
+ if (error && !cvalues[retry_list[j]]->dirty) { |
||||
+ error = 0; |
||||
+ continue; |
||||
+ } |
||||
+ if (error) |
||||
+ goto err; |
||||
+ cvalues[retry_list[j]]->dirty = false; |
||||
+ } |
||||
+ } |
||||
} |
||||
err: |
||||
return error; |
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
diff -up libcgroup-0.41/src/api.c.templates-fix libcgroup-0.41/src/api.c |
||||
--- libcgroup-0.41/src/api.c.templates-fix 2014-01-13 21:04:36.933747000 +0100 |
||||
+++ libcgroup-0.41/src/api.c 2014-01-13 21:16:44.478580105 +0100 |
||||
@@ -2974,10 +2974,10 @@ int cgroup_change_cgroup_flags(uid_t uid |
||||
available, "%d", pid); |
||||
break; |
||||
case 'p': |
||||
- if(procname) { |
||||
+ if(procname && strlen(basename(procname))) { |
||||
written = snprintf(newdest + j, |
||||
available, "%s", |
||||
- procname); |
||||
+ basename(procname)); |
||||
} else { |
||||
written = snprintf(newdest + j, |
||||
available, "%d", pid); |
@ -0,0 +1,280 @@
@@ -0,0 +1,280 @@
|
||||
From d58a95615a146f868106411aecd61af182d7c7e2 Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Sun, 21 Sep 2014 12:05:11 +0200 |
||||
Subject: [PATCH] add examples to man pages |
||||
|
||||
--- |
||||
doc/man/cgclassify.1 | 18 ++++++++++++++++++ |
||||
doc/man/cgclear.1 | 21 ++++++++++++++++++++- |
||||
doc/man/cgconfig.conf.5 | 5 +---- |
||||
doc/man/cgconfigparser.8 | 14 ++++++++++++++ |
||||
doc/man/cgcreate.1 | 9 ++++++++- |
||||
doc/man/cgdelete.1 | 8 +++++++- |
||||
doc/man/cgred.conf.5 | 2 +- |
||||
doc/man/cgrulesengd.8 | 3 --- |
||||
doc/man/cgset.1 | 11 +++++++++++ |
||||
doc/man/cgsnapshot.1 | 15 ++++++++++++++- |
||||
doc/man/lscgroup.1 | 15 +++++++++++++++ |
||||
11 files changed, 109 insertions(+), 12 deletions(-) |
||||
|
||||
diff --git a/doc/man/cgclassify.1 b/doc/man/cgclassify.1 |
||||
index db4e086..1facd2b 100644 |
||||
--- a/doc/man/cgclassify.1 |
||||
+++ b/doc/man/cgclassify.1 |
||||
@@ -57,7 +57,25 @@ controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
.TP |
||||
.B /etc/cgrules.conf |
||||
default libcgroup configuration file |
||||
+.TP |
||||
+.B /etc/cgrules.d |
||||
+default libcgroup configuration files directory |
||||
+ |
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgclassify -g cpu:student 1234 |
||||
+moves process with pid number 1234 to control group student in cpu hierarchy. |
||||
|
||||
+.TP |
||||
+.B cgclassify 1234 |
||||
+moves process with pid number 1234 to control groups based on |
||||
+\fB/etc/cgrules.conf\fR configuration file. |
||||
+ |
||||
+.TP |
||||
+.B cgclassify --sticky -g cpu:/student 1234 |
||||
+moves process with pid number 1234 to control group student in cpu hierarchy. |
||||
+The daemon of service cgred does not change cgroups of pid 1234 and its children |
||||
+(based on \fB/etc/cgrules.conf\fR). |
||||
|
||||
.SH SEE ALSO |
||||
cgrules.conf (5), cgexec (1) |
||||
diff --git a/doc/man/cgclear.1 b/doc/man/cgclear.1 |
||||
index 318c925..241a095 100644 |
||||
--- a/doc/man/cgclear.1 |
||||
+++ b/doc/man/cgclear.1 |
||||
@@ -43,5 +43,24 @@ option works only with \fB-l\fR or \fB-L\fR options. |
||||
controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
+.SH FILES |
||||
+.TP |
||||
+.B /etc/cgconfig.conf |
||||
+default templates file |
||||
+.TP |
||||
+.B /etc/cgconfig.d/ |
||||
+default templates files directory |
||||
+.RE |
||||
+ |
||||
+ |
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgclear |
||||
+unload the whole cgroup filesystem |
||||
+ |
||||
+.TP |
||||
+.B cgclear -l /etc/cgconfig.conf |
||||
+unload a subsystem of cgroup filesystem based on \fB/etc/cgconfig.conf\fR definition. |
||||
+ |
||||
.SH SEE ALSO |
||||
-cgconfigparser(1) |
||||
+cgconfigparser(1), cgconfig.conf(5) |
||||
diff --git a/doc/man/cgconfig.conf.5 b/doc/man/cgconfig.conf.5 |
||||
index a7d9935..f3a4ba9 100644 |
||||
--- a/doc/man/cgconfig.conf.5 |
||||
+++ b/doc/man/cgconfig.conf.5 |
||||
@@ -784,15 +784,12 @@ better to explicitly specify all groups and all controllers |
||||
related to them. |
||||
|
||||
.SH FILES |
||||
-.LP |
||||
-.PD .1v |
||||
.TP |
||||
.B /etc/cgconfig.conf |
||||
-.TP |
||||
default libcgroup configuration file |
||||
+.TP |
||||
.B /etc/cgconfig.d/ |
||||
default libcgroup configuration files directory |
||||
-.PD |
||||
|
||||
.SH SEE ALSO |
||||
cgconfigparser (8) |
||||
diff --git a/doc/man/cgconfigparser.8 b/doc/man/cgconfigparser.8 |
||||
index 0a20f95..8fff95f 100644 |
||||
--- a/doc/man/cgconfigparser.8 |
||||
+++ b/doc/man/cgconfigparser.8 |
||||
@@ -74,5 +74,19 @@ of this group have write access to the file. |
||||
controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
+.SH FILES |
||||
+.TP |
||||
+.B /etc/cgconfig.conf |
||||
+default libcgroup configuration file |
||||
+.TP |
||||
+.B /etc/cgconfig.d/ |
||||
+default libcgroup configuration files directory |
||||
+ |
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgconfigparser -l /etc/cgconfig.conf |
||||
+setup control group file system based on \fB/etc/cgconfig.conf\fR configuration file |
||||
+ |
||||
+ |
||||
.SH SEE ALSO |
||||
cgconfig.conf (5) |
||||
diff --git a/doc/man/cgcreate.1 b/doc/man/cgcreate.1 |
||||
index 557b5ae..17c33d8 100644 |
||||
--- a/doc/man/cgcreate.1 |
||||
+++ b/doc/man/cgcreate.1 |
||||
@@ -70,7 +70,14 @@ The default value is the same as has the parent cgroup. |
||||
controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
-.SH FILES |
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgcreate -g *:student -g devices:teacher |
||||
+create control group student in all mounted hierarchies and create |
||||
+control group teacher in hierarchy containing controller devices. |
||||
+ |
||||
+ |
||||
+ |
||||
|
||||
.SH SEE ALSO |
||||
cgrules.conf (5) |
||||
diff --git a/doc/man/cgdelete.1 b/doc/man/cgdelete.1 |
||||
index 025a799..9572287 100644 |
||||
--- a/doc/man/cgdelete.1 |
||||
+++ b/doc/man/cgdelete.1 |
||||
@@ -16,7 +16,7 @@ program removes all specified control groups. |
||||
|
||||
.TP |
||||
.B [-g] <controllers>:<path> |
||||
-Defines the control group to delete. Multiple control groups nay be |
||||
+Defines the control group to delete. Multiple control groups may be |
||||
specified. |
||||
.B -g |
||||
is optional. |
||||
@@ -35,5 +35,11 @@ Recursively remove all subgroups. |
||||
controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgdelete -g cpu,devices:/test |
||||
+remove control group test from hierarchies containing cpu and device controllers |
||||
+ |
||||
+ |
||||
.SH SEE ALSO |
||||
cgcreate (1), lscgroup (1), cgclear (1) |
||||
diff --git a/doc/man/cgred.conf.5 b/doc/man/cgred.conf.5 |
||||
index 3fe760f..1c0922f 100644 |
||||
--- a/doc/man/cgred.conf.5 |
||||
+++ b/doc/man/cgred.conf.5 |
||||
@@ -42,7 +42,7 @@ default libcgroup configuration file |
||||
|
||||
.SH SEE ALSO |
||||
cgrules.conf (5), |
||||
-cgconfig.conf (5) |
||||
+cgconfig.conf (5), cgrules.d (5) |
||||
|
||||
|
||||
|
||||
diff --git a/doc/man/cgrulesengd.8 b/doc/man/cgrulesengd.8 |
||||
index 749b6fc..2810aa5 100644 |
||||
--- a/doc/man/cgrulesengd.8 |
||||
+++ b/doc/man/cgrulesengd.8 |
||||
@@ -63,11 +63,8 @@ controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
.SH FILES |
||||
-.LP |
||||
-.PD .1v |
||||
.TP |
||||
.B /etc/cgrules.conf |
||||
-.TP |
||||
the default libcgroup configuration file |
||||
.TP |
||||
.B /etc/cgconfig.conf |
||||
diff --git a/doc/man/cgset.1 b/doc/man/cgset.1 |
||||
index be886c6..b05473f 100644 |
||||
--- a/doc/man/cgset.1 |
||||
+++ b/doc/man/cgset.1 |
||||
@@ -36,5 +36,16 @@ copied to the input cgroup. |
||||
controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgset -r cpuset.cpus=0-1 student |
||||
+set variable cpus in control group student (controller cpuset) to 0-1 |
||||
+ |
||||
+.TP |
||||
+.B cgset --copy-from group1/ group2/ |
||||
+copy all parameters of group group1 to group group2 |
||||
+(for all path where both cgroups are defined) |
||||
+ |
||||
+ |
||||
.SH SEE ALSO |
||||
cgrules.conf (1), cgcreate (1), cgget (1) |
||||
diff --git a/doc/man/cgsnapshot.1 b/doc/man/cgsnapshot.1 |
||||
index 03c85f6..48a038e 100644 |
||||
--- a/doc/man/cgsnapshot.1 |
||||
+++ b/doc/man/cgsnapshot.1 |
||||
@@ -8,7 +8,7 @@ cgsnapshot \- generate the configuration file for given controllers |
||||
|
||||
.SH SYNOPSIS |
||||
\fBcgsnapshot\fR [\fB-h\fR] [\fB-s\fR] [\fB-t\fR] [\fB-b\fR \fIfile\fR] |
||||
-[\fB-w\fR \fIfile\fR] [\fB-f\fR \fIoutput_file\fR] [\fBcontroller\fR] [...] |
||||
+[\fB-w\fR \fIfile\fR] [\fB-f\fR \fIoutput_file\fR] [\fBcontroller\fR] [...] |
||||
|
||||
.SH DESCRIPTION |
||||
\fBcgsnapshot\fR |
||||
@@ -96,5 +96,18 @@ default whitelist |
||||
.B /etc/cgconfig.conf |
||||
default libcgroup configuration file |
||||
|
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B cgsnapshot -s -f /etc/cgconfig.conf.cgsnapshot |
||||
+create configuration file which contains all mounted controllers and all |
||||
+control groups which are on the actual system |
||||
+ |
||||
+.TP |
||||
+.B cgsnapshot -s -f /etc/cgconfig.conf.cgsnapshot cpu |
||||
+create configuration file which contains hierarchy containing cpu controller and all its |
||||
+control groups on the actual system |
||||
+ |
||||
+ |
||||
+ |
||||
.SH SEE ALSO |
||||
cgconfig.conf (5) |
||||
diff --git a/doc/man/lscgroup.1 b/doc/man/lscgroup.1 |
||||
index 693fbbc..124379e 100644 |
||||
--- a/doc/man/lscgroup.1 |
||||
+++ b/doc/man/lscgroup.1 |
||||
@@ -26,6 +26,21 @@ list all existing cgroups. |
||||
controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
\fBINFO\fR, \fBWARNING\fR or \fBERROR\fR. |
||||
|
||||
+.SH EXAMPLES |
||||
+.TP |
||||
+.B lscgroup -g cpu:/ |
||||
+list all cgroups which are in hierarchy containing cpu controller |
||||
+ |
||||
+.TP |
||||
+.B lscgroup -g cpu:/student |
||||
+list all cgroups which are in hierarchy containing cpu controller |
||||
+in subgroup student |
||||
+ |
||||
+.TP |
||||
+.B lscgroup |
||||
+list all cgroups which in all hierarchies |
||||
+ |
||||
+ |
||||
.SH SEE ALSO |
||||
lssubsys (1), cgcreate (1), cgdelete (1), |
||||
cgconfig.conf (5) |
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
From 7e3eded57f77a606f173d6ede51585178ac3f9ee Mon Sep 17 00:00:00 2001 |
||||
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> |
||||
Date: Tue, 24 Jan 2017 15:46:31 +0100 |
||||
Subject: [PATCH] src/api.c: Fix level of warning messages informing about |
||||
failed user/group lookup |
||||
|
||||
--- |
||||
src/api.c | 4 ++-- |
||||
1 file changed, 2 insertions(+), 2 deletions(-) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index 2102c13..931fb3e 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -639,7 +639,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, |
||||
uid = CGRULE_INVALID; |
||||
gid = grp->gr_gid; |
||||
} else { |
||||
- cgroup_dbg("Warning: Entry for %s not" |
||||
+ cgroup_warn("Warning: Entry for %s not" |
||||
"found. Skipping rule on line" |
||||
" %d.\n", itr, linenum); |
||||
skipped = true; |
||||
@@ -656,7 +656,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, |
||||
uid = pwd->pw_uid; |
||||
gid = CGRULE_INVALID; |
||||
} else { |
||||
- cgroup_dbg("Warning: Entry for %s not" |
||||
+ cgroup_warn("Warning: Entry for %s not" |
||||
"found. Skipping rule on line" |
||||
" %d.\n", user, linenum); |
||||
skipped = true; |
||||
-- |
||||
2.7.4 |
||||
|
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
From 72a9e0c3d4f8daca9f7dc389edbc1013d7c0d808 Mon Sep 17 00:00:00 2001 |
||||
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> |
||||
Date: Fri, 8 Apr 2016 17:00:19 +0200 |
||||
Subject: [PATCH] api.c: fix order of memory subsystem parameters generated by |
||||
cgsnapshot |
||||
MIME-Version: 1.0 |
||||
Content-Type: text/plain; charset=UTF-8 |
||||
Content-Transfer-Encoding: 8bit |
||||
|
||||
Order of parameters usually doesn't matter, but that's not the case with |
||||
memory.limit_in_bytes and memory.memsw.limit_in_bytes. When the latter |
||||
is first in the list of parameters, the resulting configuration is not |
||||
loadable with cgconfigparser. |
||||
|
||||
This happens because when a cgroup is created, both memory.limit_in_bytes |
||||
and memory.memsw.limit_in_bytes parameters are initialized to highest |
||||
value possible (RESOURCE_MAX). And because memory.memsw.limit_in_bytes |
||||
must be always higher or equal to memory.limit_in_bytes, it's impossible |
||||
to change its value first. |
||||
|
||||
Make sure that after constructing parameter list of memory subsystem, |
||||
the mentioned parameters are in correct order. |
||||
|
||||
Signed-off-by: Nikola Forró <nforro@redhat.com> |
||||
--- |
||||
src/api.c | 24 ++++++++++++++++++++++++ |
||||
1 file changed, 24 insertions(+) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index 0bf0615..f5da553 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -2651,6 +2651,30 @@ int cgroup_get_cgroup(struct cgroup *cgroup) |
||||
} |
||||
} |
||||
closedir(dir); |
||||
+ |
||||
+ if (! strcmp(cgc->name, "memory")) { |
||||
+ /* |
||||
+ * Make sure that memory.limit_in_bytes is placed before |
||||
+ * memory.memsw.limit_in_bytes in the list of values |
||||
+ */ |
||||
+ int memsw_limit = -1; |
||||
+ int mem_limit = -1; |
||||
+ |
||||
+ for (j = 0; j < cgc->index; j++) { |
||||
+ if (! strcmp(cgc->values[j]->name, |
||||
+ "memory.memsw.limit_in_bytes")) |
||||
+ memsw_limit = j; |
||||
+ else if (! strcmp(cgc->values[j]->name, |
||||
+ "memory.limit_in_bytes")) |
||||
+ mem_limit = j; |
||||
+ } |
||||
+ |
||||
+ if (memsw_limit >= 0 && memsw_limit < mem_limit) { |
||||
+ struct control_value *val = cgc->values[memsw_limit]; |
||||
+ cgc->values[memsw_limit] = cgc->values[mem_limit]; |
||||
+ cgc->values[mem_limit] = val; |
||||
+ } |
||||
+ } |
||||
} |
||||
|
||||
/* Check if the group really exists or not */ |
||||
-- |
||||
2.4.11 |
||||
|
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
From 1b4b4b7f8d4443c3e630838c9b33c9a69fdb6193 Mon Sep 17 00:00:00 2001 |
||||
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> |
||||
Date: Sun, 19 Jun 2016 17:12:01 +0200 |
||||
Subject: [PATCH] api.c: fix potential buffer overflow |
||||
MIME-Version: 1.0 |
||||
Content-Type: text/plain; charset=UTF-8 |
||||
Content-Transfer-Encoding: 8bit |
||||
|
||||
It is assumed that arguments read from /proc/<pid>/cmdline don't exceed |
||||
buf_pname buffer size, which is FILENAME_MAX - 1 characters, but that's |
||||
not always the case. |
||||
|
||||
Add check to prevent buffer overflow and discard the excessive part of |
||||
an argument. |
||||
|
||||
Signed-off-by: Nikola Forró <nforro@redhat.com> |
||||
--- |
||||
src/api.c | 6 +++++- |
||||
1 file changed, 5 insertions(+), 1 deletion(-) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index b40364c..18ce21f 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -4055,13 +4055,17 @@ static int cg_get_procname_from_proc_cmdline(pid_t pid, |
||||
|
||||
while (c != EOF) { |
||||
c = fgetc(f); |
||||
- if ((c != EOF) && (c != '\0')) { |
||||
+ if ((c != EOF) && (c != '\0') && (len < FILENAME_MAX - 1)) { |
||||
buf_pname[len] = c; |
||||
len++; |
||||
continue; |
||||
} |
||||
buf_pname[len] = '\0'; |
||||
|
||||
+ if (len == FILENAME_MAX - 1) |
||||
+ while ((c != EOF) && (c != '\0')) |
||||
+ c = fgetc(f); |
||||
+ |
||||
/* |
||||
* The taken process name from /proc/<pid>/status is |
||||
* shortened to 15 characters if it is over. So the |
||||
-- |
||||
2.7.4 |
||||
|
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
From c065903104c4d28b1ad0166f84fd6b19e0cf301e Mon Sep 17 00:00:00 2001 |
||||
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> |
||||
Date: Thu, 16 Mar 2017 14:58:27 +0100 |
||||
Subject: [PATCH] src/api.c: preserve dirty flag when copying controller values |
||||
|
||||
--- |
||||
src/api.c | 1 + |
||||
1 file changed, 1 insertion(+) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index 931fb3e..e9500e0 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -1594,6 +1594,7 @@ static int cgroup_copy_controller_values(struct cgroup_controller *dst, |
||||
dst_val = dst->values[i]; |
||||
strncpy(dst_val->value, src_val->value, CG_VALUE_MAX); |
||||
strncpy(dst_val->name, src_val->name, FILENAME_MAX); |
||||
+ dst_val->dirty = src_val->dirty; |
||||
} |
||||
err: |
||||
return ret; |
||||
-- |
||||
2.7.4 |
||||
|
@ -0,0 +1,150 @@
@@ -0,0 +1,150 @@
|
||||
From 691430206f1104b752b0e52386f317e639137788 Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Mon, 15 Sep 2014 13:29:39 +0200 |
||||
Subject: [PATCH] api.c: support for setting multiline values in control files |
||||
|
||||
As of now, libcgroup does not support multiline values setting from configuration files. i.e. values in a form: |
||||
|
||||
net_prio.ifpriomap="lo 7 |
||||
eth0 66 |
||||
eth1 5 |
||||
eth2 4 |
||||
eth3 3"; |
||||
|
||||
Thus, setting of more network interfaces can not be done from configuration file. Or |
||||
|
||||
devices.allow="a *:* w |
||||
c 8:* r"; |
||||
|
||||
thus setting list of allow devices can not be set as well. The only way is to set it from userspace, e.g.: |
||||
# echo "lo 7" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap |
||||
# echo "eth 0" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap |
||||
# echo "eth 1" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap |
||||
# echo "eth 2" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap |
||||
# echo "eth 3" > /sys/fs/cgroup/net_prio/testGroup/net_prio.ifpriomap |
||||
|
||||
This patch allows setting of multiline variables. |
||||
|
||||
How this support works: |
||||
Multiline value is broken in lines and each line is set by write (man 2 write) syscall (without bufferring). |
||||
This implies change of fopen with open, fclose with close. |
||||
There is no control on multiline value, thus "eth0\n \t\n" can be set. However, setting |
||||
of " \t" will fail as write command returns -1. Thus administrator has to set correct |
||||
multiline values. |
||||
|
||||
Tested on virtual machine with fedora and rhel with network interface lo, eth0-eth3. Configuration file: |
||||
|
||||
# cat /etc/cgconfig.conf |
||||
group testGroup { |
||||
net_prio { |
||||
net_prio.ifpriomap="lo 7 |
||||
eth0 66 |
||||
eth1 5 |
||||
eth2 4 |
||||
eth3 3"; |
||||
} |
||||
} |
||||
|
||||
net_prio has to be created before: |
||||
# modprobe netprio_cgroup |
||||
# mkdir /sys/fs/cgroup/net_prio |
||||
# mount -t cgroup -onet_prio none /sys/fs/cgroup/net_prio |
||||
|
||||
Changelog: |
||||
test of success of strdup call |
||||
free str_val before return (str_val is changing in while cycle, |
||||
thus str_start_val points to the start of str_val before while) |
||||
|
||||
Signed-off-by: Jan Chaloupka <jchaloup@redhat.com> |
||||
--- |
||||
src/api.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ |
||||
1 file changed, 44 insertions(+), 6 deletions(-) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index 5751b8f..d6c9d3a 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -1495,13 +1495,18 @@ static int cg_create_control_group(const char *path) |
||||
*/ |
||||
static int cg_set_control_value(char *path, const char *val) |
||||
{ |
||||
- FILE *control_file = NULL; |
||||
+ int ctl_file; |
||||
+ char *str_val; |
||||
+ char *str_val_start; |
||||
+ char *pos; |
||||
+ size_t len; |
||||
+ |
||||
if (!cg_test_mounted_fs()) |
||||
return ECGROUPNOTMOUNTED; |
||||
|
||||
- control_file = fopen(path, "r+e"); |
||||
+ ctl_file = open(path, O_RDWR | O_CLOEXEC); |
||||
|
||||
- if (!control_file) { |
||||
+ if (ctl_file == -1) { |
||||
if (errno == EPERM) { |
||||
/* |
||||
* We need to set the correct error value, does the |
||||
@@ -1512,6 +1517,7 @@ static int cg_set_control_value(char *path, const char *val) |
||||
*/ |
||||
char *path_dir_end; |
||||
char *tasks_path; |
||||
+ FILE *control_file; |
||||
|
||||
path_dir_end = strrchr(path, '/'); |
||||
if (path_dir_end == NULL) |
||||
@@ -1543,15 +1549,47 @@ static int cg_set_control_value(char *path, const char *val) |
||||
return ECGROUPVALUENOTEXIST; |
||||
} |
||||
|
||||
- if (fprintf(control_file, "%s", val) < 0) { |
||||
+ /* Split the multiline value into lines. */ |
||||
+ /* One line is a special case of multiline value. */ |
||||
+ str_val = strdup(val); |
||||
+ if (str_val == NULL) { |
||||
last_errno = errno; |
||||
- fclose(control_file); |
||||
+ close(ctl_file); |
||||
return ECGOTHER; |
||||
} |
||||
- if (fclose(control_file) < 0) { |
||||
+ |
||||
+ str_val_start = str_val; |
||||
+ pos = str_val; |
||||
+ |
||||
+ do { |
||||
+ str_val = pos; |
||||
+ pos = strchr(str_val, '\n'); |
||||
+ |
||||
+ if (pos) { |
||||
+ *pos = '\0'; |
||||
+ ++pos; |
||||
+ } |
||||
+ |
||||
+ len = strlen(str_val); |
||||
+ if (len > 0) { |
||||
+ if (write(ctl_file, str_val, len) == -1) { |
||||
+ last_errno = errno; |
||||
+ free(str_val_start); |
||||
+ close(ctl_file); |
||||
+ return ECGOTHER; |
||||
+ } |
||||
+ } else |
||||
+ cgroup_warn("Warning: skipping empty line for %s\n", |
||||
+ path); |
||||
+ } while(pos); |
||||
+ |
||||
+ if (close(ctl_file)) { |
||||
last_errno = errno; |
||||
+ free(str_val_start); |
||||
return ECGOTHER; |
||||
} |
||||
+ |
||||
+ free(str_val_start); |
||||
return 0; |
||||
} |
||||
|
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
From 982a59755252f8a263e8004a09eceb6fdfbd5242 Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Sat, 20 Sep 2014 21:06:33 +0200 |
||||
Subject: [PATCH] config.c: xfs file system sets item->d_type to zero, stat() |
||||
and S_ISREG() test added |
||||
|
||||
--- |
||||
src/tools/tools-common.c | 21 ++++++++++++++++----- |
||||
1 file changed, 16 insertions(+), 5 deletions(-) |
||||
|
||||
diff --git a/src/tools/tools-common.c b/src/tools/tools-common.c |
||||
index 211a49a..f1b7711 100644 |
||||
--- a/src/tools/tools-common.c |
||||
+++ b/src/tools/tools-common.c |
||||
@@ -201,17 +201,24 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list, |
||||
do { |
||||
errno = 0; |
||||
item = readdir(d); |
||||
- if (item && (item->d_type == DT_REG |
||||
- || item->d_type == DT_LNK)) { |
||||
- char *tmp; |
||||
+ |
||||
+ struct stat st; |
||||
+ |
||||
+ char * tmp; |
||||
+ |
||||
+ if (item) { |
||||
ret = asprintf(&tmp, "%s/%s", dirname, item->d_name); |
||||
if (ret < 0) { |
||||
fprintf(stderr, "%s: out of memory\n", |
||||
program_name); |
||||
exit(1); |
||||
} |
||||
- ret = cgroup_string_list_add_item(list, tmp); |
||||
- free(tmp); |
||||
+ } |
||||
+ |
||||
+ if (item && (item->d_type == DT_REG |
||||
+ || item->d_type == DT_LNK |
||||
+ || (stat(tmp, &st) >= 0 && S_ISREG(st.st_mode)) ) ) { |
||||
+ ret = cgroup_string_list_add_item(list, tmp); |
||||
count++; |
||||
if (ret) { |
||||
fprintf(stderr, "%s: %s\n", |
||||
@@ -225,6 +232,10 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list, |
||||
program_name, dirname, strerror(errno)); |
||||
exit(1); |
||||
} |
||||
+ |
||||
+ if (item) { |
||||
+ free(tmp); |
||||
+ } |
||||
} while (item != NULL); |
||||
closedir(d); |
||||
|
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
From c3b2fbe31273ea71a02c86e780f0f3c0a0fa845f Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Sat, 20 Sep 2014 23:46:57 +0200 |
||||
Subject: [PATCH] extending cgroup names with default |
||||
|
||||
--- |
||||
src/lex.l | 2 +- |
||||
src/parse.y | 14 ++++++++++++-- |
||||
2 files changed, 13 insertions(+), 3 deletions(-) |
||||
|
||||
diff --git a/src/lex.l b/src/lex.l |
||||
index 1b357db..ff2b3e5 100644 |
||||
--- a/src/lex.l |
||||
+++ b/src/lex.l |
||||
@@ -42,7 +42,7 @@ jmp_buf parser_error_env; |
||||
"group" {return GROUP;} |
||||
"namespace" {return NAMESPACE;} |
||||
"template" {return TEMPLATE;} |
||||
-"default" {return DEFAULT;} |
||||
+"default" {yylval.name = strdup(yytext); return DEFAULT;} |
||||
[a-zA-Z0-9_\-\/\.\,\%\@]+ {yylval.name = strdup(yytext); return ID;} |
||||
\"[^"]*\" {yylval.name = strdup(yytext+1); yylval.name[strlen(yylval.name)-1] = '\0'; return ID; } |
||||
. {return yytext[0];} |
||||
diff --git a/src/parse.y b/src/parse.y |
||||
index 9adbc0e..e67ad54 100644 |
||||
--- a/src/parse.y |
||||
+++ b/src/parse.y |
||||
@@ -45,7 +45,7 @@ int yywrap(void) |
||||
int val; |
||||
struct cgroup_dictionary *values; |
||||
} |
||||
-%type <name> ID |
||||
+%type <name> ID DEFAULT group_name |
||||
%type <val> mountvalue_conf mount task_namevalue_conf admin_namevalue_conf |
||||
%type <val> admin_conf task_conf task_or_admin group_conf group start |
||||
%type <val> namespace namespace_conf default default_conf |
||||
@@ -99,7 +99,7 @@ default_conf |
||||
} |
||||
; |
||||
|
||||
-group : GROUP ID '{' group_conf '}' |
||||
+group : GROUP group_name '{' group_conf '}' |
||||
{ |
||||
$$ = $4; |
||||
if ($$) { |
||||
@@ -119,6 +119,16 @@ group : GROUP ID '{' group_conf '}' |
||||
} |
||||
; |
||||
|
||||
+group_name |
||||
+ : ID |
||||
+ { |
||||
+ $$ = $1; |
||||
+ } |
||||
+ | DEFAULT |
||||
+ { |
||||
+ $$ = $1; |
||||
+ } |
||||
+ |
||||
group_conf |
||||
: ID '{' namevalue_conf '}' |
||||
{ |
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
From 1078505afde08447226d9439d2ec1fd822afba82 Mon Sep 17 00:00:00 2001 |
||||
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> |
||||
Date: Wed, 9 Dec 2015 11:00:30 +0100 |
||||
Subject: [PATCH] api.c: fix infinite loop |
||||
|
||||
If getgrnam or getpwuid functions failed, the program entered |
||||
an infinite loop, because the rule pointer was never advanced. |
||||
This is now fixed by updating the pointer before continuing |
||||
to the next iteration. |
||||
--- |
||||
src/api.c | 8 ++++++-- |
||||
1 file changed, 6 insertions(+), 2 deletions(-) |
||||
|
||||
diff --git a/src/api.c b/src/api.c |
||||
index e9500e0..aa912b6 100644 |
||||
--- a/src/api.c |
||||
+++ b/src/api.c |
||||
@@ -2699,13 +2699,17 @@ static struct cgroup_rule *cgroup_find_matching_rule_uid_gid(uid_t uid, |
||||
/* Get the group data. */ |
||||
sp = &(rule->username[1]); |
||||
grp = getgrnam(sp); |
||||
- if (!grp) |
||||
+ if (!grp) { |
||||
+ rule = rule->next; |
||||
continue; |
||||
+ } |
||||
|
||||
/* Get the data for UID. */ |
||||
usr = getpwuid(uid); |
||||
- if (!usr) |
||||
+ if (!usr) { |
||||
+ rule = rule->next; |
||||
continue; |
||||
+ } |
||||
|
||||
/* If UID is a member of group, we matched. */ |
||||
for (i = 0; grp->gr_mem[i]; i++) { |
||||
-- |
||||
2.13.6 |
||||
|
@ -0,0 +1,571 @@
@@ -0,0 +1,571 @@
|
||||
From 7b1b0409f5fc1828f0feb2086fe5b8184f7eb2c6 Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Sat, 20 Sep 2014 20:02:13 +0200 |
||||
Subject: [PATCH] loading configuration files from /etc/cgconfig.d/ directory |
||||
|
||||
--- |
||||
Makefile.in | 2 +- |
||||
doc/man/cgconfig.conf.5 | 7 +- |
||||
doc/man/cgrulesengd.8 | 8 +- |
||||
include/libcgroup/config.h | 21 ++++++ |
||||
src/config.c | 181 +++++++++++++++++++++++++++++++++++++++++++-- |
||||
src/daemon/Makefile.am | 4 +- |
||||
src/daemon/Makefile.in | 25 ++++++- |
||||
src/daemon/cgrulesengd.c | 51 +++++++++++-- |
||||
src/libcgroup-internal.h | 3 + |
||||
src/libcgroup.map | 5 ++ |
||||
src/tools/tools-common.h | 2 +- |
||||
11 files changed, 286 insertions(+), 23 deletions(-) |
||||
|
||||
diff --git a/Makefile.in b/Makefile.in |
||||
index af6e89c..0349c93 100644 |
||||
--- a/Makefile.in |
||||
+++ b/Makefile.in |
||||
@@ -84,7 +84,7 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ |
||||
$(srcdir)/config.h.in $(top_srcdir)/scripts/init.d/cgconfig.in \ |
||||
$(top_srcdir)/scripts/init.d/cgred.in \ |
||||
$(srcdir)/libcgroup.pc.in COPYING INSTALL README config.guess \ |
||||
- config.sub install-sh missing ltmain.sh |
||||
+ config.sub depcomp install-sh missing ylwrap ltmain.sh |
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.in |
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
||||
diff --git a/doc/man/cgconfig.conf.5 b/doc/man/cgconfig.conf.5 |
||||
index be80e4e..a7d9935 100644 |
||||
--- a/doc/man/cgconfig.conf.5 |
||||
+++ b/doc/man/cgconfig.conf.5 |
||||
@@ -251,6 +251,9 @@ Templates does not use |
||||
.B default |
||||
section settings. |
||||
|
||||
+.I /etc/cgconfig.d/ |
||||
+directory can be used for additional configuration files. cgrulesengd searches this directory for additional templates. |
||||
+ |
||||
.\"********************************************" |
||||
.SH EXAMPLES |
||||
.LP |
||||
@@ -783,10 +786,12 @@ related to them. |
||||
.SH FILES |
||||
.LP |
||||
.PD .1v |
||||
-.TP 20 |
||||
+.TP |
||||
.B /etc/cgconfig.conf |
||||
.TP |
||||
default libcgroup configuration file |
||||
+.B /etc/cgconfig.d/ |
||||
+default libcgroup configuration files directory |
||||
.PD |
||||
|
||||
.SH SEE ALSO |
||||
diff --git a/doc/man/cgrulesengd.8 b/doc/man/cgrulesengd.8 |
||||
index 2e89c5b..749b6fc 100644 |
||||
--- a/doc/man/cgrulesengd.8 |
||||
+++ b/doc/man/cgrulesengd.8 |
||||
@@ -65,10 +65,16 @@ controls verbosity of the tool. Allowed values are \fBDEBUG\fR, |
||||
.SH FILES |
||||
.LP |
||||
.PD .1v |
||||
-.TP 20 |
||||
+.TP |
||||
.B /etc/cgrules.conf |
||||
.TP |
||||
the default libcgroup configuration file |
||||
+.TP |
||||
+.B /etc/cgconfig.conf |
||||
+the default templates file |
||||
+.TP |
||||
+.B /etc/cgconfig.d/ |
||||
+the default templates directory |
||||
|
||||
.SH SEE ALSO |
||||
cgrules.conf (5) |
||||
diff --git a/include/libcgroup/config.h b/include/libcgroup/config.h |
||||
index 43568e1..9aaa390 100644 |
||||
--- a/include/libcgroup/config.h |
||||
+++ b/include/libcgroup/config.h |
||||
@@ -84,11 +84,32 @@ int cgroup_init_templates_cache(char *pathname); |
||||
int cgroup_reload_cached_templates(char *pathname); |
||||
|
||||
/** |
||||
+ * Load the templates cache from files. Before calling this function, |
||||
+ * cgroup_templates_cache_set_source_files has to be called first. |
||||
+ * @param file_index index of file which was unable to be parsed |
||||
+ * @return 0 on success, > 0 on error |
||||
+ */ |
||||
+int cgroup_load_templates_cache_from_files(int *file_index); |
||||
+ |
||||
+/** |
||||
+ * Setting source files of templates. This function has to be called before |
||||
+ * any call of cgroup_load_templates_cache_from_files. |
||||
+ * @param tmpl_files |
||||
+ */ |
||||
+struct cgroup_string_list; |
||||
+void cgroup_templates_cache_set_source_files( |
||||
+ struct cgroup_string_list *tmpl_files); |
||||
+ |
||||
+/** |
||||
* Physically create a new control group in kernel, based on given control |
||||
* group template and configuration file. If given template is not set in |
||||
* configuration file, then the procedure works create the control group |
||||
* using cgroup_create_cgroup() function |
||||
* |
||||
+ * Templates are loaded using cgroup_load_templates_cache_from_files |
||||
+ * function, which must be preceded by cgroup_templates_cache_set_source_files |
||||
+ * call. |
||||
+ * |
||||
* The flags can alter the behavior of this function: |
||||
* CGFLAG_USE_TEMPLATE_CACHE: Use cached templates instead of |
||||
* parsing the config file |
||||
diff --git a/src/config.c b/src/config.c |
||||
index e1ee0a8..1c5fc14 100644 |
||||
--- a/src/config.c |
||||
+++ b/src/config.c |
||||
@@ -41,6 +41,8 @@ |
||||
#include <sys/stat.h> |
||||
#include <sys/types.h> |
||||
|
||||
+#include "tools/tools-common.h" |
||||
+ |
||||
unsigned int MAX_CGROUPS = 64; /* NOTE: This value changes dynamically */ |
||||
unsigned int MAX_TEMPLATES = 64; |
||||
/* NOTE: This value changes dynamically */ |
||||
@@ -89,6 +91,7 @@ static int config_template_table_index; |
||||
*/ |
||||
static struct cgroup *template_table; |
||||
static int template_table_index; |
||||
+static struct cgroup_string_list *template_files; |
||||
|
||||
|
||||
/* |
||||
@@ -1572,6 +1575,161 @@ int cgroup_init_templates_cache(char *pathname) |
||||
|
||||
} |
||||
|
||||
+/** |
||||
+ * Setting source files of templates. This function has to be called before |
||||
+ * any call of cgroup_load_templates_cache_from_files. |
||||
+ * @param tmpl_files |
||||
+ */ |
||||
+void cgroup_templates_cache_set_source_files( |
||||
+ struct cgroup_string_list *tmpl_files) |
||||
+{ |
||||
+ template_files = tmpl_files; |
||||
+} |
||||
+ |
||||
+/** |
||||
+ * Appending cgroup templates parsed by parser to template_table |
||||
+ * @param offset number of templates already in the table |
||||
+ */ |
||||
+int cgroup_add_cgroup_templates(int offset) |
||||
+{ |
||||
+ int i, ti, ret; |
||||
+ |
||||
+ for (i = 0; i < config_template_table_index; i++) { |
||||
+ ti = i + offset; |
||||
+ ret = cgroup_copy_cgroup(&template_table[ti], |
||||
+ &config_template_table[i]); |
||||
+ if (ret) |
||||
+ return ret; |
||||
+ |
||||
+ strcpy((template_table[ti]).name, |
||||
+ (config_template_table[i]).name); |
||||
+ template_table[ti].tasks_uid = |
||||
+ config_template_table[i].tasks_uid; |
||||
+ template_table[ti].tasks_gid = |
||||
+ config_template_table[i].tasks_gid; |
||||
+ template_table[ti].task_fperm = |
||||
+ config_template_table[i].task_fperm; |
||||
+ template_table[ti].control_uid = |
||||
+ config_template_table[i].control_uid; |
||||
+ template_table[ti].control_gid = |
||||
+ config_template_table[i].control_gid; |
||||
+ template_table[ti].control_fperm = |
||||
+ config_template_table[i].control_fperm; |
||||
+ template_table[ti].control_dperm = |
||||
+ config_template_table[i].control_dperm; |
||||
+ } |
||||
+ |
||||
+ return 0; |
||||
+} |
||||
+ |
||||
+/** |
||||
+ * Expand template table based on new number of parsed templates, i.e. |
||||
+ * on value of config_template_table_index. |
||||
+ * Change value of template_table_index. |
||||
+ * @return 0 on success, < 0 on error |
||||
+ */ |
||||
+int cgroup_expand_template_table(void) |
||||
+{ |
||||
+ int i; |
||||
+ |
||||
+ template_table = realloc(template_table, |
||||
+ (template_table_index + config_template_table_index) |
||||
+ *sizeof(struct cgroup)); |
||||
+ |
||||
+ if (template_table == NULL) |
||||
+ return -ECGOTHER; |
||||
+ |
||||
+ for (i = 0; i < config_template_table_index; i++) |
||||
+ template_table[i + template_table_index].index = 0; |
||||
+ |
||||
+ template_table_index += config_template_table_index; |
||||
+ |
||||
+ return 0; |
||||
+} |
||||
+ |
||||
+/** |
||||
+ * Load the templates cache from files. Before calling this function, |
||||
+ * cgroup_templates_cache_set_source_files has to be called first. |
||||
+ * @param file_index index of file which was unable to be parsed |
||||
+ * @return 0 on success, > 0 on error |
||||
+ */ |
||||
+int cgroup_load_templates_cache_from_files(int *file_index) |
||||
+{ |
||||
+ int ret; |
||||
+ int i, j; |
||||
+ int template_table_last_index; |
||||
+ char *pathname; |
||||
+ |
||||
+ if (!template_files) { |
||||
+ /* source files has not been set */ |
||||
+ cgroup_dbg("Template source files have not been set. "); |
||||
+ cgroup_dbg("Using only %s\n", CGCONFIG_CONF_FILE); |
||||
+ |
||||
+ if (template_table_index == 0) |
||||
+ /* the rules cache is empty */ |
||||
+ return cgroup_init_templates_cache( |
||||
+ CGCONFIG_CONF_FILE); |
||||
+ else |
||||
+ /* cache is not empty */ |
||||
+ return cgroup_reload_cached_templates( |
||||
+ CGCONFIG_CONF_FILE); |
||||
+ } |
||||
+ |
||||
+ if (template_table) { |
||||
+ /* template structures have to be free */ |
||||
+ for (i = 0; i < template_table_index; i++) |
||||
+ cgroup_free_controllers(&template_table[i]); |
||||
+ free(template_table); |
||||
+ template_table = NULL; |
||||
+ } |
||||
+ template_table_index = 0; |
||||
+ |
||||
+ if ((config_template_table_index != 0) || (config_table_index != 0)) { |
||||
+ /* config structures have to be clean before parsing */ |
||||
+ cgroup_free_config(); |
||||
+ } |
||||
+ |
||||
+ for (j = 0; j < template_files->count; j++) { |
||||
+ pathname = template_files->items[j]; |
||||
+ |
||||
+ cgroup_dbg("Parsing templates from %s.\n", pathname); |
||||
+ /* Attempt to read the configuration file |
||||
+ * and cache the rules. */ |
||||
+ ret = cgroup_parse_config(pathname); |
||||
+ if (ret) { |
||||
+ cgroup_dbg("Could not initialize rule cache, "); |
||||
+ cgroup_dbg("error was: %d\n", ret); |
||||
+ *file_index = j; |
||||
+ return ret; |
||||
+ } |
||||
+ |
||||
+ if (config_template_table_index > 0) { |
||||
+ template_table_last_index = template_table_index; |
||||
+ ret = cgroup_expand_template_table(); |
||||
+ if (ret) { |
||||
+ cgroup_dbg("Could not expand template table, "); |
||||
+ cgroup_dbg("error was: %d\n", -ret); |
||||
+ *file_index = j; |
||||
+ return -ret; |
||||
+ } |
||||
+ |
||||
+ /* copy template data to templates cache structures */ |
||||
+ cgroup_dbg("Copying templates to template table "); |
||||
+ cgroup_dbg("from %s.\n", pathname); |
||||
+ ret = cgroup_add_cgroup_templates( |
||||
+ template_table_last_index); |
||||
+ if (ret) { |
||||
+ cgroup_dbg("Unable to copy cgroup\n"); |
||||
+ *file_index = j; |
||||
+ return ret; |
||||
+ } |
||||
+ cgroup_dbg("Templates to template table copied\n"); |
||||
+ } |
||||
+ } |
||||
+ |
||||
+ return 0; |
||||
+} |
||||
+ |
||||
/* |
||||
* Create a given cgroup, based on template configuration if it is present |
||||
* if the template is not present cgroup is creted using cgroup_create_cgroup |
||||
@@ -1593,13 +1751,22 @@ int cgroup_config_create_template_group(struct cgroup *cgroup, |
||||
* use CGCONFIG_CONF_FILE by default |
||||
*/ |
||||
if (!(flags & CGFLAG_USE_TEMPLATE_CACHE)) { |
||||
- if (template_table_index == 0) |
||||
- /* the rules cache is empty */ |
||||
- ret = cgroup_init_templates_cache(CGCONFIG_CONF_FILE); |
||||
- else |
||||
- /* cache is not empty */ |
||||
- ret = cgroup_reload_cached_templates( |
||||
- CGCONFIG_CONF_FILE); |
||||
+ int fileindex; |
||||
+ |
||||
+ /* the rules cache is empty */ |
||||
+ ret = cgroup_load_templates_cache_from_files( |
||||
+ &fileindex); |
||||
+ if (ret != 0) { |
||||
+ if (fileindex < 0) { |
||||
+ cgroup_dbg("Error: Template source files "); |
||||
+ cgroup_dbg("have not been set\n"); |
||||
+ } else { |
||||
+ cgroup_dbg("Error: Failed to load template"); |
||||
+ cgroup_dbg("rules from %s. ", |
||||
+ template_files->items[fileindex]); |
||||
+ } |
||||
+ } |
||||
+ |
||||
if (ret != 0) { |
||||
cgroup_dbg("Failed initialize templates cache.\n"); |
||||
return ret; |
||||
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am |
||||
index f3100ed..abbbe30 100644 |
||||
--- a/src/daemon/Makefile.am |
||||
+++ b/src/daemon/Makefile.am |
||||
@@ -1,9 +1,9 @@ |
||||
-INCLUDES = -I $(top_srcdir)/include |
||||
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include |
||||
|
||||
if WITH_DAEMON |
||||
|
||||
sbin_PROGRAMS = cgrulesengd |
||||
-cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h |
||||
+cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h ../tools/tools-common.h ../tools/tools-common.c |
||||
cgrulesengd_LDADD = $(top_builddir)/src/.libs/libcgroup.la -lrt |
||||
cgrulesengd_LDFLAGS = -L$(top_builddir)/src/.libs |
||||
|
||||
diff --git a/src/daemon/Makefile.in b/src/daemon/Makefile.in |
||||
index 76f7e07..f3efc65 100644 |
||||
--- a/src/daemon/Makefile.in |
||||
+++ b/src/daemon/Makefile.in |
||||
@@ -92,8 +92,10 @@ CONFIG_CLEAN_FILES = |
||||
CONFIG_CLEAN_VPATH_FILES = |
||||
am__installdirs = "$(DESTDIR)$(sbindir)" |
||||
PROGRAMS = $(sbin_PROGRAMS) |
||||
-am__cgrulesengd_SOURCES_DIST = cgrulesengd.c cgrulesengd.h |
||||
-@WITH_DAEMON_TRUE@am_cgrulesengd_OBJECTS = cgrulesengd.$(OBJEXT) |
||||
+am__cgrulesengd_SOURCES_DIST = cgrulesengd.c cgrulesengd.h \ |
||||
+ ../tools/tools-common.h ../tools/tools-common.c |
||||
+@WITH_DAEMON_TRUE@am_cgrulesengd_OBJECTS = cgrulesengd.$(OBJEXT) \ |
||||
+@WITH_DAEMON_TRUE@ tools-common.$(OBJEXT) |
||||
cgrulesengd_OBJECTS = $(am_cgrulesengd_OBJECTS) |
||||
@WITH_DAEMON_TRUE@cgrulesengd_DEPENDENCIES = \ |
||||
@WITH_DAEMON_TRUE@ $(top_builddir)/src/.libs/libcgroup.la |
||||
@@ -294,8 +296,8 @@ target_alias = @target_alias@ |
||||
top_build_prefix = @top_build_prefix@ |
||||
top_builddir = @top_builddir@ |
||||
top_srcdir = @top_srcdir@ |
||||
-INCLUDES = -I $(top_srcdir)/include |
||||
-@WITH_DAEMON_TRUE@cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h |
||||
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include |
||||
+@WITH_DAEMON_TRUE@cgrulesengd_SOURCES = cgrulesengd.c cgrulesengd.h ../tools/tools-common.h ../tools/tools-common.c |
||||
@WITH_DAEMON_TRUE@cgrulesengd_LDADD = $(top_builddir)/src/.libs/libcgroup.la -lrt |
||||
@WITH_DAEMON_TRUE@cgrulesengd_LDFLAGS = -L$(top_builddir)/src/.libs |
||||
all: all-am |
||||
@@ -393,6 +395,7 @@ distclean-compile: |
||||
-rm -f *.tab.c |
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cgrulesengd.Po@am__quote@ |
||||
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools-common.Po@am__quote@ |
||||
|
||||
.c.o: |
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
||||
@@ -415,6 +418,20 @@ distclean-compile: |
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< |
||||
|
||||
+tools-common.o: ../tools/tools-common.c |
||||
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools-common.o -MD -MP -MF $(DEPDIR)/tools-common.Tpo -c -o tools-common.o `test -f '../tools/tools-common.c' || echo '$(srcdir)/'`../tools/tools-common.c |
||||
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tools-common.Tpo $(DEPDIR)/tools-common.Po |
||||
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../tools/tools-common.c' object='tools-common.o' libtool=no @AMDEPBACKSLASH@ |
||||
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
||||
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools-common.o `test -f '../tools/tools-common.c' || echo '$(srcdir)/'`../tools/tools-common.c |
||||
+ |
||||
+tools-common.obj: ../tools/tools-common.c |
||||
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools-common.obj -MD -MP -MF $(DEPDIR)/tools-common.Tpo -c -o tools-common.obj `if test -f '../tools/tools-common.c'; then $(CYGPATH_W) '../tools/tools-common.c'; else $(CYGPATH_W) '$(srcdir)/../tools/tools-common.c'; fi` |
||||
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tools-common.Tpo $(DEPDIR)/tools-common.Po |
||||
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../tools/tools-common.c' object='tools-common.obj' libtool=no @AMDEPBACKSLASH@ |
||||
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
||||
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools-common.obj `if test -f '../tools/tools-common.c'; then $(CYGPATH_W) '../tools/tools-common.c'; else $(CYGPATH_W) '$(srcdir)/../tools/tools-common.c'; fi` |
||||
+ |
||||
mostlyclean-libtool: |
||||
-rm -f *.lo |
||||
|
||||
diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c |
||||
index 170837a..d959eff 100644 |
||||
--- a/src/daemon/cgrulesengd.c |
||||
+++ b/src/daemon/cgrulesengd.c |
||||
@@ -34,6 +34,7 @@ |
||||
#include "libcgroup.h" |
||||
#include "cgrulesengd.h" |
||||
#include "../libcgroup-internal.h" |
||||
+#include "../tools/tools-common.h" |
||||
|
||||
#include <errno.h> |
||||
#include <stdarg.h> |
||||
@@ -59,6 +60,9 @@ |
||||
|
||||
#define NUM_PER_REALLOCATIOM (100) |
||||
|
||||
+/* list of config files from CGCONFIG_CONF_FILE and CGCONFIG_CONF_DIR */ |
||||
+static struct cgroup_string_list template_files; |
||||
+ |
||||
/* Log file, NULL if logging to file is disabled */ |
||||
FILE* logfile; |
||||
|
||||
@@ -936,6 +940,8 @@ void cgre_flash_rules(int signum) |
||||
/* Current time */ |
||||
time_t tm = time(0); |
||||
|
||||
+ int fileindex; |
||||
+ |
||||
flog(LOG_INFO, "Reloading rules configuration\n"); |
||||
flog(LOG_DEBUG, "Current time: %s\n", ctime(&tm)); |
||||
|
||||
@@ -949,7 +955,7 @@ void cgre_flash_rules(int signum) |
||||
} |
||||
|
||||
/* Ask libcgroup to reload the template rules table. */ |
||||
- cgroup_reload_cached_templates(CGCONFIG_CONF_FILE); |
||||
+ cgroup_load_templates_cache_from_files(&fileindex); |
||||
} |
||||
|
||||
/** |
||||
@@ -962,11 +968,13 @@ void cgre_flash_templates(int signum) |
||||
/* Current time */ |
||||
time_t tm = time(0); |
||||
|
||||
+ int fileindex; |
||||
+ |
||||
flog(LOG_INFO, "Reloading templates configuration.\n"); |
||||
flog(LOG_DEBUG, "Current time: %s\n", ctime(&tm)); |
||||
|
||||
/* Ask libcgroup to reload the templates table. */ |
||||
- cgroup_reload_cached_templates(CGCONFIG_CONF_FILE); |
||||
+ cgroup_load_templates_cache_from_files(&fileindex); |
||||
} |
||||
|
||||
/** |
||||
@@ -1069,6 +1077,8 @@ int main(int argc, char *argv[]) |
||||
{NULL, 0, NULL, 0} |
||||
}; |
||||
|
||||
+ int fileindex; |
||||
+ |
||||
/* Make sure the user is root. */ |
||||
if (getuid() != 0) { |
||||
fprintf(stderr, "Error: Only root can start/stop the control" |
||||
@@ -1180,6 +1190,25 @@ int main(int argc, char *argv[]) |
||||
} |
||||
|
||||
/* Ask libcgroup to load the configuration rules. */ |
||||
+ ret = cgroup_string_list_init(&template_files, |
||||
+ CGCONFIG_CONF_FILES_LIST_MINIMUM_SIZE); |
||||
+ if (ret) { |
||||
+ fprintf(stderr, "%s: cannot init file list, out of memory?\n", |
||||
+ argv[0]); |
||||
+ goto finished_without_temp_files; |
||||
+ } |
||||
+ /* first add CGCONFIG_CONF_FILE into file list */ |
||||
+ ret = cgroup_string_list_add_item(&template_files, CGCONFIG_CONF_FILE); |
||||
+ if (ret) { |
||||
+ fprintf(stderr, "%s: cannot add file to list, out of memory?\n" |
||||
+ , argv[0]); |
||||
+ goto finished; |
||||
+ } |
||||
+ |
||||
+ /* then read CGCONFIG_CONF_DIR directory for additional config files */ |
||||
+ cgroup_string_list_add_directory(&template_files, CGCONFIG_CONF_DIR, |
||||
+ argv[0]); |
||||
+ |
||||
if ((ret = cgroup_init_rules_cache()) != 0) { |
||||
fprintf(stderr, "Error: libcgroup failed to initialize rules" |
||||
"cache from %s. %s\n", CGRULES_CONF_FILE, |
||||
@@ -1188,11 +1217,18 @@ int main(int argc, char *argv[]) |
||||
} |
||||
|
||||
/* ask libcgroup to load template rules as well */ |
||||
- ret = cgroup_init_templates_cache(CGCONFIG_CONF_FILE); |
||||
+ cgroup_templates_cache_set_source_files(&template_files); |
||||
+ ret = cgroup_load_templates_cache_from_files(&fileindex); |
||||
if (ret != 0) { |
||||
- fprintf(stderr, "Error: libcgroup failed to initialize teplate"\ |
||||
- "rules from %s. %s\n", CGCONFIG_CONF_FILE, |
||||
- cgroup_strerror(ret)); |
||||
+ if (fileindex < 0) { |
||||
+ fprintf(stderr, "Error: Template source files "); |
||||
+ fprintf(stderr, "have not been set\n"); |
||||
+ } else { |
||||
+ fprintf(stderr, "Error: Failed to initialize template"); |
||||
+ fprintf(stderr, "rules from %s. ", |
||||
+ template_files.items[fileindex]); |
||||
+ fprintf(stderr, "%s\n", cgroup_strerror(-ret)); |
||||
+ } |
||||
goto finished; |
||||
} |
||||
|
||||
@@ -1259,6 +1295,9 @@ int main(int argc, char *argv[]) |
||||
ret = cgre_create_netlink_socket_process_msg(); |
||||
|
||||
finished: |
||||
+ cgroup_string_list_free(&template_files); |
||||
+ |
||||
+finished_without_temp_files: |
||||
if (logfile && logfile != stdout) |
||||
fclose(logfile); |
||||
|
||||
diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h |
||||
index 4c0f46c..c128788 100644 |
||||
--- a/src/libcgroup-internal.h |
||||
+++ b/src/libcgroup-internal.h |
||||
@@ -48,6 +48,9 @@ __BEGIN_DECLS |
||||
|
||||
|
||||
#define CGCONFIG_CONF_FILE "/etc/cgconfig.conf" |
||||
+/* Minimum number of file in template file list for cgrulesengd */ |
||||
+#define CGCONFIG_CONF_FILES_LIST_MINIMUM_SIZE 4 |
||||
+#define CGCONFIG_CONF_DIR "/etc/cgconfig.d" |
||||
|
||||
#define CGRULES_CONF_FILE "/etc/cgrules.conf" |
||||
#define CGRULES_MAX_FIELDS_PER_LINE 3 |
||||
diff --git a/src/libcgroup.map b/src/libcgroup.map |
||||
index b0c162c..f8b0fb9 100644 |
||||
--- a/src/libcgroup.map |
||||
+++ b/src/libcgroup.map |
||||
@@ -117,3 +117,8 @@ CGROUP_0.39 { |
||||
cgroup_log; |
||||
cgroup_parse_log_level_str; |
||||
} CGROUP_0.38; |
||||
+ |
||||
+CGROUP_0.40 { |
||||
+ cgroup_templates_cache_set_source_files; |
||||
+ cgroup_load_templates_cache_from_files; |
||||
+} CGROUP_0.39; |
||||
diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h |
||||
index e05465f..c723eb4 100644 |
||||
--- a/src/tools/tools-common.h |
||||
+++ b/src/tools/tools-common.h |
||||
@@ -20,7 +20,7 @@ |
||||
|
||||
#include "config.h" |
||||
#include <libcgroup.h> |
||||
-#include <libcgroup-internal.h> |
||||
+#include "../libcgroup-internal.h" |
||||
|
||||
#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, x) |
||||
#define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, x) |
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
From 92597b479aeb46c6dc630353de16328c365ff083 Mon Sep 17 00:00:00 2001 |
||||
From: jchaloup <jchaloup@redhat.com> |
||||
Date: Fri, 14 Feb 2014 10:29:33 +0100 |
||||
Subject: [PATCH] runlibcgrouptest script updated to ignore systemd |
||||
|
||||
--- |
||||
tests/runlibcgrouptest.sh | 2 +- |
||||
tests/runlibcgrouptest.sh.in | 2 +- |
||||
2 files changed, 2 insertions(+), 2 deletions(-) |
||||
|
||||
diff --git a/tests/runlibcgrouptest.sh b/tests/runlibcgrouptest.sh |
||||
index 221729c..605f045 100644 |
||||
--- a/tests/runlibcgrouptest.sh |
||||
+++ b/tests/runlibcgrouptest.sh |
||||
@@ -48,7 +48,7 @@ debug() |
||||
check_mount_fs () |
||||
{ |
||||
local NUM_MOUNT=0; |
||||
- CGROUP=`cat /proc/mounts|grep -w ^cgroup|tr -s [:space:]|cut -d" " -f3`; |
||||
+ CGROUP=`cat /proc/mounts|grep -w ^cgroup|grep -v systemd|tr -s [:space:]|cut -d" " -f3`; |
||||
|
||||
# get first word in case of multiple mounts |
||||
CGROUP=`echo $CGROUP|cut -d" " -f1`; |
||||
diff --git a/tests/runlibcgrouptest.sh.in b/tests/runlibcgrouptest.sh.in |
||||
index 119addd..8a57881 100755 |
||||
--- a/tests/runlibcgrouptest.sh.in |
||||
+++ b/tests/runlibcgrouptest.sh.in |
||||
@@ -48,7 +48,7 @@ debug() |
||||
check_mount_fs () |
||||
{ |
||||
local NUM_MOUNT=0; |
||||
- CGROUP=`cat /proc/mounts|grep -w ^cgroup|tr -s [:space:]|cut -d" " -f3`; |
||||
+ CGROUP=`cat /proc/mounts|grep -w ^cgroup|grep -v systemd|tr -s [:space:]|cut -d" " -f3`; |
||||
|
||||
# get first word in case of multiple mounts |
||||
CGROUP=`echo $CGROUP|cut -d" " -f1`; |
||||
-- |
||||
1.8.5.3 |
||||
|
@ -0,0 +1,179 @@
@@ -0,0 +1,179 @@
|
||||
From 2102de58417416a3051fee17e012964b56971fb3 Mon Sep 17 00:00:00 2001 |
||||
From: Jan Chaloupka <jchaloup@redhat.com> |
||||
Date: Sat, 20 Sep 2014 19:13:01 +0200 |
||||
Subject: [PATCH] use * character as a meta character for all mounted |
||||
controllers |
||||
|
||||
--- |
||||
doc/man/cgcreate.1 | 3 ++- |
||||
include/libcgroup/groups.h | 10 ++++++++++ |
||||
src/libcgroup.map | 7 +++++++ |
||||
src/tools/cgcreate.c | 32 +++++++++++++++++++---------- |
||||
src/wrapper.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ |
||||
5 files changed, 91 insertions(+), 11 deletions(-) |
||||
|
||||
diff --git a/doc/man/cgcreate.1 b/doc/man/cgcreate.1 |
||||
index 7068073..557b5ae 100644 |
||||
--- a/doc/man/cgcreate.1 |
||||
+++ b/doc/man/cgcreate.1 |
||||
@@ -38,7 +38,8 @@ others permissions to the owners permissions). |
||||
.TP |
||||
.B -g <controllers>:<path> |
||||
defines control groups to be added. |
||||
-\fBcontrollers\fR is a list of controllers and |
||||
+\fBcontrollers\fR is a list of controllers. Character "*" can be used |
||||
+as a shortcut for "all mounted controllers". |
||||
\fBpath\fR is the relative path to control groups |
||||
in the given controllers list. This option can be specified |
||||
multiple times. |
||||
diff --git a/include/libcgroup/groups.h b/include/libcgroup/groups.h |
||||
index d5c87aa..201558f 100644 |
||||
--- a/include/libcgroup/groups.h |
||||
+++ b/include/libcgroup/groups.h |
||||
@@ -150,6 +150,16 @@ struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup, |
||||
const char *name); |
||||
|
||||
/** |
||||
+ * Attach all mounted controllers to given cgroup. This function just modifies |
||||
+ * internal libcgroup structure, not the kernel control group. |
||||
+ * |
||||
+ * @param cgroup |
||||
+ * @return zero or error number |
||||
+ */ |
||||
+int cgroup_add_all_controllers(struct cgroup *cgroup); |
||||
+ |
||||
+ |
||||
+/** |
||||
* Return appropriate controller from given group. |
||||
* The controller must be added before using cgroup_add_controller() or loaded |
||||
* from kernel using cgroup_get_cgroup(). |
||||
diff --git a/src/libcgroup.map b/src/libcgroup.map |
||||
index f8b0fb9..8fe1990 100644 |
||||
--- a/src/libcgroup.map |
||||
+++ b/src/libcgroup.map |
||||
@@ -122,3 +122,10 @@ CGROUP_0.40 { |
||||
cgroup_templates_cache_set_source_files; |
||||
cgroup_load_templates_cache_from_files; |
||||
} CGROUP_0.39; |
||||
+ |
||||
+CGROUP_0.41 { |
||||
+} CGROUP_0.40; |
||||
+ |
||||
+CGROUP_0.42 { |
||||
+ cgroup_add_all_controllers; |
||||
+} CGROUP_0.41; |
||||
diff --git a/src/tools/cgcreate.c b/src/tools/cgcreate.c |
||||
index 73abd91..65b188a 100644 |
||||
--- a/src/tools/cgcreate.c |
||||
+++ b/src/tools/cgcreate.c |
||||
@@ -54,7 +54,6 @@ static void usage(int status, const char *program_name) |
||||
printf(" -t <tuid>:<tgid> Owner of the tasks file\n"); |
||||
} |
||||
|
||||
- |
||||
int main(int argc, char *argv[]) |
||||
{ |
||||
int ret = 0; |
||||
@@ -195,16 +194,29 @@ int main(int argc, char *argv[]) |
||||
/* add controllers to the new cgroup */ |
||||
j = 0; |
||||
while (cgroup_list[i]->controllers[j]) { |
||||
- cgc = cgroup_add_controller(cgroup, |
||||
- cgroup_list[i]->controllers[j]); |
||||
- if (!cgc) { |
||||
- ret = ECGINVAL; |
||||
- fprintf(stderr, "%s: " |
||||
- "controller %s can't be add\n", |
||||
- argv[0], |
||||
+ if (strcmp(cgroup_list[i]->controllers[j], "*") == 0) { |
||||
+ /* it is meta character, add all controllers */ |
||||
+ ret = cgroup_add_all_controllers(cgroup); |
||||
+ if (ret != 0) { |
||||
+ ret = ECGINVAL; |
||||
+ fprintf(stderr, "%s: can't add ", |
||||
+ argv[0]); |
||||
+ fprintf(stderr, "all controllers\n"); |
||||
+ cgroup_free(&cgroup); |
||||
+ goto err; |
||||
+ } |
||||
+ } else { |
||||
+ cgc = cgroup_add_controller(cgroup, |
||||
cgroup_list[i]->controllers[j]); |
||||
- cgroup_free(&cgroup); |
||||
- goto err; |
||||
+ if (!cgc) { |
||||
+ ret = ECGINVAL; |
||||
+ fprintf(stderr, "%s: ", argv[0]); |
||||
+ fprintf(stderr, "controller %s", |
||||
+ cgroup_list[i]->controllers[j]); |
||||
+ fprintf(stderr, "can't be add\n"); |
||||
+ cgroup_free(&cgroup); |
||||
+ goto err; |
||||
+ } |
||||
} |
||||
j++; |
||||
} |
||||
diff --git a/src/wrapper.c b/src/wrapper.c |
||||
index c03472a..3a9331f 100644 |
||||
--- a/src/wrapper.c |
||||
+++ b/src/wrapper.c |
||||
@@ -92,6 +92,56 @@ struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup, |
||||
return controller; |
||||
} |
||||
|
||||
+int cgroup_add_all_controllers(struct cgroup *cgroup) |
||||
+{ |
||||
+ int ret; |
||||
+ void *handle; |
||||
+ struct controller_data info; |
||||
+ struct cgroup_controller *cgc; |
||||
+ |
||||
+ /* go through the controller list */ |
||||
+ ret = cgroup_get_all_controller_begin(&handle, &info); |
||||
+ if ((ret != 0) && (ret != ECGEOF)) { |
||||
+ fprintf(stderr, "cannot read controller data: %s\n", |
||||
+ cgroup_strerror(ret)); |
||||
+ return ret; |
||||
+ } |
||||
+ |
||||
+ while (ret == 0) { |
||||
+ if (info.hierarchy == 0) { |
||||
+ /* the controller is not attached to any hierarchy |
||||
+ skip it */ |
||||
+ goto next; |
||||
+ } |
||||
+ |
||||
+ /* add mounted controller to cgroup structure */ |
||||
+ cgc = cgroup_add_controller(cgroup, info.name); |
||||
+ if (!cgc) { |
||||
+ ret = ECGINVAL; |
||||
+ fprintf(stderr, "controller %s can't be add\n", |
||||
+ info.name); |
||||
+ } |
||||
+ |
||||
+next: |
||||
+ ret = cgroup_get_all_controller_next(&handle, &info); |
||||
+ if (ret && ret != ECGEOF) |
||||
+ goto end; |
||||
+ } |
||||
+ |
||||
+end: |
||||
+ cgroup_get_all_controller_end(&handle); |
||||
+ |
||||
+ if (ret == ECGEOF) |
||||
+ ret = 0; |
||||
+ |
||||
+ if (ret) |
||||
+ fprintf(stderr, |
||||
+ "cgroup_get_controller_begin/next failed (%s)\n", |
||||
+ cgroup_strerror(ret)); |
||||
+ |
||||
+ return ret; |
||||
+} |
||||
+ |
||||
void cgroup_free_controllers(struct cgroup *cgroup) |
||||
{ |
||||
int i, j; |
||||
-- |
||||
1.9.3 |
||||
|
@ -0,0 +1,419 @@
@@ -0,0 +1,419 @@
|
||||
%global soversion_major 1 |
||||
%global soversion 1.0.41 |
||||
%global _hardened_build 1 |
||||
|
||||
Summary: Library to control and monitor control groups |
||||
Name: libcgroup |
||||
Version: 0.41 |
||||
Release: 15%{?dist} |
||||
License: LGPLv2+ |
||||
Group: Development/Libraries |
||||
URL: http://libcg.sourceforge.net/ |
||||
Source0: http://downloads.sourceforge.net/libcg/%{name}-%{version}.tar.bz2 |
||||
Source1: cgconfig.service |
||||
Source2: cgred.service |
||||
Source3: cgred.sysconfig |
||||
|
||||
Patch0: fedora-config.patch |
||||
Patch1: libcgroup-0.37-chmod.patch |
||||
Patch2: libcgroup-0.40.rc1-coverity.patch |
||||
Patch3: libcgroup-0.40.rc1-fread.patch |
||||
Patch4: libcgroup-0.40.rc1-templates-fix.patch |
||||
Patch5: libcgroup-0.41-runlibcgrouptest-systemd-fix.patch |
||||
Patch6: libcgroup-0.40.rc1-retry-to-set-control-file.patch |
||||
Patch7: libcgroup-0.41-config.c-xfs-file-system-sets-item-d_type-to-zero-st.patch |
||||
Patch8: libcgroup-0.41-loading-configuration-files-from-etc-cgconfig.d-dire.patch |
||||
Patch9: libcgroup-0.41-use-character-as-a-meta-character-for-all-mounted-co.patch |
||||
Patch10: libcgroup-0.41-add-examples-to-man-pages.patch |
||||
Patch11: libcgroup-0.41-extending-cgroup-names-with-default.patch |
||||
Patch12: libcgroup-0.41-api.c-support-for-setting-multiline-values-in-contro.patch |
||||
|
||||
# resolves #1348864 |
||||
Patch13: libcgroup-0.41-api.c-fix-order-of-memory-subsystem-parameters.patch |
||||
# resolves #1347765 |
||||
Patch14: libcgroup-0.41-api.c-fix-potential-buffer-overflow.patch |
||||
# resolves #1406927 |
||||
Patch15: libcgroup-0.41-api.c-fix-log-level.patch |
||||
# resolves #1384390 |
||||
Patch16: libcgroup-0.41-api.c-preserve-dirty-flag.patch |
||||
# resolves #1505443 |
||||
Patch17: libcgroup-0.41-infinite-loop.patch |
||||
|
||||
BuildRequires: byacc, coreutils, flex, pam-devel, systemd |
||||
Requires(pre): shadow-utils |
||||
Requires(post): systemd |
||||
Requires(preun): systemd |
||||
Requires(postun): systemd |
||||
|
||||
%description |
||||
Control groups infrastructure. The library helps manipulate, control, |
||||
administrate and monitor control groups and the associated controllers. |
||||
|
||||
%package tools |
||||
Summary: Command-line utility programs, services and daemons for libcgroup |
||||
Group: System Environment/Base |
||||
Requires: %{name}%{?_isa} = %{version}-%{release} |
||||
# needed for Delegate property in cgconfig.service |
||||
Requires: systemd >= 217-0.2 |
||||
|
||||
%description tools |
||||
This package contains command-line programs, services and a daemon for |
||||
manipulating control groups using the libcgroup library. |
||||
|
||||
%package pam |
||||
Summary: A Pluggable Authentication Module for libcgroup |
||||
Group: System Environment/Base |
||||
Requires: %{name}%{?_isa} = %{version}-%{release} |
||||
|
||||
%description pam |
||||
Linux-PAM module, which allows administrators to classify the user's login |
||||
processes to pre-configured control group. |
||||
|
||||
%package devel |
||||
Summary: Development libraries to develop applications that utilize control groups |
||||
Group: Development/Libraries |
||||
Requires: %{name}%{?_isa} = %{version}-%{release} |
||||
|
||||
%description devel |
||||
It provides API to create/delete and modify cgroup nodes. It will also in the |
||||
future allow creation of persistent configuration for control groups and |
||||
provide scripts to manage that configuration. |
||||
|
||||
%prep |
||||
%setup -q -n %{name}-%{version} |
||||
%patch0 -p1 -b .config-patch |
||||
%patch1 -p1 -b .chmod |
||||
%patch2 -p1 -b .coverity |
||||
%patch3 -p1 -b .fread |
||||
%patch4 -p1 -b .templates-fix |
||||
%patch5 -p1 -b .runlibcgrouptest-systemd-fix |
||||
%patch6 -p1 |
||||
%patch7 -p1 |
||||
%patch8 -p1 |
||||
%patch9 -p1 |
||||
%patch10 -p1 |
||||
%patch11 -p1 |
||||
%patch12 -p1 |
||||
%patch13 -p1 |
||||
%patch14 -p1 |
||||
%patch15 -p1 |
||||
%patch16 -p1 |
||||
%patch17 -p1 |
||||
|
||||
%build |
||||
%configure --enable-pam-module-dir=%{_libdir}/security \ |
||||
--enable-opaque-hierarchy="name=systemd" |
||||
# --disable-daemon |
||||
make %{?_smp_mflags} |
||||
|
||||
%install |
||||
make DESTDIR=$RPM_BUILD_ROOT install |
||||
|
||||
# install config files |
||||
install -d ${RPM_BUILD_ROOT}%{_sysconfdir} |
||||
install -m 644 samples/cgconfig.conf $RPM_BUILD_ROOT/%{_sysconfdir}/cgconfig.conf |
||||
install -d $RPM_BUILD_ROOT/%{_sysconfdir}/cgconfig.d |
||||
install -m 644 samples/cgrules.conf $RPM_BUILD_ROOT/%{_sysconfdir}/cgrules.conf |
||||
install -m 644 samples/cgsnapshot_blacklist.conf $RPM_BUILD_ROOT/%{_sysconfdir}/cgsnapshot_blacklist.conf |
||||
|
||||
# sanitize pam module, we need only pam_cgroup.so |
||||
mv -f $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so.*.*.* $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so |
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.la $RPM_BUILD_ROOT/%{_libdir}/security/pam_cgroup.so.* |
||||
|
||||
rm -f $RPM_BUILD_ROOT/%{_libdir}/*.la |
||||
|
||||
# install unit and sysconfig files |
||||
install -d ${RPM_BUILD_ROOT}%{_unitdir} |
||||
install -m 644 %SOURCE1 ${RPM_BUILD_ROOT}%{_unitdir}/ |
||||
install -m 644 %SOURCE2 ${RPM_BUILD_ROOT}%{_unitdir}/ |
||||
install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig |
||||
install -m 644 %SOURCE3 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/cgred |
||||
|
||||
%pre |
||||
getent group cgred >/dev/null || groupadd -r cgred |
||||
|
||||
%post -p /sbin/ldconfig |
||||
|
||||
%postun -p /sbin/ldconfig |
||||
|
||||
%pre tools |
||||
getent group cgred >/dev/null || groupadd -r cgred |
||||
|
||||
%post tools |
||||
if [ $1 -eq 1 ] ; then |
||||
# Initial installation |
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : |
||||
fi |
||||
%systemd_post cgconfig.service cgred.service |
||||
|
||||
%preun tools |
||||
if [ $1 -eq 0 ] ; then |
||||
# Package removal, not upgrade |
||||
/bin/systemctl --no-reload disable cgconfig.service > /dev/null 2>&1 || : |
||||
/bin/systemctl stop cgconfig.service > /dev/null 2>&1 || : |
||||
/bin/systemctl --no-reload disable cgred.service > /dev/null 2>&1 || : |
||||
/bin/systemctl stop cgred.service > /dev/null 2>&1 || : |
||||
fi |
||||
%systemd_preun cgconfig.service cgred.service |
||||
|
||||
%postun tools |
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : |
||||
if [ $1 -ge 1 ] ; then |
||||
# Package upgrade, not uninstall |
||||
/bin/systemctl try-restart cgconfig.service >/dev/null 2>&1 || : |
||||
/bin/systemctl try-restart cgred.service >/dev/null 2>&1 || : |
||||
fi |
||||
%systemd_postun_with_restart cgconfig.service cgred.service |
||||
|
||||
%triggerun -- libcgroup < 0.38 |
||||
# Save the current service runlevel info |
||||
# User must manually run systemd-sysv-convert --apply cgconfig/cgred |
||||
# to migrate them to systemd targets |
||||
/usr/bin/systemd-sysv-convert --save cgconfig >/dev/null 2>&1 ||: |
||||
/usr/bin/systemd-sysv-convert --save cgred >/dev/null 2>&1 ||: |
||||
|
||||
# Run these because the SysV package being removed won't do them |
||||
/sbin/chkconfig --del cgconfig >/dev/null 2>&1 || : |
||||
/bin/systemctl try-restart cgconfig.service >/dev/null 2>&1 || : |
||||
/sbin/chkconfig --del cgred >/dev/null 2>&1 || : |
||||
/bin/systemctl try-restart cgred.service >/dev/null 2>&1 || : |
||||
|
||||
%files |
||||
%doc COPYING README |
||||
%{_libdir}/libcgroup.so.* |
||||
|
||||
%files tools |
||||
%doc COPYING README README_systemd |
||||
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/cgconfig.conf |
||||
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/cgconfig.d |
||||
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/cgrules.conf |
||||
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/cgsnapshot_blacklist.conf |
||||
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/sysconfig/cgred |
||||
/usr/bin/cgcreate |
||||
/usr/bin/cgget |
||||
/usr/bin/cgset |
||||
/usr/bin/cgdelete |
||||
/usr/bin/lscgroup |
||||
/usr/bin/lssubsys |
||||
/usr/sbin/cgconfigparser |
||||
/usr/sbin/cgrulesengd |
||||
/usr/sbin/cgclear |
||||
/usr/bin/cgsnapshot |
||||
%attr(2755, root, cgred) /usr/bin/cgexec |
||||
%attr(2755, root, cgred) /usr/bin/cgclassify |
||||
%attr(0644, root, root) %{_mandir}/man1/* |
||||
%attr(0644, root, root) %{_mandir}/man5/* |
||||
%attr(0644, root, root) %{_mandir}/man8/* |
||||
%{_unitdir}/cgconfig.service |
||||
%{_unitdir}/cgred.service |
||||
|
||||
%files pam |
||||
%doc COPYING README |
||||
%attr(0755,root,root) %{_libdir}/security/pam_cgroup.so |
||||
|
||||
%files devel |
||||
%doc COPYING README |
||||
%{_includedir}/libcgroup.h |
||||
%{_includedir}/libcgroup/*.h |
||||
%{_libdir}/libcgroup.so |
||||
%{_libdir}/pkgconfig/libcgroup.pc |
||||
|
||||
%changelog |
||||
* Tue Oct 24 2017 Nikola Forró <nforro@redhat.com> - 0.41-15 |
||||
- resolves: #1464015 |
||||
do not verify size, mtime and checksum of config files |
||||
|
||||
* Tue Oct 24 2017 Nikola Forró <nforro@redhat.com> - 0.41-14 |
||||
- resolves: #1505443 |
||||
fix infinite loop |
||||
|
||||
* Thu Mar 16 2017 Nikola Forró <nforro@redhat.com> - 0.41-13 |
||||
- resolves: #1384390 |
||||
preserve dirty flag when copying controller values |
||||
|
||||
* Tue Jan 24 2017 Nikola Forró <nforro@redhat.com> - 0.41-12 |
||||
- resolves: #1406927 |
||||
start cgred service after nss-user-lookup target |
||||
show warnings about unsuccessful user/group lookups |
||||
|
||||
* Thu Jun 23 2016 Nikola Forró <nforro@redhat.com> - 0.41-11 |
||||
- resolves: #1347765 |
||||
fix potential buffer overflow |
||||
|
||||
* Thu Jun 23 2016 Nikola Forró <nforro@redhat.com> - 0.41-10 |
||||
- resolves: #1348864 |
||||
fix order of memory subsystem parameters generated by cgsnapshot |
||||
|
||||
* Wed Apr 06 2016 Nikola Forró <nforro@redhat.com> - 0.41-9 |
||||
- resolves: #1322571 |
||||
set Delegate property for cgconfig service |
||||
|
||||
* Sat Sep 20 2014 jchaloup <jchaloup@redhat.com> - 0.41-8 |
||||
- resolves: #885174 |
||||
loading configuration files from /etc/cgconfig.d/ directory |
||||
- resolves: #885166 |
||||
use * character as a meta character for all mounted |
||||
- resolves: #886920 |
||||
add examples to man pages |
||||
- resolves: #1143851 |
||||
extending cgroup names with default |
||||
- resolves: #1142807 |
||||
api.c: support for setting multiline values in control files |
||||
config.c: xfs file system sets item->d_type to zero, stat() and S_ISREG() test added (#885174) |
||||
|
||||
* Thu Sep 11 2014 jchaloup <jchaloup@redhat.com> - 0.41-7 |
||||
- resolves: #963515 |
||||
retry to set control file in cgroup_modify_cgroup |
||||
|
||||
* Tue Mar 04 2014 jchaloup <jchaloup@redhat.com> - 0.41-6 |
||||
- related: #1016810 |
||||
specfile corrected, make was not fired |
||||
|
||||
* Tue Feb 25 2014 jchaloup <jchaloup@redhat.com> - 0.41-5 |
||||
- related: #1016810 |
||||
missing man pages for cgrulesengd, cgred.conf, cgrule.conf added |
||||
|
||||
* Mon Feb 24 2014 jchaloup <jchaloup@redhat.com> - 0.41-4 |
||||
- related: #1016810 |
||||
cgrulesengd returned |
||||
|
||||
* Fri Feb 14 2014 jchaloup <jchaloup@redhat.com> - 0.41-3 |
||||
- related: #1052471 |
||||
runlibcgrouptest fix, ignore systemd mount |
||||
|
||||
* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 0.41-2 |
||||
- Mass rebuild 2014-01-24 |
||||
|
||||
* Tue Jan 14 2014 Peter Schiffer <pschiffe@redhat.com> 0.41-1 |
||||
- resolves: #1052471 |
||||
updated to 0.41 |
||||
|
||||
* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 0.40-1.rc1.3 |
||||
- Mass rebuild 2013-12-27 |
||||
|
||||
* Mon Nov 4 2013 Peter Schiffer <pschiffe@redhat.com> 0.40-0.rc1.3 |
||||
- related: #819568 |
||||
fixed some coverity findings |
||||
|
||||
* Fri Nov 1 2013 Peter Schiffer <pschiffe@redhat.com> 0.40-0.rc1.2 |
||||
- related: #1016810 |
||||
returned creation of cgred group, which was removed in previous commit by mistage |
||||
|
||||
* Fri Nov 1 2013 Peter Schiffer <pschiffe@redhat.com> 0.40-0.rc1.1 |
||||
- resolves: #819568, #740113 |
||||
rebased to 0.40.rc1 |
||||
- resolves: #983264 |
||||
rebuilt with full relro and PIE |
||||
- resolves: #1016810 |
||||
removed cgrulesengd daemon |
||||
|
||||
* Fri Nov 23 2012 Peter Schiffer <pschiffe@redhat.com> - 0.38-3 |
||||
- resolves: #850183 |
||||
scriptlets replaced with new systemd macros (thanks to vpavlin) |
||||
- cleaned .spec file |
||||
|
||||
* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.38-2 |
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild |
||||
|
||||
* Mon Feb 20 2012 Jan Safranek <jsafrane@redhat.com> 0.38-1 |
||||
- updated to 0.38 |
||||
|
||||
* Fri Feb 3 2012 Jan Safranek <jsafrane@redhat.com> 0.38-0.rc1 |
||||
- updated to 0.38.rc1 |
||||
|
||||
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.37.1-5 |
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild |
||||
|
||||
* Mon May 30 2011 Jan Safranek <jsafrane@redhat.com> 0.37.1-4 |
||||
- fixed cgconfig service not to unmount stuff it did not mount |
||||
- added better sample cgconfig.conf file to reflect systemd |
||||
mounting all controllers during boot (#702111) |
||||
|
||||
* Wed May 25 2011 Ivana Hutarova Varekova <varekova@redhat.com> 0.37.1-3 |
||||
- split tools part from libcgroup package |
||||
|
||||
* Fri Apr 8 2011 Jan Safranek <jsafrane@redhat.com> 0.37.1-2 |
||||
- Remove /cgroup directory, groups are created in /sys/fs/cgroup |
||||
(#694687) |
||||
|
||||
* Thu Mar 3 2011 Jan Safranek <jsafrane@redhat.com> 0.37.1-1 |
||||
- Update to 0.37.1 |
||||
|
||||
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.37-3 |
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild |
||||
|
||||
* Mon Jan 17 2011 Jan Safranek <jsafrane@redhat.com> 0.37-2 |
||||
- Create the 'cgred' group as system group, not as user |
||||
- Fix cgclassify exit code |
||||
|
||||
* Mon Dec 13 2010 Jan Safranek <jsafrane@redhat.com> 0.37-1 |
||||
- Update to 0.37 |
||||
- use /sys/fs/cgroup as default directory to mount control groups (and rely on |
||||
systemd mounting tmpfs there) |
||||
|
||||
* Fri Nov 12 2010 Jan Safranek <jsafrane@redhat.com> 0.36.2-3 |
||||
- Ignore systemd hierarchy - it's now invisible to libcgroup (#627378) |
||||
|
||||
* Mon Aug 2 2010 Jan Safranek <jsafrane@redhat.com> 0.36.2-2 |
||||
- Fix initscripts to report stopped cgconfig service as not running |
||||
(#619091) |
||||
|
||||
* Tue Jun 22 2010 Jan Safranek <jsafrane@redhat.com> 0.36.2-1 |
||||
- Update to 0.36.2, fixing packaging the libraries (#605434) |
||||
- Remove the dependency on redhat-lsb (#603578) |
||||
|
||||
* Fri May 21 2010 Jan Safranek <jsafrane@redhat.com> 0.36-1 |
||||
- Update to 0.36.1 |
||||
|
||||
* Tue Mar 9 2010 Jan Safranek <jsafrane@redhat.com> 0.35-1 |
||||
- Update to 0.35.1 |
||||
- Separate pam module to its own subpackage |
||||
|
||||
* Mon Jan 18 2010 Jan Safranek <jsafrane@redhat.com> 0.34-4 |
||||
- Added README.Fedora to describe initscript integration |
||||
|
||||
* Mon Oct 19 2009 Jan Safranek <jsafrane@redhat.com> 0.34-3 |
||||
- Change the default configuration to mount everything to /cgroup |
||||
|
||||
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.34-2 |
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild |
||||
|
||||
* Tue Jul 7 2009 Jan Safranek <jsafrane@redhat.com> 0.34-1 |
||||
- Update to 0.34 |
||||
* Mon Mar 09 2009 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.33-3 |
||||
- Add a workaround for rt cgroup controller. |
||||
* Mon Mar 09 2009 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.33-2 |
||||
- Change the cgconfig script to start earlier |
||||
- Move the binaries to /bin and /sbin |
||||
* Mon Mar 02 2009 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.33-1 |
||||
- Update to latest upstream |
||||
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> 0.32.2-4 |
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild |
||||
|
||||
* Mon Jan 05 2009 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.32.2-3 |
||||
- Fix redhat-lsb dependency |
||||
* Mon Dec 29 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.32.2-2 |
||||
- Fix build dependencies |
||||
* Mon Dec 29 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.32.2-1 |
||||
- Update to latest upstream |
||||
* Thu Oct 23 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.32.1-1 |
||||
* Tue Feb 24 2009 Balbir Singh <balbir@linux.vnet.ibm.com> 0.33-1 |
||||
- Update to 0.33, spec file changes to add Makefiles and pam_cgroup module |
||||
* Fri Oct 10 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.32-1 |
||||
- Update to latest upstream |
||||
* Thu Sep 11 2008 Dhaval Giani <dhaval@linux-vnet.ibm.com> 0.31-1 |
||||
- Update to latest upstream |
||||
* Sat Aug 2 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.1c-3 |
||||
- Change release to fix broken upgrade path |
||||
* Wed Jun 11 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.1c-1 |
||||
- Update to latest upstream version |
||||
* Tue Jun 3 2008 Balbir Singh <balbir@linux.vnet.ibm.com> 0.1b-3 |
||||
- Add post and postun. Also fix Requires for devel to depend on base n-v-r |
||||
* Sat May 31 2008 Balbir Singh <balbir@linux.vnet.ibm.com> 0.1b-2 |
||||
- Fix makeinstall, Source0 and URL (review comments from Tom) |
||||
* Mon May 26 2008 Balbir Singh <balbir@linux.vnet.ibm.com> 0.1b-1 |
||||
- Add a generatable spec file |
||||
* Tue May 20 2008 Balbir Singh <balbir@linux.vnet.ibm.com> 0.1-1 |
||||
- Get the spec file to work |
||||
* Tue May 20 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.01-1 |
||||
- The first version of libcg |
Loading…
Reference in new issue