Recent

Author Topic: Lazarus and SMB Share: Weird permission issues  (Read 1267 times)

mrmaxmusterman

  • New Member
  • *
  • Posts: 16
Lazarus and SMB Share: Weird permission issues
« on: August 22, 2021, 03:49:28 pm »
Due to me wanting to work of of multiple computers at the same time, i decided to host an smb share in my network. My machines can all connect nicely to it, inlcuding my main, but not only machine running Fedora 34 with Gnome 40. Through the normal nautilus "file explorer", i connected to my smb share with user credentials (username, group and password) which gave me access to all my files. All of my files can be now accessed with read, write and run priviledges (drwx------ / -rwx------) and all files belong to my user account and the group of my user account.

e.g. output from terminal ls -la

Code: Pascal  [Select][+][-]
  1. -rwx------. 1 Max Max 2057 20. Aug 11:24 test_project.lpi

When opening my project in Lazarus (gtk2; installed through official repository (dnf install lazarus), it opens normally as intended. When trying to write to my project (e.g. update .pas file; compiling etc.), i encounter the following error:

"Cant write file "/run/user/1000/gvfs/smb-share:server=mypi.local,share=usb%20drive/test_project.pas"."

It should be noted that the example i gave above from the file priviledges is from exacly that directoy.

If someone knows why this is happing, i'd be glad if you could help me out with this!

winni

  • Hero Member
  • *****
  • Posts: 2714
Re: Lazarus and SMB Share: Weird permission issues
« Reply #1 on: August 22, 2021, 04:14:41 pm »
Hi!

Dont let the filemanager mount your SMB share. This leads to the "user1000" . And the trouble.

Before you start to work with  the share mount it to a dedicated mount point.

For the example:
192.168.1.99 is your SMB server
Laz is a SMB share on the server
/mnt is your local mountpoint

Code: Bash  [Select][+][-]
  1. mount.cifs //192.168.1.99/Laz /mnt/ -o rw, username=mustermann, password=secret
  2.  


Winni
« Last Edit: August 22, 2021, 04:18:34 pm by winni »

mrmaxmusterman

  • New Member
  • *
  • Posts: 16
Re: Lazarus and SMB Share: Weird permission issues
« Reply #2 on: August 22, 2021, 04:53:57 pm »
It does actually work. Nice one!

The only problem i encounter rn is that i do need both sudo privileges for adding the smb share as well as for running lazarus.

If i try mounting the smb share without sudo privileges, therefore with just your code, it outputs the following error message:

Code: Bash  [Select][+][-]
  1. This program is not installed setuid root -  "user" CIFS mounts not supported.

Without sudo privileges when running lazarus, lazarus cannot access the files because they are then owned by root (sude mount.cifs ...) instead of my user.

Do you have any idea on how i could mount my share without needing to use sudo privileges?

winni

  • Hero Member
  • *****
  • Posts: 2714
Re: Lazarus and SMB Share: Weird permission issues
« Reply #3 on: August 22, 2021, 05:21:22 pm »
Hi!

As any kind of mount is  system wide you always have to be root to mount a drive.

But you can put it into the /etc/fstab file .

Then every time your machine ist started the SMB shares are mounted.

About an entry in the fstab to mount a SMB share:

https://linuxize.com/post/how-to-mount-cifs-windows-share-on-linux/


Winni

mrmaxmusterman

  • New Member
  • *
  • Posts: 16
Re: Lazarus and SMB Share: Weird permission issues
« Reply #4 on: August 22, 2021, 05:23:57 pm »
Since i dont plan on always using / being connected to the samba share, putting it into my fstab file would be the best idea for me. But still thanks for all your help!

prof7bit

  • Full Member
  • ***
  • Posts: 141
Re: Lazarus and SMB Share: Weird permission issues
« Reply #5 on: October 03, 2021, 01:55:33 pm »
An alternative to using smb shares to move work around is to set up a bidirectional folder sync, using the software Syncthing. On all machines you will work on a totally normal local folder, but in the background it will synchronize the changes on this folder across all machines that share the same folder.

You can use this even across network boundaries: I have Syncthing also installed on my phone and have a dedicated folder called "shared-work" on my phone and on both PCs at home and at my workplace I have corresponding folders that are synced to this folder on my phone.

My phone is usually always where I am, so when I am at home my phone is in my home WIFI and happily synching with my home PC. On the next day when I come to the workplace my phone logs into the work WIFI, I start my work PC and a few seconds later it has updated the corresponding folder on the PC with everything I did the previous day at home. And once I get home, as soon as I turn on my PC it automatically syncs all my day's work to my home PC.

I don't even have to pull the phone out of my pocket, just by traveling back and forth between the two WIFIs it keeps these folders in sync, and it doesn't involve any untrustworthy cloud provider, its strictly confined to the configured private devices that share the common folder. By the same mechanism also the contents of my phone camera folder find their way onto my PC and my music and audio books find their way onto my phone, without needing to lift even one finger.

I highly recommend checking out this tool, its open source and available for all platforms.

I know I should not waste any of my free time with work, but I also spend some of my work time with stuff I didn't get done at home because I was busy with work.

And of course I also use git and push to a server, so I can't lose anything, even if I accidentally rm -rf in this folder and propagate the resulting destruction to all synchronized machines.

« Last Edit: October 03, 2021, 02:10:18 pm by prof7bit »

 

TinyPortal © 2005-2018