Hi David and friends,

I'm working on adding netgroup support to Policy Kit. I'm mostly just
copying and editing PolicyKitUnixGroup, creating PolicyKitNetGroup.
That was pretty straightforward, but now I'm diving into the identity
serialization code:
polkit_identity{to_string,from_string,to_gvariant,new_for_gvariant}.

I saw the comment "TODO: we could do something with VFuncs like in
g_icon_from_string()" and thought I might want to give that a shot.
I'm assuming the idea is to have a lookup table of type names to types
that derive PolkitIdentity.

The pseudo-code would be something like:

names_to_types = {
 unix-user : PolkitUnixUser
 unix-group : PolkitUnixGroup
 netgroup : PolkitNetGroup
 extensiongroup : MyExtensionGroup
}

polkit_identity_from_string(value):
 typename, identitydata = value.split(":", 1)
 typeclass = names_to_types[typename]
 return typeclass.from_string(identitydata)

polkit_identity_to_string(identity):
 typename = identity.get_typename()
 return "%s:%s" % (typename, identity.to_string())


The same logic would work for to/from_gvariant, except instead of a
colon joined string, it would be a (typename, identity_gvariant)
tuple.

The only thing I'm worried about is changing the format of the
gvariant objects. If the to/from_gvariant methods are all defined in
the child classes, it doesn't make sense to always store the child's
attributes as key/value pairs like it is now. I can make the child
implementation compatible with the current gvariant format, but I'd
love to be able to say the children can do whatever they want. The
problem is I don't want to break dbus clients who expect a certain
format but don't link to libpolkit.

For example, in polkit_identity_new_for_gvariant, the g_variant_get
call would use (sv) instead of (sa{sv}). PolkitUnixUser could then
return just a uid instead of the "uid":uid-value pair.

Also, I'm thinking I'll just hard code the name->type table for now,
but later I could add a class method for registering new types to the
base class PolkitIdentity. I'll probably have to add another method to
the PolkitIdentity interface for getting a list of potential users in
auth_agent_handle_begin_authentication. I've got to think some more on
that.

Thoughts? Ideas? Feel free to jabber me.

Thanks!
Nikki

--
Nikki VonHollen
vonhol...@google.com
_______________________________________________
polkit-devel mailing list
polkit-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/polkit-devel

Reply via email to