Fixed issue where the server issued warnings about setting file permissions on startup on Windows platforms. This applies for the DB
directory and log file permissions. With Java 6, it is impossible to set a read and execute permission to false on Windows. The file
permissions class now takes this into account and does not consider a false result from setting read and execute permissions to false
on Windows a failure.
Fix for issue 202
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_CACHE_SIZE_AFTER_PRELOAD; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_CLEAN_DATABASE_START; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_CLEAN_DATABASE_MARKED; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_CLEAN_DATABASE_FINISH; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_SET_PERMISSIONS_FAILED; |
| | | import static org.opends.server.messages.JebMessages. |
| | | MSGID_JEB_CONFIG_ATTR_REQUIRES_RESTART; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.admin.std.server.JEBackendCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | { |
| | | if(!FilePermission.setPermissions(backendDirectory, backendPermission)) |
| | | { |
| | | throw new Exception(); |
| | | int msgID = MSGID_JEB_UNABLE_SET_PERMISSIONS; |
| | | String message = getMessage(msgID, backendPermission.toString(), |
| | | backendDirectory.toString()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.MILD_WARNING, |
| | | message, msgID); |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | // Log an warning that the permissions were not set. |
| | | int msgID = MSGID_JEB_SET_PERMISSIONS_FAILED; |
| | | String message = getMessage(msgID, backendDirectory.getPath()); |
| | | String message = getMessage(msgID, backendDirectory.toString(), |
| | | e.toString()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_WARNING, |
| | | message, msgID); |
| | | } |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.admin.std.server.SizeLimitLogRotationPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.util.TimeThread; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugVerbose; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCaught; |
| | | import org.opends.server.admin.std.server.SizeLimitLogRotationPolicyCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.util.TimeThread; |
| | | import static org.opends.server.messages.LoggerMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | |
| | | import java.io.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | |
| | | } |
| | | |
| | | |
| | | // Try to apply file permissions. Causing problems with installer. Fix |
| | | // after 0.8. |
| | | /* |
| | | // Try to apply file permissions. |
| | | if(FilePermission.canSetPermissions()) |
| | | { |
| | | try |
| | | { |
| | | if(!FilePermission.setPermissions(file, filePermissions)) |
| | | { |
| | | throw new Exception(); |
| | | int msgID = MSGID_LOGGER_UNABLE_SET_PERMISSIONS; |
| | | String message = getMessage(msgID, filePermissions.toString(), |
| | | file.toString()); |
| | | logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.MILD_WARNING, |
| | | message, msgID); |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | // Log an warning that the permissions were not set. |
| | | int msgID = MSGID_LOGGER_SET_PERMISSION_FAILED; |
| | | String message = getMessage(msgID, file.toString()); |
| | | String message = getMessage(msgID, file.toString(), |
| | | stackTraceToSingleLineString(e)); |
| | | logError(ErrorLogCategory.CONFIGURATION, |
| | | ErrorLogSeverity.SEVERE_WARNING, |
| | | message, msgID); |
| | | } |
| | | }*/ |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | CATEGORY_MASK_JEB | SEVERITY_MASK_MILD_ERROR | 145; |
| | | |
| | | /** |
| | | * The message ID of an error indicating that setting file permissions |
| | | * for the database directory is not supported. |
| | | */ |
| | | public static final int MSGID_JEB_UNABLE_SET_PERMISSIONS = |
| | | CATEGORY_MASK_JEB | SEVERITY_MASK_SEVERE_WARNING | 146; |
| | | |
| | | /** |
| | | * Associates a set of generic messages with the message IDs defined in this |
| | | * class. |
| | | */ |
| | |
| | | "This search operation has checked the maximum of %d " + |
| | | "entries for matches"); |
| | | registerMessage(MSGID_JEB_SET_PERMISSIONS_FAILED, |
| | | "Unable to set file permissions for the backend database " + |
| | | "directory %s"); |
| | | "An error occured while setting file permissions for " + |
| | | "the backend database directory %s: %s"); |
| | | registerMessage(MSGID_JEB_GET_ENTRY_COUNT_FAILED, |
| | | "Unable to determine the total number of entries in the " + |
| | | "container: %s"); |
| | |
| | | registerMessage(MSGID_JEB_SEARCH_UNINDEXED_INSUFFICIENT_PRIVILEGES, |
| | | "You do not have sufficient privileges to perform an " + |
| | | "unindexed search"); |
| | | registerMessage(MSGID_JEB_UNABLE_SET_PERMISSIONS, |
| | | "This platform does not support setting file " + |
| | | "permissions %s to the database directory %s"); |
| | | } |
| | | } |
| | |
| | | * file as the argument. |
| | | */ |
| | | public static final int MSGID_LOGGER_SET_PERMISSION_FAILED = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_MILD_WARNING | 8; |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_SEVERE_WARNING | 8; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if the current platform |
| | | * does not support setting the file permissions on the log files. This takes |
| | | * the name of the file as the argument. |
| | | */ |
| | | public static final int MSGID_LOGGER_UNABLE_SET_PERMISSIONS = |
| | | CATEGORY_MASK_LOG | SEVERITY_MASK_MILD_WARNING | 9; |
| | | |
| | | |
| | | |
| | |
| | | public static void registerMessages() |
| | | { |
| | | registerMessage(MSGID_LOGGER_ERROR_WRITING_RECORD, |
| | | "Unable to write log record for logger " + |
| | | "%s: %s. Any further writing errors will be ignored"); |
| | | "Error occured while writing log record for logger " + |
| | | "%s: %s. Any further write errors will be ignored"); |
| | | registerMessage(MSGID_LOGGER_ERROR_OPENING_FILE, |
| | | "Unable to open log file %s for logger %s: %s"); |
| | | "Error occured while opening log file %s for logger %s: " + |
| | | "%s"); |
| | | registerMessage(MSGID_LOGGER_ERROR_CLOSING_FILE, |
| | | "Unable to close log file for logger %s: %s"); |
| | | "Error occured while closing log file for logger %s: %s"); |
| | | registerMessage(MSGID_LOGGER_ERROR_FLUSHING_BUFFER, |
| | | "Unable to flush writer buffer for logger %s: %s"); |
| | | "Error occured while flushing writer buffer for " + |
| | | "logger %s: %s"); |
| | | registerMessage(MSGID_ERROR_LOGGER_INVALID_SEVERITY, |
| | | "Invalid error log severity \"%s\""); |
| | | registerMessage(MSGID_ERROR_LOGGER_INVALID_CATEGORY, |
| | |
| | | registerMessage(MSGID_ERROR_LOGGER_INVALID_OVERRIDE_SEVERITY, |
| | | "Invalid override of severity level \"%s\""); |
| | | registerMessage(MSGID_LOGGER_SET_PERMISSION_FAILED, |
| | | "Unable to set file permissions for the log file %s"); |
| | | "Error occured while setting file permissions for the " + |
| | | "log file %s: %s"); |
| | | registerMessage(MSGID_LOGGER_UNABLE_SET_PERMISSIONS, |
| | | "This platform does not support setting file " + |
| | | "permissions %s to the log file %s"); |
| | | |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | if(!DirectoryServer.getOperatingSystem().equals( |
| | | OperatingSystem.WINDOWS)) |
| | | { |
| | | // On Windows platforms, file readability permissions |
| | | // cannot be set to false. Do not consider this case |
| | | // a failure. http://java.sun.com/developer/ |
| | | // technicalArticles/J2SE/Desktop/javase6/enhancements/ |
| | | anyFailed = true; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | } |
| | | else |
| | | { |
| | | if(!DirectoryServer.getOperatingSystem().equals( |
| | | OperatingSystem.WINDOWS) || p.isOwnerReadable()) |
| | | { |
| | | // On Windows platforms, file readabilitys permissions |
| | | // cannot be set to false. Do not consider this case |
| | | // a failure. http://java.sun.com/developer/ |
| | | // technicalArticles/J2SE/Desktop/javase6/enhancements/ |
| | | anyFailed = true; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | } |
| | | else |
| | | { |
| | | if(!DirectoryServer.getOperatingSystem().equals( |
| | | OperatingSystem.WINDOWS)) |
| | | { |
| | | // On Windows platforms, file execute permissions |
| | | // cannot be set to false. Do not consider this case |
| | | // a failure. http://java.sun.com/developer/ |
| | | // technicalArticles/J2SE/Desktop/javase6/enhancements/ |
| | | anyFailed = true; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | } |
| | | else |
| | | { |
| | | if(!DirectoryServer.getOperatingSystem().equals( |
| | | OperatingSystem.WINDOWS) || p.isOwnerExecutable()) |
| | | { |
| | | // On Windows platforms, file execute permissions |
| | | // cannot be set to false. Do not consider this case |
| | | // a failure. http://java.sun.com/developer/ |
| | | // technicalArticles/J2SE/Desktop/javase6/enhancements/ |
| | | anyFailed = true; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |