Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-12-16 21:38:57

Maniaxx
Member
Registered: 2019-07-16
Posts: 8

How to mass-trust .desktop files via shell?

Hi,
all my .desktop files are untrusted since 4.18. How can i mass-trust them via shell? I do not want to manually set it via appearing gui dialog or file/properties. Icons are not shown when untrusted.

Offline

#2 2022-12-16 23:55:04

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 9,792

Re: How to mass-trust .desktop files via shell?

Two things need to be done to a .desktop file to make it trusted:

  1. it needs to be marked executable:

    chmod +x FILE
  2. it needs to have an xfce-exe-checksum metadata entry created for the file:

    f=FILE; gio set -t string $f metadata::xfce-exe-checksum "$(sha256sum $f | awk '{print $1}')"

You can then script something to have that happen iteratively to a series of files.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2022-12-17 00:13:50

Maniaxx
Member
Registered: 2019-07-16
Posts: 8

Re: How to mass-trust .desktop files via shell?

Thanks, works.
There seems to be a little bug though if the .desktop file is symlinked (to the desktop). Trying to set the symlink 'trusted' via gui or file/properties only sets the symlink (not the actual linked file as well) resulting in gui/thunar still throwing the 'untrusted' warning when invoking.

Offline

#4 2022-12-19 04:01:25

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 797

Re: How to mass-trust .desktop files via shell?

i have only ever done step 1 and never did step 2.  it has always worked for me when i did just that much?  what am i missing by not doing step 2?

Offline

#5 2022-12-19 11:35:49

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 9,792

Re: How to mass-trust .desktop files via shell?

Skaperen wrote:

i have only ever done step 1 and never did step 2.  it has always worked for me when i did just that much?  what am i missing by not doing step 2?

Checksum-based launcher trusts are new functionality added in Thunar 4.17.4 (also involving enhancements to exo and libxfce4util). In 4.18, you will need to do both.

Edit: From https://gitlab.xfce.org/xfce/thunar/-/c … ad6ffc08fe:

Only using the executable flag to 'trust' launchers is insecure, because the flag e.g. can be pre-set in archives.
'Trusting' a launcher now will generate a checksum of the launcher and  store it via gvfs-metadata.

Last edited by ToZ (2022-12-19 11:37:01)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2023-01-22 01:38:40

P2023
Member
Registered: 2023-01-22
Posts: 1

Re: How to mass-trust .desktop files via shell?

ToZ wrote:
f=FILE; gio set -t string $f metadata::xfce-exe-checksum "$(sha256sum $f | awk '{print $1}')"

Thanks for this solution.
If automating, it's worth quoting $f as it fails if it contains spaces or special characters...

f=FILE; gio set -t string "$f" metadata::xfce-exe-checksum "$(sha256sum "$f" | awk '{print $1}')"

Offline

#7 2023-01-22 01:58:17

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 9,792

Re: How to mass-trust .desktop files via shell?

Yes, you are right. Thanks for the catch.

Welcome to the forum.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 2023-01-22 17:56:42

Maniaxx
Member
Registered: 2019-07-16
Posts: 8

Re: How to mass-trust .desktop files via shell?

P2023 wrote:

If automating, it's worth quoting $f as it fails if it contains spaces or special characters...

How do you automate this? I've tried to assemble a one-liner without success in bash with 'find [...] -exec bash -c' but it always fails as the original one-liner has single and double quotes and subshell.

Offline

#9 2023-01-22 21:20:41

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 9,792

Re: How to mass-trust .desktop files via shell?

Using for loop instead of find, this works for me:

for f in ~/Desktop/*.desktop; do chmod +x "$f"; gio set -t string "$f" metadata::xfce-exe-checksum "$(sha256sum "$f" | awk '{print $1}')"; done

Last edited by ToZ (2023-01-22 21:22:27)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#10 2023-01-23 13:32:10

Maniaxx
Member
Registered: 2019-07-16
Posts: 8

Re: How to mass-trust .desktop files via shell?

Thanks. I've previously tried something similar with 'for f in $(find ...); do ...' that unfortunately broke on whitespaces but globbing is safe indeed.

Offline

Board footer

Powered by FluxBB