On 20 October 2014 15:11, Lennart Poettering <lenn...@poettering.net> wrote:
> On Wed, 15.10.14 01:58, Michal Sekletar (msekl...@kemper.freedesktop.org) > wrote: > > - mycon = context_str(bcon); > > + mycon = strdup(context_str(bcon)); > > This looks wrong! > > I meanm what is mycon? a string or a security_context_t? If it's the > latter (which it appears to be according to its type), then it should > not be assigned a string as returned by strdup(). (i figure internally > they might be the same, but if they do the dance with two distinct > types we should follow this non-sense here too...) > >From man page: const char * context_str(context_t con ); context_str Return a pointer to the string value of the context_t Valid until the next call to context_str or context_free for the same context_t* This diff seems to simply be copying the string, so that it does not become > invalid. > Shouldn't this be context_new() rather than strdup()? > > libselinux definitely has one of the most horrible APIs around! Yuck, > just yuck! Confusingly, mycon is a 'security_context_t', which is defined as: typedef char *security_context_t; I'm not sure what additional conversion is recommended/possible here.
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel