#901 Redundant upgrade code in CMSStartServlet
Closed: fixed 4 years ago by edewata. Opened 10 years ago by edewata.

The following code in CMSStartServlet seems to be intended to rename CMS.cfg from a legacy system into CS.cfg. Since this code already existed in Dogtag 9, all CMS.cfg would have been renamed to CS.cfg in Dogtag 9. Since Dogtag 10 does not support upgrading from legacy system older than Dogtag 9, this code can be removed from the servlet which will simplify maintenance.

File f = new File(path);
String old_path = "";
if (!f.exists()) {
    int index = path.lastIndexOf("CS.cfg");
    if (index != -1) {
        old_path = path.substring(0, index) + "CMS.cfg";
    }
    File f1 = new File(old_path);
    if (f1.exists()) {
        // The following block of code moves "CMS.cfg" to "CS.cfg".
        try {
            if (Utils.isNT()) {
                // NT is very picky on the path
                Utils.exec("copy " +
                    f1.getAbsolutePath().replace('/', '\\') +
                    " " +
                    f.getAbsolutePath().replace('/', '\\'));
            } else {
                // Create a copy of the original file which
                // preserves the original file permissions.
                Utils.exec("cp -p " + f1.getAbsolutePath() + " " +
                    f.getAbsolutePath());
            }

            // Remove the original file if and only if
            // the backup copy was successful.
            if (f.exists()) {
                if (!f1.delete()) {
                    CMS.debug("CMSStartServlet: init: Cannot delete file : " + old_path);
                }

                // Make certain that the new file has
                // the correct permissions.
                if (!Utils.isNT()) {
                    Utils.exec("chmod 00660 " + f.getAbsolutePath());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Metadata Update from @edewata:
- Issue set to the milestone: UNTRIAGED

7 years ago

Metadata Update from @edewata:
- Custom field feature adjusted to None
- Custom field reviewer adjusted to None
- Custom field version adjusted to None
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/1468

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Login to comment on this ticket.

Metadata