diff options
| author | Ralf Habacker <ralf.habacker@freenet.de> | 2007-03-13 16:56:32 +0000 | 
|---|---|---|
| committer | Ralf Habacker <ralf.habacker@freenet.de> | 2007-03-13 16:56:32 +0000 | 
| commit | 288d47c7833c58cef3747b15f2ece36d8612964b (patch) | |
| tree | f12e817c888d5ae30a5755c174ac5a909648d923 | |
| parent | 9362aac398e3f2ec680e30c61ebfcb1e407eff72 (diff) | |
* dbus/dbus-sysdeps-win.c: added zero byte sending and receiving after connection start up
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | dbus/dbus-sysdeps-win.c | 88 | 
2 files changed, 70 insertions, 23 deletions
| @@ -1,3 +1,8 @@ +2007-03-13  Ralf.Habacker  <ralf.habacker@freenet.de> + +	* dbus/dbus-sysdeps-win.c: added zero byte sending  +	and receiving after connection start up +  2007-03-11  Havoc Pennington  <hp@redhat.com>  	* tools/dbus-launch.c (do_close_stderr): fix C89 problem and diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 734d4ab5..2ffb3e2d 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3657,30 +3657,61 @@ retry:  dbus_bool_t -write_credentials_byte (int             server_fd, +write_credentials_byte (int            handle,                          DBusError      *error)  { -  /* FIXME: for the session bus credentials shouldn't matter (?), but -   * for the system bus they are presumably essential. A rough outline -   * of a way to implement the credential transfer would be this: -   * -   * client waits to *read* a byte. -   * -   * server creates a named pipe with a random name, sends a byte -   * contining its length, and its name. -   * -   * client reads the name, connects to it (using Win32 API). -   * -   * server waits for connection to the named pipe, then calls -   * ImpersonateNamedPipeClient(), notes its now-current credentials, -   * calls RevertToSelf(), closes its handles to the named pipe, and -   * is done. (Maybe there is some other way to get the SID of a named -   * pipe client without having to use impersonation?) -   * -   * client closes its handles and is done. -   * -   */ +/* FIXME: for the session bus credentials shouldn't matter (?), but + * for the system bus they are presumably essential. A rough outline + * of a way to implement the credential transfer would be this: + * + * client waits to *read* a byte. + * + * server creates a named pipe with a random name, sends a byte + * contining its length, and its name. + * + * client reads the name, connects to it (using Win32 API). + * + * server waits for connection to the named pipe, then calls + * ImpersonateNamedPipeClient(), notes its now-current credentials, + * calls RevertToSelf(), closes its handles to the named pipe, and + * is done. (Maybe there is some other way to get the SID of a named + * pipe client without having to use impersonation?) + * + * client closes its handles and is done. + *  + * Ralf: Why not sending credentials over the given this connection ? + * Using named pipes makes it impossible to be connected from a unix client.   + * + */ +  int bytes_written; +  DBusString buf;  + +  _dbus_string_init_const_len (&buf, "\0", 1); +again: +  bytes_written = _dbus_write_socket (handle, &buf, 0, 1 ); + +  if (bytes_written < 0 && errno == EINTR) +    goto again; +  if (bytes_written < 0) +    { +      dbus_set_error (error, _dbus_error_from_errno (errno), +                      "Failed to write credentials byte: %s", +                     _dbus_strerror (errno)); +      return FALSE; +    } +  else if (bytes_written == 0) +    { +      dbus_set_error (error, DBUS_ERROR_IO_ERROR, +                      "wrote zero bytes writing credentials byte"); +      return FALSE; +    } +  else +    { +      _dbus_assert (bytes_written == 1); +      _dbus_verbose ("wrote 1 zero byte, credential sending isn't implemented yet\n"); +      return TRUE; +    }    return TRUE;  } @@ -3703,12 +3734,23 @@ write_credentials_byte (int             server_fd,   * @returns #TRUE on success   */  dbus_bool_t -_dbus_read_credentials_unix_socket  (int              client_fd, +_dbus_read_credentials_unix_socket  (int              handle,                                       DBusCredentials *credentials,                                       DBusError       *error)  { -  /* FIXME bogus testing credentials */ +  int bytes_read; +  DBusString buf; +  _dbus_string_init(&buf); + +  bytes_read = _dbus_read_socket(handle, &buf, 1 ); +  if (bytes_read > 0)  +    { +		_dbus_verbose("got one zero byte from server"); +    } + +  _dbus_string_free(&buf);    _dbus_credentials_from_current_process (credentials); +  _dbus_verbose("FIXME: get faked credentials from current process");    return TRUE;  } | 
