[]Struct gio::DBusAuthObserver

pub struct DBusAuthObserver(_, _);

The DBusAuthObserver type provides a mechanism for participating in how a DBusServer (or a DBusConnection) authenticates remote peers. Simply instantiate a DBusAuthObserver and connect to the signals you are interested in. Note that new signals may be added in the future

Controlling Authentication Mechanisms

By default, a DBusServer or server-side DBusConnection will allow any authentication mechanism to be used. If you only want to allow D-Bus connections with the EXTERNAL mechanism, which makes use of credentials passing and is the recommended mechanism for modern Unix platforms such as Linux and the BSD family, you would use a signal handler like this:

static gboolean
on_allow_mechanism (GDBusAuthObserver *observer,
                    const gchar       *mechanism,
                    gpointer           user_data)
{
  if (g_strcmp0 (mechanism, "EXTERNAL") == 0)
    {
      return TRUE;
    }

  return FALSE;
}

Controlling Authorization # {auth-observer}

By default, a DBusServer or server-side DBusConnection will accept connections from any successfully authenticated user (but not from anonymous connections using the ANONYMOUS mechanism). If you only want to allow D-Bus connections from processes owned by the same uid as the server, you would use a signal handler like the following:

static gboolean
on_authorize_authenticated_peer (GDBusAuthObserver *observer,
                                 GIOStream         *stream,
                                 GCredentials      *credentials,
                                 gpointer           user_data)
{
  gboolean authorized;

  authorized = FALSE;
  if (credentials != NULL)
    {
      GCredentials *own_credentials;
      own_credentials = g_credentials_new ();
      if (g_credentials_is_same_user (credentials, own_credentials, NULL))
        authorized = TRUE;
      g_object_unref (own_credentials);
    }

  return authorized;
}

Implements

glib::object::ObjectExt

Implementations

impl DBusAuthObserver[src]

pub fn new() -> DBusAuthObserver[src]

Creates a new DBusAuthObserver object.

Returns

A DBusAuthObserver. Free with gobject::ObjectExt::unref.

pub fn allow_mechanism(&self, mechanism: &str) -> bool[src]

Emits the DBusAuthObserver::allow-mechanism signal on self.

mechanism

The name of the mechanism, e.g. DBUS_COOKIE_SHA1.

Returns

true if mechanism can be used to authenticate the other peer, false if not.

pub fn authorize_authenticated_peer<P: IsA<IOStream>>(
    &self,
    stream: &P,
    credentials: Option<&Credentials>
) -> bool
[src]

Emits the DBusAuthObserver::authorize-authenticated-peer signal on self.

stream

A IOStream for the DBusConnection.

credentials

Credentials received from the peer or None.

Returns

true if the peer is authorized, false if not.

pub fn connect_allow_mechanism<F: Fn(&DBusAuthObserver, &str) -> bool + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Emitted to check if mechanism is allowed to be used.

mechanism

The name of the mechanism, e.g. DBUS_COOKIE_SHA1.

Returns

true if mechanism can be used to authenticate the other peer, false if not.

pub fn connect_authorize_authenticated_peer<F: Fn(&DBusAuthObserver, &IOStream, Option<&Credentials>) -> bool + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Emitted to check if a peer that is successfully authenticated is authorized.

stream

A IOStream for the DBusConnection.

credentials

Credentials received from the peer or None.

Returns

true if the peer is authorized, false if not.

Trait Implementations

impl Clone for DBusAuthObserver

impl Debug for DBusAuthObserver

impl Default for DBusAuthObserver[src]

impl Display for DBusAuthObserver[src]

impl Eq for DBusAuthObserver

impl Hash for DBusAuthObserver

impl Ord for DBusAuthObserver

impl<T: ObjectType> PartialEq<T> for DBusAuthObserver

impl<T: ObjectType> PartialOrd<T> for DBusAuthObserver

impl StaticType for DBusAuthObserver

Auto Trait Implementations

impl RefUnwindSafe for DBusAuthObserver

impl !Send for DBusAuthObserver

impl !Sync for DBusAuthObserver

impl Unpin for DBusAuthObserver

impl UnwindSafe for DBusAuthObserver

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.