Bookstore

Recent

Author Topic: Tsavedialog & permissions in linux  (Read 393 times)

andyH

  • New Member
  • *
  • Posts: 34
Tsavedialog & permissions in linux
« on: March 02, 2020, 03:03:47 pm »
Got an app that opens a save dialog prompting the user for a filename. My code checks permissions on the destination (SaveDialog.Filename) after SaveDialog.Execute and raises a warning on 'permission denied' if the user is trying to save to a destination typically owned by root. Unfortunately within the savedialog is an option to create new folder, without the correct permissions the outcome is the screenshot.

Is there an easy way to trap this error in the same way I can test on SaveDialog.Filename after SaveDialog.Execute?

I can work round the problem by running the app as root with pkexec, but the resultant files end up owned by root. I can always do a chmod or chown on completion, but rather not do this. Running as root also has the disadvantage that testing becomes more cumbersome with the lazarus ide (have to test outside lazarus or run lazarus with pkexec - means all my sources files end up owned by root  :()

Leledumbo

  • Hero Member
  • *****
  • Posts: 8162
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Tsavedialog & permissions in linux
« Reply #1 on: March 25, 2020, 02:00:58 am »
The implementation is widgetset dependent. On qt, for example, the dialog simply disables the create folder button while on gtk is exactly as you described. Upon testing with zenity, it pops up the same error dialog so the error handling implementation is actually within the widgetset itself, not even in LCL implementation of it.

MoCityMM

  • Jr. Member
  • **
  • Posts: 73
Re: Tsavedialog & permissions in linux
« Reply #2 on: March 25, 2020, 03:51:55 pm »
Would adding the user to the wheel group for 'sudo' permissions fit your needs? It would avoid 'root' being the file owner issue.
« Last Edit: March 25, 2020, 03:55:05 pm by MoCityMM »

lucamar

  • Hero Member
  • *****
  • Posts: 2572
Re: Tsavedialog & permissions in linux
« Reply #3 on: March 25, 2020, 04:47:11 pm »
You say your app just shows a warning if the user lacks permission enough to save to the file so, what's wrong with the current behaviour of the dialog? All it does is basically the same you do: show a warning about lack of permission to create a new folder.

If that's all you need, I wouldn't worry about it.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

andyH

  • New Member
  • *
  • Posts: 34
Re: Tsavedialog & permissions in linux
« Reply #4 on: March 25, 2020, 05:14:47 pm »
Sorted this about three weeks ago, shortly after I posted. My app now runs as root so it will save anywhere. It was too confusing for newbies and then to have to explain how to chown or chmod to get read/write permissions.

MoCityMM

  • Jr. Member
  • **
  • Posts: 73
Re: Tsavedialog & permissions in linux
« Reply #5 on: March 25, 2020, 08:27:28 pm »
Weird... wonder why it was showing as 'New' on my end? Internet ghosts.

lucamar

  • Hero Member
  • *****
  • Posts: 2572
Re: Tsavedialog & permissions in linux
« Reply #6 on: March 25, 2020, 10:15:54 pm »
Weird... wonder why it was showing as 'New' on my end? Internet ghosts.

"New" means new posts in the thread, which this one has starting with Leledumbo's and going on to the rest :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

MoCityMM

  • Jr. Member
  • **
  • Posts: 73
Re: Tsavedialog & permissions in linux
« Reply #7 on: March 26, 2020, 03:35:02 pm »
So... no for the Internet Ghosts thing?  :o

Wasn't watching the post dates on the discussion...