File permissions within a snap

XiaoGuo Liu xiaoguo.liu at canonical.com
Fri Aug 26 02:32:50 UTC 2016


Hi Jenny,

I do not think you need to define "SNAP_USER_DATA".It is already there.
Please check my "hello" example code at
https://github.com/liu-xiao-guo/helloworld-demo. After you install the app,
you can run the command like:

liuxg at liuxg:~$ hello.env | grep SNAP
SNAP_USER_COMMON=/home/liuxg/snap/hello/common
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:
SNAP_COMMON=/var/snap/hello/common
SNAP_USER_DATA=/home/liuxg/snap/hello/x1
SNAP_DATA=/var/snap/hello/x1
SNAP_REVISION=x1
SNAP_NAME=hello
SNAP_ARCH=amd64
SNAP_VERSION=1.0
SNAP=/snap/hello/x1

Basically, SNAP_USER_DATA is defined as
"/home/liuxg/snap/Your_Package_Name/version_number"

Best regards,
XiaoGuo

On Thu, Aug 25, 2016 at 7:03 PM, Jenny Murphy <jenny.murphy at episensor.com>
wrote:

> Hi,
>  Do I need to define the location of SNAP_USER_DATA. Currently I added
> the following line to a wrapper script that already runs in my app :
>
> echo "User Data = " $SNAP_USER_DATA
>
>
> The result is
>  User Data =
>
>
> Thanks a lot for you help. I guess this stuff is very basic but I am
> having to get up to speed quickly on snappy.
> Jenny
>
> On 24 August 2016 at 12:01, Zygmunt Krynicki <zygmunt.krynicki at canonical.
> com> wrote:
>
>>
>> Wiadomość napisana przez Jenny Murphy <jenny.murphy at episensor.com> w
>> dniu 24.08.2016, o godz. 12:58:
>>
>> Hi,
>>  I have a java application built as a .snap.
>> As part of its normal operation it will create some files (for output).
>> However this is not successful due to permissions issue :
>> For example , I tried to create the file in /home/ubuntu/examples/ :
>> java.io.FileNotFoundException: /home/ubuntu/examples/example.txt
>> (Permission denied)
>> I got a similar result whenI tired to create it in the current dir :
>> /apps/gateway.sideload/IcNYWMFDGBeY
>>
>>
>> You can freely create files in $SNAP_USER_DATA - the per-user data
>> directory or $SNAP_DATA - the global data directory (for daemons).
>>
>> If you want to write to other locations you need an interface to do it.
>> For example you can use the home interface to get write access to most of
>> the $HOME directory.
>>
>> You can do this by just defining a „home” plug on your application.
>>
>> Best regards
>> ZK
>>
>>
>> So is there a way around this?
>>
>> Thanks in advance for any suggestions.
>>
>> --
>> *Jenny Murphy*
>> *EpiSensor, Georges Quay House, Georges Quay, Limerick, Ireland*
>> jenny.murphy at episensor.com <jenny.murphy at episensor.com>  t | +353 (0) 61
>> 512 511  w | http://www.episensor.com
>> --
>> Snapcraft mailing list
>> Snapcraft at lists.snapcraft.io
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm
>> an/listinfo/snapcraft
>>
>>
>>
>
>
> --
> *Jenny Murphy*
> *EpiSensor, Georges Quay House, Georges Quay, Limerick, Ireland*
> jenny.murphy at episensor.com <jenny.murphy at episensor.com>  t | +353 (0) 61
> 512 511  w | http://www.episensor.com
>
> --
> Snapcraft mailing list
> Snapcraft at lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
>


-- 
XiaoGuo, Liu (刘晓国)
Mobile: +86-13911181302
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/snapcraft/attachments/20160826/7e81e60c/attachment.html>


More information about the Snapcraft mailing list