Recent

Author Topic: What controls open network connections, Windows and Linux.  (Read 5652 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 8571
Re: What controls open network connections, Windows and Linux.
« Reply #15 on: April 02, 2022, 04:28:31 pm »
I've attached 2 screen shots using OpenDialog. Windows shows network drives but Linux not.

I'm running the standard LinuxMint 20. So how do I access network files from within Lazarus ?

What protocol are they made available by, and where are they mounted?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

marsheng

  • Jr. Member
  • **
  • Posts: 53
Re: What controls open network connections, Windows and Linux.
« Reply #16 on: April 02, 2022, 04:52:39 pm »
I'm new to Linux. I've used samba in the past to connect machines, but I'm not sure what Mint uses as default.

If I use Mint's file explorer and connect to a network drive, then OpenDialog finds the mapping. See attached. 

So it looks like I will need to add something on boot to add this mapping.

Still, it looks like browse network is not an option from withing Lazarus. 

PascalDragon

  • Hero Member
  • *****
  • Posts: 6387
  • Compiler Developer
Re: What controls open network connections, Windows and Linux.
« Reply #17 on: April 02, 2022, 08:51:58 pm »
Still, it looks like browse network is not an option from withing Lazarus.

This has nothing to do with Lazarus. The dialogs are provided by the widget set and if neither Qt nor GTK provide direct access to mounted network drives then you're simply out of luck. The design philosophy of Windows and Linux is simply different in that regard.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8571
Re: What controls open network connections, Windows and Linux.
« Reply #18 on: April 02, 2022, 09:57:26 pm »
This has nothing to do with Lazarus. The dialogs are provided by the widget set and if neither Qt nor GTK provide direct access to mounted network drives then you're simply out of luck. The design philosophy of Windows and Linux is simply different in that regard.

I don't think it's possible to dismiss it that brusquely.

Now I grant that the typical desktop file management app has plugins etc. that are tailored for specific network protocols, but I've just enabled NFS access to a remote share in my fstab and Lazarus's "File Open" dialog(u)e now shows the name of the remote system in the "Places" pane... twice, in actual fact, with an "operation permitted for root only" error when one (but not the other) is clicked on.

If I go to Firefox's "Open File", I see the remote system's name once and clicking on it shows the available files.

I've not really explored the SMB (Samba) situation since OP's vague as to what he's using.

Lazarus 2.2.0 gtk2, Debian 10, x86_64 KDE desktop.

Next day: the duplicated remote name has disappeared, leaving only the one that complains about no root privilege. Lazarus built for Qt doesn't have anything equivalent in the dialogue.

MarkMLl
« Last Edit: April 03, 2022, 09:07:06 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 3797
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #19 on: April 03, 2022, 01:02:46 am »
If I use Mint's file explorer and connect to a network drive, then OpenDialog finds the mapping. See attached. 

marsheng, that is what I explained to you a couple of days ago. If the network drive has been mounted, TOpenDialog finds it.  If its not mounted, it does not exist as a file system on the system and therefore cannot be found by TOpenDialog and friends.

I explained to you that you can search for and mount a drive in your own code but that will involve writing some code.

Or you establish the connection before opening your app.

By the way, its not a case of what eg Linux Mint uses as a default connection, the protocol to be used is established by the server. My guess is you have a 'server', probably a Windows box, that is offering a "windows file share", that means its SMB. The tool you need to use, as I mentioned, is smbclient.

This is not a LCL bug, its more something that LCL does not do. It would be good if it did offer you a component that does it but no one has been sufficiently motivated to write one yet. Maybe you, with the need, will write one ?  Thats how OpenSource works.

@PascalDragon - the TOpenDialog family do provide access to mounted file systems, the OP wants the tools to find and mount a remote FS that is currently unmounted.

As I mentioned, it could be implemented with a "network" button or link that would scan, using nominated protocols, the local network, offer the user a list and then get required credentials and mount, using either GVFS, smbclient, whatever KDE uses, etc.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

marsheng

  • Jr. Member
  • **
  • Posts: 53
Re: What controls open network connections, Windows and Linux.
« Reply #20 on: April 03, 2022, 01:22:47 am »
>> If the network drive has been mounted, TOpenDialog finds it.

Quite correct, but being new to Linux, I'm still finding my way. I didn't mount the drive, file explorer did it for me.

This is quite different to windows where you perform map network drive. It is an operation I chose to do. 

So my next step is to find how to mount drive on boot. Should not be to difficult.

Thanks Wallace.
« Last Edit: April 03, 2022, 03:16:48 am by marsheng »

MarkMLl

  • Hero Member
  • *****
  • Posts: 8571
Re: What controls open network connections, Windows and Linux.
« Reply #21 on: April 03, 2022, 08:35:52 am »
Quite correct, but being new to Linux, I'm still finding my way. I didn't mount the drive, file explorer did it for me.

It is not "File Explorer", generally speaking there is no such thing on Linux.

It is some part of your desktop environment, and the details will vary by distro (and it is fairly common for systems to allow the user to select which one he wants at login).

And the remote filesystem is not necessarily mounted, some desktop environments access remote resources directly.

If the remote filesystem is /not/ mounted, then it's unreasonable to expect Lazarus or apps built using the LCL etc. to see it.

It's also unreasonable to expect an arbitrary program to control mounts or unmounts: unix is more restrictive of this than Windows.

So it's really down to you to find your way around your system. But I also must emphasise that you need to read all questions and suggestions once you've started a topic: earlier messages give you some useful hints which I suspect you've not really absorbed.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Warfley

  • Hero Member
  • *****
  • Posts: 2054
Re: What controls open network connections, Windows and Linux.
« Reply #22 on: April 03, 2022, 01:50:46 pm »
So my next step is to find how to mount drive on boot. Should not be to difficult.

How to mount an SMB share: https://linoxide.com/howto-mount-smb-filesystem-using-etcfstab/
Code: Bash  [Select][+][-]
  1. mount -t cifs -o vers=1.0,username=user_name //server_name/share_name /mnt/data
Note that the website say you should use sud (i.e. sudo mount ...) but because you are going to execute this on the startup, it will be executed as root anyway, so no need for sudo

For running a script/command on startup, there are multiple ways to do so on linux, see https://www.simplified.guide/linux/automatically-run-program-on-startup#automatically-run-program-on-linux-startup-via-systemd
For you relevant are only the first 3 methods, as the other ones are not executed on boot but rather on user login/creation of the user shell. The third option System V rc.local is probably the easiest, but I don't know how wide the support for this still is, as most Linux distros are using systemd.
The first option systemd is probably the "intendet" way for most linux distros, as most linux distros are based on systemd, but it is also the most complicated one (as systemd always makes things more complicated).
I personally would go with the second method the cron job, because it does not rely on your distro being systemd or sytem V, but only requires cron to be installed and is also very easy to do

PS: if you want to search or lookup the SMB shares in your network, see this: https://superuser.com/questions/1492010/finding-all-samba-shares-in-local-network

dbannon

  • Hero Member
  • *****
  • Posts: 3797
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #23 on: April 04, 2022, 01:28:08 am »
Code: Bash  [Select][+][-]
  1. mount -t cifs -o vers=1.0,username=user_name //server_name/share_name /mnt/data

I thought Linux does not support SMB 1.0 any more because of security concerns ?  I am away from home now and away from any SMB shares so cannot test...

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dsiders

  • Hero Member
  • *****
  • Posts: 1608
Re: What controls open network connections, Windows and Linux.
« Reply #24 on: April 04, 2022, 08:46:26 am »
Code: Bash  [Select][+][-]
  1. mount -t cifs -o vers=1.0,username=user_name //server_name/share_name /mnt/data

I thought Linux does not support SMB 1.0 any more because of security concerns ?  I am away from home now and away from any SMB shares so cannot test...

Davo

Samba 4.11 dropped it. Microsoft dropped it for Windows 10.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6387
  • Compiler Developer
Re: What controls open network connections, Windows and Linux.
« Reply #25 on: April 04, 2022, 01:31:36 pm »
@PascalDragon - the TOpenDialog family do provide access to mounted file systems, the OP wants the tools to find and mount a remote FS that is currently unmounted.

I'm aware. The point is that it's not part of the LCL's control whether the open dialog provided by the widgetset is able to display mounted network drives (for example it might only display mounted local drives separately) or whether the dialog would be able to display unmounted, but discovered network shares.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8571
Re: What controls open network connections, Windows and Linux.
« Reply #26 on: April 04, 2022, 02:43:58 pm »
[quote author=dbannon link=topic=58913.msg439407#msg439407 date=16489405
I'm aware. The point is that it's not part of the LCL's control whether the open dialog provided by the widgetset is able to display mounted network drives (for example it might only display mounted local drives separately) or whether the dialog would be able to display unmounted, but discovered network shares.

So far, it looks as though the gtk2 widget lists any server that has a mountpoint in /etc/fstab, irrespective of whether there's a live session to it. The Qt dialog(u)e doesn't have the equivalent pane.

I'd be surprised if GTK was prepared to get directly involved in setting up shares because (a) in the general case it involves elevated permissions and (b) GTK- as an architectural decision- flatly refuses to cooperate with setuid-root etc. programs.

So I think OP's out of luck as far as setting up new connections is concerned.

But I'd expect the LCL and Firefox file open dialogues to behave similarly, i.e. show the content of mapped shares.

I'm taking a bit of a prod at this from a user's perspective, since it raises a few questions that I need to be able to answer.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 3797
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #27 on: April 05, 2022, 02:00:29 am »
...
I'd be surprised if GTK was prepared to get directly involved in setting up shares because (a) in the general case it involves elevated permissions and (b) GTK- as an architectural decision- flatly refuses to cooperate with setuid-root etc. programs.

Well, GVFS is a close friend of GTK and is the tool of choice for most (but not all) distros to "network enable" their file managers. KDE/Plasma based ones being the notable exception.  Its seems to me that it would be possible to call gvfs methods but we'd have to also cover KIO. And the sensible place for it to appear is in the TOpenDialogs. So, when you think of it like that, it does sound a lot like it should be a OS widget set responsibility.

EDIT: removed silly question about QT doing a better job, it does not.

Davo
« Last Edit: April 05, 2022, 08:41:56 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 8571
Re: What controls open network connections, Windows and Linux.
« Reply #28 on: April 07, 2022, 12:37:36 pm »
I'm taking a bit of a prod at this from a user's perspective, since it raises a few questions that I need to be able to answer.

I had to refresh my memory about working with shared files, in particular SMB tends to be a bit of a moving target.

Working on a Linux client with a Linux server, remote directories already mounted using either SMB (v2.0) or NFS (v4) show up correctly in the gtk2 "Places" pane (i.e. with a name from /stc/fstab rather than just as a local directory), although I suspect that I might be seeing the NFS-mounted one also appear as a dummy with no content and that this doesn't time out after a couple of days.

There's an obvious gotcha for the inexperienced user in that a drive/directory might appear empty if the name filter at the bottom of the dialog(u)e is only looking for .lpr, .pas and so on

Lazarus compiled for Qt5 has no equivalent to the Places pane, but remote directories etc. can be seen by looking at their mountpoints.

Other widgetsets, particularly Windows, untested. However I don't think there's a fundamental problem with Lazarus, subject to user expectations as to whether an arbitrary app should be able to set up or tear down shares.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018