Create a file using snap app


#1

Hi All,
I am new to creating snaps. I am trying to build snap for my C application. The C application creates a pid file in /var/run when I run it via snap it fails with permission denied error while creation of file.

Below is my snapcraft.yaml file:

name: test
version: "2.0"
confinement: devmode
architectures:
  - x86_64

parts:
  test:
    plugin: dump
    source: http://example.com/test.tar.gz

apps:
   start:
     command: bin/run
     daemon: simple
     plugs: [network, home]
   stop:
      command: bin/run stop
      plugs: [network]
   reload:
      command: bin/run reload
      plugs: [network]

Am I missing something? Please guide me in case of mistakes.


#2

make your C app follow standards and have it read the XDG_RUNTIME_DIR environment variable instead, this will point to a writable dir for your snap.