In libseccomp, what is scmp_filter_ctx? And what is it used for? - bpf

What actually stores scmp_filter_ctx since it's defined as void?
See seccomp header file.
In general what is a context ?

It's not defined as void but void *, so it's a generic pointer.
From a quick glance at the file you link I would say it points to some object which structure you can't access (and don't need to know about). The context seems to be the object storing the information seccomp needs to work, and you only need to init, update or use it through the API functions exposed in that header file.
If you really want to see what's inside, just read the source :). In src/api.c it's apparently casted as a struct db_filter_col *, which of course is not exposed to users.

Related

Macros in Datafusion using Argument setter

Using Argument setter by supplying the parameter value I want to make the Datafusion pipeline as resuable. As said by many other answer's have tried implementing using the cloud reusable pipeline example given in Google guide.I was not able to pass the parameter Json file.So how to create the API to that parameter Json file stored in Google storage.Please explain the values to be passed to Argument setter like URL,Request response etc., If any one of you had implemented in your projects.
Thank you.
ArgumentSetter plugin reads from a HTTP endpoint and it must be publicly accessible as is depicted within the GCP documentation. Currently, there is not a way to read from a non-public file stored in GCS. This behavior has been reported in order to be improved to CDAP through this ticket.
Can you please provide what you've tried so far and where you're stuck?
The URL field in argument setter would contain the API endpoint you're making a call to. Make sure you include any headers your call would need like Authorization, Accept etc.
If you're having issues with argument setter a good check is to use Curl or any other tool to make sure you're able to talk to the endpoint you're trying to use.
Here's some documentation about Argument setter: https://github.com/data-integrations/argument-setter
Define a JSON file with appropriate name/value pairs. Upload it in a GCS bucket - make it public by changing permissions (add "allUsers" in permissions list). When you save it, the file will say "Public to Internet"
Copy the https path to the file and use it in Arguments Setter. If you're able to access this path from curl/ your browser, Argument Setter will be able to do too..
There are other problems I've encountered while using Argument Setter though - the pipe doesn't supersede runtime arguments over default values provided in the URL many a times, specially when the pipe is duplicated.
To make file public
You have to make your bucket public, currently there is no other way.
gsutil iam ch allUsers:objectViewer gs://BUCKET_NAME

Access to an object's fields is only permitted within its methods in matlab

I need to modify the cluster methods of the phytree object in matlab. After modifying it, I change the name to cluster_second. Then, when I run the function, I got the error saying that
Access to an object's fields is only permitted within its methods.
I understand what is going on here. Because I need to use tr.tree, and it is a field of the phytree object which can only be accessed within that phytree object's method. Obviously, cluster_second does not satisfy that condition. Can anyone help me out with this? Many thanks.
If you want your cluster_second method to be a method of phytree, put the file cluster_second.m into the directory \toolbox\bioinfo\bioinfo\#phytree. All phytree objects will then have an additional method cluster_second (as well as the original cluster method).
It's possible that you may also be able to put it into a different folder named #phytree, as long this #phytree folder is on your path. I'm afraid I don't have Bioinformatics Toolbox on my current machine to test that, though.

MATLAB doesn't show help for user-created class private methods and properties

This is the problem:
Create a class and set the access to be private for some of the properties or methods.
Use the doc command for the created class. This will auto-generate documentation from your comments and show it in the built-in help browser.
doc classname
The problem is that documentation for the private properties and methods is not shown in the help browser. Is there any way to overcome this problem?
So I spent like 10 minutes using the debugger, jumping from one function to the next, tracing the execution path of a simple doc MyClass call.
Eventually it lead me to the following file:
fullfile(toolboxdir('matlab'),'helptools','+helpUtils','isAccessible.m')
This function is called during the process of generating documentation for a class to determine if the class elements (including methods, properties, and events) are publicly accessible and non-hidden. This information is used later on to "cull" the elements.
So if you are willing to modify MATLAB's internal functions, and you want the docs to always show all methods and properties regardless of their scope, just rewrite the function to say:
function b = isAccessible(classElement, elementKeyword)
b = true;
return
% ... some more code we'll never reach!
end
Of course, don't forget to make a backup of the file in case you changed your mind later :)
(on recent Windows, you'll need to perform this step with administrative privileges)
As a test, take the sample class defined in this page and run doc someClass. The result:
This behaviour is by design - the auto-generated documentation is intended for users of the class, who would only be able to access the public properties and methods.
There's no way that I'm aware of to change this behaviour.
You could try:
Use an alternative system of auto-generating documentation such as this from the MATLAB Central File Exchange (which I believe will document all properties, not just public).
Implement your own doc command. Your doc command should accept exactly the same inputs as the built-in doc command, detect if its inputs correspond to your class/methods/properties etc, and if so display their documentation, otherwise pass its inputs straight through to the built-in doc. Make sure your command is ahead of the built-in on the path.

Do I have to put get/set methods in the class definition in matlab ?

Is one forced to place all get and set functions in the class definition file in Matlab ?
I'm asking since this really makes the file a bit messy and defeats the purpose of having a class definition folder.
Yes, if you use property set and get access methods (in fact any method with a dot in the name), you must include them within the classdef file, not in separate files. See the documentation.
However, if you have have a special reason to want to put as much as possible in separate files, you can define methods getMyProp and setMyProp in separate files, and then within the classdef file have the get.myProp and set.myProp functions call them.
If you use them then you need to define them. but you can also define your variables as public.

How to convert Objective C textual (po) representation to real object

In xcode you can use po object to see a textual representation of a given object. Is it possible to convert from this textual representation to a real objective c object?
Thanks
I suppose you could parse out the address, assign it to a pointer, and retrieve the object from memory that way, but that IS A HORRIBLY BAD IDEA AND YOU SHOULD NEVER DO THAT.
Real question: what are you trying to do?
I have a project that may inspire you, its on GitHub and its called NDJSON. Basically it uses runtime introspection to get properties an object has and set those properties using a json key of the same value. You could do something like that but get the property values instead of set. To help in situation where the type can not be determined like the type of objects to go in a collection or to map a json key to differently named property I have defined an informal protocol that has some methods that return dictionary mapping json key to property names or class to use for property name, there are also method to return a list of json keys to ignore or alternatively the only keys to accept. If you look at my code on git hub there is a class called NDJSONDeserializer which contains this logic. There is a function called getTypeNameFromPropertyAttributes() which parses out the string result of Apples runtime method property_getAttributes() which you will want to look at.
No, the representation you see from po <instance> is the result of -[<instance> debugDescription], which by default returns -[<instance> description], as described in http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html.
Unless the instance you're dealing with just happens to provide a description which is a serialized form of itself, you're SOL. Most objects don't.
The real question, as Dave points out is, what are you trying to do? po only works in the gdb console, so I assume this is a debugging issue. In that case, do you know that the gdb console supports sending messages to instances? So you can do:
po [<myInstance> methodReturningAnOtherObject]
or
po [<myInstance> valueForKeyPath:#"some.long.key.path"]
to follow the object graph from within the debugger console.