GNS3 / gns3-gui

GNS3 Graphical Network Simulator
http://www.gns3.com
GNU General Public License v3.0
2.17k stars 436 forks source link

Project cannot be deleted because it is not in the default project directory: '/root/GNS3/projects' #3638

Closed jlamsens closed 3 weeks ago

jlamsens commented 1 month ago

GNS3 Version: v2.2.49 Operating System: Linux Mint 21.3

Please bear with me, while I do my best to accurately describe the steps to get this issue.

Clean OS

  1. Fully up-to-date clean install of Linux Mint 21.3 (user created during installation: "guru")

Pre-check1 guru@hp:~$ id uid=1000(guru) gid=1000(guru) groups=1000(guru),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lpadmin),136(sambashare) -> user "guru" memberships

Install some tools

  1. sudo apt install openssh-server -y
  2. sudo apt install tree -y
  3. sudo apt install apt-transport-https ca-certificates curl gnupg -y

Install GNS3

  1. sudo add-apt-repository ppa:gns3/ppa
  2. sudo apt update
  3. sudo apt install gns3-gui gns3-server -y a. ubridge question: yes b. dumpcap question: yes c. Use Systemd to automatically launch the GNS3 server at boot: yes

Post-check1 guru@hp:~$ ps faux | grep gns[3] root 12548 0.2 0.1 211276 50236 ? Ss 11:12 0:01 /usr/share/gns3/gns3-server/bin/python /usr/bin/gns3server --local -> server process running as root

Post-check2 guru@hp:~$ ls Desktop Documents Downloads Music Pictures Public Templates Videos -> no GNS3 folder yet

Start GNS3 (wizard starts)

  1. Run appliances on my local computer (I do not need any virtual machine)
  2. Accept default settings
  3. Connection to the local GNS3 server has been successful!
  4. Summary: finish

Post-check3 guru@hp:~$ ps faux | grep gns[3] guru 13142 1.6 0.4 1461548 152096 ? Sl 11:19 0:02 | _ /usr/share/gns3/gns3-gui/bin/python /usr/bin/gns3 root 12548 0.3 0.1 368476 59748 ? Ssl 11:12 0:01 /usr/share/gns3/gns3-server/bin/python /usr/bin/gns3server --local -> server process running as root -> GUI running as "guru", the currently logged in user

Create project

  1. File -> New Blank Project
  2. Name: Test1 (Location suggested is /home/guru/GNS3/projects/Test1)

Post-check4 guru@hp:~$ ls Desktop Documents Downloads GNS3 Music Pictures Public Templates Videos -> directory "GNS3" is created

guru@hp:~$ tree -pug GNS3/ [drwxr-xr-x root root ] GNS3/ └── [drwxr-xr-x root root ] projects └── [drwxr-xr-x root root ] Test1 └── [-rw-r--r-- root root ] Test1.gns3

2 directories, 1 file -> but the "owner" of that folder, including subfolders is "root"

  1. File -> Delete project -> Error while closing project b1f89d8f-a34b-49ae-bc65-f4d03d07f9c9: Project 'Test1' cannot be deleted because it is not in the default project directory: '/root/GNS3/projects'

  2. Close GNS3

  3. guru@hp:~$ sudo chown -R guru:guru GNS3/

guru@hp:~$ tree -pug GNS3 [drwxr-xr-x guru guru ] GNS3 └── [drwxr-xr-x guru guru ] projects └── [drwxr-xr-x guru guru ] Test1 ├── [drwxr-xr-x guru guru ] project-files │   └── [drwxr-xr-x guru guru ] images └── [-rw-r--r-- guru guru ] Test1.gns3 -> change ownership and check

  1. Start GNS3 and open project "Test1"

  2. guru@hp:~$ tree -pug GNS3 [drwxr-xr-x guru guru ] GNS3 └── [drwxr-xr-x guru guru ] projects └── [drwxr-xr-x guru guru ] Test1 ├── [drwxr-xr-x guru guru ] project-files │   └── [drwxr-xr-x guru guru ] images └── [-rw-r--r-- root root ] Test1.gns3 -> only the ownership of projectfile "Test1.gns3" changes back to "root"

This is because of the ownership (see Post-check4) that should be "guru" and not "root", right?

Best regards, Jurgen L.

jlamsens commented 1 month ago

Update: when you do a reboot, both services get started with ownership of "guru" now...:

guru@hp:~$ ps faux | grep gns[3] guru 2047 7.4 0.4 1585068 141396 ? Sl 15:56 0:00 | _ /usr/share/gns3/gns3-gui/bin/python /usr/bin/gns3 guru 2064 8.4 0.1 512740 56476 ? Sl 15:56 0:00 | _ /usr/share/gns3/gns3-server/bin/python /usr/bin/gns3server --local --log=/home/guru/.config/GNS3/2.2/gns3_server.log --pid=/home/guru/.config/GNS3/2.2/gns3_server.pid

New projects then get the correct permissions (and you can delete them).

grossmj commented 1 month ago

Thanks for the report. Looks like there is something wrong with how we install the systemd service.

jlamsens commented 1 month ago

I wrote earlier, that after a reboot, I could once see that the gns3server service got started with ownership of "guru". The problem is, I cannot reproduce this a second time on a clean Linux Mint 21.3 using the exact same steps. The gns3-server process stays owned by "root". Very strange...

Anyway, editing the gns3server.service systemd file and adding "User=guru" (in my case the current logged in user) under the "[Service] section + reboot solved the problem. Then the service gets started under "guru" and I can delete my own projects now.

Thanks for looking into this and have a nice day.

grossmj commented 1 month ago

Anyway, editing the gns3server.service systemd file and adding "User=guru" (in my case the current logged in user) under the "[Service] section + reboot solved the problem. Then the service gets started under "guru" and I can delete my own projects now.

This is a way to do it I think.

As for the setting up the systemd service when installing the gns3-server package Do you think we should automatically create a "gns3" user and "gns3" group if they don't exist and then add User=gns3 Group=gns3 in the gns3server.service systemd file or try to update that file to add the user who installed the package?

I looked at using a user systemd service (https://www.baeldung.com/linux/systemd-create-user-services) instead however I think it does not really fit the use case for gns3-server. Especially, by default user services are shutdown at the end of the last session.

Please let me know if you have another idea.

jlamsens commented 1 month ago

Hmm, good question. I'm not an expert in this.

I would not add the user who installs the package to the gns3server.service systemd file; when you create another user, for example "guru2" and login with that user and start the GNS3 client (GUI), you get errors because it cannot connect to the server process that is still running as "guru"...

So multiple users should be able to connect the client (GUI) to the server process, but the individual project files that they create, should be owned by the user creating them. Preferably, the server process should not run as root, I guess?

grossmj commented 3 weeks ago

So multiple users should be able to connect the client (GUI) to the server process, but the individual project files that they create, should be owned by the user creating them. Preferably, the server process should not run as root, I guess?

I have made changes to create a service account gns3-server with a default home directory in /var/lib/gns3-server using systemd-sysusers and systemd-tmpfiles. The systemd service runs under that account and its name is also gns3-server. Unfortunately, at the moment we cannot separate projects files based on what user created them.