This is first part of uid-gid function. Add support for reading directory (now it's SYSCONFIG/ais/security, should be something different? Really not sure), and it reads WHOLE files from this directory and adds them to objdb. This can be (maybe) some security problem (Steve should I care about it?)
Regards, Honza
commit 20090d706aa8e000d06449f0a65c85286207f601 Author: Jan Friesse <[email protected]> Date: Tue May 12 18:07:33 2009 +0200 coroparse: Support for reading configuration files from /etc/ais/security diff --git a/trunk/exec/coroparse.c b/trunk/exec/coroparse.c index 5a71381..8a461ab 100644 --- a/trunk/exec/coroparse.c +++ b/trunk/exec/coroparse.c @@ -47,6 +47,7 @@ #include <errno.h> #include <signal.h> #include <string.h> +#include <dirent.h> #include <corosync/lcr/lcr_comp.h> #include <corosync/engine/objdb.h> @@ -156,7 +157,45 @@ static int parse_section(FILE *fp, return 0; } +static int read_security_files_into_objdb( + struct objdb_iface_ver0 *objdb, + const char **error_string) +{ + FILE *fp; + const char *dirname; + DIR *dp; + struct dirent *dirent; + char *filename[PATH_MAX + NAME_MAX + 1]; + int res = 0; + + dirname = SYSCONFDIR "/ais/security"; + dp = opendir (dirname); + + if (dp == NULL) + return 0; + + while (dirent = readdir (dp)) { + if (dirent->d_type == DT_REG) { + snprintf(filename, sizeof (filename), "%s/%s", dirname, dirent->d_name); + + fp = fopen (filename, "r"); + if (fp == NULL) continue; + + res = parse_section(fp, objdb, OBJECT_PARENT_HANDLE, error_string); + + fclose (fp); + if (res != 0) { + goto error_exit; + } + } + } + +error_exit: + closedir(dp); + + return res; +} /* Read config file and load into objdb */ static int read_config_file_into_objdb( @@ -186,6 +225,10 @@ static int read_config_file_into_objdb( fclose(fp); if (res == 0) { + res = read_security_files_into_objdb(objdb, error_string); + } + + if (res == 0) { snprintf (error_reason, sizeof(error_string_response), "Successfully read main configuration file '%s'.\n", filename); *error_string = error_reason;
_______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
