[icinga-checkins] icinga.org: icinga-core/test/ido: Added config option to lowercase the username

git at icinga.org git at icinga.org
Wed Oct 3 01:18:36 CEST 2012


Module: icinga-core
Branch: test/ido
Commit: 763935cb6dc14a59d0975f807ab11e5da64c4d65
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=763935cb6dc14a59d0975f807ab11e5da64c4d65

Author: Alexander Hofmann <alexander.hofmann at dfs.de>
Date:   Sun Sep 16 21:06:12 2012 +0200

Added config option to lowercase the username

With this option enabled icinga translates every username
to all lowercase letters. This can be very useful if the
username is stored in an (case-insensitive) ActiveDirectory.

refs #3171

Signed-off-by: Ricardo Bartels <ricardo at bitchbrothers.com>

---

 AUTHORS                  |    1 +
 Changelog                |    2 ++
 cgi/cgiauth.c            |    7 +++++++
 cgi/cgiutils.c           |    5 +++++
 cgi/config.c             |    4 ++++
 sample-config/cgi.cfg.in |   10 ++++++++++
 6 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 211c319..ac5815b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,6 +19,7 @@ Mark Gius
 DECOIT GmbH
 Stephen Gran
 Marius Hein
+Alexander Hofmann
 Matthieu Kermagoret
 Petya Kohts
 Julius Kriukas
diff --git a/Changelog b/Changelog
index 86ca7b7..c8a4285 100644
--- a/Changelog
+++ b/Changelog
@@ -49,6 +49,7 @@ ENHANCEMENTS
 * classic ui: javascript refresh jumps to page top, not restoring previous scrolling position; add url param 'scroll=' #2855 - MF
 * classic ui: Cleaned up "linkBox" in all cgi's #3154 - RB
 * classic ui: add command to delete host downtime and all associated service downtimes (extinfo.cgi, status.cgi command drop down) - RD/MF
+* classic ui: Added config option to convert login username to lower case #3171 - AH
 
 * idoutils: do not pass host and port if not set in the config, letting mysql|pgsql drivers autoselect the socket #2698 - MF
 * idoutils: fix mismatched types for uint casts in bulkops (oracle) #2646 - TD
@@ -142,6 +143,7 @@ classic ui: Added/Changed cgi.cfg options
 	** "result_limit" (default: 50) - #2725
 	** "result_limit" replaces "default_num_displayed_log_entries" - #2725
 	** default_expiring_disabled_notifications_duration=86400 #905
+	** lowercase_user_name - #3171
 * classic ui: change strings in json output: !!!IMPORTANT!!!
 	** host -> host_name
 	** service -> service_description
diff --git a/cgi/cgiauth.c b/cgi/cgiauth.c
index 63f087d..b52ae3d 100644
--- a/cgi/cgiauth.c
+++ b/cgi/cgiauth.c
@@ -60,6 +60,7 @@ extern char		*default_user_name;
 
 extern int		use_authentication;
 extern int		use_ssl_authentication;
+extern int		lowercase_user_name;
 extern int		show_all_services_host_is_authorized_for;
 
 /* get current authentication information */
@@ -68,6 +69,7 @@ int get_authentication_information(authdata *authinfo) {
 	char temp_data[MAX_INPUT_BUFFER];
 	contact *temp_contact;
 	contactgroup *temp_contactgroup;
+	int i = 0;
 
 	/** BEGIN MACRO declaration */
 
@@ -151,6 +153,11 @@ int get_authentication_information(authdata *authinfo) {
 	if (temp_ptr == NULL || (!strcmp(temp_ptr, "") && strcmp(default_user_name, "")))
 		temp_ptr = default_user_name;
 
+	if (lowercase_user_name == TRUE) {
+		for (i = 0; i < strlen(temp_ptr); i++)
+			temp_ptr[i] = tolower(temp_ptr[i]);
+	}
+
 	authinfo->username = (char *)malloc(strlen(temp_ptr) + 1);
 
 	if (authinfo->username == NULL)
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 8b9b4a5..baaf107 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -149,6 +149,8 @@ int             persistent_ack_comments = FALSE;
 
 int             use_ssl_authentication = FALSE;
 
+int             lowercase_user_name = FALSE;
+
 int             default_statusmap_layout_method = 0;
 
 int		color_transparency_index_r = 255;
@@ -573,6 +575,9 @@ int read_cgi_config_file(char *filename) {
 		else if (!strcmp(var, "use_ssl_authentication"))
 			use_ssl_authentication = (atoi(val) > 0) ? TRUE : FALSE;
 
+		else if (!strcmp(var, "lowercase_user_name"))
+			lowercase_user_name = (atoi(val) > 0) ? TRUE : FALSE;
+
 		else if (!strcmp(var, "status_show_long_plugin_output"))
 			status_show_long_plugin_output = (atoi(val) > 0) ? TRUE : FALSE;
 
diff --git a/cgi/config.c b/cgi/config.c
index 4b29e8f..7baeaea 100644
--- a/cgi/config.c
+++ b/cgi/config.c
@@ -115,6 +115,7 @@ extern int escape_html_tags;
 extern int extinfo_show_child_hosts;
 extern int highlight_table_rows;
 extern int lock_author_names;
+extern int lowercase_user_name;
 extern int persistent_ack_comments;
 extern int refresh_rate;
 extern int refresh_type;
@@ -234,6 +235,7 @@ int org_extinfo_show_child_hosts;
 int org_first_day_of_week;
 int org_highlight_table_rows;
 int org_lock_author_names;
+int org_lowercase_user_name;
 int org_persistent_ack_comments;
 int org_refresh_rate;
 int org_refresh_type;
@@ -4088,6 +4090,7 @@ void display_cgiconfig(void) {
 	PRINT_CONFIG_LINE_STRING(http_charset, org_http_charset)
 	PRINT_CONFIG_LINE_STRING(illegal_output_chars, org_illegal_macro_output_chars)
 	PRINT_CONFIG_LINE_INT(lock_author_names, org_lock_author_names, "bool")
+	PRINT_CONFIG_LINE_INT(lowercase_user_name, org_lowercase_user_name, "bool")
 	PRINT_CONFIG_LINE_STRING(main_config_file, org_main_config_file)
 	PRINT_CONFIG_LINE_STRING(nagios_check_command, org_nagios_check_command)
 	PRINT_CONFIG_LINE_STRING(normal_sound, org_normal_sound)
@@ -4527,6 +4530,7 @@ void store_default_settings(void) {
 	org_first_day_of_week = week_starts_on_monday;
 	org_highlight_table_rows = highlight_table_rows;
 	org_lock_author_names = lock_author_names;
+	org_lowercase_user_name = lowercase_user_name;
 	org_persistent_ack_comments = persistent_ack_comments;
 	org_refresh_rate = refresh_rate;
 	org_refresh_type = refresh_type;
diff --git a/sample-config/cgi.cfg.in b/sample-config/cgi.cfg.in
index f22cbbb..678c192 100644
--- a/sample-config/cgi.cfg.in
+++ b/sample-config/cgi.cfg.in
@@ -162,6 +162,16 @@ use_ssl_authentication=0
 
 
 
+# LOWERCASE USER NAME
+# This option controls whether or not the username is converted
+# to all lowercase letters. Can be useful if the username is stored
+# in Active Directory (case-insensitive).
+
+lowercase_user_name=0
+
+
+
+
 # DEFAULT USER
 # Setting this variable will define a default user name that can
 # access pages without authentication.  This allows people within a





More information about the icinga-checkins mailing list