chiark / gitweb /
priv: Remove references to transferring `tunnel_ops *' pointers.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 19 May 2010 23:46:53 +0000 (00:46 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 19 May 2010 23:46:53 +0000 (00:46 +0100)
None of that happens since the helper became a separate executable;
instead, tunnel driver names are passed.  I've taken the opportunity to
fix other fossils in the privilege-separation commentary.

No substantive changes.

priv/comm.c
priv/priv.h

index ad2e518c64474888fb335abfaf1d96a7f58c58d2..316f6c8ed384e1eb6f73bf7aba4a00e31eda1d6f 100644 (file)
@@ -65,16 +65,15 @@ int pc_put(const void *p, size_t sz)
   return (0);
 }
 
-/* --- @pc_puterr@, @pc_putuint@, @pc_putsz@, @pc_puttops@ --- *
+/* --- @pc_puterr@, @pc_putuint@, @pc_putsz@ --- *
  *
  * Arguments:  @int err@ = error number to write
  *             @uint u@ = unsigned integer to write
  *             @size_t sz@ = size to write
- *             @const tunnel_ops *tops@ = tunnel pointer to write
  *
  * Returns:    Zero on success, @-1@ on error (and @errno@ set).
  *
- * Use:                Sends an error/integer/size/tunnel-ops pointer.
+ * Use:                Sends an error/integer/size.
  */
 
 #define PUT(abbr, type)                                                \
@@ -87,7 +86,7 @@ COMM_TYPES(PUT)
  *
  * Returns:    Zero on success, @-1@ on error (and @errno@ set).
  *
- * Use:                Sends a string/error/integer/tunnel-ops pointer.
+ * Use:                Sends a string.
  */
 
 int pc_putstring(const char *s)
@@ -132,23 +131,22 @@ int pc_get(void *p, size_t sz)
   return (0);
 }
 
-/* --- @pc_geterr@, @pc_getuint@, @pc_getsz@, @pc_getops@ --- *
+/* --- @pc_geterr@, @pc_getuint@, @pc_getsz@ --- *
  *
  * Arguments:  @int *err@ = where to put the error number
  *             @uint *u@ = where to put the unsigned integer
  *             @size_t *sz@ = where to put the size
- *             @const tunnel_ops **tops@ = where to put the tunnel pointer
  *
  * Returns:    Zero on success, @-1@ on error (and @errno@ set).
  *
- * Use:                Receives an error/integer/size/tunnel-ops pointer.
+ * Use:                Receives an error/integer/size.
  */
 
 #define GET(abbr, type)                                                        \
   int pc_get##abbr(type *x) { return (pc_get(x, sizeof(*x))); }
 COMM_TYPES(GET)
 
-/* --- @pc_gettring@ --- *
+/* --- @pc_getstring@ --- *
  *
  * Arguments:  @dstr *d@ = where to pc_put the string
  *
index 225075a6b9c7dca561a155198f216b3aff7d7b0c..0223cd0fb8c26e1049cf9170959a24c7fdf9a064 100644 (file)
  *
  * The protocol works like this.  Messages begin with a request code which is
  * a single @unsigned int@.  The server sends a request @PS_TUNRQ@ to the
- * helper, followed by a @const tunnel_ops *@ referring to the tunnel driver
- * of interest.  The server responds with a sequence of @PS_TRACE@ and/or
- * @PS_WARN@ messages, followed by either a @PS_TUNFD@ carrying a file
- * descriptor, or a @PS_TUNERR@ followed by an integer @errno@ code.
+ * helper, followed by a strin naming the tunnel driver of interest.  The
+ * server responds with a sequence of @PS_TRACE@ and/or @PS_WARN@ messages,
+ * followed by either a @PS_TUNFD@ carrying a file descriptor, or a
+ * @PS_TUNERR@ followed by an integer @errno@ code.
+ *
+ * Simple data items are sent as native representations.  A string is sent as
+ * a @size_t@ giving the string's length in bytes followed by that many
+ * characters.  There is no padding for alignment.
  *
  * If all else fails, the helper process will just quit.
  */
 
 enum {
-  PS_TUNRQ,                            /* Request (@tunnel_ops *@) */
-  PS_TUNFD,                            /* Tunnel descriptor (string) */
+  PS_TUNRQ,                            /* Request (string) */
+  PS_TUNFD,                            /* Tunnel descriptor (nothing) */
   PS_TUNERR,                           /* Error (@int errno@) */
 #ifndef NTRACE
   PS_TRACE,                            /* Trace (@unsigned mask@, string) */
@@ -101,7 +105,7 @@ extern int pc_fd;                   /* File descriptor for comms */
   _(uint, unsigned int)                                                        \
   _(sz, size_t)
 
-/* --- @put@ --- *
+/* --- @pc_put@ --- *
  *
  * Arguments:  @const void *p@ = pointer to buffer
  *             @size_t sz@ = size of the buffer
@@ -113,34 +117,33 @@ extern int pc_fd;                 /* File descriptor for comms */
 
 extern int pc_put(const void */*p*/, size_t /*sz*/);
 
-/* --- @puterr@, @putuint@, @putsz@, @puttops@ --- *
+/* --- @pc_puterr@, @pc_putuint@, @pc_putsz@ --- *
  *
  * Arguments:  @int err@ = error number to write
  *             @uint u@ = unsigned integer to write
  *             @size_t sz@ = size to write
- *             @const tunnel_ops *tops@ = tunnel pointer to write
  *
  * Returns:    Zero on success, @-1@ on error (and @errno@ set).
  *
- * Use:                Sends an error/integer/size/tunnel-ops pointer.
+ * Use:                Sends an error/integer/size.
  */
 
 #define DECL(abbr, type) extern int pc_put##abbr(type /*x*/);
 COMM_TYPES(DECL)
 #undef DECL
 
-/* --- @putstring@ --- *
+/* --- @pc_putstring@ --- *
  *
  * Arguments:  @const char *s@ = pointer to string to write
  *
  * Returns:    Zero on success, @-1@ on error (and @errno@ set).
  *
- * Use:                Sends a string/error/integer/tunnel-ops pointer.
+ * Use:                Sends a string.
  */
 
 extern int pc_putstring(const char */*s*/);
 
-/* --- @get@ --- *
+/* --- @pc_get@ --- *
  *
  * Arguments:  @void *p@ = pointer to buffer
  *             @size_t sz@ = size of the buffer
@@ -152,23 +155,22 @@ extern int pc_putstring(const char */*s*/);
 
 extern int pc_get(void */*p*/, size_t /*sz*/);
 
-/* --- @geterr@, @getuint@, @getsz@, @getops@ --- *
+/* --- @pc_geterr@, @pc_getuint@, @pc_getsz@ --- *
  *
  * Arguments:  @int *err@ = where to put the error number
  *             @uint *u@ = where to put the unsigned integer
  *             @size_t *sz@ = where to put the size
- *             @const tunnel_ops **tops@ = where to put the tunnel pointer
  *
  * Returns:    Zero on success, @-1@ on error (and @errno@ set).
  *
- * Use:                Receives an error/integer/size/tunnel-ops pointer.
+ * Use:                Receives an error/integer/size.
  */
 
 #define DECL(abbr, type) extern int pc_get##abbr(type */*x*/);
 COMM_TYPES(DECL)
 #undef DECL
 
-/* --- @gettring@ --- *
+/* --- @pc_getstring@ --- *
  *
  * Arguments:  @dstr *d@ = where to put the string
  *