How to use PutFile in windows shared folder - linux

Am trying to use NiFi's putFile to write into a windows mounted directory, first I used below command to mount the directory
sudo mount -t cifs //IP/export_path/ /home/exported_data/ -o username=user,password='pw',dir_mode=0777,file_mode=0777,nounix
and the file is written correctly but preceeded by dot . but then nifi throws an error stating that ...
Unable to remove temporary file /home/exported_data/.reject_2020-04-21.csv due to java.nio.file.AccessDeniedException: /home/exported_data/.reject_2020-04-21.csv: java.nio.file.AccessDeniedException: /home/exported_data/.reject_2020-04-21.csv
I also tried to set properties in putFile like Owner = nifi and Permissions = 777 but it didn't work
I think it could be related to permissions issue, but am not sure how to solve it

Related

Unable to create / edit files as non-root through Samba mount

I'm trying to setup a code-server (vscode in browser) instance and read/write from a mounted samba share. Unfortunately when I try to add a file it gives me an error that I do not have permissions to read/write to that folder. When I try to add files with the same credentials on Windows it does work though. This is the error that VSCode gives me:
Unable to write file
'vscode-remote://localhost:8080/home/user/repository/test'
(NoPermissions (FileSystemError): Error: EACCES: permission denied,
open '/home/gmetitieri/user/test')
If I sudo touch file.txt then the file will be created and added. I already used chmod and added full access to the folder but it still won't work. Is this a credentials thing or am I missing something?
I already tried this answer but it still doesn't let me write as non-root
Edit: This is the command I used to mount the drive (just with different folder names and IP address):
sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.examplecredentials //192.168.18.112/sharedDir /media/share
Considering "non-root through Samba", especially in new releases of OpenSuse (...15.3 -- 15.4), I do few movements into normal configuration panels (no sudo commands or anything technical).
Using Yast Firewall section -- For now (immediate solution):
I turn off the firewall, then see what you can turn on (after this) to keep the samba working with Microsoft Windows.
More details on how to do this with images on my website.
This happens when the directory on the Samba share does not have permission for non-root users.
In your smb4.conf file:
[test]
comment = Test share
path = /path/to/directory
force user = unixuser
valid users = sambauser
In this example, unixuser should be the owner of the files in /path/to/directory. The user logged into Samba in this example is a user called sambauser.

NiFi 1.10.0 - PutFile does not see the destination directory

We are facing a peculiar problem on one of our 2 environments. A PutFile processor throws the following error
PutFile[id=xxx] Penalizing StandardFlowFileRecord[uuid=xxx,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=xxx, container=default, section=1012], offset=94495, length=9778],offset=0,name=xxxxxxxxxxxxxxxx_PROD_20200513020001.json.gz,size=9778] and routing to 'failure' because the output directory /data/home/datadelivery/OUT/Test does not exist and Processor is configured not to create missing directories
After enabling the creation of missing directories, the error changes to:
Could not set create directory with permissions 664 because /data/home/datadelivery/OUT/Test: java.nio.file.AccessDeniedException: /data/home/datadelivery/OUT/TestPutFile[id=xxx...
Based on the error message one would think that it is an issue with file and folder permissions, however, the path /data/home/datadelivery/OUT/Test exists, and the nifi user can access and create files and folders in there as well (verified from the command line). The same folder permissions and ownership rights are configured on our DEV environment, where the PutFile processor works as expected. We could change the configuration to use a different location, but I'd rather find the root cause instead.
Where should I start debugging?
Thank you for your help in advance!
Kind regards, Julius
Strange issue, I would try to set full permission on the folder/file you want to write (ie chmod 777 + chown nifi:nifi + recursively), and see if the error is still there. If not it's kind of a start ...
Restarting the NiFi service solved the problem. The issue was that the Unix user (nifi) was modified months after starting the NiFi service. Most probably this was the reason the PutFile processor wasn't able to access a folder which the nifi unix user could.

NFS mount using CHEF on LINUX | permissions of directory not getting changed

I am trying to do an NFS mount using CHEF. I have mounted it successfully. Please find the below code.
# Execute mount
node['chef_book']['mount_path'].each do |path_name|
mount "/#{path_name['local']}" do
device "10.34.56.1:/data"
fstype 'nfs'
options 'rw'
retries 3
retry_delay 30
action %i[mount enable]
end
end
i am able to successfully mount and make an entry in fstab file. But, after mounting the user:group for the mount linked is changing to root:root , which i was not expecting.
i want to use myuser:mygroup as owner:group. I tried changing the same using chown command but am getting permission denied issue
request some guidance
As mentioned in the comment, this is not something Chef controls per se. After the mount, the folder will be owned by whatever the NFS server says. You can try to chmod the folder after mounting but that's up to your NFS configuration and whatnot as to if it will be allowed.

After mounting netapp to directory the inside directory doesn't exist

I am trying to mount our netapp but after mounting im getting weird result.
I will give the weird results. We are trying to mount a netapp DFS share.
First i tried to mount without a specific domain.
mount -t cifs -o rw,mand,user=<user>,password=<passowrd>,noserverino //ip/dfs <directory path>
The mount worked but i couldn't access the inner directories.
The message:
bash: cd: : No such file or directory
Then i tried to mount with specific domain.
mount -t cifs -o rw,mand,user=<user>,password=<passowrd>,noserverino,domain=<domainName> //ip/dfs <directory path>
The mount also worked it but now when i tried to access the directory i got the message: **
bash: cd: : Permission denied
I also know it should work because i was able to view the share via a windows 7 station and it worked perfectly.
Also, i used the file manager of gnome and used "connect to server". It also worked and i could access the inner directories.
If you need more information let me know, and thank you for the help.

Tired of creating /run/postgresql and setting read and execute writes after every reboot

I'm running Arch Linux, I installed PostgreSQL as any other arch package. I'm running postgres with a local database located in my user directory. (postgres -D /home/user/data/) When I do so, I get the error FATAL: could not create lock file "/run/postgresql/.s.PGSQL.5432.lock": No such file or directory. Creating the directory /run/postgresql and giving the postgres user access solves this problem
$ sudo mkdir /run/postgresql
$ sudo chmod a+w /run/postgresql
however I'm tired of writing these commands every time I reboot, as /run gets cleared when rebooting. I could write a script to execute these commands, but I feel like I'm doing this the wrong way to begin with. Is there any way I could let postgres create its directory itself, or maybe have it not use /run/postgres for it's lock files in the first place?
Postgres creates the lock file in /run/postgresql by default.
From the manpage:
-k directory
Specifies the directory of the Unix-domain socket on which postgres is
to listen for connections from client applications. The default is
normally /run/postgresql, but can be changed at build time.
Use -k directory to tell postgres to use a different directory.
Run your command as postgres -k /tmp -D /home/user/data/.
Solution 1 (By managing temporary directory /run/postgresql, /var/run/postgresql)
Directory /run/postgresql is a temporary directory. Path
/var/run/postgresql is usually a symbolic link to /run/postgresql.
systemd-tmpfiles is mechanism to manage such temporary files and directories. systemd-tmpfiles creates temporary directories during
boot and sets their owner, group and permissions. It may read configuration files in three different locations. Files in
/etc/tmpfiles.d override files with the same name in
/usr/lib/tmpfiles.d and /run/tmpfiles.d.
We can create directory /run/postgresql on the fly at boot time using systemd-tmpfiles mechanism by creating postgresql configuration file as below
echo "d /run/postgresql 0755 postgres postgres -" > /usr/lib/tmpfiles.d/postgresql.conf
Solution 2 (By relocating PostgreSQL lock file location)
Another way to fix the issue is to relocate the PostgreSQL lock file
location. We can do so by using below query
ALTER SYSTEM SET unix_socket_directories='<any-existing-path-with-valid-permissions>, /tmp';
Here we can provide any path for PostgreSQL lock file which is already present on the system and have required permissions to manage lock files by postgres user.

Resources