Bug 129917 - Installing shared extensions with sudo makes LO unusable
Summary: Installing shared extensions with sudo makes LO unusable
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All Linux (All)
: medium normal
Assignee: Samuel Mehrbrodt (allotropia)
URL:
Whiteboard: target:7.0.0
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-10 08:33 UTC by Samuel Mehrbrodt (allotropia)
Modified: 2020-02-03 09:27 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Mehrbrodt (allotropia) 2020-01-10 08:33:49 UTC
When installing a shared extension with unopkg on Linux like this:

sudo unopkg add --shared extension.oxt

the extension will first be unpacked in the user's directory and afterwards put into the right place in the LibreOffice installation.

During this, some files owned by root are created in the user profile. Afterwards, LO refuses to start because of this.

This is not a problem when running unopkg as root, since a different user profile (from user root) will be used.

So the suggestion is to use a temporary user profile when installing a shared extension on Linux.

There is a patch for that at https://bz.apache.org/ooo/show_bug.cgi?id=86080 .
However that bug was closed as a duplicate of https://bz.apache.org/ooo/show_bug.cgi?id=79648 which again was closed because "unopkg is not used anymore during setup, so the issue is invalid".

That assumption is wrong, since above case (installing a shared extension with sudo) was not considered.

So I suggest to implement the solution from https://bz.apache.org/ooo/show_bug.cgi?id=86080 (use a temporary user profile when installing shared extensions on Linux).
Comment 1 Xisco Faulí 2020-01-10 14:06:49 UTC
Patch in gerrit: https://gerrit.libreoffice.org/c/core/+/86543
Comment 2 Stephan Bergmann 2020-01-14 12:49:53 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #0)
> During this, some files owned by root are created in the user profile.

What files exactly?

> Afterwards, LO refuses to start because of this.

Exactly how to does it fail?

I cannot reproduce either of the above with my local (--enable-release-build) build of current master towards LO 6.5 on Linux:
> $ make -O -j12 Extension_test-passive # to have an extension to install
> $ sudo chown -R root:root instdir
> $ instdir/program/unopkg add --shared workdir/Extension/test-passive.oxt # fails
> ERROR: Exception occurred: You need write permissions to install a shared extension!
> 
> ERROR: unopkg failed.
> 
> warn:unotools.config:1463448:1463448:unotools/source/config/configmgr.cxx:140: ConfigManager not empty
> $ sudo instdir/program/unopkg add --shared workdir/Extension/test-passive.oxt # succeeds
> warn:io.connector:1463461:1463461:io/source/connector/connector.cxx:97: Connector : couldn't connect to pipe 5269f5c34e8aa8af6dd77832dc0c0c7bdc247d6edacf90cf305573ecda5d6e(10)
> 
> > accepting pipe,name=5269f5c34e8aa8af6dd77832dc0c0c7bdc247d6edacf90cf305573ecda5d6e...connection established.warn:io.connector:1463461:1463461:io/source/connector/connector.cxx:97: Connector : couldn't connect to pipe 2fddec53f0846d1872c8ec74379e0c03179ff2f23315418cbef80f7b21ef5d4(10)
> 
> > accepting pipe,name=2fddec53f0846d1872c8ec74379e0c03179ff2f23315418cbef80f7b21ef5d4...connection established.warn:unotools.config:1463461:1463461:unotools/source/config/configmgr.cxx:140: ConfigManager not empty
> $ find ~/.config/libreoffice/ -uid 0 # finds nothing
> $ instdir/program/soffice # works fine
Comment 3 Samuel Mehrbrodt (allotropia) 2020-01-21 07:46:47 UTC
(In reply to Stephan Bergmann from comment #2)
> (In reply to Samuel Mehrbrodt (CIB) from comment #0)
> > During this, some files owned by root are created in the user profile.
> 
> What files exactly?

I did the same as you did (only that I don't have a release build, so user profile is in instdir/user).

After installing https://github.com/smehrbrodt/libreoffice-starter-extension/raw/master/dist/StarterProject.oxt with "sudo unopkg add --shared" I get the whole extension unpacked and with owner root in 

instdir/user/extensions/tmp/extensions/lunkgs7b.tmp_

Also the following files have owner root:

instdir/user/extensions/shared/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc
instdir/user/extensions/shared/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/common.rdb
instdir/user/extensions/shared/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/backenddb.xml
instdir/user/extensions/shared/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/Linux_X86_64.rdb
instdir/user/extensions/shared/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/Linux_X86_64rc
instdir/user/extensions/shared/lastsynchronized
instdir/user/extensions/bundled/lastsynchronized

After that, when starting LO, only the splash screen is shown, then LO crashes.
Comment 4 Commit Notification 2020-02-03 09:17:58 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c51a43bd70aa9fec0a051e51622a6a91f5aaa1a9

tdf#129917 Use temp user profile when installing shared extensions

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Stephan Bergmann 2020-02-03 09:23:00 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #3)
> (In reply to Stephan Bergmann from comment #2)
> > (In reply to Samuel Mehrbrodt (CIB) from comment #0)
> > > During this, some files owned by root are created in the user profile.
> > 
> > What files exactly?
> 
> I did the same as you did (only that I don't have a release build, so user
> profile is in instdir/user).
> 
> After installing
> https://github.com/smehrbrodt/libreoffice-starter-extension/raw/master/dist/
> StarterProject.oxt with "sudo unopkg add --shared" I get the whole extension
> unpacked and with owner root in 
> 
> instdir/user/extensions/tmp/extensions/lunkgs7b.tmp_
> 
> Also the following files have owner root:

(For the record:  Maybe the reason why I couldn't reproduce that with my local build was that I had configured it with various --enable-ext-*, so it came with various bundled extensions, so the relevant UserInstallation directories/files had already been created with my user credentials before the `sudo unopkg`.)