)]}'
{"specs/liberty/privsep.rst":[{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"b7a31a139b877b61ed339d1be2107b281047d703","unresolved":false,"context_lines":[{"line_number":56,"context_line":"Otherwise known as \"Why don\u0027t we just run agents as root?\""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"Running with the least privileges possible is a common defensive"},{"line_number":59,"context_line":"security design.  The assumption is that it *might* be possible to"},{"line_number":60,"context_line":"remotely exploit your service via the publicly exposed network"},{"line_number":61,"context_line":"protocols so you want to run the bulk of your code with reduced/no"},{"line_number":62,"context_line":"privilege and only gain special privileges when absolutely required."}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_6f3ebd8d","line":59,"updated":"2015-07-21 22:00:44.000000000","message":"Actually without https://blueprints.launchpad.net/oslo.messaging/+spec/trusted-messaging being implemented its not IMHO a question of \u0027might\u0027, just \u0027when\u0027.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"140c54bc07e7e1c1bb68f3829108e7f424fa3f4d","unresolved":false,"context_lines":[{"line_number":81,"context_line":"   * Avoid root as much as possible"},{"line_number":82,"context_line":"   * Security interface should be easy to audit"},{"line_number":83,"context_line":"#. Easy to use by developers"},{"line_number":84,"context_line":"   * Just add a new function with a decorator"},{"line_number":85,"context_line":"#. Performance"},{"line_number":86,"context_line":"   * Allows library use rather than parsing output of command line tools"},{"line_number":87,"context_line":""}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_355ff40f","line":84,"updated":"2015-07-24 16:24:47.000000000","message":"I\u0027m a little worried about foot-guns occuring where ease of use compromises the actual realised security by bringing in too much or inappropriate code. Decorating X implies to me that folk will do things like\n\n class Something:\n\n     def insecure(self):pass\n\n     @privsep\n     def secure(self):pass\n\nWhich is clearly (to my eye) insecure.\n\nI\u0027d like to see the secured code physically separated (e.g. in dedicated modules), and lintable rules on what it can import. Using a decorator on the remoting entry points would be fine given those constraints.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"eaf8b908b1579747da5b10e46b8d054528143c9a","unresolved":false,"context_lines":[{"line_number":81,"context_line":"   * Avoid root as much as possible"},{"line_number":82,"context_line":"   * Security interface should be easy to audit"},{"line_number":83,"context_line":"#. Easy to use by developers"},{"line_number":84,"context_line":"   * Just add a new function with a decorator"},{"line_number":85,"context_line":"#. Performance"},{"line_number":86,"context_line":"   * Allows library use rather than parsing output of command line tools"},{"line_number":87,"context_line":""}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_957b447b","line":84,"in_reply_to":"3a50d1a3_355ff40f","updated":"2015-07-27 01:07:54.000000000","message":"1. Only plain-old-data types are supported across the serialisation boundary, not objects.  So passing ``self`` in your example wouldn\u0027t work.\n\n2. The decorator can only be used below a known (configured in code) python module prefix, and the current suggestion in the review discussion is that this should be a new top-level python package.\n\nObviously with (2) we could run more aggressive/different linters just on that subtree, although I haven\u0027t suggested that anywhere here explicitly.\n\nIs that sufficient to satisfy your concern?","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"426d85b7c80d6b16b659a8e392ce317d9aa27073","unresolved":false,"context_lines":[{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"},{"line_number":125,"context_line":"multiprocessing\u0027s usual insecure serialisation options with a"},{"line_number":126,"context_line":"json-based alternative."},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"The underlying communication channel must not be exposed remotely -"},{"line_number":129,"context_line":"Unix sockets or pipes are obvious choices."}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_e0609a03","line":126,"updated":"2015-07-21 23:51:14.000000000","message":"https://github.com/openstack/oslo.serialization/blob/master/oslo_serialization/msgpackutils.py#L298 (the kinds of special objects that can be serialized, outside of the normal msgpack specification).","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"140c54bc07e7e1c1bb68f3829108e7f424fa3f4d","unresolved":false,"context_lines":[{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"},{"line_number":125,"context_line":"multiprocessing\u0027s usual insecure serialisation options with a"},{"line_number":126,"context_line":"json-based alternative."},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"The underlying communication channel must not be exposed remotely -"},{"line_number":129,"context_line":"Unix sockets or pipes are obvious choices."}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_d59a50c5","line":126,"updated":"2015-07-24 16:24:47.000000000","message":"using msgpack directly would be appropriate here I think, unless we can get oslo.serialization to be more paranoid than has been my impression thus far: I defer to folk more experienced with its development than me though.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"6b192b196071d867e586daf67d27de698bbf30a3","unresolved":false,"context_lines":[{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"},{"line_number":125,"context_line":"multiprocessing\u0027s usual insecure serialisation options with a"},{"line_number":126,"context_line":"json-based alternative."},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"The underlying communication channel must not be exposed remotely -"},{"line_number":129,"context_line":"Unix sockets or pipes are obvious choices."}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_656a2ef0","line":126,"in_reply_to":"3a50d1a3_01ba5e0a","updated":"2015-07-22 16:14:30.000000000","message":"Either? Might be useful to send a ML question about that, I\u0027m not really sure myself, I created the \u0027msgpackutils.py\u0027 code, so if I was to say security, then I\u0027d say it, but might want to ask the general oslo developers :)","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"eaf8b908b1579747da5b10e46b8d054528143c9a","unresolved":false,"context_lines":[{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"},{"line_number":125,"context_line":"multiprocessing\u0027s usual insecure serialisation options with a"},{"line_number":126,"context_line":"json-based alternative."},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"The underlying communication channel must not be exposed remotely -"},{"line_number":129,"context_line":"Unix sockets or pipes are obvious choices."}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_95c904af","line":126,"in_reply_to":"3a50d1a3_d59a50c5","updated":"2015-07-27 01:07:54.000000000","message":"dims answered my openstack-dev question declaring that oslo.serialization *is* intended to be suitable for security-sensitive purposes.  So I\u0027ll switch the spec to be \"whatever oslo.serialization can encode\".","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"d55ebdd6750415321db28c4dc3025a1b3467ddeb","unresolved":false,"context_lines":[{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"},{"line_number":125,"context_line":"multiprocessing\u0027s usual insecure serialisation options with a"},{"line_number":126,"context_line":"json-based alternative."},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"The underlying communication channel must not be exposed remotely -"},{"line_number":129,"context_line":"Unix sockets or pipes are obvious choices."}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_01ba5e0a","line":126,"in_reply_to":"3a50d1a3_e0609a03","updated":"2015-07-22 07:10:57.000000000","message":"Oh neat, I was unaware of oslo.serialization.\n\nIs the priority of oslo.serialization convenience or security?\nIf I use that library for this purpose, we need to impress a suitable level of paranoia on oslo.serialization development.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"95207c9b68a5e6f866e2f85f3abd313f0fecb1fa","unresolved":false,"context_lines":[{"line_number":132,"context_line":"unprivileged portions of privsep.  Specific serialisation and"},{"line_number":133,"context_line":"communication choices are implementation details and can be changed"},{"line_number":134,"context_line":"over time without compatibility concerns."},{"line_number":135,"context_line":""},{"line_number":136,"context_line":"Developer\u0027s Point of View"},{"line_number":137,"context_line":"-------------------------"},{"line_number":138,"context_line":""}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_1b1e575f","line":135,"updated":"2015-07-21 23:55:30.000000000","message":"What is the handshake that is done to ensure that a new client that comes online (or a malicious user that has gotten access to the socket/pipe file) can\u0027t request the privileged process to do things on its behalf, is there some kind of shared token/key? (afaik multiprocessing managers use a shared authkey that is used for this, perhaps something similar?) \n\n - https://hg.python.org/cpython/file/b4cbecbc0781/Lib/multiprocessing/managers.py#l697","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"d55ebdd6750415321db28c4dc3025a1b3467ddeb","unresolved":false,"context_lines":[{"line_number":132,"context_line":"unprivileged portions of privsep.  Specific serialisation and"},{"line_number":133,"context_line":"communication choices are implementation details and can be changed"},{"line_number":134,"context_line":"over time without compatibility concerns."},{"line_number":135,"context_line":""},{"line_number":136,"context_line":"Developer\u0027s Point of View"},{"line_number":137,"context_line":"-------------------------"},{"line_number":138,"context_line":""}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_41206648","line":135,"in_reply_to":"3a50d1a3_1b1e575f","updated":"2015-07-22 07:10:57.000000000","message":"The privileged process connects back to the unprivileged, so no access to the privileged process is ever exposed.  I\u0027ll add a paragraph describing this.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"f1d89d1db3587523126f1bc30856db0a4de25637","unresolved":false,"context_lines":[{"line_number":167,"context_line":"only basic \"json like\" python types are accepted in args or return"},{"line_number":168,"context_line":"values - no user-defined objects."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":171,"context_line":"decorator are not available across the privsep channel.  \"Data\""},{"line_number":172,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":173,"context_line":"into the stub modules, so constants are easily available on both"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_00b02689","line":170,"updated":"2015-07-21 23:50:13.000000000","message":"If there are 2 libraries, each defining commands, how are they all found? Import time? How will the server (started say at time zero) that responds to these requests work (as the `import` will happen in the client, not in the server). Especially if say stevedore is used (which it frequently is) and the code that uses stevedore imports a plug-in at runtime [say at time zero + 1] (what happens to the imports of the plugin that are marked with @privileged.entrypoint)? How does the \u0027server\u0027 now know that new entrypoints have now been imported (the plugin import happened in client code, not on the server).","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"140c54bc07e7e1c1bb68f3829108e7f424fa3f4d","unresolved":false,"context_lines":[{"line_number":167,"context_line":"only basic \"json like\" python types are accepted in args or return"},{"line_number":168,"context_line":"values - no user-defined objects."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":171,"context_line":"decorator are not available across the privsep channel.  \"Data\""},{"line_number":172,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":173,"context_line":"into the stub modules, so constants are easily available on both"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_f59f4cb2","line":170,"updated":"2015-07-24 16:24:47.000000000","message":"Stevedore isn\u0027t magic: its just import glue around setuptools entrypoints. So the answer is: If plugins for privileged commands are needed in a given process, load plugins before loading ...commands. I think the spec is already predictable on this and nothing needs added.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"d55ebdd6750415321db28c4dc3025a1b3467ddeb","unresolved":false,"context_lines":[{"line_number":167,"context_line":"only basic \"json like\" python types are accepted in args or return"},{"line_number":168,"context_line":"values - no user-defined objects."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":171,"context_line":"decorator are not available across the privsep channel.  \"Data\""},{"line_number":172,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":173,"context_line":"into the stub modules, so constants are easily available on both"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_41262616","line":170,"in_reply_to":"3a50d1a3_00b02689","updated":"2015-07-22 07:10:57.000000000","message":"Hrm. Currently the libraries are found at import time.  You\u0027re absolutely right that this means the privileged side won\u0027t know about new modules that arrive at run-time.\n\nI\u0027ll have to think about this use case further.  The idea of the client \"suggesting\" that new code should be loaded into the server is terrifying.  I think the only way to go will be for the server to already know about all plugins at start time, from some trusted source (presumably from the regular python load path, and/or config files).\n\nI need to learn more about the stevedore internals, but I _think_ this should be ok - with the caveat that plugins won\u0027t be detected until the whole process (both priv and unpriv) is restarted.  Is there a use case for loading plugins that are genuinely installed after process-start?\n\nThoughts?","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"6b192b196071d867e586daf67d27de698bbf30a3","unresolved":false,"context_lines":[{"line_number":167,"context_line":"only basic \"json like\" python types are accepted in args or return"},{"line_number":168,"context_line":"values - no user-defined objects."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":171,"context_line":"decorator are not available across the privsep channel.  \"Data\""},{"line_number":172,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":173,"context_line":"into the stub modules, so constants are easily available on both"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_28f63df9","line":170,"in_reply_to":"3a50d1a3_41262616","updated":"2015-07-22 16:14:30.000000000","message":"Other option is to do something like that we do for oslo.config, where each library/project that wants to use oslo.config exposes a entrypoint that is then used to generate the config file.\n\nThe configuration generator then afaik scans over all these entrypoints and gathers all the config options (which then makes a config file). This approach will probably work for privsep, but it would require yet another entrypoint that can be scanned over....\n\nIe, search the various projects/libraries for https://github.com/openstack/oslo.messaging/blob/master/setup.cfg#L59 (that\u0027s the name afaik).\n\n - http://docs.openstack.org/developer/oslo.config/generator.html#defining-option-discovery-entry-points\n\nSo u could do something similar for privsep and scan all the lists returned from those entrypoints. One possible solution at least...","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"f1d89d1db3587523126f1bc30856db0a4de25637","unresolved":false,"context_lines":[{"line_number":172,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":173,"context_line":"into the stub modules, so constants are easily available on both"},{"line_number":174,"context_line":"sides.  Note that the client is a separate process, so modifying an"},{"line_number":175,"context_line":"imported global has no effect on the privileged code."},{"line_number":176,"context_line":""},{"line_number":177,"context_line":"It is of course possible to import the \"real\" modules below"},{"line_number":178,"context_line":"``_commands`` and invoke those functions in the unprivileged process"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_0002663d","line":175,"updated":"2015-07-21 23:50:13.000000000","message":"When does the server get started? I assume there must be some \u0027start\u0027 function that does the forking off of a  separate process (and that process scans the possible functions somehow and creates a registry of them?)","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"d55ebdd6750415321db28c4dc3025a1b3467ddeb","unresolved":false,"context_lines":[{"line_number":172,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":173,"context_line":"into the stub modules, so constants are easily available on both"},{"line_number":174,"context_line":"sides.  Note that the client is a separate process, so modifying an"},{"line_number":175,"context_line":"imported global has no effect on the privileged code."},{"line_number":176,"context_line":""},{"line_number":177,"context_line":"It is of course possible to import the \"real\" modules below"},{"line_number":178,"context_line":"``_commands`` and invoke those functions in the unprivileged process"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_a197eaea","line":175,"in_reply_to":"3a50d1a3_0002663d","updated":"2015-07-22 07:10:57.000000000","message":"In the current implementation, it gets started (via rootwrap) on first use.  There\u0027s also some hopeful alternative code that will fork it off at process start, presumably before dropping privs for the main process (ie: following the \"usual\" privileged unix daemon model).\n\nI\u0027ll add a paragraph describing this in more detail.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"140c54bc07e7e1c1bb68f3829108e7f424fa3f4d","unresolved":false,"context_lines":[{"line_number":185,"context_line":"Configuration files will require an additional section:"},{"line_number":186,"context_line":"::"},{"line_number":187,"context_line":""},{"line_number":188,"context_line":"   [privsep]"},{"line_number":189,"context_line":"   user \u003d novapriv"},{"line_number":190,"context_line":"   group \u003d novapriv"},{"line_number":191,"context_line":"   capabilities \u003d CAP_SYS_ADMIN, CAP_NET_ADMIN"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_95a4c808","line":188,"updated":"2015-07-24 16:24:47.000000000","message":"This will play poorly with the defaults below, or force no defaults which is kindof worse.\n\nI suggest having each process define the config section it will use itself rather than it being inherited from privsep automagically.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"eaf8b908b1579747da5b10e46b8d054528143c9a","unresolved":false,"context_lines":[{"line_number":185,"context_line":"Configuration files will require an additional section:"},{"line_number":186,"context_line":"::"},{"line_number":187,"context_line":""},{"line_number":188,"context_line":"   [privsep]"},{"line_number":189,"context_line":"   user \u003d novapriv"},{"line_number":190,"context_line":"   group \u003d novapriv"},{"line_number":191,"context_line":"   capabilities \u003d CAP_SYS_ADMIN, CAP_NET_ADMIN"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_35b91016","line":188,"in_reply_to":"3a50d1a3_95a4c808","updated":"2015-07-27 01:07:54.000000000","message":"Yeah, I think this is a good suggestion - particularly if/when we have more than one privileged process (with a different set of privileges+code).\n\nWe can certainly hardcode suitable capabilities into the instantiating code, but do we have a good default for {user,group}?","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"140c54bc07e7e1c1bb68f3829108e7f424fa3f4d","unresolved":false,"context_lines":[{"line_number":188,"context_line":"   [privsep]"},{"line_number":189,"context_line":"   user \u003d novapriv"},{"line_number":190,"context_line":"   group \u003d novapriv"},{"line_number":191,"context_line":"   capabilities \u003d CAP_SYS_ADMIN, CAP_NET_ADMIN"},{"line_number":192,"context_line":""},{"line_number":193,"context_line":"This is the uid, gid and capabilities that the privileged process"},{"line_number":194,"context_line":"should run with.  By default, the privileged process continues to run"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_b5a9c4e1","line":191,"updated":"2015-07-24 16:24:47.000000000","message":"So this means that a single process has the union of capabilities. Would it make sense to allow multiple such:\n\n [secureblockdev]\n user \u003d novapriv\n group \u003d novapriv\n capabilities \u003d ...\n\n [securenetwork]\n user \u003d novapriv\n group \u003d novapriv\n capabilities \u003d ...\n\nReducing the chance that a bug in the network glue can be exploited to alter /etc/shadow...","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"eaf8b908b1579747da5b10e46b8d054528143c9a","unresolved":false,"context_lines":[{"line_number":188,"context_line":"   [privsep]"},{"line_number":189,"context_line":"   user \u003d novapriv"},{"line_number":190,"context_line":"   group \u003d novapriv"},{"line_number":191,"context_line":"   capabilities \u003d CAP_SYS_ADMIN, CAP_NET_ADMIN"},{"line_number":192,"context_line":""},{"line_number":193,"context_line":"This is the uid, gid and capabilities that the privileged process"},{"line_number":194,"context_line":"should run with.  By default, the privileged process continues to run"}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_355030d4","line":191,"in_reply_to":"3a50d1a3_b5a9c4e1","updated":"2015-07-27 01:07:54.000000000","message":"Agreed, with the clarification that to isolate the processes this would need to be:\n\n [secureblockdev]\n user \u003d novapriv1\n group \u003d novapriv1\n ...\n [securenetwork]\n user \u003d novapriv2\n group \u003d novapriv2\n ...\n\nYou can see why this only scales to a small-ish number of distinct privileged processes.","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"771987a15226277c766817d0f0d906c9efd8c5a2","unresolved":false,"context_lines":[{"line_number":255,"context_line":"Most of the remaining work involves moving the core mechanism to a new"},{"line_number":256,"context_line":"oslo.privsep project, and rebasing the prototype Neutron change onto"},{"line_number":257,"context_line":"that common core."},{"line_number":258,"context_line":""},{"line_number":259,"context_line":"Once the bulk of the code exists in oslo.privsep we should encourage"},{"line_number":260,"context_line":"wide review by the OpenStack Security Group and others."},{"line_number":261,"context_line":""}],"source_content_type":"text/x-rst","patch_set":2,"id":"3a50d1a3_553ea328","line":258,"updated":"2015-07-23 04:54:25.000000000","message":"Just a thought, is this library more generic than just openstack, if so why not just call it \u0027privsep\u0027 and publish it on pypi as that name? It seems useful outside openstack imho (and therefore may not really benefit from a oslo.* prefix). Thoughts?\n\nhttps://pypi.python.org/pypi/privsep seems untaken to :)","commit_id":"7afae982b8e9ba01b4ba3224662e88b4e900fcdf"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"67a0be0079df9f2f71cf4b6b3d8101ed52be1e61","unresolved":false,"context_lines":[{"line_number":110,"context_line":"process will be unable to perform many functions, and will need to be"},{"line_number":111,"context_line":"restarted by the admin - this is essentially similar to an uncaught"},{"line_number":112,"context_line":"exception destroying a critical worker thread and leaving an"},{"line_number":113,"context_line":"inconsistent state."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Communication with privleged process"},{"line_number":116,"context_line":"------------------------------------"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_9c92da9e","line":113,"updated":"2015-07-24 01:35:44.000000000","message":"How does the admin get notified by the unpriv process if the priv process dies?","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":110,"context_line":"process will be unable to perform many functions, and will need to be"},{"line_number":111,"context_line":"restarted by the admin - this is essentially similar to an uncaught"},{"line_number":112,"context_line":"exception destroying a critical worker thread and leaving an"},{"line_number":113,"context_line":"inconsistent state."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Communication with privleged process"},{"line_number":116,"context_line":"------------------------------------"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_f7b777f3","line":113,"in_reply_to":"3a50d1a3_9c92da9e","updated":"2015-07-24 07:21:13.000000000","message":"I had imagined the continual stream of exceptions that would result from every privileged operation would be notification enough ;)\n\nMore seriously: We know definitively when the privsep channel closes, so is there some more direct notification we should give at that point?  Perhaps we should raise a SystemExit exception and cause the unpriv process to also exit.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":110,"context_line":"process will be unable to perform many functions, and will need to be"},{"line_number":111,"context_line":"restarted by the admin - this is essentially similar to an uncaught"},{"line_number":112,"context_line":"exception destroying a critical worker thread and leaving an"},{"line_number":113,"context_line":"inconsistent state."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Communication with privleged process"},{"line_number":116,"context_line":"------------------------------------"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_ee40cb09","line":113,"in_reply_to":"3a50d1a3_dffe0238","updated":"2015-07-27 00:45:30.000000000","message":"No, there\u0027s only 2 processes: A) the main process which runs without privileges (which is why I call it the unprivileged process in most of this doc), and B) the privileged process.\n\nI can see why you misunderstood this, since I never actually explain that anywhere in the spec... Would referring to them as \"main\" and \"privileged\" be clearer?  Perhaps I could try adding an ascii art diagram...","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"022f8c04fe88f3216bf8e8902c0f9bd32a27f15c","unresolved":false,"context_lines":[{"line_number":110,"context_line":"process will be unable to perform many functions, and will need to be"},{"line_number":111,"context_line":"restarted by the admin - this is essentially similar to an uncaught"},{"line_number":112,"context_line":"exception destroying a critical worker thread and leaving an"},{"line_number":113,"context_line":"inconsistent state."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Communication with privleged process"},{"line_number":116,"context_line":"------------------------------------"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_5b3643e8","line":113,"in_reply_to":"3a50d1a3_ee40cb09","updated":"2015-07-27 10:33:12.000000000","message":"Yes, that would be much clearer. You could also call them \"client\" and \"daemon\", for example.\n\nAnd since I understand that there are only 2 processes now, I don\u0027t see any profit from that fate sharing. With approach implemented in rootwrap-daemon you could easily kill daemon without affecting main process and it\u0027ll get restarted and reload its configs and code. Why do you want to get rid of this feature?","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":110,"context_line":"process will be unable to perform many functions, and will need to be"},{"line_number":111,"context_line":"restarted by the admin - this is essentially similar to an uncaught"},{"line_number":112,"context_line":"exception destroying a critical worker thread and leaving an"},{"line_number":113,"context_line":"inconsistent state."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Communication with privleged process"},{"line_number":116,"context_line":"------------------------------------"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_dffe0238","line":113,"in_reply_to":"3a50d1a3_f7b777f3","updated":"2015-07-24 12:53:43.000000000","message":"Here\u0027s how I understand this. There are 3 processes in play here: main process (e.g. some Neutron agent), unpriv process used as client for priv process and priv process implementing necessary functions.\n\nIf it\u0027s so, then we most surely can kill unpriv process whenever priv process dies, but we should restart it from main process like rootwrap\u0027s Client does.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_48acb08b","line":121,"range":{"start_line":121,"start_character":34,"end_line":121,"end_character":64},"updated":"2015-07-23 15:07:03.000000000","message":"Why? What does msgpack offer that JSON doesn\u0027t? JSON implementation is already in trusted Python stdlib, so why add 3rd party (less trusted) module here?","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"698aac86ff63bc71cc1329731838166c206f6da0","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_1171cce0","line":121,"in_reply_to":"3a50d1a3_1c3b2a9e","updated":"2015-07-24 05:09:31.000000000","message":"If that\u0027s the only pro\u0027s then we should use JSON as premature optimizations can\u0027t outweigh security.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"022f8c04fe88f3216bf8e8902c0f9bd32a27f15c","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_41b1748e","line":121,"range":{"start_line":121,"start_character":34,"end_line":121,"end_character":64},"in_reply_to":"3a50d1a3_2e9b13cb","updated":"2015-07-27 10:33:12.000000000","message":"I doubt it will be a bottleneck on the scale of Neutron (not in a local microbenchmark). And even if it is we should seriously consider no sacrificing security for speed.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_2e9b13cb","line":121,"range":{"start_line":121,"start_character":34,"end_line":121,"end_character":64},"in_reply_to":"3a50d1a3_3f7846f8","updated":"2015-07-27 00:45:30.000000000","message":"It\u0027s trivial to swap out msgpack for json (since the data objects supported are identical) and I don\u0027t feel like the choice of serialisation formats is the interesting part of this spec.\n\nIn order to remove the distraction, I\u0027ll back away from msgpack in this spec (ie: suggest just regular json), and then followup with a separate change and some benchmarking later showing that json serialisation is indeed the major bottleneck here ;)","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"67a0be0079df9f2f71cf4b6b3d8101ed52be1e61","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_1c3b2a9e","line":121,"in_reply_to":"3a50d1a3_48acb08b","updated":"2015-07-24 01:35:44.000000000","message":"IIUC, it is binary-based and compresses the traffic","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_774a87ae","line":121,"range":{"start_line":121,"start_character":34,"end_line":121,"end_character":64},"in_reply_to":"3a50d1a3_48acb08b","updated":"2015-07-24 07:21:13.000000000","message":"Unlike other places where we use JSON, this use case is entirely internal - between different pieces of privsep code.  Usually JSON is chosen for a public API because it is human readable and has implementations in many languages.  None of those reasons are important here, so instead I went for something that is significantly faster to generate and parse.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":118,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":119,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":120,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":121,"context_line":"executed during deserialisation.  This spec proposes ``msgpack`` as a"},{"line_number":122,"context_line":"simple, understandable, json-datatypes-only format that is also fast"},{"line_number":123,"context_line":"to produce and parse.  For comparison, ``rootwrap-daemon`` uses the"},{"line_number":124,"context_line":"``multiprocessing`` library with additional code to replace"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_3f7846f8","line":121,"range":{"start_line":121,"start_character":34,"end_line":121,"end_character":64},"in_reply_to":"3a50d1a3_774a87ae","updated":"2015-07-24 12:53:43.000000000","message":"You\u0027re right, those reasons are not important here. The only important thing here is security. We shouldn\u0027t broaden scope of code that we have to trust unless we absolutely have to. We have to trust stdlib since we\u0027re using Python (and since we\u0027re not the only ones here, we have some confidence in stdlib security), but we don\u0027t have to trust 3rd-party library that would implement msgpack for us. So it still looks like security (JSON in stdlib) vs premature optimization (is serialization really a bottleneck here?).","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"67a0be0079df9f2f71cf4b6b3d8101ed52be1e61","unresolved":false,"context_lines":[{"line_number":138,"context_line":"channel.  If no specific \"start\" method has already been invoked when"},{"line_number":139,"context_line":"the first call into a privsep client stub function, then the 3rd"},{"line_number":140,"context_line":"option is used.  We may want to revisit these choices as the"},{"line_number":141,"context_line":"recommended OpenStack secure deployment story evolves."},{"line_number":142,"context_line":""},{"line_number":143,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":144,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_37d4ff45","line":141,"updated":"2015-07-24 01:35:44.000000000","message":"I was thinking of needing a D-H key exchange, but that might be overkill","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"5dc98b4dd7c805f98d61cc14dc38965bc10a2af8","unresolved":false,"context_lines":[{"line_number":138,"context_line":"channel.  If no specific \"start\" method has already been invoked when"},{"line_number":139,"context_line":"the first call into a privsep client stub function, then the 3rd"},{"line_number":140,"context_line":"option is used.  We may want to revisit these choices as the"},{"line_number":141,"context_line":"recommended OpenStack secure deployment story evolves."},{"line_number":142,"context_line":""},{"line_number":143,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":144,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_ae88b9c7","line":141,"in_reply_to":"3a50d1a3_37d4ff45","updated":"2015-07-24 04:33:32.000000000","message":"Eck, sounds like a little to much overkill for, I\u0027d prefer a foundation first, add D-H key exchange later maybe?","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":138,"context_line":"channel.  If no specific \"start\" method has already been invoked when"},{"line_number":139,"context_line":"the first call into a privsep client stub function, then the 3rd"},{"line_number":140,"context_line":"option is used.  We may want to revisit these choices as the"},{"line_number":141,"context_line":"recommended OpenStack secure deployment story evolves."},{"line_number":142,"context_line":""},{"line_number":143,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":144,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_77a60755","line":141,"in_reply_to":"3a50d1a3_37d4ff45","updated":"2015-07-24 07:21:13.000000000","message":"Yeah, given that the channel is local, we can rely on the kernel security primitives working as expected - so I\u0027m hopeful we can combine some set of those to provide the required security.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"698aac86ff63bc71cc1329731838166c206f6da0","unresolved":false,"context_lines":[{"line_number":138,"context_line":"channel.  If no specific \"start\" method has already been invoked when"},{"line_number":139,"context_line":"the first call into a privsep client stub function, then the 3rd"},{"line_number":140,"context_line":"option is used.  We may want to revisit these choices as the"},{"line_number":141,"context_line":"recommended OpenStack secure deployment story evolves."},{"line_number":142,"context_line":""},{"line_number":143,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":144,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_512f54f6","line":141,"in_reply_to":"3a50d1a3_ae88b9c7","updated":"2015-07-24 05:09:31.000000000","message":"I agree, DH is an overkill for local IPC. You can easily share a secret over direct pipe (stdin/out) and verify it with digest auth, for example. (That\u0027s how multiprocessing and rootwrap-daemon work)","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"67a0be0079df9f2f71cf4b6b3d8101ed52be1e61","unresolved":false,"context_lines":[{"line_number":152,"context_line":"   This is designed to mirror the \"normal\" way that Unix daemons work,"},{"line_number":153,"context_line":"   and does not use sudo at any point.  It requires an additional call"},{"line_number":154,"context_line":"   inserted in main() and changes to the initial process environment,"},{"line_number":155,"context_line":"   so poses the most difficult migration."},{"line_number":156,"context_line":""},{"line_number":157,"context_line":"2. Use ``sudo``"},{"line_number":158,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_3cfb8649","line":155,"updated":"2015-07-24 01:35:44.000000000","message":"This would be my preference, coupled with moving the socket pair down to stdin/stdout for the priv process","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":152,"context_line":"   This is designed to mirror the \"normal\" way that Unix daemons work,"},{"line_number":153,"context_line":"   and does not use sudo at any point.  It requires an additional call"},{"line_number":154,"context_line":"   inserted in main() and changes to the initial process environment,"},{"line_number":155,"context_line":"   so poses the most difficult migration."},{"line_number":156,"context_line":""},{"line_number":157,"context_line":"2. Use ``sudo``"},{"line_number":158,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_374e3f97","line":155,"in_reply_to":"3a50d1a3_3cfb8649","updated":"2015-07-24 07:21:13.000000000","message":"I agree, but it\u0027s a large departure from existing OpenStack practice.  I don\u0027t want to couple this spec with such a migration so I\u0027m leaving that for a distant future conversation (and we would need a compatibility story anyway during migration, so afaics options 2,3 still need to exist).","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":167,"context_line":"   This starts the privileged process by using ``sudo`` and"},{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_a8cc5489","line":170,"updated":"2015-07-23 15:07:03.000000000","message":"Rootwrap allows those. It\u0027s daemon mode that\u0027s limited in this regard.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"022f8c04fe88f3216bf8e8902c0f9bd32a27f15c","unresolved":false,"context_lines":[{"line_number":167,"context_line":"   This starts the privileged process by using ``sudo`` and"},{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_e11be07e","line":170,"in_reply_to":"3a50d1a3_6ee7db40","updated":"2015-07-27 10:33:12.000000000","message":"I understand now. I think you should drop this option too to avoid these unnecessary complications.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":167,"context_line":"   This starts the privileged process by using ``sudo`` and"},{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_6ee7db40","line":170,"in_reply_to":"3a50d1a3_7f57ae26","updated":"2015-07-27 00:45:30.000000000","message":"My code for this \"method 3\" does indeed work with rootwrap-daemon - by negotiating a Unix socket instead of stdin/stdout, and forking to allow the original process started by rootwrap-daemon to exit quickly.\n\nAs I\u0027ve also just typed elsewhere, if we\u0027re happy with just supporting rootwrap (not rootwrap-daemon), then we can drop method 3 entirely.  The only reason I implemented it was to work within rootwrap-daemon\u0027s limitations.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":167,"context_line":"   This starts the privileged process by using ``sudo`` and"},{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_7f57ae26","line":170,"in_reply_to":"3a50d1a3_92dc0176","updated":"2015-07-24 12:53:43.000000000","message":"I\u0027m confused by your question. I\u0027ll try to answer parts of it:\n- We can\u0027t use rootwrap-daemon here since it doesn\u0027t support long-lived process.\n- I don\u0027t see much differences between 2nd and 3rd points, so maybe they should be merged, yes. It pretty much doesn\u0027t matter how we start up priv process as long as it gives full local privileges (root).","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":167,"context_line":"   This starts the privileged process by using ``sudo`` and"},{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_92dc0176","line":170,"in_reply_to":"3a50d1a3_a8cc5489","updated":"2015-07-24 07:21:13.000000000","message":"Oh good point, of course it is.  I was confused by the usual wrappers that projects put around running rootwrap commands, but of course those aren\u0027t mandatory..\n\nDo you think there\u0027s a reason to keep this Unix socket method and rename it to \"Use rootwrap-daemon\", or should I just discard (3) entirely and rename (2) to \"Use sudo or rootwrap\" (and stdin/stdout)?","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"},{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_230865d9","line":177,"range":{"start_line":171,"start_character":22,"end_line":177,"end_character":59},"updated":"2015-07-23 15:07:03.000000000","message":"You leave a window of opportunity here for another process  (UP2) with the same security access as your unprivileged one (UP) to get connected to by the privileged (P) one:\n- UP spawns P passing socket as an argument;\n- UP2 sees new spawned process\u0027 arguments, unlink()s socket and creates a new one;\n- P connects to UP2 instead of UP.\n\nNote that almost the same issue will appear if you pass socket pass in any other way (inotify can tell UP2 where to do its dirty work, for example).\n\nThat\u0027s why you should either create socket from the privileged side or pass already connected socket in some secure way (stdin can be replaced with one of ends of socketpair/pipe from option 1, for example).","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"5dc98b4dd7c805f98d61cc14dc38965bc10a2af8","unresolved":false,"context_lines":[{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_6ea95124","line":177,"in_reply_to":"3a50d1a3_230865d9","updated":"2015-07-24 04:33:32.000000000","message":"Have P and UP share a common token only they know about, reject (or disconnect the socket) if any communication happens does not pass the right token? If UP2 does what u said it does, I wouldn\u0027t think UP2 knows the common token and therefore would just get its socket closed/dropped.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"},{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_d2db694e","line":177,"range":{"start_line":171,"start_character":22,"end_line":177,"end_character":59},"in_reply_to":"3a50d1a3_230865d9","updated":"2015-07-24 07:21:13.000000000","message":"Please double-check my logic:  The reason I thought this was ok is:\n\n- UP2 must be running as either uid\u003d0 or the same uid as UP in order to satisfy the file access permissions checks and connect to the listening socket.\n- The uid\u003d0 case isn\u0027t interesting, because that user is already root ;)\n- In the same-uid-as-UP case, UP2 is *already allowed* to start it\u0027s own fresh copy of the privsep daemon (via the sudo/rootwrap config) and do everything the privileged code will allow it to do.\n- So UP2 hijacking UP\u0027s connection only allows UP2 to either mess with UP (which it can already do via ptrace/kill/whatever since it\u0027s the same uid) or mess with the commands sent to P - neither of which allows UP2 to do things it couldn\u0027t do anyway.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"698aac86ff63bc71cc1329731838166c206f6da0","unresolved":false,"context_lines":[{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_f1e6a0af","line":177,"in_reply_to":"3a50d1a3_6ea95124","updated":"2015-07-24 05:09:31.000000000","message":"Still UP2 can connect to UP socket before unlinking it and then be the MITM. And I wouldn\u0027t like adding full-fledged encryption here (TLS will help with all this, I guess) just because we don\u0027t like creating sockets from root.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"},{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_dac0507f","line":177,"range":{"start_line":171,"start_character":22,"end_line":177,"end_character":59},"in_reply_to":"3a50d1a3_d2db694e","updated":"2015-07-24 12:53:43.000000000","message":"Same UID !\u003d same privileges (in broad sense). Sysadmin may choose to restrict or broaden main process\u0027 privileges with any available instrument (AppArmor, SELinux, whatever), so even if another process has the same UID doesn\u0027t mean it can start its own pirvsep daemon, but it still can mangle with local FS.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"022f8c04fe88f3216bf8e8902c0f9bd32a27f15c","unresolved":false,"context_lines":[{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"},{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_2ced3fef","line":177,"range":{"start_line":171,"start_character":22,"end_line":177,"end_character":59},"in_reply_to":"3a50d1a3_da949be9","updated":"2015-07-27 10:33:12.000000000","message":"You can (and should if you care about security) deny user processes to read each other\u0027s memory, and even without it I\u0027m talking about hijacking connection by using only external observation without any penetration into unprivileged process.\n\nI think we should just drop 3rd option since it only raises complexity and questions about security. I don\u0027t think I can provide a realistic example of exploit that might be created for this, but I can say that this broadens both processes\u0027 attack surface.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":168,"context_line":"   ``rootwrap`` (or ``rootwrap-daemon``)."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Rootwrap doesn\u0027t allow long-lived commands, nor streaming data over"},{"line_number":171,"context_line":"   stdin and stdout.  To workaround these limitations, this approach"},{"line_number":172,"context_line":"   opens a new Unix socket on the unprivileged side, and start a"},{"line_number":173,"context_line":"   helper process via rootwrap with the path to the Unix socket as an"},{"line_number":174,"context_line":"   argument.  The helper process (running with root privileges thanks"},{"line_number":175,"context_line":"   to rootwrap) connects back to this socket then forks and exits,"},{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_da949be9","line":177,"range":{"start_line":171,"start_character":22,"end_line":177,"end_character":59},"in_reply_to":"3a50d1a3_dac0507f","updated":"2015-07-27 00:45:30.000000000","message":"I still see so many ways for a same-uid process to hijack the socket (even with password tokens - eg: by just reading the token out of UP\u0027s memory) that I\u0027m having trouble understanding what situation I\u0027d be designing for.\n\n(Assuming we\u0027re keeping method 3...) Could you describe in more detail a concrete realistic setup that would indeed protect UP from UP2?  I think that would be very helpful (both to influence the code and to include as a deployment suggestion in this spec).","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"},{"line_number":181,"context_line":"   privileged process exposing an entry point."},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"   This approach is the default since it requires no change to"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_43e331d9","line":180,"range":{"start_line":179,"start_character":3,"end_line":180,"end_character":44},"updated":"2015-07-23 15:07:03.000000000","message":"How are connections from unprivileged to privileged bad or insecure? That\u0027s how processes communicate with kernel FWIW.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"},{"line_number":181,"context_line":"   privileged process exposing an entry point."},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"   This approach is the default since it requires no change to"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_a850b05f","line":180,"range":{"start_line":179,"start_character":3,"end_line":180,"end_character":44},"in_reply_to":"3a50d1a3_43e331d9","updated":"2015-07-24 07:21:13.000000000","message":"If there is a way to connect from unpriv to priv, then the priv side needs to authenticate the unpriv side.  If there is any way to subvert or bypass this authentication then you have a problem.  If it is possible to do the reverse (as it is in this case) then there is no need to check, and no opportunity to have bugs in the check.\n\nIn our case there are some other advantages to:\n- With unpriv-\u003epriv, the priv process has a window where the  unpriv process might exit unexpectedly and the priv process will hang around indefinitely (or perhaps with a timeout) until it realises.  With priv-\u003eunpriv there is no such window of uncertainty - if the connect fails, you exit immediately.\n- Because the listening socket is created in the filesystem *then* passed to the other process, it can be created in a temporary directory.  This removes the need to configure a \"well-known\" path ahead of time.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"},{"line_number":181,"context_line":"   privileged process exposing an entry point."},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"   This approach is the default since it requires no change to"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_ee7beb79","line":180,"range":{"start_line":179,"start_character":3,"end_line":180,"end_character":44},"in_reply_to":"3a50d1a3_9ac40860","updated":"2015-07-27 00:45:30.000000000","message":"Agreed.  The only reason I implemented the Unix socket approach (\"method 3\") was to work within the limitations of rootwrap-daemon (and I mistakenly thought rootwrap too until you corrected me above ;)\n\nAs you suggest, I think we should drop method 3 (and its Unix socket negotiation) entirely and just use rootwrap (or bare sudo) and stdin/stdout.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":176,"context_line":"   allowing rootwrap to exit.  The unprivileged process accepts the"},{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"},{"line_number":181,"context_line":"   privileged process exposing an entry point."},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"   This approach is the default since it requires no change to"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_9ac40860","line":180,"range":{"start_line":179,"start_character":3,"end_line":180,"end_character":44},"in_reply_to":"3a50d1a3_a850b05f","updated":"2015-07-24 12:53:43.000000000","message":"Ok, I agree that both ways to connect these processes are equally bad in terms of coupling processes. So why don\u0027t just pass socket/pipe as stdin and forget about creating domain sockets? It\u0027ll provide necessary coupling and (as a bonus) will make privsep daemon look like UNIX filter and make UNIX philosophy worshipers happy (j/k)","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"},{"line_number":181,"context_line":"   privileged process exposing an entry point."},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"   This approach is the default since it requires no change to"},{"line_number":184,"context_line":"   existing OpenStack deployments (other than an updated rootwrap"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_83705941","line":181,"range":{"start_line":180,"start_character":46,"end_line":181,"end_character":46},"updated":"2015-07-23 15:07:03.000000000","message":"Even if it doesn\u0027t act as connection initiator doesn\u0027t mean that it doesn\u0027t provide an entry point. It still does server side of some RPC, so please don\u0027t give false sense of security here.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":177,"context_line":"   first connection to its listening socket, and continues."},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"   Note that (unlike rootwrap-daemon) the connection is made from the"},{"line_number":180,"context_line":"   privileged side to the unprivileged side.  At no point is the"},{"line_number":181,"context_line":"   privileged process exposing an entry point."},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"   This approach is the default since it requires no change to"},{"line_number":184,"context_line":"   existing OpenStack deployments (other than an updated rootwrap"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_e83eb8d9","line":181,"range":{"start_line":180,"start_character":46,"end_line":181,"end_character":46},"in_reply_to":"3a50d1a3_83705941","updated":"2015-07-24 07:21:13.000000000","message":"Yeah, I think I used a poor choice of words.  I meant to say that it doesn\u0027t expose a point where other processes can attempt to connect to it.  I\u0027ll clarify this sentence - thanks.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":230,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":231,"context_line":"into the stub modules, so constants are easily available on both"},{"line_number":232,"context_line":"sides.  Note that the client is a separate process, so modifying an"},{"line_number":233,"context_line":"imported global has no effect on the privileged code."},{"line_number":234,"context_line":""},{"line_number":235,"context_line":"It is of course possible to import the \"real\" modules below"},{"line_number":236,"context_line":"``_commands`` and invoke those functions in the unprivileged process"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_d98090f9","line":233,"updated":"2015-07-23 15:07:03.000000000","message":"- When is privileged process started?\n- When is \"client\" (unprivileged process from above as I understand) started?\n- Is \"client\" kept alive like rootwrap-daemon\u0027s Client keeps it alive?\n- Does privileged daemon directly import some.known.prefix._commands? It looks like this requires trust in quite a lot of code (all __init__.py modules along the way from \"some\" to \"_commands\") which can accidentally (with no intention to compromise security) import some bad library.\n\nMaybe we should create a completely separate package instead? E.g. for Neutron we can add a separate package, call it \"neutron_privileged\", pack and distribute it in the same package from pip/apt/yum POV, but in a separate package from Python import machinery\u0027s POV. This way it will be clear for developer that it\u0027s a dangerous area and shouldn\u0027t include unwanted packages. This would also make it clear that globals are not shared as well.\nHelper module (commands.py in your example) would be reduced to smth like:\n\n  from oslo_privsep import create_client_shim\n  imprort neutron_privileged as privileged\n  privileged \u003d create_client_shim(privileged)\n\nAfter that server (privileged process) will have to import only \"neutron_privileged\". For further hardending oslo.privsep can provide a console endpoint that would be called with name of package as an argument like \"oslo_privsep_daemon neutron_privileged\".","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":230,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":231,"context_line":"into the stub modules, so constants are easily available on both"},{"line_number":232,"context_line":"sides.  Note that the client is a separate process, so modifying an"},{"line_number":233,"context_line":"imported global has no effect on the privileged code."},{"line_number":234,"context_line":""},{"line_number":235,"context_line":"It is of course possible to import the \"real\" modules below"},{"line_number":236,"context_line":"``_commands`` and invoke those functions in the unprivileged process"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_3a533f3b","line":233,"in_reply_to":"3a50d1a3_7ada5c19","updated":"2015-07-27 00:45:30.000000000","message":"Oh right, yes I was confused by \"package\" ;)\nI\u0027ll update the spec to recommend privileged code goes in a new top-level python package, within the existing project git repo.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":230,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":231,"context_line":"into the stub modules, so constants are easily available on both"},{"line_number":232,"context_line":"sides.  Note that the client is a separate process, so modifying an"},{"line_number":233,"context_line":"imported global has no effect on the privileged code."},{"line_number":234,"context_line":""},{"line_number":235,"context_line":"It is of course possible to import the \"real\" modules below"},{"line_number":236,"context_line":"``_commands`` and invoke those functions in the unprivileged process"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_7ada5c19","line":233,"in_reply_to":"3a50d1a3_91c4fc5f","updated":"2015-07-24 12:53:43.000000000","message":"As I said, separate package from Python\u0027s POV !\u003d separate package on PyPI/Ubuntu/CentOS/whatever. Just like setuptools installs \u0027easy_install\u0027 module, \u0027pkg_resources\u0027 package and \u0027setuptools\u0027 package, we can recommend privsep library consumers to provide a separate top-level package packaged in same PyPI/whatever package (no word to substitute \"package\", sorry...), versioned and distributed with itself.\n\nSo yes, I recommend a new, separate top-level (true top-level) package for this.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":230,"context_line":"objects (not functions, modules, etc) *are* automatically imported"},{"line_number":231,"context_line":"into the stub modules, so constants are easily available on both"},{"line_number":232,"context_line":"sides.  Note that the client is a separate process, so modifying an"},{"line_number":233,"context_line":"imported global has no effect on the privileged code."},{"line_number":234,"context_line":""},{"line_number":235,"context_line":"It is of course possible to import the \"real\" modules below"},{"line_number":236,"context_line":"``_commands`` and invoke those functions in the unprivileged process"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_91c4fc5f","line":233,"in_reply_to":"3a50d1a3_d98090f9","updated":"2015-07-24 07:21:13.000000000","message":"The privileged process is started on first use when using methods (2) or (3) from the list at line 143 above.  The privileged process is started early in main() when using method (1).  I\u0027ll clarify this in the text at this point.\n\nI think I\u0027ve added confusion by suddenly using the word \"client\" here.  I\u0027ll remove that and stick to using (as you guessed) \"unprivileged process\" consistently.  The unprivileged process is the main (nova-compute/neutron-agent/etc) python process.\n\n ---\n\nThe privileged daemon directly imports some.known.prefix._commands, which yes assumes the python load path that the privileged daemon is run with is secure.  I went around and around on this and couldn\u0027t come up with anything _except_ assuming the privileged python load path was secure - I\u0027d welcome suggestions that reduced this exposure.\n\n ---\n\nSplitting the privileged code into a separate package is a good suggestion.  The downside is that it introduces a weaker coupling between privileged and unprivileged codebases, and thus issues around upgrading and version synchronisation.  I was hoping having a known prefix within the (eg) neutron codebase would achieve similar results and yet still be obviously tightly coupled wrt release management but I can understand your concerns with unexpected stuff up the parent module tree.\n\nDo you think recommending we use a new \"top-level\" import path within the regular project repo would satisfy both concerns?  (eg: \"some.known.prefix\" is just \"neutron_privileged\" and the file tree looks like openstack/neutron/neutron_privileged/commands.py)","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":251,"context_line":"This is the uid, gid and capabilities that the privileged process"},{"line_number":252,"context_line":"should run with.  By default, the privileged process continues to run"},{"line_number":253,"context_line":"with whatever uid/gid/capabilities the process was originally started"},{"line_number":254,"context_line":"with (probably root)."},{"line_number":255,"context_line":""},{"line_number":256,"context_line":"In the most paranoid setup, the privileged process should run as a"},{"line_number":257,"context_line":"dedicated non-root user, separate from the unprivileged user.  Neither"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_7a612b04","line":254,"updated":"2015-07-23 15:07:03.000000000","message":"It should be noted and implemented (if it\u0027s not) that no user code is run or imported before all capabilities are dropped.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":251,"context_line":"This is the uid, gid and capabilities that the privileged process"},{"line_number":252,"context_line":"should run with.  By default, the privileged process continues to run"},{"line_number":253,"context_line":"with whatever uid/gid/capabilities the process was originally started"},{"line_number":254,"context_line":"with (probably root)."},{"line_number":255,"context_line":""},{"line_number":256,"context_line":"In the most paranoid setup, the privileged process should run as a"},{"line_number":257,"context_line":"dedicated non-root user, separate from the unprivileged user.  Neither"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_9a4ac8ab","line":254,"in_reply_to":"3a50d1a3_71c37039","updated":"2015-07-24 12:53:43.000000000","message":"Except code in neutron.agent.linux.daemon that is. I think all that code should move to oslo.privsep.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":251,"context_line":"This is the uid, gid and capabilities that the privileged process"},{"line_number":252,"context_line":"should run with.  By default, the privileged process continues to run"},{"line_number":253,"context_line":"with whatever uid/gid/capabilities the process was originally started"},{"line_number":254,"context_line":"with (probably root)."},{"line_number":255,"context_line":""},{"line_number":256,"context_line":"In the most paranoid setup, the privileged process should run as a"},{"line_number":257,"context_line":"dedicated non-root user, separate from the unprivileged user.  Neither"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_71c37039","line":254,"in_reply_to":"3a50d1a3_7a612b04","updated":"2015-07-24 07:21:13.000000000","message":"Yes, the caps are dropped before entering the main loop that reads messages from the socket.  (see line 297 in https://review.openstack.org/#/c/155631/14/neutron/agent/privileged/daemon.py if you\u0027re curious)","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"39c274bf7a807ac6633ec104f6b34c9ca875622f","unresolved":false,"context_lines":[{"line_number":251,"context_line":"This is the uid, gid and capabilities that the privileged process"},{"line_number":252,"context_line":"should run with.  By default, the privileged process continues to run"},{"line_number":253,"context_line":"with whatever uid/gid/capabilities the process was originally started"},{"line_number":254,"context_line":"with (probably root)."},{"line_number":255,"context_line":""},{"line_number":256,"context_line":"In the most paranoid setup, the privileged process should run as a"},{"line_number":257,"context_line":"dedicated non-root user, separate from the unprivileged user.  Neither"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_7a9ea755","line":254,"in_reply_to":"3a50d1a3_9a4ac8ab","updated":"2015-07-27 00:45:30.000000000","message":"Moving that code to oslo.privsep is absolutely the plan.  The primary blocker right now is achieving approval on this spec ;)","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":305,"context_line":"security, and I felt such workarounds resulted in fragile and"},{"line_number":306,"context_line":"difficult to audit code right at the place you want neither."},{"line_number":307,"context_line":""},{"line_number":308,"context_line":"Thankfully, we only require a narrow set of features and rewriting the"},{"line_number":309,"context_line":"core communication code from scratch turned out to be only about as"},{"line_number":310,"context_line":"much code as the multiprocessing workarounds in rootwrap-daemon.  The"},{"line_number":311,"context_line":"result is significantly less ambiguous code at the security entry"},{"line_number":312,"context_line":"point."},{"line_number":313,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_b9ad84ea","line":310,"range":{"start_line":308,"start_character":57,"end_line":310,"end_character":63},"updated":"2015-07-23 15:07:03.000000000","message":"You don\u0027t include here missing features described in Limitations. So it looks like you\u0027ll have to reimplement multiprocessing instead of reusing it.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":305,"context_line":"security, and I felt such workarounds resulted in fragile and"},{"line_number":306,"context_line":"difficult to audit code right at the place you want neither."},{"line_number":307,"context_line":""},{"line_number":308,"context_line":"Thankfully, we only require a narrow set of features and rewriting the"},{"line_number":309,"context_line":"core communication code from scratch turned out to be only about as"},{"line_number":310,"context_line":"much code as the multiprocessing workarounds in rootwrap-daemon.  The"},{"line_number":311,"context_line":"result is significantly less ambiguous code at the security entry"},{"line_number":312,"context_line":"point."},{"line_number":313,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_d1692427","line":310,"range":{"start_line":308,"start_character":57,"end_line":310,"end_character":63},"in_reply_to":"3a50d1a3_b9ad84ea","updated":"2015-07-24 07:21:13.000000000","message":"Agreed, we will likely end up with more code in the end, and I will remove the unnecessary comparison of lines of code.   I\u0027m primarily concerned with using an insecure library, but then patching it to be secure - and the discussion should focus purely on that aspect.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":305,"context_line":"security, and I felt such workarounds resulted in fragile and"},{"line_number":306,"context_line":"difficult to audit code right at the place you want neither."},{"line_number":307,"context_line":""},{"line_number":308,"context_line":"Thankfully, we only require a narrow set of features and rewriting the"},{"line_number":309,"context_line":"core communication code from scratch turned out to be only about as"},{"line_number":310,"context_line":"much code as the multiprocessing workarounds in rootwrap-daemon.  The"},{"line_number":311,"context_line":"result is significantly less ambiguous code at the security entry"},{"line_number":312,"context_line":"point."},{"line_number":313,"context_line":""}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_60b4eed0","line":310,"range":{"start_line":308,"start_character":57,"end_line":310,"end_character":63},"in_reply_to":"3a50d1a3_d1692427","updated":"2015-07-24 12:53:43.000000000","message":"I wouldn\u0027t call multiprocessing insecure. Only xmlrpclib and pickle are. And so all patching happens only in replacing its serializer which is totally separate from multiprocessing itself.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"23e068a9be59e37d0c68fbe2410ae11ff4130521","unresolved":false,"context_lines":[{"line_number":340,"context_line":"possible, but need to build their own machinery (eg: spawn a"},{"line_number":341,"context_line":"background thread/process and add a function to poll for completion)."},{"line_number":342,"context_line":""},{"line_number":343,"context_line":"Improving this mostly requires adding message IDs to associate"},{"line_number":344,"context_line":"requests with responses, and using a thread worker pool on the"},{"line_number":345,"context_line":"privileged side."},{"line_number":346,"context_line":""},{"line_number":347,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":348,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_792e1c8d","line":345,"range":{"start_line":343,"start_character":0,"end_line":345,"end_character":16},"updated":"2015-07-23 15:07:03.000000000","message":"That\u0027s already implemented in multiprocessing, so I\u0027m for code reuse.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"a94cd543868b3f4fdd3e34a1f035b8de8d2cfe2f","unresolved":false,"context_lines":[{"line_number":340,"context_line":"possible, but need to build their own machinery (eg: spawn a"},{"line_number":341,"context_line":"background thread/process and add a function to poll for completion)."},{"line_number":342,"context_line":""},{"line_number":343,"context_line":"Improving this mostly requires adding message IDs to associate"},{"line_number":344,"context_line":"requests with responses, and using a thread worker pool on the"},{"line_number":345,"context_line":"privileged side."},{"line_number":346,"context_line":""},{"line_number":347,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":348,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_540e50e6","line":345,"range":{"start_line":343,"start_character":0,"end_line":345,"end_character":16},"in_reply_to":"3a50d1a3_543bc29c","updated":"2015-07-24 12:53:43.000000000","message":"If you take a look at multiprocessing code, code paths used by rootwrap-daemon are rather simple. The hard part is concentrated around forking and cross-process synchronization primitives that won\u0027t be used here.\nBut if you stand with not using multiprocessing (I doubt it\u0027ll be of use for worker pool since some thread pool will be better) you\u0027ll either have to use another 3rd party library and trust it or write something of your own (and trust it).","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"6b74b150fec78be6b92ac58d4e507b9ccccbf4e4","unresolved":false,"context_lines":[{"line_number":340,"context_line":"possible, but need to build their own machinery (eg: spawn a"},{"line_number":341,"context_line":"background thread/process and add a function to poll for completion)."},{"line_number":342,"context_line":""},{"line_number":343,"context_line":"Improving this mostly requires adding message IDs to associate"},{"line_number":344,"context_line":"requests with responses, and using a thread worker pool on the"},{"line_number":345,"context_line":"privileged side."},{"line_number":346,"context_line":""},{"line_number":347,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":348,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"}],"source_content_type":"text/x-rst","patch_set":3,"id":"3a50d1a3_543bc29c","line":345,"range":{"start_line":343,"start_character":0,"end_line":345,"end_character":16},"in_reply_to":"3a50d1a3_792e1c8d","updated":"2015-07-24 07:21:13.000000000","message":"I\u0027m reluctant to use multiprocessing as the actual privilege separation boundary, for the complexity reasons mentioned above - but yes using it within the privileged process as a worker pool is definitely worth considering.","commit_id":"5cae270165c9b61f03db4dc087df753cf951ba74"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"1e2cb7b5391662c924f67e1c294d457e7776ca9a","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":103,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"},{"line_number":104,"context_line":"just requires CAP_NET_ADMIN and CAP_SYS_ADMIN (for network"},{"line_number":105,"context_line":"namespaces), but there are some operations that require additional"},{"line_number":106,"context_line":"permissions.  Extrapolating this to absurdity, eventually the"},{"line_number":107,"context_line":"privileged process accumulates *all* required capabilities and"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_127898f1","line":104,"range":{"start_line":104,"start_character":32,"end_line":104,"end_character":45},"updated":"2015-07-27 11:31:29.000000000","message":"It seems CAP_SYS_ADMIN gives process almost unlimited privileges. Is it possible to somehow avoid that? From what I gather, CAP_SYS_ADMIN is needed to create network namespace, but is not needed to join it. Is it possible to further limit privileged process to a separate user (and, probably other) namespace(s) so that it can\u0027t do any harm to root namespace but only can create new namespaces and pass them back?\n\nThis is just a suggestion, it can be done later in project-specific privileged code. But I think oslo.privsep should include ways to call some specific \"drop privileges\" callback from user code.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"3b2706a22474017acbc83fe5d6ac09035e933779","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":103,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"},{"line_number":104,"context_line":"just requires CAP_NET_ADMIN and CAP_SYS_ADMIN (for network"},{"line_number":105,"context_line":"namespaces), but there are some operations that require additional"},{"line_number":106,"context_line":"permissions.  Extrapolating this to absurdity, eventually the"},{"line_number":107,"context_line":"privileged process accumulates *all* required capabilities and"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_feb82f13","line":104,"range":{"start_line":104,"start_character":32,"end_line":104,"end_character":45},"in_reply_to":"3a50d1a3_127898f1","updated":"2015-07-29 01:13:31.000000000","message":"(Yuriy: that\u0027s for *user* namespaces, which have slightly different rules.  The only namespaces we use extensively outside the container projects currently (afaik) are network namespaces with Neutron.  I\u0027m focussing on the network namespaces here because Neutron has a use-case that requires frequently re-entering and tweaking things inside an existing net ns.)\n\nUnfortunately CAP_SYS_ADMIN (in the target namespace) is needed for setns(), not just creating namespaces.  Yes, we can probably do something involving putting the privileged daemon itself into a new intermediate namespace, although I haven\u0027t thought that one through yet.  Passing namespace fds between processes over Unix sockets is another potentially useful technique that I haven\u0027t explored.  Having said that, I think dropping uid\u003d0 is still quite a big win even if we continue to hold some of these scary-looking capabilities.\n\nThe network namespace case (specifically) is extra complicated because we most likely want to stay compatible with what iproute does with network namespaces.  iproute does a bunch of extra bind mount nonsense above and beyond the minimal kernel primitives to make the namespace outlive the iproute process that created it - and this unfortunately continues to need uid\u003d0 and all sorts of unfortunate filesystem stuff.  In my prototype neutron patch, I left createns/deletens with sudo/rootwrap and just concentrated on the \"enter existing namespace\" codepaths, which requires \"just\" CAP_SYS_ADMIN.  If we don\u0027t need to retain iproute compatibility (big \"if\"), then we can make this (and a bunch of garbage collection paths) simpler - but we can\u0027t do that with the existing short-lived cli-based approach.\n\nMy goal in this spec is to get the core \"function calls through a persistent process\" primitive in place.  I agree we\u0027ll need to explore further how we can best use all these new toys (selinux! seccomp!) once we have that basic functionality.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"0d6dccd42fb7a03e0fbc2b5f0c2b83b05690f68e","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":103,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"},{"line_number":104,"context_line":"just requires CAP_NET_ADMIN and CAP_SYS_ADMIN (for network"},{"line_number":105,"context_line":"namespaces), but there are some operations that require additional"},{"line_number":106,"context_line":"permissions.  Extrapolating this to absurdity, eventually the"},{"line_number":107,"context_line":"privileged process accumulates *all* required capabilities and"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_f69b64c7","line":104,"in_reply_to":"3a50d1a3_127898f1","updated":"2015-07-28 11:53:31.000000000","message":"I\u0027m not sure that\u0027s possible.  Assume for a moment that the privileged process is joined to a non root namespace as you suggest. What is to prevent it from joining back?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"f8cc1e3e5196a7f4b5d874a89e7518f566115cba","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":103,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"},{"line_number":104,"context_line":"just requires CAP_NET_ADMIN and CAP_SYS_ADMIN (for network"},{"line_number":105,"context_line":"namespaces), but there are some operations that require additional"},{"line_number":106,"context_line":"permissions.  Extrapolating this to absurdity, eventually the"},{"line_number":107,"context_line":"privileged process accumulates *all* required capabilities and"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_c5b22c96","line":104,"in_reply_to":"3a50d1a3_f69b64c7","updated":"2015-07-28 13:31:16.000000000","message":"From setns(2) manpage:\n\n  It is not permitted to use setns() to reenter the caller\u0027s current user namespace.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"2e6fbd9acbf8d4ba0494a293e118c4652136f190","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"A design limitation from using capabilities is that the privileged"},{"line_number":103,"context_line":"process is limited to *only those* capabilities.  Eg: most of Neutron"},{"line_number":104,"context_line":"just requires CAP_NET_ADMIN and CAP_SYS_ADMIN (for network"},{"line_number":105,"context_line":"namespaces), but there are some operations that require additional"},{"line_number":106,"context_line":"permissions.  Extrapolating this to absurdity, eventually the"},{"line_number":107,"context_line":"privileged process accumulates *all* required capabilities and"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_80eb8112","line":104,"range":{"start_line":104,"start_character":32,"end_line":104,"end_character":45},"in_reply_to":"3a50d1a3_feb82f13","updated":"2015-07-29 10:49:12.000000000","message":"\u003e Yuriy: that\u0027s for *user* namespaces, which have slightly different rules.\n\nYes, I\u0027m talking about limiting privileged process further with user namespace (and probably others too) so that it won\u0027t have CAP_SYS_ADMIN in root namespace. A separate mount namespace would be nice too so that it won\u0027t be able to bind-mount sudo binary or smth like that (I don\u0027t know if it will work that way). Otherwise we have a process that\u0027s not running as root, but have mostly the same capabilities.\n\n\u003e The only namespaces we use extensively outside the container projects currently (afaik) are network namespaces with Neutron. I\u0027m focussing on the network namespaces here because Neutron has a use-case that requires frequently re-entering and tweaking things inside an existing net ns.\n\nI\u0027m talking about limiting privsep daemon itself, it can be hidden from its callers.\n\n\u003e Unfortunately CAP_SYS_ADMIN (in the target namespace) is needed for setns(), not just creating namespaces. \n\nYeah, I tried it myself and found out that manpage forgot to mention that CAP_SYS_ADMIN is needed for joining network namespaces too.\n\n\u003e Passing namespace fds between processes over Unix sockets is another potentially useful technique that I haven\u0027t explored.\n\nI doubt it\u0027ll work this way: capabilities are verified on setns() call, not at open() for namespace fd. Passing open AF_NETLINK sockets might work though.\n\n\u003e The network namespace case (specifically) is extra complicated because we most likely want to stay compatible with what iproute does with network namespaces.\n\nI don\u0027t think this is necessary, but operators won\u0027t like you if you hide these namespaces from their usual places. As for creation and deletion, I don\u0027t think that calling iproute for this will provide significant performance overhead. Of course, you could do this from privsep daemon as well to avoid some of it.\n\n\u003e My goal in this spec is to get the core \"function calls through a persistent process\" primitive in place. I agree we\u0027ll need to explore further how we can best use all these new toys (selinux! seccomp!) once we have that basic functionality.\n\nYes, sure. As I said, it\u0027s just a suggestion.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"1e2cb7b5391662c924f67e1c294d457e7776ca9a","unresolved":false,"context_lines":[{"line_number":109,"context_line":"allows a particularly diverse service to instantiate multiple privsep"},{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_92b6e888","line":113,"range":{"start_line":112,"start_character":0,"end_line":113,"end_character":58},"updated":"2015-07-27 11:31:29.000000000","message":"I don\u0027t see any profit from that fate sharing. With approach implemented in rootwrap-daemon you could easily kill daemon without affecting main process and it\u0027ll get restarted and reload its configs and code. Why do you want to get rid of this feature?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"6914d6a4e15c1925a0608c1ee820dab40fe0c9d7","unresolved":false,"context_lines":[{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_28ab268b","line":113,"in_reply_to":"1a4dcd0f_454a2785","updated":"2015-08-04 08:13:08.000000000","message":"Ok, then I take back the part about RC system. Still we will most likely have ops invent autorestart scripts that we should avoid.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"749e38b1743898bc3cbd8c1469d858a81a0a29ac","unresolved":false,"context_lines":[{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_454a2785","line":113,"in_reply_to":"3a50d1a3_0fd93956","updated":"2015-08-04 01:37:14.000000000","message":"Yuriy: I think you\u0027ve misunderstood option 1.  In that proposed method, the *main* process is started from some init system - and the priv process is forked off from that at some point early in startup.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"f8cc1e3e5196a7f4b5d874a89e7518f566115cba","unresolved":false,"context_lines":[{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_77118b51","line":113,"in_reply_to":"3a50d1a3_16d6104f","updated":"2015-07-28 13:31:16.000000000","message":"Oh, I do agree that privileged process should die once unprivileged process dies. I don\u0027t like the idea of having to restart Neutron agent, for example, just because smth went wrong in privileged process. We can just restart privileged process automatically like rootwrap-daemon\u0027s Client does.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"99c9ef745b54bcf4ab848d01202cd1a8df90fb1a","unresolved":false,"context_lines":[{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_f6906798","line":113,"in_reply_to":"3a50d1a3_2052ad67","updated":"2015-08-02 03:39:28.000000000","message":"But its not being run from an init system: its closer in model to a thread (which is a pid with page sharing) - not a daemon.\n\nI\u0027m very pro fate sharing here. It simplifies deployment, and will fail closed in the event of issues, rather than failing open.\n\nLets get some thoughtful feedback on the operators list.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"0d6dccd42fb7a03e0fbc2b5f0c2b83b05690f68e","unresolved":false,"context_lines":[{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_16d6104f","line":113,"in_reply_to":"3a50d1a3_92b6e888","updated":"2015-07-28 11:53:31.000000000","message":"I admit to being confused by this - why isn\u0027t the explanation given in this paragraph a good enough reason?  I\u0027d much rather have the privileged process automatically shut down than leave it around waiting for manual killing.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"3b2706a22474017acbc83fe5d6ac09035e933779","unresolved":false,"context_lines":[{"line_number":109,"context_line":"allows a particularly diverse service to instantiate multiple privsep"},{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_deee93ec","line":113,"range":{"start_line":112,"start_character":0,"end_line":113,"end_character":58},"in_reply_to":"3a50d1a3_92b6e888","updated":"2015-07-29 01:13:31.000000000","message":"My thinking was:\n\n1. Fate sharing removes a few ambiguities and simplifies the code - no retries, no \"wait for connect\" on the priv side, no need to wonder about when each side should give up, etc.\n\n2. Since exceptions are being caught quite high up the event loop, there are few reasons the privileged process should exit.  Quite possibly, the privileged process is hard-crashing due to some attempted exploit and the most noisy and paranoid response is just to exit rather than restart and give the attacker another opportunity.  A DoS is bad, but a remote exploit is worse.\n\n3. If the privileged daemon was started via \"method 1\" (fork before dropping privs), then there is no way to restart the privileged daemon from the unprivileged process (no sudo with this approach).","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"2e6fbd9acbf8d4ba0494a293e118c4652136f190","unresolved":false,"context_lines":[{"line_number":109,"context_line":"allows a particularly diverse service to instantiate multiple privsep"},{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_2052ad67","line":113,"range":{"start_line":112,"start_character":0,"end_line":113,"end_character":58},"in_reply_to":"3a50d1a3_deee93ec","updated":"2015-07-29 10:49:12.000000000","message":"From operator\u0027s POV, it would look like your damn service just started to fail and need reboot like a damn Windows machine (this isn\u0027t an actual wording, it\u0027ll be stronger). And there will come autorestart cron jobs etc. If daemon is run from some RC system, it\u0027ll most likely just restart it automatically. So either way you\u0027ll have some restart logic, why not put it all in one place?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"b9174f2e533bec42a1eea8efaaf4badf4524211c","unresolved":false,"context_lines":[{"line_number":110,"context_line":"daemons, each with their own set of permissions and privileged code."},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Unlike ``rootwrap-daemon``, this spec proposes that the privileged"},{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_0fd93956","line":113,"in_reply_to":"3a50d1a3_f6906798","updated":"2015-08-02 09:56:45.000000000","message":"The first option below suggest that it can be used to start priv process from some RC system. I\u0027ve just said that in any of those options we\u0027ll end up with some restart mechanism in place.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"1e2cb7b5391662c924f67e1c294d457e7776ca9a","unresolved":false,"context_lines":[{"line_number":128,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_2d30d9e7","line":132,"range":{"start_line":131,"start_character":53,"end_line":132,"end_character":30},"updated":"2015-07-27 11:31:29.000000000","message":"The same issue bothers me with oslo.serialization. Even given that it\u0027s our code, it brings a lot of dependencies along with it. That\u0027s not secure at all. Please take a look at oslo.rootwrap\u0027s requirements.txt - there\u0027s only \u0027six\u0027 there (and that can be avoided) for this very reason. We shouldn\u0027t trust anyone but stdlib.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"ed478444952169a111817cd9b723aa2f0a3881b6","unresolved":false,"context_lines":[{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_b4ee6d89","line":132,"in_reply_to":"1a4dcd0f_6804ce7d","updated":"2015-08-13 00:36:39.000000000","message":"The privsep privileged code will go on to load the project\u0027s privileged code, so any libraries the project chooses to use at that point will be executed in the privileged context.\n\nCircling back to your original concern, we should indeed be careful about what we import in privileged code.  I\u0027m suggesting that enforcing a \"stdlib only\" rule here is unnecessarily extreme when project code is (hopefully!) going to go on and use a bunch of other python libraries anyway.\n\nI\u0027d like us to leave ourselves open to individual case-by-case decisions instead, so regarding oslo.serialization:  Do we have security concerns with using this library?  Should we bring these up with the relevant folks and see if we can come up with something that we _would_ be happy to reuse, or is it better to duplicate effort here in the name of predictability?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"6914d6a4e15c1925a0608c1ee820dab40fe0c9d7","unresolved":false,"context_lines":[{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_6804ce7d","line":132,"in_reply_to":"1a4dcd0f_e5925357","updated":"2015-08-04 08:13:08.000000000","message":"Let\u0027s not mix oslo.privsep and project\u0027s code here. Project\u0027s code can use whatever authors feel necessary to get job done. Privsep code must ensure that privileges are dropped and do it in the most secure way possible which must include using only trusted libs on privsep side.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"3b2706a22474017acbc83fe5d6ac09035e933779","unresolved":false,"context_lines":[{"line_number":128,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_3ed0d7f5","line":132,"range":{"start_line":131,"start_character":53,"end_line":132,"end_character":30},"in_reply_to":"3a50d1a3_2d30d9e7","updated":"2015-07-29 01:13:31.000000000","message":"Ah, let\u0027s talk about this elephant in the room: One of the directions I\u0027m intending to encourage(*) with this approach is to use python libraries rather than command line tools, eg: I think using netlink via pyroute2 is less open to abuse and confusion than generating/parsing ip(8) command lines.\n\n(*) .. with appropriate care for well-tested and competent upstream projects.\n\nThis will mean that in some places we\u0027ll be using 3rd party python libraries where before we were using 3rd party command line tools - making requirements.txt fatter than what it was with rootwrap.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"2e6fbd9acbf8d4ba0494a293e118c4652136f190","unresolved":false,"context_lines":[{"line_number":128,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_e0c1254f","line":132,"range":{"start_line":131,"start_character":53,"end_line":132,"end_character":30},"in_reply_to":"3a50d1a3_3ed0d7f5","updated":"2015-07-29 10:49:12.000000000","message":"I\u0027m all for using Python instead of shell-ish APIs. But all these calls and imports should be done after privileges are dropped, i.e. in project\u0027s code (in prj_privileged package), not in basic oslo.privsep code. Privsep code runs as usual root, so it has the same requirements as rootwrap: as little 3rd-party modules as possible. You\u0027re not going to place pyroute2 to requirements.txt in oslo.privsep, are you?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"749e38b1743898bc3cbd8c1469d858a81a0a29ac","unresolved":false,"context_lines":[{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_e5925357","line":132,"in_reply_to":"3a50d1a3_5621119d","updated":"2015-08-04 01:37:14.000000000","message":"pyroute2 would be in neutron\u0027s requirements.txt, absolutely.\n\nI\u0027m just making sure everyone here is clear that there are going to be more non-trivial 3rd-party python libraries loaded into the privileged process than we had with rootwrap (but less reliance on 3rd party non-python tools) and that \"we shouldn\u0027t trust anyone but stdlib\" is an explicit non-goal with the privsep approach.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"15abd014ceb9f16e68d5ec38b94e9d0b6206e841","unresolved":false,"context_lines":[{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_5621119d","line":132,"in_reply_to":"3a50d1a3_b68adf62","updated":"2015-08-03 00:53:26.000000000","message":"+1 to lifeless\u0027s comment","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"99c9ef745b54bcf4ab848d01202cd1a8df90fb1a","unresolved":false,"context_lines":[{"line_number":129,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":130,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":131,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":132,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":133,"context_line":"datatypes and a small set of simple additional types."},{"line_number":134,"context_line":""},{"line_number":135,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_b68adf62","line":132,"in_reply_to":"3a50d1a3_e0c1254f","updated":"2015-08-02 03:39:28.000000000","message":"pyroute2 would be a dependency of the using project, not oslo.privsep.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"2e6fbd9acbf8d4ba0494a293e118c4652136f190","unresolved":false,"context_lines":[{"line_number":149,"context_line":""},{"line_number":150,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":151,"context_line":""},{"line_number":152,"context_line":"   This just creates a pair of anonymous connected Unix sockets, and"},{"line_number":153,"context_line":"   then forks the new privileged process.  The assumption is that the"},{"line_number":154,"context_line":"   original process was started with at least the required privileges"},{"line_number":155,"context_line":"   (perhaps from something like systemd), and this \"start\" function is"},{"line_number":156,"context_line":"   invoked early in the process startup - prior to the regular"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_d642afaa","line":153,"range":{"start_line":152,"start_character":3,"end_line":153,"end_character":41},"updated":"2015-07-29 10:49:12.000000000","message":"Ok, reading this again I don\u0027t understand how unprivileged process will get its end of pipe/socketpair. Do you plan to have some other daemon (like initd or systemd\u0027s all-in-one) receiving connection and spawning these privileged daemons?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"6914d6a4e15c1925a0608c1ee820dab40fe0c9d7","unresolved":false,"context_lines":[{"line_number":149,"context_line":""},{"line_number":150,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":151,"context_line":""},{"line_number":152,"context_line":"   This just creates a pair of anonymous connected Unix sockets, and"},{"line_number":153,"context_line":"   then forks the new privileged process.  The assumption is that the"},{"line_number":154,"context_line":"   original process was started with at least the required privileges"},{"line_number":155,"context_line":"   (perhaps from something like systemd), and this \"start\" function is"},{"line_number":156,"context_line":"   invoked early in the process startup - prior to the regular"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_88f35a73","line":153,"range":{"start_line":152,"start_character":3,"end_line":153,"end_character":41},"in_reply_to":"1a4dcd0f_05997f6e","updated":"2015-08-04 08:13:08.000000000","message":"It looks very much like the second option except that the main process itself would be responsible for dropping root instead of RC system.\n\nIt looks like we should tighten scope of this blueprint to include only one option (the 2nd one seems to be the most straightforward) and maybe implement additional ways to start processes later if that\u0027s needed.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"749e38b1743898bc3cbd8c1469d858a81a0a29ac","unresolved":false,"context_lines":[{"line_number":149,"context_line":""},{"line_number":150,"context_line":"1. Basic ``socketpair()`` and ``fork()``"},{"line_number":151,"context_line":""},{"line_number":152,"context_line":"   This just creates a pair of anonymous connected Unix sockets, and"},{"line_number":153,"context_line":"   then forks the new privileged process.  The assumption is that the"},{"line_number":154,"context_line":"   original process was started with at least the required privileges"},{"line_number":155,"context_line":"   (perhaps from something like systemd), and this \"start\" function is"},{"line_number":156,"context_line":"   invoked early in the process startup - prior to the regular"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_05997f6e","line":153,"range":{"start_line":152,"start_character":3,"end_line":153,"end_character":41},"in_reply_to":"3a50d1a3_d642afaa","updated":"2015-08-04 01:37:14.000000000","message":"No, it\u0027s far simpler than that - see the start_via_fork() function in the prototype code for the exact method.  Basically it just calls socketpair(), forks, and then the child and parent processes each use a different one of the socketpair endpoints.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"99c9ef745b54bcf4ab848d01202cd1a8df90fb1a","unresolved":false,"context_lines":[{"line_number":165,"context_line":""},{"line_number":166,"context_line":"   This starts the privileged process on first request by using"},{"line_number":167,"context_line":"   ``sudo`` (or ``sudo`` and ``rootwrap``) and communicating over"},{"line_number":168,"context_line":"   stdin and stdout."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Requires a single suitable ``sudoers`` or rootwrap filters entry,"},{"line_number":171,"context_line":"   but is otherwise simple to understand."}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_56e83b16","line":168,"updated":"2015-08-02 03:39:28.000000000","message":"I\u0027d like to suggest that we never communicate over stdin/stdout for several reasons.\n\n 1) making stdin/stdout 8-bit clean is different in different Python versions. We will have bugs there.\n 2) stdin and stdout are very useful for interactive debugging with pdb, without needing to write up a manhole facility\n\nInstead:\n\n - always communicate over a socketpair\n - leave stdin/stdout for debugging if needed - and provide an option so that when the daemon is spawned / forked from the server process, the console stdin/out can be the ones passed down. When off that option would result in stdin/stdout being closed and unusable.\n - use stderr for logging from the privsep daemon. Have that share the fd with the server process stderr.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"ed478444952169a111817cd9b723aa2f0a3881b6","unresolved":false,"context_lines":[{"line_number":165,"context_line":""},{"line_number":166,"context_line":"   This starts the privileged process on first request by using"},{"line_number":167,"context_line":"   ``sudo`` (or ``sudo`` and ``rootwrap``) and communicating over"},{"line_number":168,"context_line":"   stdin and stdout."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Requires a single suitable ``sudoers`` or rootwrap filters entry,"},{"line_number":171,"context_line":"   but is otherwise simple to understand."}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_afd05854","line":168,"in_reply_to":"1a4dcd0f_5b3c4493","updated":"2015-08-13 00:36:39.000000000","message":"lifeless: If you were asking me that question, no it doesn\u0027t address your second concern (stdin/stdout mucking with pdb use).\n\nMy reasons for using stdin/stdout were: A) secure+simple communication channel, B) they\u0027re the ~only fds that survive across sudo.  I hadn\u0027t considered the impact on pdb, and I agree that\u0027s an issue with using stdin/stdout.\n\nIf I\u0027m going to use stdin/stdout, I think I need to add an explicit --use-stdinout so it doesn\u0027t do this by default (current implementation just used the absence of unix socket path from \"method 3\" to imply stdin/stdout).\n\nThe other alternative is to drop method 2 and restore method 3 (pass path of unix socket to connect back to as argument).\n\n(There are some other alternatives I don\u0027t like, like creating stdin as a unix socket and passing an additional unix socket fd across stdin - will leave stdin/out unmangled for pdb use, but is otherwise too weird/surprising)\n\nEdit: we discussed this over IRC, and our conclusion was to close (and reopen on /dev/null) stdin/stdout and add a helper function to start pdb on a new unix socket or tty.  The latter helper wouldn\u0027t be called anywhere automatically and would require developer action if/when pdb was desired.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"b9174f2e533bec42a1eea8efaaf4badf4524211c","unresolved":false,"context_lines":[{"line_number":165,"context_line":""},{"line_number":166,"context_line":"   This starts the privileged process on first request by using"},{"line_number":167,"context_line":"   ``sudo`` (or ``sudo`` and ``rootwrap``) and communicating over"},{"line_number":168,"context_line":"   stdin and stdout."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Requires a single suitable ``sudoers`` or rootwrap filters entry,"},{"line_number":171,"context_line":"   but is otherwise simple to understand."}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_af65a5af","line":168,"in_reply_to":"3a50d1a3_56e83b16","updated":"2015-08-02 09:56:45.000000000","message":"Unfortunately sudo will close all fds except 0, 1 and 2 on invocation and using smth else for interaction with the daemon would require special sudoers rules just for privsep daemon even if we use rootwrap.\n\n\u003e 1) making stdin/stdout 8-bit clean is different in different Python versions. We will have bugs there.\n\nThe solution is to not use sys.stdin/out for this communication. We can directly use appropriate file descriptor with socket.fromfd, for example.\n\n\u003e 2) stdin and stdout are very useful for interactive debugging with pdb, without needing to write up a manhole facility\n\nYou can easily use Pdb with stdin/stdout parameters to use them instead of real stdin/stdout for debugging:\n\n  import pdb\n  pdb.Pdb(stdin\u003dopen(\u0027/dev/pts/42\u0027, \u0027r\u0027), stdout\u003dopen(\u0027/dev/pts/42\u0027, \u0027w\u0027)).set_trace()\n\nI don\u0027t think we should complicate configuration and/or deployment for the sake of less mouthful debugging.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"749e38b1743898bc3cbd8c1469d858a81a0a29ac","unresolved":false,"context_lines":[{"line_number":165,"context_line":""},{"line_number":166,"context_line":"   This starts the privileged process on first request by using"},{"line_number":167,"context_line":"   ``sudo`` (or ``sudo`` and ``rootwrap``) and communicating over"},{"line_number":168,"context_line":"   stdin and stdout."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Requires a single suitable ``sudoers`` or rootwrap filters entry,"},{"line_number":171,"context_line":"   but is otherwise simple to understand."}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_459547e2","line":168,"in_reply_to":"3a50d1a3_af65a5af","updated":"2015-08-04 01:37:14.000000000","message":"I have solutions for both (\"method 3\" removed in an earlier revision avoids stdin/stdout entirely).  I can restore it and we have to carry code for all versions, or the two of you can come to some agreement ;)","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"baafc875f9c462099fa8be570de6acdf4f19df46","unresolved":false,"context_lines":[{"line_number":165,"context_line":""},{"line_number":166,"context_line":"   This starts the privileged process on first request by using"},{"line_number":167,"context_line":"   ``sudo`` (or ``sudo`` and ``rootwrap``) and communicating over"},{"line_number":168,"context_line":"   stdin and stdout."},{"line_number":169,"context_line":""},{"line_number":170,"context_line":"   Requires a single suitable ``sudoers`` or rootwrap filters entry,"},{"line_number":171,"context_line":"   but is otherwise simple to understand."}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_5b3c4493","line":168,"in_reply_to":"3a50d1a3_af65a5af","updated":"2015-08-04 02:24:07.000000000","message":"So I don\u0027t understand how your reply addresses my second concern. Turn it around - why do you want to use stdin/stdout?","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"1e2cb7b5391662c924f67e1c294d457e7776ca9a","unresolved":false,"context_lines":[{"line_number":208,"context_line":"      print \"privsep is running as %s\" % uid"},{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_1f21804d","line":212,"range":{"start_line":211,"start_character":50,"end_line":212,"end_character":24},"updated":"2015-07-27 11:31:29.000000000","message":"This interface seems too \u0027magic\u0027 to me. How about reversing the process? You can create a special object and register all entry points with it instead of walking around packages\u0027 internals. For example:\n\nprj_privileged/__init__.py can look like:\n\n  from oslo_privsep import capabilities as c\n  from oslo_privsep import Privsep\n\n  CFG_SECTION \u003d \u0027privsep\u0027\n  DEFAULT_CAPS \u003d [c.CAP_SYS_ADMIN, c.CAP_NET_ADMIN]\n\n  privsep \u003d Privsep(__name__, \u0027privsep\u0027, CFG_SECTION, DEFAULT_CAPS)\n\nprj_privileged/foo.py will look like:\n\n  import os\n  import prj_privileged\n\n  @prj_privileged.privsep\n  def example_task_that_requires_privileges():\n      return os.getuid()\n\nand usage will look like:\n\n  from prj_privileged import foo\n\n  def bar():\n      uid \u003d foo.privileged.example_task_that_requires_privileges()\n      print \"privsep is running as %s\" % uid\n\nThis approach will make it clear where entry points are registered at and which entry points should get to which privsep daemon. With this approach you don\u0027t need a separate namespace (_commands) for callback implementations since decorator should properly replace every method with appropriate call of Privsep instance method.\n\nNote that Privsep constructor receives arguments like \"root package for privileged operations\" and \"name of variable where all entry points are registered\". This makes it clear where would daemon side get its settings (from object-registry).\n\nAnother note: the fact that we\u0027ll be starting daemon based on import-time information may look like an issue, but it isn\u0027t. All modules that provide these endpoints will already be imported before we\u0027ll call them in run time. Even if that\u0027s not the case, we can push information about new modules to be loaded to daemon side to make sure they are loaded there. Of course they should be limited to provided root package\u0027s namespace.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"6914d6a4e15c1925a0608c1ee820dab40fe0c9d7","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_e8253ec2","line":212,"in_reply_to":"1a4dcd0f_fbc990ad","updated":"2015-08-04 08:13:08.000000000","message":"Not arbitrary code, but code from a special package that resides in protected part of filesystem (/usr/lib). The only thing that would change is when priv side get information about commands and loads the code. But maybe you\u0027re right and we should have a clear point in time after which no new code can be loaded. In this case unpriv side will have to provide all modules to load in the first command to priv side.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"99c9ef745b54bcf4ab848d01202cd1a8df90fb1a","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_96e6c342","line":212,"in_reply_to":"3a50d1a3_161850d2","updated":"2015-08-02 03:39:28.000000000","message":"I don\u0027t think pushing new modules to the privileged side is safe. Its a clear way to inject arbitrary code into a new security context.\n\nLikewise, the privileged side needs to make sure it never imports anything once its up and running.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"f8cc1e3e5196a7f4b5d874a89e7518f566115cba","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_170047aa","line":212,"in_reply_to":"3a50d1a3_161850d2","updated":"2015-07-28 13:31:16.000000000","message":"If we limit amount of trust by specifying root package that should be parent of any package to be loaded, it should be ok.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"2e6fbd9acbf8d4ba0494a293e118c4652136f190","unresolved":false,"context_lines":[{"line_number":208,"context_line":"      print \"privsep is running as %s\" % uid"},{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_96a667bf","line":212,"range":{"start_line":211,"start_character":50,"end_line":212,"end_character":24},"in_reply_to":"3a50d1a3_1e8b9bc4","updated":"2015-07-29 10:49:12.000000000","message":"\u003e I can switch between client+server behaviour by flipping a global\n\nNot global - everything should be limited to Privsep instance.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11682,"name":"Ryan Moats","email":"rmoats@us.ibm.com","username":"regXboi"},"change_message_id":"0d6dccd42fb7a03e0fbc2b5f0c2b83b05690f68e","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_161850d2","line":212,"in_reply_to":"3a50d1a3_1f21804d","updated":"2015-07-28 11:53:31.000000000","message":"I mostly like this - I\u0027m not sure about the idea of pushing new module information to the demon however...","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"3b2706a22474017acbc83fe5d6ac09035e933779","unresolved":false,"context_lines":[{"line_number":208,"context_line":"      print \"privsep is running as %s\" % uid"},{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_1e8b9bc4","line":212,"range":{"start_line":211,"start_character":50,"end_line":212,"end_character":24},"in_reply_to":"3a50d1a3_1f21804d","updated":"2015-07-29 01:13:31.000000000","message":"Yeah, I like this and I think doing more in the decorator is indeed cleaner.  Having a single/obvious namespace will make static analysis tools much happier too - it will look just like you\u0027re calling the real function body.\n\n(Thinking out loud) I think some wrapper code from the decorator will need to hang around so I can switch between client+server behaviour by flipping a global or somesuch that I can use rather than trying to reimport..  Yep, seems fine.\n\nI *really* don\u0027t want the client telling the server what code to import - but this isn\u0027t a problem, the code to just find (and perhaps import on first use) a \"module.function\" path below an existing parent package is straightforward and already written for the existing commands/_commands approach.\n\nYeah this seems much cleaner, thanks.  (Fwiw, my first version just looked for functions that didn\u0027t start with underscore.  I didn\u0027t re-evaluate the interface once that changed to use explicit decorators.)","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"baafc875f9c462099fa8be570de6acdf4f19df46","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_fbc990ad","line":212,"in_reply_to":"3a50d1a3_8fff89aa","updated":"2015-08-04 02:24:07.000000000","message":"@Yuriy:\n\nimport can execute arbitrary code. I don\u0027t need to demonstrate a active attack right now for it to be a clear path to vulnerabilities. The privileged side needs to be hermetic and there needs to be no way for the unprivileged side to cause it to load/execute arbitrary code *other than* the privileged commands it is intended to run.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"b9174f2e533bec42a1eea8efaaf4badf4524211c","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"The magic is in ``some/known/prefix/commands.py``.  This file needs to"},{"line_number":211,"context_line":"invoke some ``oslo.privsep`` code at import time, which walks all the"},{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_8fff89aa","line":212,"in_reply_to":"3a50d1a3_96e6c342","updated":"2015-08-02 09:56:45.000000000","message":"One way or another priv side will get a list of modules to import. We can just push it as a first command message, for example.\n\n\u003e Its a clear way to inject arbitrary code into a new security context.\n\nCan you describe a scenario for this? I don\u0027t see how pushing which modules to import at run time is less secure than doing so in config/startup time. As long as we\u0027re limited to a certain preconfigured package (which is always deployed readonly), noone (except omnipotent root, of course) can inject any code to priv side.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"1e2cb7b5391662c924f67e1c294d457e7776ca9a","unresolved":false,"context_lines":[{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"},{"line_number":216,"context_line":"   from oslo_privsep import capabilities as c"},{"line_number":217,"context_line":"   from oslo_privsep import unprivileged"},{"line_number":218,"context_line":""}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_dfc8f876","line":215,"range":{"start_line":215,"start_character":8,"end_line":215,"end_character":37},"updated":"2015-07-27 11:31:29.000000000","message":"You should use recommended package name (\"prj_privileged\") in examples.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"3b2706a22474017acbc83fe5d6ac09035e933779","unresolved":false,"context_lines":[{"line_number":212,"context_line":"code below ``_commands`` and generates small client stub functions."},{"line_number":213,"context_line":"::"},{"line_number":214,"context_line":""},{"line_number":215,"context_line":"   # In some/known/prefix/commands.py (once per project)"},{"line_number":216,"context_line":"   from oslo_privsep import capabilities as c"},{"line_number":217,"context_line":"   from oslo_privsep import unprivileged"},{"line_number":218,"context_line":""}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_5eb3639a","line":215,"range":{"start_line":215,"start_character":8,"end_line":215,"end_character":37},"in_reply_to":"3a50d1a3_dfc8f876","updated":"2015-07-29 01:13:31.000000000","message":"Will do...","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"99c9ef745b54bcf4ab848d01202cd1a8df90fb1a","unresolved":false,"context_lines":[{"line_number":232,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":233,"context_line":"first stub is called unless the daemon has already been started.  Once"},{"line_number":234,"context_line":"started, the same channel is reused and the privileged daemon persists"},{"line_number":235,"context_line":"until the channel is closed (presumably when the main process exits)."},{"line_number":236,"context_line":""},{"line_number":237,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":238,"context_line":"decorator are not available across the privsep channel.  \"Data\""}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_b6e17f2c","line":235,"updated":"2015-08-02 03:39:28.000000000","message":"I worry about just-in-time starting. Better to have a clear model of \u0027start this now\u0027 so that we can rely on it being safe to do the start-as-root-drop-prives model in future.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"6914d6a4e15c1925a0608c1ee820dab40fe0c9d7","unresolved":false,"context_lines":[{"line_number":232,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":233,"context_line":"first stub is called unless the daemon has already been started.  Once"},{"line_number":234,"context_line":"started, the same channel is reused and the privileged daemon persists"},{"line_number":235,"context_line":"until the channel is closed (presumably when the main process exits)."},{"line_number":236,"context_line":""},{"line_number":237,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":238,"context_line":"decorator are not available across the privsep channel.  \"Data\""}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_6b4da871","line":235,"in_reply_to":"1a4dcd0f_1b81dc4a","updated":"2015-08-04 08:13:08.000000000","message":"Autostart worked fine in rootwrap daemon. It also provides better API from developer\u0027s POV: just import necessary stuff and use it, so let\u0027s keep that one if we strongly need to keep only one of them.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"baafc875f9c462099fa8be570de6acdf4f19df46","unresolved":false,"context_lines":[{"line_number":232,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":233,"context_line":"first stub is called unless the daemon has already been started.  Once"},{"line_number":234,"context_line":"started, the same channel is reused and the privileged daemon persists"},{"line_number":235,"context_line":"until the channel is closed (presumably when the main process exits)."},{"line_number":236,"context_line":""},{"line_number":237,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":238,"context_line":"decorator are not available across the privsep channel.  \"Data\""}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_1b81dc4a","line":235,"in_reply_to":"3a50d1a3_0f229954","updated":"2015-08-04 02:24:07.000000000","message":"I specifically object to this because it *will* get missed in some entry points and then we\u0027ll have random breakage when we try to do the drop-privs route. So lets use the least set of behaviours API design approach. Explicit start, and then everything assumes its running.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"b9174f2e533bec42a1eea8efaaf4badf4524211c","unresolved":false,"context_lines":[{"line_number":232,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":233,"context_line":"first stub is called unless the daemon has already been started.  Once"},{"line_number":234,"context_line":"started, the same channel is reused and the privileged daemon persists"},{"line_number":235,"context_line":"until the channel is closed (presumably when the main process exits)."},{"line_number":236,"context_line":""},{"line_number":237,"context_line":"Functions that are not marked with the ``@privileged.entrypoint``"},{"line_number":238,"context_line":"decorator are not available across the privsep channel.  \"Data\""}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_0f229954","line":235,"in_reply_to":"3a50d1a3_b6e17f2c","updated":"2015-08-02 09:56:45.000000000","message":"I think we can provide both alternatives: call some start() method explicitly or call any method that would trigger start().","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"99c9ef745b54bcf4ab848d01202cd1a8df90fb1a","unresolved":false,"context_lines":[{"line_number":251,"context_line":"spec suggests projects create a new top-level python package within"},{"line_number":252,"context_line":"their regular git repository to hold modules intended to be used via"},{"line_number":253,"context_line":"privsep (eg: create ``neutron.git/neutron_privileged/commands.py``)."},{"line_number":254,"context_line":""},{"line_number":255,"context_line":"Operator\u0027s Point of View"},{"line_number":256,"context_line":"------------------------"},{"line_number":257,"context_line":""}],"source_content_type":"text/x-rst","patch_set":5,"id":"3a50d1a3_56cfdbb2","line":254,"updated":"2015-08-02 03:39:28.000000000","message":"Missing things from developers point of view:\n\n - debugging\n - profiling\n - coverage\n\nAnd what about the latency of these calls: whats the concurrency model of privsep calls.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"749e38b1743898bc3cbd8c1469d858a81a0a29ac","unresolved":false,"context_lines":[{"line_number":251,"context_line":"spec suggests projects create a new top-level python package within"},{"line_number":252,"context_line":"their regular git repository to hold modules intended to be used via"},{"line_number":253,"context_line":"privsep (eg: create ``neutron.git/neutron_privileged/commands.py``)."},{"line_number":254,"context_line":""},{"line_number":255,"context_line":"Operator\u0027s Point of View"},{"line_number":256,"context_line":"------------------------"},{"line_number":257,"context_line":""}],"source_content_type":"text/x-rst","patch_set":5,"id":"1a4dcd0f_4579c7fb","line":254,"in_reply_to":"3a50d1a3_56cfdbb2","updated":"2015-08-04 01:37:14.000000000","message":"Ack, I\u0027ll add some words on these.\n\nDebugging can be improved by avoiding stdin/stdout as you suggested above.\n\nI suspect profiling/coverage will have poor answers, since it\u0027s a different process and the profiling data will be split/hidden from a naive profiling/coverage run on the main process.","commit_id":"192cb8eac0b7a264d58c8e7c042175235e27d200"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"613de2699ac8530f2a13d21da2eb237a5c3dd2e6","unresolved":false,"context_lines":[{"line_number":156,"context_line":"The communication channel must be secure.  In particular, python"},{"line_number":157,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":158,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":159,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":160,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":161,"context_line":"datatypes and a small set of simple additional types."},{"line_number":162,"context_line":""},{"line_number":163,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_3accc488","line":160,"range":{"start_line":159,"start_character":53,"end_line":160,"end_character":30},"updated":"2015-08-18 12:28:14.000000000","message":"(moving discussion to current patchset)\n\n\u003e Do we have security concerns with using this library?\n\nYes, it has a lot of dependencies that should be audited to make sure it\u0027s secure.\n\n\u003e Should we bring these up with the relevant folks and see if we can come up with something that we _would_ be happy to reuse, or is it better to duplicate effort here in the name of predictability?\n\nI personally don\u0027t see any benefit from using oslo.serialization here: it doesn\u0027t support deserializing anything but normal JSON types, so it doesn\u0027t provide anything to our RPC usecase builtin json module doesn\u0027t already provide. The only duplicated effort here will be calling `json.dumps` and `json.loads`.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":157,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":158,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":159,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":160,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":161,"context_line":"datatypes and a small set of simple additional types."},{"line_number":162,"context_line":""},{"line_number":163,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_eca88179","line":160,"in_reply_to":"fa1b9901_3accc488","updated":"2015-08-19 22:22:10.000000000","message":"Thats presumes we have no binary data to transport. json.dumps cannot transport even clean encoded unicode like u\"☃\".encode(\u0027utf8\u0027) - it has to have the actual string.\n\nmsgpack or bson or $other binary-safe codec would be a much better choice. oslo.serialization does (AFAIK) achieve this by layering stuff on top of JSON. Not ideal.\n\nI fully support using msgpack here. I see no versioned API needs, which is the primary case for oslo.serialization. OTOH I am happy with using oslo.serialization too, since it has to be approximately as paranoid - even if it hasn\u0027t been to date).","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"0db7d7d004611a05b22daaf965f7e59332fee1cb","unresolved":false,"context_lines":[{"line_number":157,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":158,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":159,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":160,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":161,"context_line":"datatypes and a small set of simple additional types."},{"line_number":162,"context_line":""},{"line_number":163,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_c0a8ce8e","line":160,"in_reply_to":"fa1b9901_d57bbd8a","updated":"2015-08-20 07:52:16.000000000","message":"Supporting binary strings in JSON serialization is embarrassingly simple to implement (see https://github.com/openstack/oslo.rootwrap/blob/master/oslo_rootwrap/jsonrpc.py#L32-L33 and lines 54-55). It has some overhead, yes, but it should be negligible compared to other overheads in play here. If that\u0027s the only concern about using builtin json, I\u0027d suggest just keeping these 4 LOCs in the library.\n\nI think that whatever decision we come to here, we can change it later. But if you start using oslo.serialization and providing all its pseudo-support for datetimes and such to library users, you\u0027ll have to keep that support around even if you decide to follow \u0027empty requirements.txt\u0027 rule. In other case (starting with stdlib) you won\u0027t provide any extra features until you either decide to use some external library or implement them all in your code.\n\nSo my truce proposal is:\n- let\u0027s start with stdlib json;\n- let\u0027s not mention \u0027no 3rd-party libraries\u0027 rule anywhere in spec;\n- let\u0027s see how it plays out and bring more people to the discussion later.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":157,"context_line":"\"pickle\" and many other serialisation libraries are unsuitable because"},{"line_number":158,"context_line":"they contain convenience features that can allow unexpected code to be"},{"line_number":159,"context_line":"executed during deserialisation.  This spec proposes delegating this"},{"line_number":160,"context_line":"task to ``oslo.serialization``, which supports primitive json-ish"},{"line_number":161,"context_line":"datatypes and a small set of simple additional types."},{"line_number":162,"context_line":""},{"line_number":163,"context_line":"The underlying communication channel must not be exposed remotely -"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_d57bbd8a","line":160,"in_reply_to":"fa1b9901_eca88179","updated":"2015-08-20 03:10:03.000000000","message":"oslo.serialization provides both json-based and msgpack-based alternatives.  I had _thought_ they were functional equivalents for each other but I see now they aren\u0027t - which is frankly disappointing.\n\nMy intention with suggesting oslo.serialization was that we would also pick up the small number of additional simple/safe types you see in `msgpackutils.default_registry`[1].  I\u0027m fine with A) saying we\u0027ll support these additional types also over JSON (and adding that functionality to oslo.serialization.jsonutils), B) dropping any types beyond the json primitives, C) using msgpack with or without oslo.serialization.\n\nlifeless raises an important point and transparently handling binary strings in _some_ fashion is a requirement here.  I will make sure that case is covered in the unittests, and this may restrict the initial implementation choices.\n\nI think reasonable people could disagree over how efficiently serialisation needs to happen and the risks of introducing a non-stdlib dependency - and I\u0027d love to be able to move _this_ part of the discussion out to a later spec/change on the understanding that the specific implementation choice doesn\u0027t change the architecture and can be changed easily over privsep\u0027s future.  *I* *just* *don\u0027t* *care* about this detail of the spec - and I\u0027d ask the reviewers to come to some temporary truce that will let us move forward on the more important changes discussed here.\n\n[1] http://docs.openstack.org/developer/oslo.serialization/api.html#oslo_serialization.msgpackutils.default_registry","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"613de2699ac8530f2a13d21da2eb237a5c3dd2e6","unresolved":false,"context_lines":[{"line_number":215,"context_line":"   filesystem permissions only allow the same uid, or root - and a"},{"line_number":216,"context_line":"   process running as the same uid is already entrusted to start its own"},{"line_number":217,"context_line":"   privileged daemon via ``sudo``/``rootwrap``, so this would grant no"},{"line_number":218,"context_line":"   additional privilege."},{"line_number":219,"context_line":""},{"line_number":220,"context_line":"   This approach is the default since it requires no change to"},{"line_number":221,"context_line":"   existing OpenStack deployments (other than an updated rootwrap"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_dff25a9a","line":218,"updated":"2015-08-18 12:28:14.000000000","message":"(moving discussion to this patchset)\n\n\u003e Edit: we discussed this over IRC, and our conclusion was to close (and reopen on /dev/null) stdin/stdout and add a helper function to start pdb on a new unix socket or tty. The latter helper wouldn\u0027t be called anywhere automatically and would require developer action if/when pdb was desired.\n\nIf you\u0027re going to shut stdin/out/err anyway and don\u0027t need them for debugging with pdb, why not just pass a connected socket as one of these descriptors?","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"0db7d7d004611a05b22daaf965f7e59332fee1cb","unresolved":false,"context_lines":[{"line_number":215,"context_line":"   filesystem permissions only allow the same uid, or root - and a"},{"line_number":216,"context_line":"   process running as the same uid is already entrusted to start its own"},{"line_number":217,"context_line":"   privileged daemon via ``sudo``/``rootwrap``, so this would grant no"},{"line_number":218,"context_line":"   additional privilege."},{"line_number":219,"context_line":""},{"line_number":220,"context_line":"   This approach is the default since it requires no change to"},{"line_number":221,"context_line":"   existing OpenStack deployments (other than an updated rootwrap"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_6053023a","line":218,"in_reply_to":"fa1b9901_38447048","updated":"2015-08-20 07:52:16.000000000","message":"I can through another argument for using stdin/out for passing one end of socketpair to priv side: it\u0027s uniform with option #1. You get connected socket on both sides by duplicating one of ends with fork().\n\nIt\u0027s up to you, both ways are legit, but I vote for simplicity, hardending and uniformity.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":215,"context_line":"   filesystem permissions only allow the same uid, or root - and a"},{"line_number":216,"context_line":"   process running as the same uid is already entrusted to start its own"},{"line_number":217,"context_line":"   privileged daemon via ``sudo``/``rootwrap``, so this would grant no"},{"line_number":218,"context_line":"   additional privilege."},{"line_number":219,"context_line":""},{"line_number":220,"context_line":"   This approach is the default since it requires no change to"},{"line_number":221,"context_line":"   existing OpenStack deployments (other than an updated rootwrap"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_38447048","line":218,"in_reply_to":"fa1b9901_ccc25d34","updated":"2015-08-20 03:10:03.000000000","message":"Also, we were concerned about leaving stdin as another potential attack point into the privileged context.  We didn\u0027t have any specific concerns, but we also didn\u0027t have any specific need to leave stdin open (other than making pdb easier).\n\nOnce we decided to not use stdio as the communication channel, then I agree the pros/cons of actually closing stdin/out are pretty weak on both sides and I could go either way on this.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":215,"context_line":"   filesystem permissions only allow the same uid, or root - and a"},{"line_number":216,"context_line":"   process running as the same uid is already entrusted to start its own"},{"line_number":217,"context_line":"   privileged daemon via ``sudo``/``rootwrap``, so this would grant no"},{"line_number":218,"context_line":"   additional privilege."},{"line_number":219,"context_line":""},{"line_number":220,"context_line":"   This approach is the default since it requires no change to"},{"line_number":221,"context_line":"   existing OpenStack deployments (other than an updated rootwrap"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_ccc25d34","line":218,"in_reply_to":"fa1b9901_dff25a9a","updated":"2015-08-19 22:22:10.000000000","message":"Because of the limitations of this startup mode described two paragraphs up.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":261,"context_line":""},{"line_number":262,"context_line":"   # In neutron_privileged/__init__.py (once per project)"},{"line_number":263,"context_line":"   from oslo_privsep import capabilities as c"},{"line_number":264,"context_line":"   from oslo_privsep import decorator"},{"line_number":265,"context_line":""},{"line_number":266,"context_line":"   CFG_SECTION \u003d \u0027privsep\u0027  # important with multiple privsep daemons"},{"line_number":267,"context_line":"   DEFAULT_CAPS \u003d [c.CAP_SYS_ADMIN, c.CAP_NET_ADMIN]  # eg"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_477aa678","line":264,"updated":"2015-08-19 22:22:10.000000000","message":"Nit: decorator is awfully generic. Don\u0027t make me get the paddle :). http://thecodelesscode.com/case/34","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":261,"context_line":""},{"line_number":262,"context_line":"   # In neutron_privileged/__init__.py (once per project)"},{"line_number":263,"context_line":"   from oslo_privsep import capabilities as c"},{"line_number":264,"context_line":"   from oslo_privsep import decorator"},{"line_number":265,"context_line":""},{"line_number":266,"context_line":"   CFG_SECTION \u003d \u0027privsep\u0027  # important with multiple privsep daemons"},{"line_number":267,"context_line":"   DEFAULT_CAPS \u003d [c.CAP_SYS_ADMIN, c.CAP_NET_ADMIN]  # eg"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_586844b9","line":264,"in_reply_to":"fa1b9901_477aa678","updated":"2015-08-20 03:10:03.000000000","message":"Agreed!  I started calling this a \"privileged context\" when I started writing the code.  I\u0027ll update the spec to match...","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":281,"context_line":"           return result"},{"line_number":282,"context_line":"       else:"},{"line_number":283,"context_line":"           # privileged_mode"},{"line_number":284,"context_line":"           return _real_example_function(*args, **kwargs)"},{"line_number":285,"context_line":""},{"line_number":286,"context_line":"The unprivileged \"client stub\" function will serialise any arguments,"},{"line_number":287,"context_line":"communicate with the privsep process, and deserialise the return"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_07c7ce96","line":284,"updated":"2015-08-19 22:22:10.000000000","message":"Is it possible to determine \u0027privileged mode\u0027 during import time? If so the decorator could act more as a compiler, and resolve to either returning the original function or returning the proxy. I guess not, given the longer term desire to be able to fork(). Nevermind :)","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":281,"context_line":"           return result"},{"line_number":282,"context_line":"       else:"},{"line_number":283,"context_line":"           # privileged_mode"},{"line_number":284,"context_line":"           return _real_example_function(*args, **kwargs)"},{"line_number":285,"context_line":""},{"line_number":286,"context_line":"The unprivileged \"client stub\" function will serialise any arguments,"},{"line_number":287,"context_line":"communicate with the privsep process, and deserialise the return"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_18d72cee","line":284,"in_reply_to":"fa1b9901_07c7ce96","updated":"2015-08-20 03:10:03.000000000","message":"I learnt from my previous privsep iterations that it\u0027s quite awkward to control irreversible decisions at import time :/","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":286,"context_line":"The unprivileged \"client stub\" function will serialise any arguments,"},{"line_number":287,"context_line":"communicate with the privsep process, and deserialise the return"},{"line_number":288,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":289,"context_line":"accepted in args or return values - no user-defined objects."},{"line_number":290,"context_line":""},{"line_number":291,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":292,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_2772127c","line":289,"updated":"2015-08-19 22:22:10.000000000","message":"Lets be specific about the types, for clarity.\nbytes, str, list, dict, set, frozenset, int, float\n\nWhat about exceptions?","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":286,"context_line":"The unprivileged \"client stub\" function will serialise any arguments,"},{"line_number":287,"context_line":"communicate with the privsep process, and deserialise the return"},{"line_number":288,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":289,"context_line":"accepted in args or return values - no user-defined objects."},{"line_number":290,"context_line":""},{"line_number":291,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":292,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_d306751c","line":289,"in_reply_to":"fa1b9901_2772127c","updated":"2015-08-20 03:10:03.000000000","message":"If we\u0027re going with oslo.serialization, then the specific list is whatever o.s says (and will almost certainly expand slowly over time).  If we\u0027re dumping oslo.serialization then I can certainly list the initial set we expect to support here.\n\nI\u0027ll add a mention of exceptions.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":298,"context_line":"otherwise available as normal so module-level constants, etc are"},{"line_number":299,"context_line":"available as expected.  Note that the unprivileged process is a"},{"line_number":300,"context_line":"separate process, so modifying an imported global will have no effect"},{"line_number":301,"context_line":"on the privileged code."},{"line_number":302,"context_line":""},{"line_number":303,"context_line":"The decorator can be set to \"privileged mode\" even within the"},{"line_number":304,"context_line":"unprivileged process, in which case it will pass calls through to the"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_a7a8628e","line":301,"updated":"2015-08-19 22:22:10.000000000","message":"I wonder if we can make this safer. E.g:\n\nOnly the privsep decorated functions are available from a privsep module. The way this could works is that privsep modules are actually replacement rich objects, and this only exported things are present on the surface. The only exported things would be the entry points - and so globals within the module wouldn\u0027t be accessible from outside (without shenanigans) - avoiding programmer error.\n\nPerhaps a minor concern.\n\nAnother, less intrusive way, would be for the decorator to not actually decorate the function, but to promote the call stub to be visible outside.\n\ne.g.\n\n def privsep(self, fn):\n     name \u003d fn.__name__\n     @wraps(fn)\n     def remote_stub(*args, **kwargs):\n         ....\n     setattr(self.interface, name, remote_stub)\n     @wraps(fn)\n     def local_only(*args, **kwargs):\n           if in_unprivileged_mode:\n               raise Exception(\"Cannot call privileged code when in unprivileged mode\")\n           return fn(*args, **kwargs)\n     return fn\n\nThe more I think about this the more I like it:\n\n- the importable names are only the stubs\n- the stubs are still autocreated\n- both entry points are accessible, should we need to e.g. have privsep daemons with a privsep daemon (which sounds a little odd on the face of it, but when you consider we have potentially very different code around we might want most of it to not have access to some capability- further risk minimisation).\n\nOTOH I may have gone off the deep end. This comment is merely meant to provoke thought, not to request a change.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":298,"context_line":"otherwise available as normal so module-level constants, etc are"},{"line_number":299,"context_line":"available as expected.  Note that the unprivileged process is a"},{"line_number":300,"context_line":"separate process, so modifying an imported global will have no effect"},{"line_number":301,"context_line":"on the privileged code."},{"line_number":302,"context_line":""},{"line_number":303,"context_line":"The decorator can be set to \"privileged mode\" even within the"},{"line_number":304,"context_line":"unprivileged process, in which case it will pass calls through to the"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_53dd856d","line":301,"in_reply_to":"fa1b9901_a7a8628e","updated":"2015-08-20 03:10:03.000000000","message":"I think this is no different to other module-private concerns elsewhere in python.  We can name things with underscores, add documentation, etc - and then if people *still* call the function then they just might have had good reason and be making the right tradeoff (vs cut+pasting the code or something worse)...","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"613de2699ac8530f2a13d21da2eb237a5c3dd2e6","unresolved":false,"context_lines":[{"line_number":307,"context_line":"outside unittests with mocked environments."},{"line_number":308,"context_line":""},{"line_number":309,"context_line":"Importing ``foo.bar.baz`` involves loading (and hence trusting)"},{"line_number":310,"context_line":"``foo/__init.py`` and ``foo/bar/__init__.py``.  Consequently, this"},{"line_number":311,"context_line":"spec recommends projects create a new top-level python package within"},{"line_number":312,"context_line":"their regular git repository to hold modules intended to be used via"},{"line_number":313,"context_line":"privsep (eg: create ``neutron.git/neutron_privileged/...`` as in the"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_df201afa","line":310,"range":{"start_line":310,"start_character":6,"end_line":310,"end_character":15},"updated":"2015-08-18 12:28:14.000000000","message":"missing second __ in __init__","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":307,"context_line":"outside unittests with mocked environments."},{"line_number":308,"context_line":""},{"line_number":309,"context_line":"Importing ``foo.bar.baz`` involves loading (and hence trusting)"},{"line_number":310,"context_line":"``foo/__init.py`` and ``foo/bar/__init__.py``.  Consequently, this"},{"line_number":311,"context_line":"spec recommends projects create a new top-level python package within"},{"line_number":312,"context_line":"their regular git repository to hold modules intended to be used via"},{"line_number":313,"context_line":"privsep (eg: create ``neutron.git/neutron_privileged/...`` as in the"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_13e38d34","line":310,"range":{"start_line":310,"start_character":6,"end_line":310,"end_character":15},"in_reply_to":"fa1b9901_df201afa","updated":"2015-08-20 03:10:03.000000000","message":"Oops, fixed.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":332,"context_line":"will be provided to start pdb on a new Unix socket.  This must not be"},{"line_number":333,"context_line":"able to be invoked in a production deployment for obvious reasons, and"},{"line_number":334,"context_line":"will require the developer to patch in an appropriate call before"},{"line_number":335,"context_line":"using pdb."},{"line_number":336,"context_line":""},{"line_number":337,"context_line":".. _pdb: https://docs.python.org/3/library/pdb.html"},{"line_number":338,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_e7f73a57","line":335,"updated":"2015-08-19 22:22:10.000000000","message":"So, since folk can trivial do:\n\nimport rpdb;rpdb.set_trace() in production, I don\u0027t think the \u0027must not be\u0027 standard is necessary. We don\u0027t want to enable foot-guns, but being harder to use than the existing low bar of alternative get-me-a-pdb-in-a-remote-process adds no value. I suggest just having a helper function with an appropriately clear name, and letting developers // ops choose when to use it.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":332,"context_line":"will be provided to start pdb on a new Unix socket.  This must not be"},{"line_number":333,"context_line":"able to be invoked in a production deployment for obvious reasons, and"},{"line_number":334,"context_line":"will require the developer to patch in an appropriate call before"},{"line_number":335,"context_line":"using pdb."},{"line_number":336,"context_line":""},{"line_number":337,"context_line":".. _pdb: https://docs.python.org/3/library/pdb.html"},{"line_number":338,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_f36a9980","line":335,"in_reply_to":"fa1b9901_e7f73a57","updated":"2015-08-20 03:10:03.000000000","message":"Yep, weakened to \"clearly not a good idea, but ..\"","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"613de2699ac8530f2a13d21da2eb237a5c3dd2e6","unresolved":false,"context_lines":[{"line_number":368,"context_line":"channel only."},{"line_number":369,"context_line":""},{"line_number":370,"context_line":"This spec has no solution to offer, and developers using profiling"},{"line_number":371,"context_line":"tools will need to be aware of this limitation."},{"line_number":372,"context_line":""},{"line_number":373,"context_line":""},{"line_number":374,"context_line":"Operator\u0027s Point of View"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_5f12ca63","line":371,"updated":"2015-08-18 12:28:14.000000000","message":"One can store profiles in different files and then load them simultaneously to one Stats object with https://docs.python.org/3/library/profile.html#pstats.Stats.add","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"4f46f286316a72395f4474f0518ff39e09555c9d","unresolved":false,"context_lines":[{"line_number":368,"context_line":"channel only."},{"line_number":369,"context_line":""},{"line_number":370,"context_line":"This spec has no solution to offer, and developers using profiling"},{"line_number":371,"context_line":"tools will need to be aware of this limitation."},{"line_number":372,"context_line":""},{"line_number":373,"context_line":""},{"line_number":374,"context_line":"Operator\u0027s Point of View"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_8c06a584","line":371,"in_reply_to":"fa1b9901_5f12ca63","updated":"2015-08-19 22:22:10.000000000","message":"I think its reasonable to say \u0027because each process can be profiled, it is possible to build a unified profiler in future, but it is out of scope for this iteration\u0027.","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"86fa8ade1f20fde979e3894cca25a5f1aa25e720","unresolved":false,"context_lines":[{"line_number":368,"context_line":"channel only."},{"line_number":369,"context_line":""},{"line_number":370,"context_line":"This spec has no solution to offer, and developers using profiling"},{"line_number":371,"context_line":"tools will need to be aware of this limitation."},{"line_number":372,"context_line":""},{"line_number":373,"context_line":""},{"line_number":374,"context_line":"Operator\u0027s Point of View"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa1b9901_33ea51dc","line":371,"in_reply_to":"fa1b9901_8c06a584","updated":"2015-08-20 03:10:03.000000000","message":"Done","commit_id":"b1d8baabeae2055d25cba9d98411f8e399086bf1"},{"author":{"_account_id":13997,"name":"SHIGEMATSU Mitsuhiro","email":"shigematsu.mitsuhiro@lab.ntt.co.jp","username":"pshige"},"change_message_id":"b1ce922ab41ea597afb32e7bab50dcf18e2c0b44","unresolved":false,"context_lines":[{"line_number":3,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":4,"context_line":""},{"line_number":5,"context_line":"It is difficult to sufficiently describe security policy at the"},{"line_number":6,"context_line":"granualarity of command lines.  Consequently numerous rootwrap entries"},{"line_number":7,"context_line":"effectively grant full root access to anyone permitted to run"},{"line_number":8,"context_line":"rootwrap."},{"line_number":9,"context_line":""}],"source_content_type":"text/x-rst","patch_set":7,"id":"da20952f_7acc116a","line":6,"updated":"2015-08-30 13:42:57.000000000","message":"s/granualarity/granularity/","commit_id":"a92294fb0a95eb07c8aea0840f08d85fa64e1d95"},{"author":{"_account_id":13997,"name":"SHIGEMATSU Mitsuhiro","email":"shigematsu.mitsuhiro@lab.ntt.co.jp","username":"pshige"},"change_message_id":"b1ce922ab41ea597afb32e7bab50dcf18e2c0b44","unresolved":false,"context_lines":[{"line_number":44,"context_line":"effectively reset to \"full privileges\" mid-way through the call stack."},{"line_number":45,"context_line":""},{"line_number":46,"context_line":"Generating command lines and parsing textual output from tools is slow"},{"line_number":47,"context_line":"and susceptable to inconsistencies across tool versions, since"},{"line_number":48,"context_line":"typically this output was not designed as a programmatic API.  In"},{"line_number":49,"context_line":"Neutron in particular, the command lines are often repeated"},{"line_number":50,"context_line":"invocations of trivial ip(8) commands and the overhead is significant"}],"source_content_type":"text/x-rst","patch_set":7,"id":"da20952f_da5c3d7f","line":47,"updated":"2015-08-30 13:42:57.000000000","message":"s/susceptable/susceptible/","commit_id":"a92294fb0a95eb07c8aea0840f08d85fa64e1d95"},{"author":{"_account_id":13997,"name":"SHIGEMATSU Mitsuhiro","email":"shigematsu.mitsuhiro@lab.ntt.co.jp","username":"pshige"},"change_message_id":"b1ce922ab41ea597afb32e7bab50dcf18e2c0b44","unresolved":false,"context_lines":[{"line_number":113,"context_line":"process *share fate* with the main (unprivileged) process."},{"line_number":114,"context_line":"Specifically: the privileged process should exit when the unprivileged"},{"line_number":115,"context_line":"process has exited, and once started no attempt should be made to"},{"line_number":116,"context_line":"restart the privleged process if it exits.  If the privileged process"},{"line_number":117,"context_line":"exits for some reason, it is due to a bug and may be currently under"},{"line_number":118,"context_line":"attack - restarting the process gives the attacker another"},{"line_number":119,"context_line":"opportunity.  If the privileged process exits, the unprivileged"}],"source_content_type":"text/x-rst","patch_set":7,"id":"da20952f_3a4c59c7","line":116,"updated":"2015-08-30 13:42:57.000000000","message":"s/privleged/privileged/","commit_id":"a92294fb0a95eb07c8aea0840f08d85fa64e1d95"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"61b0356316d8fdb4b4bd0a354ab4bbad22793221","unresolved":false,"context_lines":[{"line_number":277,"context_line":"   def example_function(*args, **kwargs):"},{"line_number":278,"context_line":"       if in_unprivileged_mode:"},{"line_number":279,"context_line":"           privsep_channel.send((CALL, \u0027example_function\u0027, args, kwargs))"},{"line_number":280,"context_line":"\t   result \u003d privsep_channel.read()"},{"line_number":281,"context_line":"\t   if result.raised_exception():"},{"line_number":282,"context_line":"\t       raise result.exc_class(result.exc_args)"},{"line_number":283,"context_line":"           return result.value"},{"line_number":284,"context_line":"       else:"},{"line_number":285,"context_line":"           # privileged_mode"}],"source_content_type":"text/x-rst","patch_set":7,"id":"fa1b9901_40c27e35","line":282,"range":{"start_line":280,"start_character":0,"end_line":282,"end_character":47},"updated":"2015-08-20 07:52:08.000000000","message":"Are those \u003ctab\u003es in the beginning of these lines? Please avoid them.","commit_id":"a92294fb0a95eb07c8aea0840f08d85fa64e1d95"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"ed97b3b3b50c677e8a767889755d9cdbc0a9a876","unresolved":false,"context_lines":[{"line_number":277,"context_line":"   def example_function(*args, **kwargs):"},{"line_number":278,"context_line":"       if in_unprivileged_mode:"},{"line_number":279,"context_line":"           privsep_channel.send((CALL, \u0027example_function\u0027, args, kwargs))"},{"line_number":280,"context_line":"\t   result \u003d privsep_channel.read()"},{"line_number":281,"context_line":"\t   if result.raised_exception():"},{"line_number":282,"context_line":"\t       raise result.exc_class(result.exc_args)"},{"line_number":283,"context_line":"           return result.value"},{"line_number":284,"context_line":"       else:"},{"line_number":285,"context_line":"           # privileged_mode"}],"source_content_type":"text/x-rst","patch_set":7,"id":"fa1b9901_7bb17746","line":282,"range":{"start_line":280,"start_character":0,"end_line":282,"end_character":47},"in_reply_to":"fa1b9901_40c27e35","updated":"2015-08-20 07:57:50.000000000","message":"oops, silly editor - fixed locally and will be in the next revision (assuming there is one).","commit_id":"a92294fb0a95eb07c8aea0840f08d85fa64e1d95"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"2f24da332def5c964398ee7f0b6ab91d8308288c","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"da20952f_c0f6478e","line":293,"updated":"2015-09-01 08:07:25.000000000","message":"Is it worth mentioning that the args has to be basic types too?\n\nAlso - I still think its worth writing the list of supported types. I\u0027d actually like it to be a fixed, explicit list - since oslo.serialization can serialize *anything*, and thats a nightmare to me.","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"650185cd697df1d2cfc25b01d5b344c66c3d0b15","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"ba15a1d1_f65592c1","line":293,"in_reply_to":"ba15a1d1_ce7907ca","updated":"2015-09-17 08:44:03.000000000","message":"You can \"lie\" about traceback on py3 too, but what\u0027s the profit? I mean, how priv-side traceback would be useful in any form other that text data? I think we shouldn\u0027t get smart here, just dump traceback to a string and log it on client side.","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":4190,"name":"lifeless","email":"robertc@robertcollins.net","username":"lifeless"},"change_message_id":"b5e0f9cb9df5d1b42ddf2c933526dc03d642050a","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"da20952f_b8f0f992","line":293,"in_reply_to":"da20952f_6aeb5fb1","updated":"2015-09-08 21:42:11.000000000","message":"we can use a traceback2 ExceptionSummary if you want - thats easily reducable to basic types and reconstituted, to preserve the tb","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"2fdb36d5dea7c374a131298c1e11059a5d51c370","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"ba15a1d1_ce7907ca","line":293,"in_reply_to":"da20952f_b8f0f992","updated":"2015-09-17 00:51:42.000000000","message":"I\u0027ve removed oslo.serialization and explicitly listed the supported types.\n\nAnd oh look, I *can* lie about the traceback on py2 (3rd arg to raise).  Huh, perhaps I can make the traceback meaningful on the unprivileged side - this will be fun :)","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"0313fcc8aba14d4f2c21abbe6137b14f6db1b6fb","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"da20952f_ed480d8d","line":293,"in_reply_to":"da20952f_c0f6478e","updated":"2015-09-01 15:09:57.000000000","message":"If u go about using msgpack in oslo.serialization the capabilities are pretty small in what can be serialized, its only the basic types + these basic additions @ https://github.com/openstack/oslo.serialization/blob/master/oslo_serialization/msgpackutils.py#L284 so this could be your desired list?\n\nFor exceptions that are triggered in the privileged code that\u0027s IMHO a more interesting question of how to transmit that back, because it is highly likely the unprivileged code will not be able to access the privileged code\u0027s exception types to be able to reconstruct a new exception (and exception backtraces can\u0027t be serialized anyway to...)\n\nIn taskflow we have:\n\nhttp://docs.openstack.org/developer/taskflow/types.html#module-taskflow.types.failure which could help in this situtation if needed (said code could be shared somehow)","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"79205691a6b4f8a092b215b1ea682876bcddcefc","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"da20952f_ea452fb3","line":293,"in_reply_to":"da20952f_c0f6478e","updated":"2015-09-02 05:20:12.000000000","message":"Re oslo.serialization: Yes, I hadn\u0027t fully realised that the json-version supports serializing *anything* until quite recently - and that\u0027s definitely not what I intended here.\n\noslo.serialization is dead to me - I\u0027ll drop it from this spec, and list the expected types explicitly (basic json + bytes (+ exc in the reverse direction)).","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":11279,"name":"Angus Lees","email":"gus@inodes.org","username":"gus"},"change_message_id":"79205691a6b4f8a092b215b1ea682876bcddcefc","unresolved":false,"context_lines":[{"line_number":290,"context_line":"value.  Note (by choice) only basic \"json-ish\" python types are"},{"line_number":291,"context_line":"accepted in args or return values - no user-defined objects.  If the"},{"line_number":292,"context_line":"privileged code raises an exception, it will be caught and re-raised"},{"line_number":293,"context_line":"on the unprivileged side (using the ``.args`` property)."},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"As described earlier, the privileged daemon will be started when the"},{"line_number":296,"context_line":"first stub is called unless the daemon has already been started.  Once"}],"source_content_type":"text/x-rst","patch_set":8,"id":"da20952f_6aeb5fb1","line":293,"in_reply_to":"da20952f_ed480d8d","updated":"2015-09-02 05:20:12.000000000","message":"Re exceptions: Yes, this is a legitimate concern.  I\u0027m intending to pass (exc_class_name, args) across the serialisation boundary, then walk the module/object tree to find the class object, and instantiate that simply with exc_class_object(args).  I see from your Failure docs that you\u0027re well aware of this, and the limitations ;)\n\nYes, the exception stacktrace gets lost (or rather, logged separately).\nRe security: Originally I only supported builtin exception classes (ie: exceptions.*), but I figured communicating errors back via user-defined exceptions is a) going to be a very commonly desired feature and b) not particularly security sensitive in the privileged-\u003eunprivileged direction.","commit_id":"082095c7d2d22000bcd3bf1f9fba9e89b9243cc4"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"60db12dde756d8fa4b4eeb6ba7d1c1c1f9f94077","unresolved":false,"context_lines":[{"line_number":159,"context_line":"executed during deserialisation.  For its simplicity, this spec"},{"line_number":160,"context_line":"proposes using ``json`` and limiting function argument/return values"},{"line_number":161,"context_line":"to the basic JSON datatypes (32-bit integer, 32-bit floats, unicode"},{"line_number":162,"context_line":"string, boolean, array, dictionary), with the addition of a bytestring"},{"line_number":163,"context_line":"type.  In the return direction (privileged to unprivileged), there"},{"line_number":164,"context_line":"will also be support for catching and re-raising most exception"},{"line_number":165,"context_line":"objects (assumes the class can be found on the unprivileged side and"}],"source_content_type":"text/x-rst","patch_set":9,"id":"ba15a1d1_0044ee18","line":162,"updated":"2015-09-21 20:02:42.000000000","message":"Intersting, didn\u0027t think json had a bytestring type.","commit_id":"8d5fb4e529bd7f90d26c163dc35444e5f28f0c13"},{"author":{"_account_id":708,"name":"Yuriy Taraday","email":"yuriy@taraday.nl","username":"yorik-sar"},"change_message_id":"8fa90bb9cc22b7e07ddb40771f814ef01113db51","unresolved":false,"context_lines":[{"line_number":159,"context_line":"executed during deserialisation.  For its simplicity, this spec"},{"line_number":160,"context_line":"proposes using ``json`` and limiting function argument/return values"},{"line_number":161,"context_line":"to the basic JSON datatypes (32-bit integer, 32-bit floats, unicode"},{"line_number":162,"context_line":"string, boolean, array, dictionary), with the addition of a bytestring"},{"line_number":163,"context_line":"type.  In the return direction (privileged to unprivileged), there"},{"line_number":164,"context_line":"will also be support for catching and re-raising most exception"},{"line_number":165,"context_line":"objects (assumes the class can be found on the unprivileged side and"}],"source_content_type":"text/x-rst","patch_set":9,"id":"ba15a1d1_cc7704d3","line":162,"in_reply_to":"ba15a1d1_0044ee18","updated":"2015-09-22 06:20:39.000000000","message":"It does not, but it can be implemented like in rootwrap-daemon, for example.","commit_id":"8d5fb4e529bd7f90d26c163dc35444e5f28f0c13"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"aa2feb375924f62edf4afc3cc3bb5f8cf035f415","unresolved":false,"context_lines":[{"line_number":416,"context_line":""},{"line_number":417,"context_line":"* \"We need to run a few commands as root\" -\u003e start using sudo"},{"line_number":418,"context_line":"* \"too many commands and sudoers is becoming unwieldy\" -\u003e introduce rootwrap"},{"line_number":419,"context_line":"* \"rootwrap is expensive to reinvoke every time\" -\u003e rootwrap-daemon"},{"line_number":420,"context_line":""},{"line_number":421,"context_line":"Run the entire python process with required privileges"},{"line_number":422,"context_line":"------------------------------------------------------"}],"source_content_type":"text/x-rst","patch_set":9,"id":"ba15a1d1_547cb671","line":419,"updated":"2015-09-22 18:23:01.000000000","message":"I was just thinking that this spec is a great natural progression beyond rootwrap daemon.  I was involved with rootwrap daemon around the time it kicked off and was agreed on in Atlanta.  I recall expressing my hope that it would evolve in to a better model but at the time we had a serious performance problem to solve [1].  It is really cool to see progress on this.  I look forward to Neutron taking advantage of this model.\n\n [1] http://eavesdrop.openstack.org/meetings/neutron_l3/2014/neutron_l3.2014-03-13-15.00.log.html#l-101","commit_id":"8d5fb4e529bd7f90d26c163dc35444e5f28f0c13"}]}
