Bug 488859 - startProcess() can generate service names that are too long
Summary: startProcess() can generate service names that are too long
Status: REPORTED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 6.3.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-21 04:35 UTC by kdrk
Modified: 2024-06-21 20:12 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kdrk 2024-06-21 04:35:34 UTC
SUMMARY
SystemdProcessRunner::startProcess() and ScopedProcessRunner::startProcess() are generating service names including the whole escaped file name.
Systemd returns "Invalid unit name or type." when the service/unit name is longer than 255 bytes.
This can be problematic with multi-byte characters.

With the leading "app-" and trailing "@<uuid>.service" taking 45 bytes, 210 bytes are left for the escaped file name.
For example, most CJK characters are 3 bytes long when encoded in UTF-8. These become 12 bytes in the service name  (currently it's 15 bytes because of Bug 488854).
A file name with 18 3-byte characters or more will get the  "Invalid unit name or type." error.

Is it necessary to include the whole file name? There is already the uuid part.
If it's necessary, tell the user to use a shorter file name can be helpful.

STEPS TO REPRODUCE
Execute a .desktop file with a moderately long file name, for example
"そこまで長いというわけでもないファイル名.desktop"

OBSERVED RESULT
The following error can be seen by journalctl -e
kf.kio.gui: Failed to launch process as service: "app-\\x-1d\\x-7f\\x-63\\x-1d\\x-7f\\x-6d\\x-1d\\x-7f\\x-42\\x-1d\\x-7f\\x-59\\x-17\\x-6b\\x-49\\x-1d\\x-7f\\x-7c\\x-1d\\x-7f\\x-58\\x-1d\\x-7f\\x-7c\\x-1d\\x-7f\\x-7a\\x-1d\\x-7e\\x-71\\x-1d\\x-7f\\x-6f\\x-1d\\x-7f\\x-59\\x-1d\\x-7e\\x-7e\\x-1d\\x-7f\\x-56\\x-1d\\x-7f\\x-7c\\x-1d\\x-7d\\x-6b\\x-1d\\x-7e\\x-5f\\x-1d\\x-7e\\x-5c\\x-1d\\x-7d\\x-55\\x-1b\\x-70\\x-73@19241a262b06459c90ecaf538b57c701.service" "org.freedesktop.DBus.Error.InvalidArgs" "Invalid unit name or type."

EXPECTED RESULT
Run the application without error.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20240618
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.1