Update all of the command-line tools to ensure that the exit code should always
be between 0 and 255, which are the bounds enforced by most shells and
operating environments. Any negative value, or any positive value greater than
255 will be changed to 255.
OpenDS Issue Number: 1883
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | int exitCode = configMain(args); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(exitCode); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH; |
| | | import static org.opends.server.util.StaticUtils.wrapText; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | /** |
| | |
| | | { |
| | | int result = configureWindowsService(args, System.out, System.err); |
| | | |
| | | System.exit(result); |
| | | System.exit(filterExitCode(result)); |
| | | } |
| | | |
| | | /** |
| | |
| | | int returnCode = encodePassword(args, true, System.out, System.err); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(returnCode); |
| | | System.exit(filterExitCode(returnCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | int exitCode = installMain(args); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(exitCode); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | int returnCode = mainPasswordModify(args, true, System.out, System.err); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(returnCode); |
| | | System.exit(filterExitCode(returnCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | |
| | | int exitCode = mainDiff(args, false); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(exitCode); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | int returnCode = ldifModifyMain(args, false); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(returnCode); |
| | | System.exit(filterExitCode(returnCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | int exitCode = mainSearch(args); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(exitCode); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | int returnCode = main(args, System.out, System.err); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(returnCode); |
| | | System.exit(filterExitCode(returnCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.LockFileManager; |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | // Decode the base DN provided by the user. |
| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class is used to start the Windows service associated with this |
| | |
| | | { |
| | | int result = startWindowsService(System.out, System.err); |
| | | |
| | | System.exit(result); |
| | | System.exit(filterExitCode(result)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | if (result != LDAPResultCode.SUCCESS) |
| | | { |
| | | System.exit(result); |
| | | System.exit(filterExitCode(result)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | int result = stopWindowsService(System.out, System.err); |
| | | |
| | | System.exit(result); |
| | | System.exit(filterExitCode(result)); |
| | | } |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | System.exit(filterExitCode(retCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | |
| | |
| | | int exitCode = mainWait(args); |
| | | if (exitCode != EXIT_CODE_SUCCESS) |
| | | { |
| | | System.exit(exitCode); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | // Run the application. |
| | | int exitCode = app.run(args); |
| | | if (exitCode != 0) { |
| | | System.exit(exitCode); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | int returnCode = makeLDIF.makeLDIFMain(args); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(returnCode); |
| | | System.exit(filterExitCode(returnCode)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Filters the provided value to ensure that it is appropriate for use as an |
| | | * exit code. Exit code values are generally only allowed to be between 0 and |
| | | * 255, so any value outside of this range will be converted to 255, which is |
| | | * the typical exit code used to indicate an overflow value. |
| | | * |
| | | * @param exitCode The exit code value to be processed. |
| | | * |
| | | * @return An integer value between 0 and 255, inclusive. If the provided |
| | | * exit code was already between 0 and 255, then the original value |
| | | * will be returned. If the provided value was out of this range, |
| | | * then 255 will be returned. |
| | | */ |
| | | public static int filterExitCode(int exitCode) |
| | | { |
| | | if (exitCode < 0) |
| | | { |
| | | return 255; |
| | | } |
| | | else if (exitCode > 255) |
| | | { |
| | | return 255; |
| | | } |
| | | else |
| | | { |
| | | return exitCode; |
| | | } |
| | | } |
| | | } |
| | | |