File Access Example: Accessing the File System Using P.I.P.S.

This example application shows, using a P.I.P.S. (P.I.P.S. Is POSIX on the Symbian platform) program, the restrictions on file access that are imposed by the Symbian platform Security model.

It shows that programs can access their own directories, but cannot, without platform security capabilities not available to ordinary programs, access the directories of other programs, or the system binary directory sys/bin.

This example defines an executable file with no platform security capabilities. The program first creates its own secure directory that it can write to and read from. It then attempts to use a file in a private directory of another program, and then in sys/bin, and shows that these attempts are denied.

Download

Click on the following link to download the example: FileAccessExample.zip

Click: browse to view the example code.

Description

The following sections provide more information about the steps that the example performs.

Create a secure directory

The example creates an empty secure directory for the program by using the mkdir(const char *,mode_t) function.

This empty secure directory is created in C:\private\E80000C9, as 0xE80000C9 is a unique identifier for the program (as specified by the third UID in its project file).

Write and read a file in the private directory

The example writes and reads a file in the secure directory using the fopen(const char *, const char *) and other file stream functions.

Write and read a file in the private directory of another program

The example attempts to write and read a file in the secure directory of another program.

The fopen() function is expected to return NULL, indicating that access is not possible, as the program has insufficient platform security capabilities.

Write and read a file in the sys/bin directory

The example attempts to write and read a file in the system's sys/bin directory, where program binaries are stored.

Again, the fopen() function is expected to return NULL, indicating that access is not possible, as the program has insufficient platform security capabilities.

Build

The example builds an executable called fileaccessexample.exe in the standard locations.

To run the example, start fileaccessexample.exe from the file system or from your IDE. After launching the executable, depending on the emulator you are using, you may need to navigate away from the application launcher or shell screen to view the console.