On Thu, Aug 2, 2012 at 9:04 PM, Paul Moore <pmo...@redhat.com> wrote:
> On Thursday, August 02, 2012 06:36:49 PM tmpsan...@gmail.com wrote:
> > From: "Thiago Marcos P. Santos" <thiago.san...@intel.com>
> >
> > It is always nice to provide this alternative version of variadic
> functions
> > since there is no portable way of wrapping them.
>
> Hmm, this would have been nice last week when I asked for any API changes.
> It
> doesn't mean we can't add it, just that the bar is a little bit higher now.
>
> I understand the basic why, but can you provide a concrete example of an
> application which needs this functionality?
>
> I'm also not sure about the new function names, I would like to keep the
> API
> "namespaced" with the "seccomp_" prefix ... maybe tack a "_va" on the end
> instead?
>
>
I have a class called SeccompFilters. I want to keep the seccomp context
private and at the same time I want to let people add rules by using the
addRule() method. For that I would need something like the code bellow.
void SeccompFilters::addRule(uint32_t action, int syscall, unsigned int
arg_cnt, ...)
{
va_list args;
va_start(args, arg_cnt);
int rc = seccomp_rule_add_va(m_context, action, syscall, arg_cnt, args);
// error handling, failure is fatal
va_end(args);
}
I'm tempted to handle every error when adding filters as fatal. People
willing to do the same, no matter if it is C or C++, can use the _va
functions to create a wrapper. C99 supports variadic macro, which might
help C developers, but doesn't solve my case because it could only be used
inside the class.
#define seccomp_rule_add_or_crash(context, action, syscall, arg_cnt, ...) \
ASSERT(seccomp_rule_add(context, action, syscall, arg_cnt,
##__VA_ARGS__) >= 0);
If you are curious about for what purpose this code has being worked on:
https://bugs.webkit.org/show_bug.cgi?id=89875
And I'm totally fine on changing the name. My original inspiration was the
[v]printf() family, but I guess it works for libc because they don't care
about namespace.
Cheers,
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libseccomp-discuss mailing list
libseccomp-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss