7

I'm trying to add a ppa but get error: Permission denied: '/etc/apt/sources.list.d/google-earth.list':

~$ sudo add-apt-repository ppa:otto-kesselgulasch/gimp-edge

[...]

Press [ENTER] to continue or ctrl-c to cancel adding it

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 168, in <module>
    if not sp.add_source_from_shortcut(shortcut, options.enable_source):
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 768, in add_source_from_shortcut
    self.set_modified_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 492, in set_modified_sourceslist
    self.save_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 658, in save_sourceslist
    self.sourceslist.save()
  File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 413, in save
    files[source.file] = open(source.file, "w")
PermissionError: [Errno 13] Permission denied: '/etc/apt/sources.list.d/google-earth.list'

same happens when trying to run as root instead of using sudo:

~$ sudo su -
~# add-apt-repository ppa:otto-kesselgulasch/gimp-edge

The source file of the ppa is created, but is empty:

~$ ll /etc/apt/sources.list.d/otto-kesselgulasch-ubuntu-gimp-edge-xenial.list*
-rw-r--r-- 1 root root 0 Apr  3 10:26 /etc/apt/sources.list.d/otto-kesselgulasch-ubuntu-gimp-edge-xenial.list
-rw-r--r-- 1 root root 0 Mai  3 15:03 /etc/apt/sources.list.d/otto-kesselgulasch-ubuntu-gimp-edge-xenial.list.save

Owner of that google-earth.list is root with u:rw access.

~$ ll /etc/apt/sources.list.d/google-earth.list
-rw-r--r-- 1 root root 188 Apr  3 10:27 /etc/apt/sources.list.d/google-earth.list

~$ getfacl /etc/apt/sources.list.d/google-earth.list
getfacl: Removing leading '/' from absolute path names
# file: etc/apt/sources.list.d/google-earth.list
# owner: root
# group: root
user::rw-
group::r--
other::r--

There is also enough free space:

~$ df -h /etc/apt/sources.list.d/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       902G  252G  604G  30% /

apt update / apt upgrade are working fine.

What is going on here ?
(PS: I don't need a workaround, I know that I can add the deb manually.)

5
  • 1
    Anything look odd in lsattr /etc/apt/sources.list.d/?
    – Zanna
    May 3, 2018 at 13:37
  • 2
    Great, thanks, that's it ... google-earth.list was set immutable ... ----i--------e-- /etc/apt/sources.list.d/google-earth.list. A simple sudo chattr -i /etc/apt/sources.list.d/google-earth.list fixed the problem. Do you want to write an answer that I can accept or should I write the answer myself?
    – pLumo
    May 3, 2018 at 13:42
  • 1
    I remember that I made that file immutable some weeks ago because webupd8 told me to do it... webupd8.org/2016/03/fix-failed-to-fetch-google-chrome_3.html --> Update 2
    – pLumo
    May 3, 2018 at 13:44
  • 1
    Another question would the be, why apt-add-repository needs to open google-earth.list with 'w' option ...
    – pLumo
    May 3, 2018 at 13:47
  • Sorry for the slow response - good to know you found the problem and fixed it, but, yeah I am pretty baffled as to why you adding a new PPA requires a write action on an old one. I wonder if that ("w" in line 413) should be considered a bug in add-apt-repository. I would have thought the existing files could be read, and then a new file written, but I don't know Python. I am willing to write an answer, but it might be better if you do, since you can probably explain better how it happened
    – Zanna
    May 3, 2018 at 14:14

1 Answer 1

6

Thanks to the hint from Zanna I found the issue:

lsattr output showed that google-earth.list was set immutable.

~$ lsattr /etc/apt/sources.list.d/google-earth.list
----i--------e-- /etc/apt/sources.list.d/google-earth.list

With this attribute set, not even root can write the file.
To fix it, I just used chattr -i to remove the immutable attribute on the file:

~$ sudo chattr -i /etc/apt/sources.list.d/google-earth.list

I made that file immutable myself, because after each Google Earth Update, [arch=amd64] gets removed from the source file (blame Google !). I originally found that "immutable fix" on webupd8.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .