Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

User cannot disable or remove stock skills due to permissions #238

Closed
hariedo opened this issue Feb 3, 2018 · 4 comments
Closed

User cannot disable or remove stock skills due to permissions #238

hariedo opened this issue Feb 3, 2018 · 4 comments

Comments

@hariedo
Copy link

hariedo commented Feb 3, 2018

I'm running a Picroft 0.9.16.

The documentation for the Mycroft Skill Manager (msm) lists a number of commands including the remove command. The examples show this tool being run from the login user (e.g., pi) in the login shell (e.g., ssh to bash).

If I try to remove a stock built-in skill that is listed as [installed], many errors are incurred due to lack of permissions to write to various installation paths for the skills. Some configuration items are modified, but the skill is still listed as [installed] and still has partial functionality.

pi@picroft:~ $ msm remove mycroft-weather
Searching for 'mycroft-weather'...
Removing 'skill-weather'...13:18:32.861 - root - INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
13:18:33.053 - root - INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
13:18:33.839 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.16-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:18:33.846 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.16-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:18:33.850 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:18:33.855 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
13:18:33.865 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:18:35.435 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device//setting HTTP/1.1" 401 38
13:18:35.448 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:18:36.229 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/auth/token HTTP/1.1" 401 38
13:18:36.240 - mycroft.configuration.config:__init__:175 - ERROR - HTTPError fetching remote configuration: 401
13:18:36.244 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /opt/mycroft/web_config_cache.json loaded
13:18:36.248 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:18:36.252 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
rm: cannot remove ‘skill-weather/vocab/de-de/WeatherType.voc’: Permission denied
rm: cannot remove ‘skill-weather/vocab/de-de/Precipitation.voc’: Permission denied
rm: cannot remove ‘skill-weather/vocab/de-de/Windy.voc’: Permission denied
rm: cannot remove ‘skill-weather/vocab/de-de/Humidity.voc’: Permission denied
rm: cannot remove ‘skill-weather/vocab/de-de/Sunset.voc’: Permission denied
           ...      (many similar errors)     ...
rm: cannot remove ‘skill-weather/.git/HEAD’: Permission denied
rm: cannot remove ‘skill-weather/requirements.txt’: Permission denied
13:18:36.970 - root - INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
13:18:37.113 - root - INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
13:18:37.906 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.16-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:18:37.913 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.16-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:18:37.918 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:18:37.923 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
13:18:37.933 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:18:38.825 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device//setting HTTP/1.1" 401 38
13:18:38.838 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:18:39.682 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/auth/token HTTP/1.1" 401 38
13:18:39.693 - mycroft.configuration.config:__init__:175 - ERROR - HTTPError fetching remote configuration: 401
13:18:39.697 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /opt/mycroft/web_config_cache.json loaded
13:18:39.701 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:18:39.705 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
13:18:40.343 - root - INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
13:18:40.486 - root - INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
13:18:41.286 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.16-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:18:41.294 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.16-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:18:41.299 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:18:41.304 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
13:18:41.314 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:18:42.884 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device//setting HTTP/1.1" 401 38
13:18:42.897 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:18:44.364 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/auth/token HTTP/1.1" 401 38
13:18:44.377 - mycroft.configuration.config:__init__:175 - ERROR - HTTPError fetching remote configuration: 401
13:18:44.382 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /opt/mycroft/web_config_cache.json loaded
13:18:44.386 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:18:44.390 - mycroft.configuration.config:load_local:128 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
msm: error 249
pi@picroft:~ $ msm list | grep weather
mycroft-weather [installed]

If I try to restore install the functionality completely, it says that the skill already exists.

pi@picroft:~ $ msm install mycroft-weather
Searching for for 'mycroft-weather'...exists
msm: error 20

I say "partial functionality" because I noticed that the constant polling which WeatherSkill performs has dropped from 3 queries per minute down to just 1 query per minute.

Expected behavior:

  • user should be able to non-destructively disable skills, not just attempt to remove all trace
@el-tocino
Copy link
Contributor

Can you run "ls -la" in the skill-weather directory? Guessing it's owned by someone other than the pi user (probably by the mycroft user)

@hariedo
Copy link
Author

hariedo commented Feb 5, 2018

Yes, in the picroft image, the stock skills are installed with the mycroft packages.

pi@picroft:~ $ ls -ld skills
lrwxrwxrwx 1 root root 19 Sep 28 21:57 skills -> /opt/mycroft/skills
pi@picroft:~/skills/skill-weather $ ll
total 68
drwxr-xr-x 4 mycroft mycroft  4096 Dec 21 15:56 dialog
-rw-r--r-- 1 mycroft mycroft 23129 Dec 20 22:23 __init__.py
-rw-r--r-- 1 mycroft mycroft 11357 Dec 20 22:23 LICENSE
-rw-r--r-- 1 mycroft mycroft   665 Dec 20 22:23 README.md
drwxr-xr-x 3 mycroft mycroft  4096 Sep 28 21:57 regex
-rw-r--r-- 1 mycroft mycroft    52 Sep 28 21:57 requirements.txt
-rw-r--r-- 1 mycroft mycroft    55 Feb  4 13:38 settings.json
-rw-r--r-- 1 mycroft mycroft   924 Dec 20 22:23 settingsmeta.json
drwxr-xr-x 3 mycroft mycroft  4096 Sep 28 21:57 test
drwxr-xr-x 4 mycroft mycroft  4096 Dec 21 15:56 vocab

With current permissions, it would not be enough to add user pi to group mycroft, but maybe that would make sense at some point. The user mycroft is not intended for login, and the mycroft-cli-client is running as user pi. The msm command really should be ferrying requests into a backend, and performing those requested tasks as user mycroft.

mycroft    824  0.0  0.3   4976  3220 ?        Ss   Feb04   0:00 /lib/systemd/systemd --user
mycroft    834  0.0  0.1   6812  1332 ?        S    Feb04   0:00 (sd-pam)  
mycroft    856  2.2  2.5  31368 23968 ?        S    Feb04  24:52 python2.7 /usr/local/bin/mycroft-messagebus
mycroft    860  0.2  3.5 190484 33468 ?        Sl   Feb04   3:03 python2.7 /usr/local/bin/mycroft-audio
mycroft   1059  2.8  4.6 240616 44004 ?        Sl   Feb04  31:32 python2.7 /usr/local/bin/mycroft-skills
root      2108  0.0  0.1   2140  1096 ?        S    Feb04   0:00 mycroft-admin-service
root      2110  0.0  1.1  14668 10860 ?        S    Feb04   0:02 mycroft-admin-service
mycroft   2144 24.7  3.7 277340 35712 ?        Sl   Feb04 272:43 python2.7 /usr/local/bin/mycroft-speech-client
pi        2236  0.3  2.9 173036 27532 tty1     Sl+  Feb04   3:38 python2.7 /usr/local/bin/mycroft-cli-client
mycroft   2260  1.5  0.8 101540  7688 ?        Sl   Feb04  17:36 /usr/bin/pulseaudio --start --log-target=syslog
pi        3050  5.0  2.8 179692 26748 pts/0    Sl+  Feb04  55:17 python2.7 /usr/local/bin/mycroft-cli-client

I think there needs to be a distinction between "installed" and "activated" for skills. You should be able to turn on and turn off skills without having to delete any files.

@forslund
Copy link
Collaborator

forslund commented Feb 5, 2018

Hi,

There current way to disable skills is to blacklist them in the configuration.

The default config looks like this

  "skills": {
    ...
    "blacklisted_skills": ["skill-media", "send_sms", "skill-wolfram-alpha"],
    ...
  }

and you can override this list by editing the /etc/mycroft/mycroft.conf config and inserting the following before the last }

  "skills": {
    "blacklisted_skills": ["skill-media", "send_sms", "skill-wolfram-alpha", "skill-stock"]
  }

The json parser is a bit picky so make sure to add a , at the end of the line before this new section and just to be safe make a backup of the file.

On a separate note:
When modifying skills I usually do sudo su mycroft to work as the mycroft user on the device. msm should change the permissions to mycroft:mycroft when run as the pi user.

@penrods
Copy link
Contributor

penrods commented Mar 1, 2018

FYI, I added this as a feature request:
MycroftAI/skill-installer#18

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants