No Printing

When I install my snap it will not print. It goes to print but then fails with:

java.awt.print.PrinterIOException

But the jar works fine when it is just a executable jar.

Here is my Yaml:

name: highlighterpdf
title: HighlighterPdf
version: 1.0.2
summary: Highiight the text in a Pdf.
description:
        HighlighterPdf  is a free and open source software application that you can use to 
        highlight text in your pdf document. You can select text in a colour of your choice        
        and then save it.
confinement: strict
grade: stable

base: core18



apps:
 highlighterpdf:
   extensions: [gnome-3-28]
   command: highlighterpdf.sh 
   environment:
         JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-amd64
         PATH: $JAVA_HOME/bin:$PATH
   plugs:
      - home
      - network
      - cups-control
   
      
   
parts:
  highlighterpdf:
       source: https://github.com/gerry136/highlighterpdf.git
       plugin: dump
       stage-packages:
           - unzip
           - openjdk-11-jdk

Just an update from above.

I used layout to make:

layout:
/usr/bin/lpr:
bind: $SNAP/usr/bin/lpr

but I get the exception when I try to print:

Caused by: java.io.IOException: Cannot run program “/usr/bin/lpr”: error=13, Permission denied

how can I change the permissions when I try to use chmod or sudo in the layout statement it will not start and says it has to be clean?

assuming you included lpr or lprng in your stage-packages, you can use:

sudo snap install snappy-debug
snappy-debug.security scanlog highlighterpdf

from a second terminal, then start your app … that should show some info about the permission issues

Thanks Ogra

I can get it printing now but that is using confinement – classic in my yaml.
I tried to load it up to the store and got the following:

Error while processing…
The store was unable to accept this snap.

  • package contains external symlinks: usr/lib/jvm/java-11-openjdk-amd64/lib/security/cacerts
  • (NEEDS REVIEW) confinement ‘classic’ not allowed. If your snap needs classic confinement to function, please make a request for this snap to use classic by creating a new topic in the forum using the ‘store-requests’ category and detail the technical reasons why classic is required.
  • confinement ‘classic’ not allowed with plugs/slots

not sure what to do now

well, what were the permission errors the scanlog command printed ?

a printing issue is most likely not a good enough reason to get classic confinement permitted by the reviewers …

the scanlog reads:

= AppArmor =
Time: May 9 18:17:48
Log: apparmor=“DENIED” operation=“connect” profile=“snap.highlighterpdf.highlighterpdf” name="/run/cups/cups.sock" pid=20475 comm=“AWT-EventQueue-” requested_mask=“wr” denied_mask=“wr” fsuid=1000 ouid=0
File: /run/cups/cups.sock (write)
Suggestions:

  • adjust program to use $SNAP_DATA
  • adjust program to use /run/shm/snap.$SNAP_NAME.*
  • adjust program to use /run/snap.$SNAP_NAME.*
  • adjust snap to use snap layouts (Snap layouts)

I have not :

included lpr or lprng in your stage-packages

how do I do that?

The denial indicates your snap should plugs: [ cups-control ]. Do that and then run: sudo snap connect highlighterpdf:cups-control and it will hopefully work for you.

There is a known bug with snappy-debug that it is not recommending the cups-control interface (specifically, the access is in an AppArmor abstraction and snappy-debug doesn’t currently look at abstractions included in the snapd policy). I’ll take a look at fixing that soon.

Thanks for your reply

I already have cups-controls in my plugs so when I try to run:

sudo snap connect highlighterpdf:cups-control

it comes back with the error message

error: snap “highlighterpdf” has no plug named “cups-control”

funny, because your snapcraft,yaml above defines it …

I know that is what is throwing me I have tried loads in different combinations

well, are you sure your currently used snapcraft.yaml still has it in the plugs: section ?

yes look


name: highlighterpdf
title: HighlighterPdf
version: 1.0.2
summary: Highiight the text in a Pdf.
description:
        HighlighterPdf  is a free and open source software application that you can use to 
        highlight text in your pdf document. You can select text in a colour of your choice        
        and then save it.
confinement: strict
grade: stable

base: core18



apps:
 highlighterpdf:
   extensions: [gnome-3-28]
   command: java -jar $SNAP/highlighterpdf.jar
   environment:
         JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-amd64
         PATH: $JAVA_HOME/bin:$PATH
   plugs:
      - cups-control
      - home
      - network
      
      
    
   
parts:
  highlighterpdf:
       source: https://github.com/gerry136/highlighterpdf.git
       plugin: dump
      
       
       build-packages:
           - openjdk-11-jdk
            
       stage-packages:
           - unzip
           - openjdk-11-jdk
           - lpr

and the curently installed snap has been built from this snapcraft.yaml ?

$ grep cups /snap/highlighterpdf/current/meta/snap.yaml
...

when I enter

$ grep cups /snap/highlighterpdf/current/meta/snap.yaml

it comes back with

 - cups-control

``
with cups being in red

what does that mean? is it a positive or negative result?

scanlog came up with:

the scanlog reads:

= AppArmor =
Time: May 9 18:17:48
Log: apparmor=“DENIED” operation=“connect” profile=“snap.highlighterpdf.highlighterpdf” name="/run/cups/cups.sock" pid=20475 comm=“AWT-EventQueue-” requested_mask=“wr” denied_mask=“wr” fsuid=1000 ouid=0
File: /run/cups/cups.sock (write)
Suggestions:

  • adjust program to use $SNAP_DATA
  • adjust program to use /run/shm/snap.$SNAP_NAME.*
  • adjust program to use /run/snap.$SNAP_NAME.*
  • adjust snap to use snap layouts (Snap layouts)

how do I do this?

Did you run sudo snap connect highlighterpdf:cups-control after installing the snap?

yes I did and it seemed to run