mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
05.46.2007 8f5c232ab629b7aa83c5a1d4eff9648874a0c9ca
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
27 files modified
103 ■■■■■ changed files
opends/src/server/org/opends/server/tools/BackUpDB.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ConfigureDS.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ConfigureWindowsService.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/EncodePassword.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ExportLDIF.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ImportLDIF.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/InstallDS.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPCompare.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPDelete.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPModify.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPPasswordModify.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPSearch.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDIFDiff.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDIFModify.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDIFSearch.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ListBackends.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ManageAccount.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RebuildIndex.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RestoreDB.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/StartWindowsService.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/StopDS.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/StopWindowsService.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/VerifyIndex.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/WaitForFileDelete.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/StaticUtils.java 31 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -64,7 +64,6 @@
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;
@@ -96,7 +95,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
@@ -498,7 +497,7 @@
      catch(Exception e)
      {
        System.err.println("Error installing the custom error logger: " +
            StaticUtils.stackTraceToSingleLineString(e));
                           stackTraceToSingleLineString(e));
      }
    }
opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -135,7 +135,7 @@
    int exitCode = configMain(args);
    if (exitCode != 0)
    {
      System.exit(exitCode);
      System.exit(filterExitCode(exitCode));
    }
  }
opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -44,7 +44,7 @@
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.*;
/**
@@ -153,7 +153,7 @@
  {
    int result = configureWindowsService(args, System.out, System.err);
    System.exit(result);
    System.exit(filterExitCode(result));
  }
  /**
opends/src/server/org/opends/server/tools/EncodePassword.java
@@ -82,7 +82,7 @@
    int returnCode = encodePassword(args, true, System.out, System.err);
    if (returnCode != 0)
    {
      System.exit(returnCode);
      System.exit(filterExitCode(returnCode));
    }
  }
opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -63,7 +63,6 @@
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;
@@ -94,7 +93,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
@@ -444,7 +443,7 @@
      catch(Exception e)
      {
        System.err.println("Error installing the custom error logger: " +
            StaticUtils.stackTraceToSingleLineString(e));
                           stackTraceToSingleLineString(e));
      }
opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -104,7 +104,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
opends/src/server/org/opends/server/tools/InstallDS.java
@@ -137,7 +137,7 @@
    int exitCode = installMain(args);
    if (exitCode != 0)
    {
      System.exit(exitCode);
      System.exit(filterExitCode(exitCode));
    }
  }
opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -279,7 +279,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -259,7 +259,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -534,7 +534,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -103,7 +103,7 @@
    int returnCode = mainPasswordModify(args, true, System.out, System.err);
    if (returnCode != 0)
    {
      System.exit(returnCode);
      System.exit(filterExitCode(returnCode));
    }
  }
opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -568,7 +568,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
opends/src/server/org/opends/server/tools/LDIFDiff.java
@@ -59,6 +59,7 @@
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.*;
@@ -107,7 +108,7 @@
    int exitCode = mainDiff(args, false);
    if (exitCode != 0)
    {
      System.exit(exitCode);
      System.exit(filterExitCode(exitCode));
    }
  }
opends/src/server/org/opends/server/tools/LDIFModify.java
@@ -398,7 +398,7 @@
    int returnCode = ldifModifyMain(args, false);
    if (returnCode != 0)
    {
      System.exit(returnCode);
      System.exit(filterExitCode(returnCode));
    }
  }
opends/src/server/org/opends/server/tools/LDIFSearch.java
@@ -119,7 +119,7 @@
    int exitCode = mainSearch(args);
    if (exitCode != 0)
    {
      System.exit(exitCode);
      System.exit(filterExitCode(exitCode));
    }
  }
opends/src/server/org/opends/server/tools/ListBackends.java
@@ -79,7 +79,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
opends/src/server/org/opends/server/tools/ManageAccount.java
@@ -493,7 +493,7 @@
    int returnCode = main(args, System.out, System.err);
    if (returnCode != 0)
    {
      System.exit(returnCode);
      System.exit(filterExitCode(returnCode));
    }
  }
opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -42,7 +42,6 @@
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;
@@ -83,7 +82,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
@@ -346,7 +345,7 @@
    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.
opends/src/server/org/opends/server/tools/RestoreDB.java
@@ -63,7 +63,6 @@
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;
@@ -94,7 +93,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
@@ -363,7 +362,7 @@
      catch(Exception e)
      {
        System.err.println("Error installing the custom error logger: " +
            StaticUtils.stackTraceToSingleLineString(e));
                           stackTraceToSingleLineString(e));
      }
    }
opends/src/server/org/opends/server/tools/StartWindowsService.java
@@ -34,6 +34,7 @@
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
@@ -65,7 +66,7 @@
  {
    int result = startWindowsService(System.out, System.err);
    System.exit(result);
    System.exit(filterExitCode(result));
  }
  /**
opends/src/server/org/opends/server/tools/StopDS.java
@@ -136,7 +136,7 @@
    if (result != LDAPResultCode.SUCCESS)
    {
      System.exit(result);
      System.exit(filterExitCode(result));
    }
  }
opends/src/server/org/opends/server/tools/StopWindowsService.java
@@ -34,6 +34,7 @@
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -69,7 +70,7 @@
  {
    int result = stopWindowsService(System.out, System.err);
    System.exit(result);
    System.exit(filterExitCode(result));
  }
  /**
opends/src/server/org/opends/server/tools/VerifyIndex.java
@@ -58,7 +58,6 @@
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;
@@ -88,7 +87,7 @@
    if(retCode != 0)
    {
      System.exit(retCode);
      System.exit(filterExitCode(retCode));
    }
  }
@@ -357,7 +356,7 @@
    catch(Exception e)
    {
      System.err.println("Error installing the custom error logger: " +
          StaticUtils.stackTraceToSingleLineString(e));
                         stackTraceToSingleLineString(e));
    }
opends/src/server/org/opends/server/tools/WaitForFileDelete.java
@@ -96,7 +96,7 @@
      int exitCode = mainWait(args);
      if (exitCode != EXIT_CODE_SUCCESS)
      {
        System.exit(exitCode);
        System.exit(filterExitCode(exitCode));
      }
    }
    catch (Exception e)
opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -109,7 +109,7 @@
    // Run the application.
    int exitCode = app.run(args);
    if (exitCode != 0) {
      System.exit(exitCode);
      System.exit(filterExitCode(exitCode));
    }
  }
opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -87,7 +87,7 @@
    int returnCode = makeLDIF.makeLDIFMain(args);
    if (returnCode != 0)
    {
      System.exit(returnCode);
      System.exit(filterExitCode(returnCode));
    }
  }
opends/src/server/org/opends/server/util/StaticUtils.java
@@ -3784,5 +3784,36 @@
    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;
    }
  }
}