Choose style:

Author Topic: How to restart nemo-desktop from a script running as root  (Read 203 times)

0 Members and 1 Guest are viewing this topic.

Offline Ulysses_

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 0
  • New Forum User
    • View Profile
How to restart nemo-desktop from a script running as root
« on: June 19, 2019, 02:11:56 pm »
One would think that root can run anything as if he were any user, using sudo -u like this:

pkill nemo-desktop
sudo -u user nemo-desktop &

It does not work. It produces this error:

(nemo-desktop:4378): dconf-CRITICAL **: 16:50:26.008: unable to create file '/home/user/.cache/dconf/user': Permission denied. dconf will not work properly.

But it works if you're an ordinary user. What's the proper way to restart nemo-desktop if you're root? This is needed when resuming VM's where vmware allows you to run your own script as root.
« Last Edit: June 22, 2019, 08:48:53 am by Ulysses_ »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25311
  • Karma: 2793
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: How to restart nemo-desktop from a script running as root
« Reply #1 on: June 19, 2019, 02:40:44 pm »
if you're already root, you shouldn't need sudo .. try
Code: [Select]
su user -c "nohup nemo-desktop"
obviously replace "user" with the users name.
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Ulysses_

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 0
  • New Forum User
    • View Profile
Re: How to restart nemo-desktop from a script running as root
« Reply #2 on: June 20, 2019, 05:33:01 am »
Same thing happens except the errors go to nohup.out.

Tried gksudo -u user nemo-desktop and it still happens. Is nemo-desktop launched from a script at boot time that we can copy from?

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25311
  • Karma: 2793
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: How to restart nemo-desktop from a script running as root
« Reply #3 on: June 20, 2019, 09:12:45 am »
Nope, it's just launched with a .desktop launcher at
Code: [Select]
/etc/xdg/autostart/nemo-autostart.desktop
which contains the line
Code: [Select]
Exec=nemo-desktop
your problem is this gets executed as the user, and apparently that user doesn't have permission to write to its own /home/user/.cache/dconf/user

What's the output from:
Code: [Select]
sudo namei -om /home/user/.cache/dconf/user
maybe your script will have to change ownership of that path prior to running su user -c "nohup nemo-desktop" or similar.
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Ulysses_

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 0
  • New Forum User
    • View Profile
Re: How to restart nemo-desktop from a script running as root
« Reply #4 on: June 21, 2019, 05:02:53 pm »
Nice command that. Here's the output:

f: /home/user/.cache/dconf/user
 drwxr-xr-x root root /
 drwxr-xr-x root root home
 drwxrwxr-x user user user
 drwxrwxr-x user user .cache
 drwx------ root root dconf
 -rw------- root root user

This is a hack really but these two commands:

chmod 777 /home/user/.cache/dconf
chmod 777 /home/user/.cache/dconf/user

remove the error and you get another load of errors:

# cat nohup.out

(nemo-desktop:3569): GLib-GIO-CRITICAL **: 00:00:31.650: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(nemo-desktop:3569): libunity-CRITICAL **: 00:00:37.701: unity-launcher.vala:157: Unable to connect to session bus: Could not connect: Connection refused

(nemo-desktop:3569): libunity-CRITICAL **: 00:00:40.737: unity-launcher.vala:157: Unable to connect to session bus: Could not connect: Connection refused

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:40.746: g_strstr_len: assertion 'haystack != NULL' failed
** Message: 00:00:40.746: nemo-desktop: session is not cinnamon (checked XDG_SESSION_DESKTOP,DESKTOP_SESSION environment variables.) Applying default behavior

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:40.747: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.767: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.768: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.768: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): LIBDBUSMENU-GLIB-WARNING **: 00:00:43.769: Unable to get session bus: Could not connect: Connection refused

(nemo-desktop:3569): LIBDBUSMENU-GLIB-WARNING **: 00:00:43.769: Unable to get session bus: Could not connect: Connection refused

(nemo-desktop:3569): Gtk-WARNING **: 00:00:43.893: Invalid input string

(nemo-desktop:3569): Gtk-WARNING **: 00:00:43.894: Invalid input string

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.905: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.905: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.905: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): GLib-CRITICAL **: 00:00:43.906: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed

(nemo-desktop:3569): Gtk-WARNING **: 00:00:43.906: Invalid input string

(nemo-desktop:3569): Gtk-WARNING **: 00:00:43.906: Invalid input string

(nemo-desktop:3569): Gtk-WARNING **: 00:00:43.906: Invalid input string

But 20 seconds later, the files appear on the desktop as if nemo-desktop is happy.
« Last Edit: June 21, 2019, 05:04:46 pm by Ulysses_ »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25311
  • Karma: 2793
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: How to restart nemo-desktop from a script running as root
« Reply #5 on: June 21, 2019, 07:41:37 pm »
I'd have likely done
Code: [Select]
chown user:user /home/user/.cache/dconf
chown user:user /home/user/.cache/dconf/user
myself, but each to their own :)



And if you don't wanna keep spamming the nohup.out file (so it doesn't keep getting bigger each boot) .. either delete it as part of the script, or start nemo desktop with:
Code: [Select]
su user -c "nohup nemo-desktop >/dev/null 2>&1 &"
so the output is directed to the black hole that is /dev/null
« Last Edit: June 21, 2019, 07:50:24 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Ulysses_

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 0
  • New Forum User
    • View Profile
Re: How to restart nemo-desktop from a script running as root
« Reply #6 on: June 22, 2019, 09:14:04 am »
Those 20 seconds of wait till the desktop appears are not ok. The whole point of this exercise is productivity, while staying secure with separate VM's for different sites. Just discovered that the problem does not occur at all with the live CD. Maybe I ought to try and install peppermint on a brand new VM and see if it happens there. Any other ideas to try before doing that?
« Last Edit: June 22, 2019, 01:28:47 pm by Ulysses_ »