summaryrefslogtreecommitdiffstats
path: root/pki/base/silent/src/http/HTTPClient.java
diff options
context:
space:
mode:
authorjdennis <jdennis@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-11-19 20:38:27 +0000
committerjdennis <jdennis@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-11-19 20:38:27 +0000
commit43cccf7e4c8fa9f99ac5f0b79ab1a994223ca17d (patch)
tree303129a9c1d186e6e0ee794ec1917f9eb1f32f0d /pki/base/silent/src/http/HTTPClient.java
parentdc7c8dc30d495e21396d32bafcce716b13e32369 (diff)
Utilities cleanup
This is the final patch in a series mostly devoted to clean up of the common library. After application of this patch pkicommon will be in it's proposed form. A large proportion of this patch is devoted to replacing the use of UNIX shell commands to perform basic file system operations with built in Perl functions. The other items in this patch are things which didn't logically fit into any of the other patches. The rationale for eschewing the use of shell commands where possible is: 1) shell commands are OS specific, not all UN*X variants have the same behavior. 2) shell commands are available only on UN*X variants. 3) the built in Perl functions are portable across most OS's 4) the built in Perl functions have better error handling and reporting 5) the built in Perl functions are more efficient since they don't need to spawn a shell to do one simple operation, instead they call into the native OS library in the same process/thread. 6) the built in Perl functions are not subject to shell interpretation thus making their use more robust. It's not unusual to have to properly quote arguments when using a shell to protect against unintended interpretation by the shell. Or worse to expose the application to injection attacks where expanding a shell command results in an untended operation performed with root privileges. Also, many of the commands which used the Perl backtick operator to perform a shell operation were not properly detecting if the command failed. The backtick operator returns the stdout of the executed shell command and discards stderr. The old code would capture the result of the backtick operator (stdout), test to see if it was the empty string and if so concluded the command succeeded. This is not correct, one needs to check the exit status to determine success/failure. If an error did occur the command probably wrote to stderr, but stderr is discarded by the backtick operator. All this is documented in the patch which added the run_command() utility. For those routines for which there wasn't a Perl built-in equivalent the code was changed to call run_command() instead of using the backtick operator. Each of the utility routines which creates/copies files/directories had their parameter list expanded to accept optional specification of the permission and ownership to be applied to the file system object. This allows one call to replace multiple calls to utility routines which ultimately makes the code in pkicreate smaller, less verbose, easier to read and more robust. The code used to parse an initscript was removed (extract_chkconfig_parameters_from_start_stop_script()), it wasn't called and I'm at a loss for why this would have been needed in the first place. Also the parametrization of the start/stop positions is changing as we move closer to LSB. The global variable chkconfig_fields was also removed. It was only used in the routine extract_chkconfig_parameters_from_start_stop_script(). What's up with these global variables which should be private to the subroutine utilizing them? Many routines had logging added to them for tracing purposes. A call to emit() with the subroutine name and parameters. Many routines had the dry run check added to them. If $dry_run is true they emit their tracing information and then return success. Many routines had calls to add_install_info() added to them. This is used to record the installation actions being performed. Code that formerly had used shell commands to operate recursively on directories now instead iterate over the contents of the directories invoking our utilities, this allows us to use our primitives which record the installation action. For example rather than copy_directory() doing a "cp -r src dst" we walk the tree and invoke our own create_directory() and copy_file() routines which are responsible for recording the operation and doing such things as setting permissions and ownership. Comments referencing arg0, arg1, etc. were removed or edited (see previous patch for parameter list clean up for an explanation). Some functions were renamed to better reflect their actual operation as would be understood by a system administrator. e.g. give_file_to() became set_owner_group(), give_directory_to() became set_owner_group_on_directory_contents(). A utility called set_permissions() was added as well as a utility called set_file_props() which sets permissions and ownership with a single call. The routines move_file() and move_directory() were removed. They were using the deprecated shell methodology but were never called by any code. Rather than re-implement them I just removed them, if we need these again in the future we can add them back with the preferred Perl methodology. A potential bug was fixed in copy_directory(). The logic used to enumerate the set of destination directories which needed to be created had a logic flaw. If a source directory was empty it wouldn't get created in the destination. This occurred because the previous logic was to enumerate all the source files to be copied and generate a set of directories from those, but if a directory was empty it wouldn't show up in the file list. The new logic is to independently enumerate both directories and files in the src tree, this makes the directory list complete. Add utility to return the initscript name, get_registry_initscript_name(). git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@1545 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/silent/src/http/HTTPClient.java')
0 files changed, 0 insertions, 0 deletions