-1

My Environment is OSX BIG SUR.

For space reasons, I need to move files from my Hard disk to a NAS (on my local network). The current applications accessing these files (en read mode) were developed in Java.
I suppose I should use a Mount command in programs with the SMB protocol, but how to do this without be prompted for password with the SUDO command ? So I'm looking for some examples.

  • While the initial reason comes from programming, this question seems to be general computer usage question (https://superuser.com), a Mac question (https://apple.stackexchange.com/) or maybe even a "server" question (https://serverfault.com/, but I doubt it). [This question](https://apple.stackexchange.com/questions/329392/how-to-escape-password-for-smb-mount) or [this one](https://serverfault.com/questions/367950/secure-way-to-mount-a-password-protected-cifs-share-in-mac) might lead you towards the right solution. – Joachim Sauer Dec 12 '20 at 09:41

1 Answers1

1

You have a few ways to go:

Have java execute the smb mount command

This is a walking disaster; you don't want your java process to gain root privileges to do this.

Have java be an smb client

Possible... use JCifs-ng. The docs are lacking, and this would have been a lot simpler if it had integrated into the new files / filesystem API, but it doesn't. You'll have some coding to do.

Learn sysops

All you really need is for the OS to have that samba share mounted someplace and then, to your java process, it's all just files on a filesystem. Don't make the smb mount happen in java, ensure it's already set up before your java process even starts.

rzwitserloot
  • 85,357
  • 5
  • 51
  • 72