revision 1.29 date: 2008-05-29 05:09:16 +0000 * queue-pr.c: (submit_file_network): Setup the same regex syntax as the one setup by init_gnats, so the default regex pattern in get_referenced_pr_id() will behave in queue-pr the same way as when called by gnatsd. ---------------------------- revision 1.28 date: 2007-10-25 17:29:29 +0000 * queue-pr.c - (extract_field_name): New function. It extracts field name from the field specification, which may include an optional scope. - (get_field_type): New function. It returns field type for the field name. This function can handle field name notation with an optional scope. This function is now used by (read_edit_directives) and (validate_directive), since in both cases field name can contain an optional scope. - (validate_directive): Fixed logic. When an error is found in a directive we should return right away rather then try to process it further. ---------------------------- revision 1.27 date: 2007-10-25 00:34:10 +0000 queue-pr.c (valid_file) Free allocated memory after use. ---------------------------- revision 1.26 date: 2007-09-17 23:47:26 +0000 Avoid queue-pr crash due to uninitialized pointer. Also avoid clients from reporting "cannot understand" for server replies that include known error codes. * queue-pr.c (read_edit_directives): Initialize edits[cnt].message to NULL so that free_edit_info will not attempt to free it if remains unallocated. * queue-pr.c (free_edit_info): Set pointers to NULL after freeing them to avoid attempts to use or free them again. * queue-pr.c (free_server_reply): Set pointers to NULL after freeing them to avoid attempts to use or free them again. * client.c (get_reply): Add some missing error codes, so that clients do not report "cannot understand" for these well-defined codes. ---------------------------- revision 1.25 date: 2007-06-19 05:32:30 +0000 queue-pr.c (submit_file_local): Memory leak fix queue-pr.c (send_failure_notification): Removing unnecessary memory allocations, and adjusting whitespace formatting in the message so that a newline appears, and no redundant spaces appear. ---------------------------- revision 1.24 date: 2007-05-29 07:44:11 +0000 This is a fix to a crash when queue-pr tries to free a static string. Also, allowing edit directive values to preserve 1 or 2 trailing newlines for better readability of appended messages. (validate_directive): Malloc the fixed error messages so they can be freed, and avoid the crash that this PR reports. Other messages used the directive->message are malloced (coming from the server or otherwise, see functions handle_edit_failures and apply edits) so I could not opt to avoid freeing the message in free_edit_info. (remove_trailing_spaces): Added FieldType in the signature. If the field is multitext, then preserve trailing newlines (up to 2). The 1st newline prevents the first line of a message from appearing on the same line as the last line of a previous message (if you do @gnats audit-trail+sometext without a newline after the +, subsequest appends appear like: sometextResponsible-Changed-From-To: ...) The 2nd newline, if found, allows things like: @gnats audit-trail + text <<< purposeful blank line @gnats to have the blank line preserved, to allow messages having blank lines separate them for readability. Also, first check the loop condition before checking if the char is-space, to avoid calling isspace unnecessarily or out of bounds. (read_edit_directives): Determine field type outside the switch block, so it can be passed when remove_trailing_spaces is called later. (update_pr): Remove free of server_reply->message, since the subsequent free_server_reply call, takes care of it. ---------------------------- revision 1.23 date: 2007-03-04 17:42:13 +0000 queue-pr.c: removed the set_syslog_level call so it uses the default set by misc.c. In the future we may want to add a command-line option to control the log level. ---------------------------- revision 1.22 date: 2007-03-02 07:44:10 +0000 - Renaming netSubmitNewPR to netSubmitPR since that function can also re-submit existing PRs, not just brand new ones. - Improved the error message in queue-pr.c update function regarding a PR mismatch occuring during an update (if netSubmitPR returns a wrong number). ---------------------------- revision 1.21 date: 2007-03-02 01:23:29 +0000 Making sure the queue-pr client (in network mode) exits when a queue file has errors, by looking at the return value of netSubmitNewPR(). This will avoid deletion of the file so an operator can investigate the failure and salvage the data. Additionally, rename the file to .file (move_aside) to avoid repeated processing. Also, adding informative reasons to the various calls to move_aside. This will help debug the conditions related to the various .gnats queue files. An edit directive error during PR creation will result in .file.create_edit. A mail loop error will result in the queue file renamed to .file.mail_loop, and so on. Also added some extra logging in update(), as well as increased logging level to LOG_NOTICE since we are missing too valuable messages right now. ---------------------------- revision 1.20 date: 2006-06-22 18:46:52 +0000 - Add initialization for error_desc pointers which was largely missed. * queue-pr.c ---------------------------- revision 1.19 date: 2005-10-05 04:47:37 +0000 - Removed unneeded define GNATS_EDIT_DIRECTIVE_LEN - read_edit_directives: header lines were read into a smaller buffer than the fgets size parameter. Changed the buffer size to BUFSIZ which is 1024 (or larger on some systems) to accomodate the maximum allowable header lengths (998 excluding the CRLF according to rfc2822) - run_gnats: call init_logging in network mode. It was already being called for local mode (by routine init_gnats) - init_logging: openlog program_name instead of "gnatsd", to correctly identify the calling program ---------------------------- revision 1.18 date: 2005-09-27 17:45:03 +0000 * queue-pr.c: (apply_edits): Updated to pass session id to (netEditField). (get_session_id): New function used to generate a session id token. (update_pr): Updated to allow locking of a PR with a seesion id and bail out if lock failed. If lock successful, it will use the session id to submit all the edit directives in the mail and the rest of the mail body. At the end it will unlock the PR. (create_pr): Updated to allow it lock the newly created PR with a session id and unlock it when done. (submit_file_network): Updated to indicate if the file was processed successfully and ---------------------------- revision 1.17 date: 2005-06-28 18:44:56 +0000 * queue-pr.c: (validate_directive) added checking to allow text and multienum field type for append action. (remove_leading_spaces): New function to remove leading spaces. (remove_trailing_spaces): New function to remove trailing spaces. (read_edit_directives): Updated to handle append action for text and multienum fields. Handled the spaces and newlines issues in the input text. ---------------------------- revision 1.16 date: 2005-03-31 21:45:12 +0000 * queue-pr.c : Back out the patch. Need more consideration, may be for the next release. ---------------------------- revision 1.15 date: 2005-01-25 01:42:33 +0000 * queue-pr.c (apply_edits) : Updated to allow file stay in queue if edit directive in message is failed to apply due to PR lock for the --enable-edits mode. (create_pr) : Small change to follow GNATS coding style. (update_pr) : Ditto. ---------------------------- revision 1.14 date: 2004-12-09 00:59:26 +0000 * queue-pr.c (create_pr) - we need to rewind fp before submit the new message. ---------------------------- revision 1.13 date: 2004-12-02 02:30:42 +0000 * queue-pr.c (create_pr) - New function to unload create new PR function that used to be done in submit_file_network. (update_pr) - New function to unload the PR update function that used to done in submit_file_network. ---------------------------- revision 1.12 date: 2004-11-30 22:20:57 +0000 * queue-pr.c (submit_file_network) - Updated to allow message body to be submitted before applying any edit directives. If the message subject line doesn't have any PR reference number, it is assumed to be a new PR and the message will be submitted first, followed by edit directives if any. ---------------------------- revision 1.11 date: 2004-06-07 21:40:49 +0000 queue-pr.c : Updated (edit_info) struct to include edit directive command, e.g. append or replace, and optional change reason. (get_multiline_value) - New function. It will be invloved to process a multiline edit directive. (read_edit_directives) - Enhanced to allow append operation for edit directives. (validate_directive) - New function. Validate the field in an edit directive must be valid and operation that it is trying to involve must be valid for the field type. (submit_file_network) - Enhanced such that if a mail message only contains edit directive and nothing else, then it will not try to submit that mail message to create unnecessary email message from gnats. ---------------------------- revision 1.10 date: 2004-05-07 21:00:02 +0000 * queue-pr.c : Added header file "pcodes.h". Updated edit_info struct to allow return code and message from gnatsd being handled. (free_edit_info): Allow to free up memory allocated for message from gnatsd. (read_edit_directives): Changed to allow capturing of the edit directive until a newline character. (send_failure_notification): New function - allows queue-pr to compose and send an email to the submitter on edit failure. (handle_edit_failures): New function - loop through the edit_info struts and find out all the edits that either passed or failed and call up send_failure_notification to notify the submitter on failure. (free_server_reply): New function - free up memory allocated to SeverReply struct. (apply_edits): Enhanced so that apply_edit will return a value on finish. It also populates the edit_info structs with the values from ServerReply struct and call up handle_edit_failure if it saw an edit failure. (move_aside): Enhanced so that the failed message will be moved aside with a suffix added. The function signature is changed. (submit_file_network): Enhanced to check the return state of apply_edits. (valid_file): Calls to move_side signature changed. ---------------------------- revision 1.9 date: 2004-03-31 11:27:16 +0000 * queue-pr.c: the previous commit broke the solaris build...limits.h was inadvertently removed during development...it's back now. ---------------------------- revision 1.8 date: 2004-03-31 11:00:24 +0000 * queue-pr.c: Added a new '--enable-edits' command line option which, if specified, will search the body of the email message for specially formatted edit directives which are applied to the PR after the message is submitted. This is only supported when running queue-pr in network mode. Also defined a new struct (network_info) for passing around the network parameters to clean up some of the function signatures. (read_edit_directives): New function - extract any edit directives from the body of the message into an in-memory cache for later processing. (free_edit_info): New function - free up the cached edit directives. (apply_edits): New function - process any edit directives found in the body of the message. (submit_file_network): Enhanced to allow for processing of edit directives. (run_gnats): Signature change - takes and passes down a new enable_edits flag which tells the submit function whether or not to process edit directives. (main): Stuff all network mode parameters into a new network_info struct to simplify function signatures. Also, now takes a '--enable-edits' option to control whether or not edit directives in the body of the message are allowed - only supported for network mode. ---------------------------- revision 1.7 date: 2003-10-31 00:31:15 +0000 * gnats.h (get_reply, netSubmitNewPR): Reset signatures back to what they were earlier...basically rolling back changes associated with an alternate patch which was applied to the Juniper sources. * queue-pr.c (netSubmitNewPR): Ditto. ---------------------------- revision 1.6 date: 2003-08-12 01:28:55 +0000 * queue-pr.c (submit_file_network): open/close a new gnatsd connection for every file being processed. This allows for gnatsd errors associated with a file in the queue, without affecting additional files in the queue. (run_gnats): Ditto. Also, we now exit if we can't connect to gnatsd. (main): When running in network mode, no longer connect to gnatsd from main. Rather connect to gnatsd for every file that needs to be processed allowing for gnatsd errors that result in an exit. ---------------------------- revision 1.5 date: 2003-05-29 19:56:02 +0000 in order to prevent mail loops (ie. if address@hidden is mistakenly entered in the Notify-List field), gnats will add an X-header to all outgoing mail. queue-pr will look for this header, and reject any message containing it. ---------------------------- revision 1.4 date: 2003-04-14 21:57:23 +0000 * queue-pr.c (run_gnats) : Replaced client_unlock_gnats call with a call to unlock_gnats. ---------------------------- revision 1.3 date: 2003-04-09 07:16:28 +0000 * queue-pr.c : Allow queue-pr to be run in network mode. The primary motivation for this work was to avoid having to define a password in the dbconfig file when using the Oracle datastore - since queue-pr running in localhost mode accesses the PR data repository directly, it needs to establish it's own database connection which requires a password. When a client connects to a gnats database through gnatsd running in daemon mode, it uses Oracle's proxy authentication which avoids the need for a per-gnats-database oracle password. Note that in network mode, all errors are simply logged to stderr rather than being emailed to gnats-admin - this may need to be re-addressed at some point. ---------------------------- revision 1.2 date: 2003-02-18 02:55:23 +0000 the call to init_gnats (which invokes the db initialization function) is now only made when running in 'run' mode...there's no need to connect to the datastore when simply queuing incoming PR messages. This makes queue-pr a little more robust in 'queue' mode in the face of a misconfigured dbconfig file (or when the database is down if running with a database backend). ---------------------------- revision 1.1 date: 2002-12-06 10:32:58 +0000 Initial revision ---------------------------- revision 1.1.1.1 date: 2002-12-06 10:32:58 +0000 Source based on Gnats 4.0 beta 2 with modifications by Mel Hatzis to generalize the backend datastore. ---------------------------- revision 1.12.2.2 date: 2004-12-09 00:56:46 +0000 * queue-pr.c (create_pr) - we need to rewind fp before submit the new message. ---------------------------- revision 1.12.2.1 date: 2004-12-02 02:35:25 +0000 * queue-pr.c (create_pr) - New function to unload create new PR function that used to be done in submit_file_network. (update_pr) - New function to unload the PR update function that used to done in submit_file_network. ---------------------------- revision 1.23.8.1 date: 2007-05-29 08:08:19 +0000 Merging changes from revision 1.24 into the 4.0.7.1 branch. ---------------------------- revision 1.28.16.9 date: 2009-08-04 09:30:22 +0000 * queue-pr.c -(submit_file_network): - Modified to extract the list of recipients in the file submitted to create a pr. - Modified the create_pr function call. -(create_pr): - Modified the signature of the function to accept the pr subject and list of recipients in the file submitted to avoid reallocating pr for the same file and reading the header again which results in empty header values in the created PR. ---------------------------- revision 1.28.16.8 date: 2009-07-22 09:55:38 +0000 * queue-pr.c -(create_pr): - Modified the netSubmitPR function call. - Added a condition to rename the queue file and send failure notification to the submitter if some error occurs while submitting a PR using netSubmitPR function (i.e. netSubmitPR returns "0"). -(update_pr): - Modified netSubmitPR function call. -(send_failure_notification): - Modified the signature of the function to distinguish between create and update failure to send the corresponding failure notification. - Renamed the passed_edits to passed_msg, failed_edits to failied_msg as this function is used to notify both create and edit failures. ---------------------------- revision 1.28.16.7 date: 2009-07-17 05:16:51 +0000 * queue-pr.c: -(update_pr): - Added a condition to check and return value -1 for nonexistent PRs. - Fixed some pre-existing whitespace issues. -(submit_file_network): - Added a condition to return exit status 2 when queue-pr is running in the network mode and encounters nonexistent PR(s). So, renames the file to avoid queue-pr to reprocess these nonexistent PR(s). - Fixed some pre-existing whitespace issues. ---------------------------- revision 1.28.16.6 date: 2009-05-28 09:17:06 +0000 * queue-pr.c: -(cmpr_mtime): New primary function for qsort to sort the files in the gnats queue directory. -(run_gnats): Modify to sort the queue directory to process the queue files in the arival order. -(valid_file): Modify a condition to check for core file as systems will be cofigured to create core files with name: core.progname.pid instead of simply core. - Added a file structure to store file name and file last modified time. ---------------------------- revision 1.28.16.5 date: 2009-04-17 22:59:26 +0000 * queue-pr.c (update_pr): Updated the netLockPR function call with return_pr argument set to 0 to make use of lock-nopr. This change will reduce the time taken to edit the PR from email directives. * queue-pr.c (create_pr): Updated the netLockPR function call with return_pr argument set to 0 to make use of lock-nopr. ---------------------------- revision 1.28.16.4 date: 2009-03-16 23:15:32 +0000 Allow specifying a custom queue directory in the queue-pr commandline. * queue-pr.c: Adding qdir (-i for short) to the long_options struct, as well as updating USAGE accordingly. (drop_msg): Refactoring function slightly, adding some comments, and improving error message by including queue directory name when reporting failure to rename queue file. (main): - Reordiring getopt_long short option list in alphabetical order for easier maintenance. - Minor whitespace fixes. - Process new option -i (--qdir) that specifies custom queue directory to override gnats-queue. This allows maintaining multiple queues. If the specified directory is a full path it is used as is, otherwise it is assumed to be relative to the database directory (like gnats-queue is). ---------------------------- revision 1.28.16.3 date: 2009-01-19 19:52:29 +0000 Minor fix for a PR already implemented earlier: * queue-pr.c (move_aside): This function should not rename files that have been specified in the command line, since they are not part of a queue. Also refactoring the code a little to make it simpler, and improved on the comments. ---------------------------- revision 1.28.16.2 date: 2008-11-25 20:03:33 +0000 * queue-pr.c (run_gnats): - Force user to specify the -r or -q option, since queue-pr doesn't do anything without them. - Make queue-pr -f and -r options work together to run a user-specified queue file outside the gnats queue directory. - Free the memory allocated in this function before returning. ---------------------------- revision 1.28.16.1 date: 2008-05-29 14:38:56 +0000 Merging changes for configurable subject line PR matching feature * queue-pr.c (merging revision 1.29) =============================================================================