Currently, the list of files to be parsed is constructed by reading the
directories passed with '-L' command line option or by cgrulesend from
'/etc/cgconfig.d'. The directories might also host non-configuration
files, parsing them will result in failure.
Consider the following example:
# ls /etc/cgconfig.d
cgconfig-oradb.conf cgconfig-oradb.conf.rpmsave test .conf e
# /usr/sbin/cgconfigparser -l /etc/cgconfig.conf -L /etc/cgconfig.d -s 1664
/usr/sbin/cgconfigparser; error loading /etc/cgconfig.d/cgconfig-oradb.conf.rpmsave:
Cgroup, the requested group parameter does not exist
fix it by skipping files with non .conf extensions, while building the
list of files to be parsed for cgroup configurations.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
errno = 0;
item = readdir(d);
if (item && (item->d_type == DT_REG || item->d_type == DT_LNK)) {
- char *tmp;
+ char *tmp, *file_ext;
+
+ /* we are interested in .conf files, skip others */
+ file_ext = strstr(item->d_name, ".conf");
+ if (!file_ext)
+ continue;
+
+ if (strcmp(file_ext, ".conf") || strlen(item->d_name) == 5)
+ continue;
ret = asprintf(&tmp, "%s/%s", dirname, item->d_name);
if (ret < 0) {