[libvirt] [PATCH 4/8] Define internal APIs for managing identities

Eric Blake eblake at redhat.com
Mon Mar 11 19:06:15 UTC 2013


On 03/06/2013 05:49 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Introduce a local object virIdentity for managing security
> attributes used to form a client application's identity.
> Instances of this object are intended to be used as if they
> were immutable, once created & populated with attributes
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---

> +/**
> + * virIdentitySetAttr:
> + * @ident: the identity to modify
> + * @attr: the attribute type to set
> + * @value: the identifying value to associate with @attr
> + *
> + * Sets an identifying attribute @attr on @ident. Each
> + * @attr type can only be set once.
> + *
> + * Returns: 0 on success, or -1 on error
> + */
> +int virIdentitySetAttr(virIdentityPtr ident,
> +                       unsigned int attr,
> +                       const char *value)
> +{
> +    int ret = -1;
> +    VIR_DEBUG("ident=%p attribute=%u value=%s", ident, attr, NULLSTR(value));

This says value can be NULL...

> +
> +    if (ident->attrs[attr]) {
> +        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
> +                        _("Identity attribute is already set"));
> +        goto cleanup;
> +    }
> +
> +    if (!(ident->attrs[attr] = strdup(value))) {

...but this would crash.  Isn't it easier to just require that value be
non-NULL if you are going to call this function?

> +
> +    if (!virIdentityIsEqual(identa, identb)) {
> +        VIR_DEBUG("Empty identities were no equal");

s/no/not/


> +
> +    if (virIdentityIsEqual(identa, identb)) {
> +        VIR_DEBUG("Mis-atched identities should not be equal");

s/Mis-atched/Mismatched/

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130311/d41210d6/attachment-0001.sig>


More information about the libvir-list mailing list