ricardomv / snapper-gui

GUI for snapper, a tool for Linux filesystem snapshot management, works with btrfs, ext4 and thin-provisioned LVM volumes
GNU General Public License v2.0
226 stars 32 forks source link

changes windows is always empty #31

Closed aney1 closed 5 years ago

aney1 commented 6 years ago

When trying to show the changes between two snapshots the window is empty: index

Console is showing the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/snappergui/changesWindow.py", line 145, in on_idle_init_paths_tree
    self.add_path_to_tree(str(entry[0]), int(entry[1]), files_tree)
  File "/usr/local/lib/python3.5/dist-packages/snappergui/changesWindow.py", line 70, in add_path_to_tree
    node.children[parts[-1]] = changesWindow.TreeNode(path, None, status, False)
TypeError: 'NoneType' object does not support item assignment

In the Snapper logfile (/var/log/snapper.log), everything looks like its working:

2018-01-29 16:46:14 MIL libsnapper(4138) Comparison.cc(Comparison):56 - num1:8 num2:32
2018-01-29 16:46:14 MIL libsnapper(4138) Comparison.cc(load):167 - num1:8 num2:32
2018-01-29 16:46:14 MIL libsnapper(4138) Comparison.cc(load):216 - read 97075 lines

Ubuntu 16.04.03

ricardomv commented 6 years ago

Hi thanks for the report, i think this has something to do with permissions, can you start the application as root?

rickysarraf commented 6 years ago

I've run into the same problem while packaging it for Debian. It would make more sense to ship a policykit file if you want to run the app as root because on modern systems, which run Wayland, running a GUI application with root privileges is not going to be easy.

rrs@priyasi:/var/tmp/Debian-Build/temp/snapper-gui (master)$ snapper-gui 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/snappergui/changesWindow.py", line 145, in on_idle_init_paths_tree
    self.add_path_to_tree(str(entry[0]), int(entry[1]), files_tree)
  File "/usr/lib/python3/dist-packages/snappergui/changesWindow.py", line 70, in add_path_to_tree
    node.children[parts[-1]] = changesWindow.TreeNode(path, None, status, False)
TypeError: 'NoneType' object does not support item assignment
rickysarraf commented 6 years ago

So I did some brute force to run it as root and indeed it works then. Part of the reason may be the following:

rrs@priyasi:~$ sudo snapper -c homedir list
Type   | # | Pre # | Date                              | User | Cleanup  | Description | Userdata
-------+---+-------+-----------------------------------+------+----------+-------------+---------
single | 0 |       |                                   | root |          | current     |         
single | 1 |       | Tue 24 Jul 2018 02:58:00 PM +0545 | root |          |             |         
single | 2 |       | Tue 24 Jul 2018 03:00:18 PM +0545 | root | timeline | timeline    |         
single | 3 |       | Tue 24 Jul 2018 03:55:22 PM +0545 | rrs  |          |             |         
single | 4 |       | Tue 24 Jul 2018 04:00:23 PM +0545 | root | timeline | timeline    |         
single | 5 |       | Tue 24 Jul 2018 05:00:23 PM +0545 | root | timeline | timeline    |         
single | 6 |       | Tue 24 Jul 2018 06:00:23 PM +0545 | root | timeline | timeline    |         
single | 7 |       | Tue 24 Jul 2018 07:00:19 PM +0545 | root | timeline | timeline    |         
19:22 โ™’โ™’โ™’   โ˜บ ๐Ÿ˜„   

Since most snapshots are created by user root, accessing them isn't allowed to the normal user.

rickysarraf commented 6 years ago

Okay. the problem is with snapper rather than with the GUI itself. Since the .snapshots folder is marked root only, it does not allow the user to access the data. It does make me wonder then why is the snapper utility, as a normal user, allowed to create snapshots. Hmmm.

-rw-r--r-- 1 rrs  rrs        97 May 17  2011  .signature
drwxr-x--- 1 root root       16 Jul 24 19:25  .snapshots/
...snipped....
19:26 โ™’โ™’โ™’   โ˜บ ๐Ÿ˜„    
rrs@priyasi:~$ cd .snapshots/
-bash: cd: .snapshots/: Permission denied
19:26 โ™’โ™’โ™’    โ˜น ๐Ÿ˜Ÿ=> 1  
rrs@priyasi
rickysarraf commented 6 years ago

Okay. So this is the crux of the problem: https://wiki.archlinux.org/index.php/Snapper#Access_for_non-root_users

This is more a snapper problem that this GUI. And I must also thank you for creating the GUI application. I hadn't thanked you in the beginning of the report. Thank You.

rickysarraf commented 6 years ago

I filed a bug report here: https://github.com/openSUSE/snapper/issues/416

rickysarraf commented 6 years ago

It indeed is a permission problem. After the permissions set proper with snapper, I can successfully see the diff for the subvolume.

Citing the manpage

PERMISSIONS
       Non-root users can be allowed to use a configuration by setting ALLOW_USERS
       or ALLOW_GROUPS in the config file. For all operations to work, the user
       must also be able to read and access the .snapshots directory inside the
       subvolume. The .snapshots directory must be owned by root and must not be
       writable by anybody else.

       Here are some methods how to achieve that:

       ยท   Make the directory accessible for everyone:

           chmod a+rx .snapshots

       ยท   Make the directory accessible for a group the user belongs to, e.g.:

           chown :users .snapshots

       ยท   Make the directory accessible for the user using ACLs, e.g.:

           setfacl -m u:tux:rx .snapshots

       The last method can be performed by snapper, see the SYNC_ACL setting in
       snapper-configs(5).

image

rickysarraf commented 6 years ago

Just one additional glitch. After I exit the application, it throws the following exception:

rrs@priyasi:/var/tmp$ man snapper
10:36 โ™’โ™’โ™’   โ˜บ ๐Ÿ˜„    
rrs@priyasi:/var/tmp$ snapper-gui 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/snappergui/mainWindow.py", line 203, in on_main_destroy
    for snapshot in snapper.ListSnapshots(config[0]):
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: error.no_permissions: org.freedesktop.DBus.Error.Failed
10:39 โ™’โ™’โ™’   โ˜บ ๐Ÿ˜„    
rrs@priyasi:/var/tmp$ 
rickysarraf commented 6 years ago

Just FYI. I pushed it into Debian and will be your point of contact for the package for Debian and its derivatives. Expect some more traction on this tool now

developer91234 commented 9 months ago

How can this application do anything if pretty much all snapper operations require root access? I just opened it up on arch and naturally it shows nothing because even viewing snapshots requires root, never mind actually doing anything with them. The problem doesn't go away even after making the snapshot directory available to world because apparently snapper just requires root for everything even if it doesn't need it. @ricardomv

developer91234 commented 9 months ago

Ofc running snapper-gui as root everything is fine but guis shouldn't be run as root.