From 530abb5c8bd28d3bf5c1eff08873b63677f3af8e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Aug 2005 07:57:36 -0600 Subject: [PATCH] small corrections to the IM. server-tools/instance-manager/IMService.cpp: removed \n from log_info calls as these will be added automatically server-tools/instance-manager/user_map.cc: added back in support for password files using \r\n, this time without breaking the const contract. --- server-tools/instance-manager/IMService.cpp | 12 ++++++------ server-tools/instance-manager/user_map.cc | 17 +++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/server-tools/instance-manager/IMService.cpp b/server-tools/instance-manager/IMService.cpp index b6195d15603..a5070dcf0f6 100644 --- a/server-tools/instance-manager/IMService.cpp +++ b/server-tools/instance-manager/IMService.cpp @@ -44,24 +44,24 @@ int HandleServiceOptions(Options options) if (options.install_as_service) { if (winService.IsInstalled()) - log_info("Service is already installed\n"); + log_info("Service is already installed"); else if (winService.Install()) - log_info("Service installed successfully\n"); + log_info("Service installed successfully"); else { - log_info("Service failed to install\n"); + log_info("Service failed to install"); ret_val= -1; } } else if (options.remove_service) { if (! winService.IsInstalled()) - log_info("Service is not installed\n"); + log_info("Service is not installed"); else if (winService.Remove()) - log_info("Service removed successfully\n"); + log_info("Service removed successfully"); else { - log_info("Service failed to remove\n"); + log_info("Service failed to remove"); ret_val= -1; } } diff --git a/server-tools/instance-manager/user_map.cc b/server-tools/instance-manager/user_map.cc index 1498f2fa947..7fce2f75e28 100644 --- a/server-tools/instance-manager/user_map.cc +++ b/server-tools/instance-manager/user_map.cc @@ -25,12 +25,6 @@ #include "log.h" -#ifdef __WIN__ -#define NEWLINE_LEN 2 -#else -#define NEWLINE_LEN 1 -#endif - struct User { char user[USERNAME_LENGTH + 1]; @@ -43,6 +37,7 @@ struct User int User::init(const char *line) { const char *name_begin, *name_end, *password; + int line_ending_len= 1; if (line[0] == '\'' || line[0] == '"') { @@ -64,8 +59,14 @@ int User::init(const char *line) if (user_length > USERNAME_LENGTH) goto err; - /* assume that newline characater is present */ - if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + NEWLINE_LEN) + /* + assume that newline characater is present + we support reading password files that end in \n or \r\n on + either platform. + */ + if (password[strlen(password)-2] == '\r') + line_ending_len= 2; + if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + line_ending_len) goto err; memcpy(user, name_begin, user_length);