Mike Rylander [Wed, 30 Jul 2014 17:29:46 +0000 (13:29 -0400)]
LP#1350457: Pass caller's session to subrequests called via method_lookup
In the process of looking up a method for an internal subrequest, we lose
session info. This is a problem when the subrequest makes a remote request,
because then the subrequest can't look up the proper locale, among other
things. The forthcoming branch passes the caller's session to the subrequest.
This patch also teaches OpenSRF object registration how to strip certain
object members -- in particular, the session -- so that introspection
continues to work.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Mike Rylander [Thu, 10 Sep 2015 20:56:13 +0000 (16:56 -0400)]
LP#1494486: Limit damage caused by dropped drone XMPP sockets
It is apparently possible for drones to get into a state where their XMPP
socket is closed but they don't notice. This is bad because the drone can
continue to receive requests from its listener but can no longer respond
to them. To limit the pain this can cause, we should kill the drone as soon
as we notice this condition.
To avoid overhead, this commit notices when the socket returns an error (or
raises a signal, in Perl) upon write, and exits immediately. One message
will be lost, but the drone will no longer be a black hole that does nothing
but absorb requests it can never fill.
To test
-------
[1] Start an OpenSRF stack and look for a drone process.
[2] Use lsof to identify which socket that drone is using
to talk to XMPP.
[3] Use gdb to attach to the process and close the socket, e.g.,
$ gdb -p $PID
(gdb) p close(11) # or whatever the socket number was
(gdb) c
[4] Use srfsh to make requests of that service. Eventually, one
of them will hit the drone.
[5] Sans patch, the request will get handled by the drone, but
the results will never get sent, and the drone will remain
available to handle other requests.
[6] With the patch, the drone will exit when it discovers that it
can no longer write to the XMPP socket.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Galen Charlton [Wed, 3 Jun 2015 17:42:06 +0000 (17:42 +0000)]
LP#1461625: ensure srfsh doesn't close STDOUT prematurely
Ensure that when running srfsh in non-interactive mode
that reads commands directly from a file, (i.e.,
"srfsh script.srfsh" or as a shebang script), it does
not close STDOUT after handling the first request.
To test
-------
[1] Create a srfsh script containing:
[2] Run "srfsh script.srfsh". Note that only the
results of the first echo request are output.
[3] Apply the patch and recompile, then run
"srfsh script.srfsh" again. This time, the
output of both requests is displayed.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
Galen Charlton [Tue, 24 Mar 2015 21:00:57 +0000 (21:00 +0000)]
LP#1436047: make srfsh --safe act as if "! command" doesn't exist
This patch make srfsh treat attempting to run an external
command via "! command" as a parsing error if --safe is
supplied. It also suppress mention of "! commands" from
the internal help.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
Mike Rylander [Tue, 24 Mar 2015 20:22:16 +0000 (16:22 -0400)]
LP#1436047: Allow disabling of "bang commands" in srfsh
srfsh has the ability to execute commands via system() calls using
the common "!command" syntax. This is very useful, but it would
be nice to be able to turn that functionality off in some cases.
This branch adds argument parsing to detect a new '--safe' command
line parameter, which disables the "!command" syntax.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Avoid referencing variable defined somewhere outside the send_ws()
function. Doing so happened to result in re-sending the same message
twice in some cases.
Signed-off-by: Bill Erickson <berickxx@gmail.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
Ben Shum [Mon, 10 Nov 2014 17:20:31 +0000 (12:20 -0500)]
LP#1391248: Fix NameVirtualHost warnings in websockets apache2.conf
For the websockets configuration, the sample apache2.conf for Apache 2.4 (i.e.
Ubuntu 14.04, etc.) contains NameVirtualHost entries that are no longer
needed.
When starting apache2-websockets, you may see warnings like:
AH00548: NameVirtualHost has no effect and will be removed in the next
release /etc/apache2-websockets/apache2.conf:53
Remove the NameVirtualHost entries and these warnings go away.
Signed-off-by: Ben Shum <bshum@biblio.org> Signed-off-by: Bill Erickson <berickxx@gmail.com>
Ben Shum [Sat, 13 Sep 2014 22:23:46 +0000 (18:23 -0400)]
LP#1369169: Mention the requirement for valid SSL certificate
The apache2-websockets instance will not start without a valid SSL certificate
in /etc/apache2/ssl. Include a mention of this in the README with the extra
stipulation that it is still possible to use a self-signed SSL certificate for
testing purposes, but this is not recommended for live installations.
Signed-off-by: Ben Shum <bshum@biblio.org> Signed-off-by: Bill Erickson <berickxx@gmail.com>
Ben Shum [Fri, 12 Sep 2014 21:58:11 +0000 (17:58 -0400)]
LP#1369169: Add websockets section to the OpenSRF README
Remove the separate README.websockets and move the contents into the primary
OpenSRF README document so that all steps are in one place.
Additional edits to the websockets instructions to detail differences made
between Ubuntu 14.04 Trusty and Debian / Ubuntu 12.04 Precise. More edits
may be necessary for Debian Jessie later?
Also, create a separate config file for Apache 2.4 that is copied into place
for Ubuntu Trusty and potentially other systems that will need it.
Signed-off-by: Ben Shum <bshum@biblio.org> Signed-off-by: Bill Erickson <berickxx@gmail.com>
Ben Shum [Sat, 13 Sep 2014 22:04:54 +0000 (18:04 -0400)]
LP#1369169: Add Apache 2.4 specific configuration file for websockets
For Apache 2.4, there were some necessary modifications for running the
websockets code properly. Similar to how we do things in Evergreen, we
added a new directory for apache_24 which contains the modified apache2.conf
file.
Signed-off-by: Ben Shum <bshum@biblio.org> Signed-off-by: Bill Erickson <berickxx@gmail.com>
This allows the OpenSRF JavaScript client library (or
to be precise, one that has been modified to direct
requests at a different domain) to take advantage of CORS
support.
Bennett Goble [Tue, 22 May 2012 15:57:56 +0000 (11:57 -0400)]
LP#1002028: Cross Origin Resource Sharing for OpenSRF
Background
----------
Browsers' same-origin policy currently restricts requests to the current
website's domain to prevent various nefarious scenarios. However,
because APIs and other web resources need to remain open to cross-site
use Cross Origin Resource Sharing (CORS) was created to allow services
to formally authorize cross-origin requests. CORS makes it simple to use
OpenSRF's HTTP translator and gateway APIs on websites using separate
domains.
Example Scenarios
-----------------
1) A library would like an AJAX-driven "quicksearch" box on their main
site, which is hosted on a different domain than their catalog.
2) A developer wants to create new web applications and services that
tie into Evergreen, but does not wish to install EG locally or
configure a proxy.
Implementation
--------------
The function crossOriginHeaders() has been added to apachetools.c.
Incoming requests are checked to see if they have an Origin header. The
value of the Origin header is checked against a whitelist defined in
opensrf_core.xml config (XPath: /config/gateway/cross_origin/origin).
The function returns 1 if CORS headers have been added to the response.
Notes
-----
* The OpenSRF Javascript client library (opensrf.js) defaults to the root
of the current web host "/osrf-http-translator." In addition, synchronous
requests are presumed in some situations: resulting in the oncomplete
method never returning (Blocking requests are not possible with cross-
domain XHR.)
* It is also possible to enable CORS with the Apache "set header"
configuration directive. However, this means that the necessary headers
would be appended to every response.
Links
-----
Specification - http://www.w3.org/TR/cors/
Wikipedia Article - http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
Josh Stompro [Wed, 21 May 2014 13:26:53 +0000 (08:26 -0500)]
(doc) Reorder changes to ejabberd.cfg in install instructions
I found it annoying that the list of changes to make to ejabberd.cfg
didn't follow the order that the options showed up in the default
Debian ejabberd.cfg. I reordered them so after you finish changing one
option, you can search forward in the document for the next term.
Mike Rylander [Wed, 30 Jul 2014 17:29:46 +0000 (13:29 -0400)]
LP#1350457: Pass caller's session to subrequests called via method_lookup
In the process of looking up a method for an internal subrequest, we lose
session info. This is a problem when the subrequest makes a remote request,
because then the subrequest can't look up the proper locale, among other
things. The forthcoming branch passes the caller's session to the subrequest.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
The most common form of XMPP error messages are "bounced" messages, i.e.
those where the recipient is not available. Instead of passing these
useless and confusing messages down to a drone for processing, log the
error in the listener and drop the message.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
There appears to be a bug in Chromium where loading the same page
multiple times (without a refresh or cache clear) causes the
SharedWorker to fail to instantiate on every other page load.
Further research pending. Disabling SharedWorker's entirely for
now.
Note, to replicate, load a page using shared workers, focus the
browser address bar, hit Enter to load the page again. The shared
worker will fail to load on every other page load, though it will
appear to the SharedWorker caller (opensrf.js) that the port is open.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
* avoid unneccessary and wrong incantation of apr_thread_exit. The two
sub-threads now both live for the duration of the process.
* to be safe, create thread mutex before threads
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
It was falling behind the shared lib in bug fixes and features. A
per-tab WS implementation is (maybe) a dangerous thing to have around,
as well, since it encourages /many/ connections. Can resurrect later if
needed.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Mon, 3 Mar 2014 15:29:23 +0000 (10:29 -0500)]
LP#1268619: websocket: avoid module auto configuration
We don't want osrf_websocket_translator to be directly loaded as a
module, since it is not an apache module, but a shared library loaded by
an apache module (mod_websockets). This is especially true of the default
apache instance.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Added support for an idle timeout and idle check interval configuration
variables. These allow each websocket apache process to kick off
clients that have been connected and are idle for too long, thus hogging
a process unnecessarily.
Added a SIGUSR1 signal handler which forces the idle timeout to be very
low and a short re-check period so that the client can be kicked as soon
as there are no open conversations.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
* starting packet inspection
* activity log; recipient removal
* only cache connected recipients; use request_rec pool for session_pool parent
* wrap all thread work in mutex
* session memory goodness
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
* use jsonObjectFree() on jsonObjets, not free();
* removed some debugging logs
* accommodate API changes for Apache 2.4
* safer logging:
Avoid using ap_log_rerror, in particular referencing server->request
from the responder thread, since the request_rec will be invalid after
on_disconnect is called.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
OpenSRF can run mutiple times, as different users, on one host.
Right now we look for all service processes, but we should only
look for our own. This patch does that.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
LP#1285915: document that perl2JSON doesn't order hash keys
This patch documents that JSON strings returned by
OpenSRF::Utils::JSON->perl2JSON() should not be expected to have
hash keys sorted in any particular order. It also adjusts a
corresponding test case to consistently pass under Perl 5.18, which
introduces hash order randomization.
Forcing JSON output to be in canonical form is another option, and
easily done by JSON::XS, but would add overhead.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berick@esilibrary.com>
LP#1234816: improve const-correctness of osrfCachePutString and osrfCachePutObject
Since the cache key is not modified by osrfCachePutString and
osrfCachePutObject, this patch changes the key parameter of those
two functions from char* to const char*. It also updates one
caller osrfCachePutObject to not cast away const-ness.
This patch has no functional impact, but enables future callers
of osrfCachePut* to pass constant strings without having to
cast away the const-ness.
Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berick@esilibrary.com>
This script is no longer user, since ejabberdctrl is used instead.
What's more, this script uses a Perl package (libnet-jabber-perl) which
is no longer available in Debian (Jessie).
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Docgen output would be a bit more useful if it respected the formatting
(such as it is) of the signature content provided by the developer. So,
let's make that happen.
Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Instead of simply producing an error message in the OpenSRF logs, calls
to nonexistent subroutines are now fatal errors which will stop code
execution.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Fri, 12 Oct 2012 20:57:15 +0000 (16:57 -0400)]
LP#1066131: srfsh.py should not require opensrf.settings
Update srfsh.py to connect to the opensrf network without automatically
reading the opensrf.setting server data. This allows srfsh.py to run a
non-private network.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Tue, 7 Jan 2014 19:06:06 +0000 (14:06 -0500)]
osrf_control router-de/re-register and reload commands
Added support for the following new command line options:
--router-de-register
--router-de-register-all
Sends a SIGUSR1 signal to the selected service(s), which causes each
service's listener process to send an "unregister" command to all
registered routers. The --all variant sends the signal to all
running listeners. The non-(--all) variant requires a --service.
--router-re-register
--router-re-register-all
Sends a SIGUSR2 signal to the selected service(s), which causes each
service's listener process to send a "register" command to all
configured routers routers. The --all variant sends the signal to
all running listeners. The non-(--all) variant requires a --service.
--reload
--reload-all
Sends a SIGHUP signal to the selected service(s). SIGHUP causes
each Listener process to reload its opensrf_core.xml config file
and gracefully re-launch drone processes. The -all variant sends
the signal to all services. The non-(-all) variant requires a
--service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Tue, 7 Jan 2014 19:06:06 +0000 (14:06 -0500)]
osrf_control router-de/re-register and reload commands
Added support for the following new command line options:
--router-de-register
--router-de-register-all
Sends a SIGUSR1 signal to the selected service(s), which causes each
service's listener process to send an "unregister" command to all
registered routers. The --all variant sends the signal to all
running listeners. The non-(--all) variant requires a --service.
--router-re-register
--router-re-register-all
Sends a SIGUSR2 signal to the selected service(s), which causes each
service's listener process to send a "register" command to all
configured routers routers. The --all variant sends the signal to
all running listeners. The non-(--all) variant requires a --service.
--reload
--reload-all
Sends a SIGHUP signal to the selected service(s). SIGHUP causes
each Listener process to reload its opensrf_core.xml config file
and gracefully re-launch drone processes. The -all variant sends
the signal to all services. The non-(-all) variant requires a
--service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Thu, 21 Nov 2013 21:37:38 +0000 (16:37 -0500)]
recover osrf_control router start
With the addition of service verification, which ensures that a service
is meant to run on the requested host, we lost the ability to start the
router by itself, since the router is never explicitly configured to run
anywhere. This patch assumes the router is always a valid service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Wells <dbw2@calvin.edu>
Bill Erickson [Thu, 21 Nov 2013 21:37:38 +0000 (16:37 -0500)]
recover osrf_control router start
With the addition of service verification, which ensures that a service
is meant to run on the requested host, we lost the ability to start the
router by itself, since the router is never explicitly configured to run
anywhere. This patch assumes the router is always a valid service.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Wells <dbw2@calvin.edu>
Bill Erickson [Thu, 5 Dec 2013 17:27:44 +0000 (12:27 -0500)]
OpenSRF client disconnect robustification (Perl)
* Improve detection of client connection state with jabber server
Be more aggressive in testing and responding to failed connectivity.
It can happen in various ways, depending on what's happening to the
jabber server (death, delay, graceful shutdown). With these changes
we attempt to cover all the bases and detect as early as possible that
a connection has died, specifically when trying to create a new
connection after one has failed.
* Do a better job of cleaning up dead connections
Transport::PeerHandle now has a reset() action which disconnects (when
possible) and clears the global connection reference.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bill Erickson [Thu, 5 Dec 2013 17:27:44 +0000 (12:27 -0500)]
OpenSRF client disconnect robustification (Perl)
* Improve detection of client connection state with jabber server
Be more aggressive in testing and responding to failed connectivity.
It can happen in various ways, depending on what's happening to the
jabber server (death, delay, graceful shutdown). With these changes
we attempt to cover all the bases and detect as early as possible that
a connection has died, specifically when trying to create a new
connection after one has failed.
* Do a better job of cleaning up dead connections
Transport::PeerHandle now has a reset() action which disconnects (when
possible) and clears the global connection reference.
Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>