Sandbox python app

Hello,

I am new in the development of legato applications, I had configured my environment and tried to run some legato apps writen in C like the documentation and it works fine.

So I was following the steps in this link to put a python code to run on sandbox
http://legato.io/legato-docs/latest/howToSecuritySandboxConfigSample.html

I could create the app and install it on the target but it does not work and I got the following messages

Jan 6 01:00:24 fx30 user.warn Legato: -WRN- | supervisor[511]/supervisor T=main | app.c app_SigChildHandler() 3373 | Process ‘python’ in app ‘helloPython’ faulted: Ignored.
Jan 6 01:00:24 fx30 user.info Legato: INFO | supervisor[511]/supervisor T=main | apps.c DeactivateAppContainer() 349 | Application ‘helloPython’ has stopped.

My module is the FX30, anybody could tell me the best way to track where the problem is?

Thanks in advance

Gustavo

Hello Gustavo,

It is required to list all the files that are required for a python calls from inside a sandbox.
This list must be added to the *.adef of *.cdef file.
This lists depends on the product you are using.

Example with a product different from FX30:
requires: {
file: {
“/usr/bin/python”
“/bin/”
“/usr/bin/python2.7”
“/bin/”
“/usr/lib/libpython2.7.so.1.0”
“/lib/”
}
}

Such list can be got by running this target tool:
# sbtrace <myApp>
see also sbtrace - Legato Docs

Regards.

Hello flu,

Thank you for your suggestion, it has helped me to start find the missing files in my app.

I added the files that were requested by sbtrace in my requires section like this:

file:
{
/usr/bin/python /usr/bin/python
/usr/lib/libpython2.7.so.1.0 /usr/lib/
/lib/libutil.so.1 /lib/
/proc/meminfo /proc/meminfo
/usr/lib/libreadline.so.5 /usr/lib/
/lib/libtinfo.so.5 /lib/
/etc/terminfo /etc/terminfo
}

Unfortunately I am having problem to start the app, when I follow the sbtrace and type Yes for modules, at the end even with an alert of internal error, the app status changes to “running”.

Do you have an idea of what I can do to solve this?

Thank you so much!

BR

Gustavo

Hello Gustao,

The Legato App might not work well after a sbtracing.
I suggest doing this:

sbtrace
app restart

Regards,
flu.

Thanks flu,

I did that, and check the log of the board, what I get for the python process was this

Jan 6 00:32:42 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | proc.c proc_Start() 1394 | Starting process ‘python’ with pid 2239
Jan 6 00:32:42 fx30 user.info Legato: INFO | sbtrace[2238]/sbtrace T=main | sbtrace.c AttachHandler() 646 | Attaching to process 2239.
Jan 6 00:32:42 fx30 user.info Legato: INFO | sbtrace[2238]/sbtrace T=main | sbtrace.c AttachHandler() 659 | Unblocking process 2239.
Jan 6 00:32:42 fx30 user.info Legato: INFO | supervisor[2239]/supervisor T=main | proc.c proc_Start() 1359 | Execing ‘python’
Jan 6 00:32:47 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c CreateDirLink() 1451 | Created directory link ‘/proc’ to ‘/legato/systems/current/appsWriteable/helloPython/proc’.
Jan 6 00:32:49 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c CreateFileLink() 1583 | Created file link ‘/usr/lib/libreadline.so.5’ to ‘/legato/systems/current/appsWriteable/helloPython/usr/lib/libreadline.so.5’.
Jan 6 00:32:51 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c CreateFileLink() 1583 | Created file link ‘/lib/libtinfo.so.5’ to ‘/legato/systems/current/appsWriteable/helloPython/lib/libtinfo.so.5’.
Jan 6 00:32:52 fx30 user.emerg Legato: EMR | sbtrace[2238]/sbtrace T=main | sbtrace.c HandleSysCall() 1214 | Could not import file /etc/terminfo. LE_NOT_FOUND.
Jan 6 00:32:53 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c RemoveLinks() 2420 | Removing link /proc from helloPython.
Jan 6 00:32:53 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c RemoveLinks() 2420 | Removing link /usr/lib/libreadline.so.5 from helloPython.
Jan 6 00:32:53 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c RemoveLinks() 2420 | Removing link /lib/libtinfo.so.5 from helloPython.

It looks like it can’t import terminfo, all this folders that are linked I must put in the .adef file isn’t it?

Thank you a lot

BR

Gustavo

Hello Gustavo,

As terminfo is a folder, you should use this instead;

requires: {

dir: {

“/etc/terminfo” “/etc/terminfo”

}

KR,
flu.

Hi Flu,

Thank you for the advices,

I had some progress by using the Developer Studio to compile the app, by now I could get to this message

=ERR= | python[9530] | ‘getpwuid(): uid not found: 1023’

According to the example, when I got this, it was suppose just to put the envVars section and it would work, but in my case it shows that python command was not recognized.

Is this the only way that I can put my application to run at startup of the board?

Thanks a lot

Best Regards

Gustavo

Hello Gustavo,

Here is a working sandboxed Legato Application, that can call Py_* functions and runs a *.py file (previoulsy bundled into the *.update package)

KR,
flu.

LegatoPy.zip (3.2 KB)

1 Like