Executing a script inside snap package. Is this possible?

Michael Hall mhall119 at ubuntu.com
Mon Apr 17 01:06:07 UTC 2017


Running a script inside of your snap with either /bin/sh or /bin/bash
should be no problem at all. However looking at your script I see that
you're making dbus calls out to the Plasma Shell, and that *will* be
blocked by the strict confinement.

You will probably need to get a snapd interface created to support this
dbus interface, or maybe you can use the generic 'dbus' interface and
specify this service, which would have to be manuall connected. I'm
hoping someone from the snapd or security teams can chime in and be more
specific about what your options are here.

Michael Hall
mhall119 at ubuntu.com

On 04/16/2017 05:13 PM, Eloy GarcĂ­a (PC Actual) wrote:
> Hello everybody.
> 
> I develop a graphical java-based application which is published in the
> Ubuntu Store as a snap package (sctrict confinment) called
> wallpaperdownloader to download, manage and set desktop wallpapers.
> 
> I'm developing version 2.7 which will bring KDE support, but for this I
> need to execute a shell script from Java. In classic confinement and
> natively, this script is executed without problems. I use this code to do
> it:
> 
> process = Runtime.getRuntime().exec("/bin/sh " + WDUtilities.getAppPath() +
> WDUtilities.URL_SLASH + WDUtilities.PLASMA_SCRIPT + " " +  wallpaperPath);
> 
> As you can see, I use /bin/sh command to run the script. This is the
> content of the script:
> 
> #!/bin/bash
> 
> # Changing wallpaper
> qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript
> "var allDesktops = desktops();print (allDesktops);for
> (i=0;i<allDesktops.length;i++) {d =
> allDesktops[i];d.wallpaperPlugin = 'org.kde.image';d.currentConfigGroup =
> Array('Wallpaper', 'org.kde.image', 'General');d.writeConfig('Image',
> 'file://"$1"')}"
> 
> This command changes the current wallpaper for version 5.8 or higher in
> Plasma.
> 
> When this part is executed within the snap package (strict confinement),
> nothing happens. I have tried to include bash and dash pacakges as
> stage-packages but it doesn work. Is this something that can be achieved
> using the snap package system?
> 
> Thank you very much!
> 
> Best,
> 
> Eloy
> 




More information about the Snapcraft mailing list