Drupal 8: How to use private file system for node - linux

Scenario:
I want to create a field field and attach it to a content type and willing to store the uploaded file into private file system.
I am using Drupal 8.6, php 7.1 and linux
My default file system is public, but for that specific file field, I want to store it, into private folder. So I created a folder outside my document root folder e.g. /var/www/private and set that into settings.php.
The purpose of this field is that, to allow, certain logged in users to able to download and restrict other.
I googled a lot, there are lot of suggestions, none worked or pointed the issue I am facing. I set the file directory as "dcouments/[date:custom:Y]-[date:custom:m]".
Now when i trying to upload a file, it gives me error like, folder "documents/2018-09" can't be created and upload failed. Surely it seems permission issue, i gave "private" folder to "rwxrwxr-x" permission, but its not working. Strangely it works in windows system.
Could anyone suggest, how to fix that? Whats going wrong there?
thanks in advance!

Permissions you defined may just be fine. The problem maybe that the private folder doesn't belong to www-data neither to its group. Check the real owner of the folder and set it to www-data. This should do the trick.

What I actually find out that, the web-server don't have permission to create sub-directory in the private folder.

Related

How do you allow IIS to access a symlink folder?

I have a two webservers, on each webserver in the C:\inetpub\logs\LogFiles I have created a symbolic link to the other servers log file folders, so essentially I can be logged in to one of the webservers and see the logs on both servers in one place. This works perfectly.
I am building a webpage to make the log files available via a webpage, the code simply goes to the C:\inetpub\logs\LogFiles directory and lists the files in each sub folder, i.e. W3SVC1 (the local folder) and webserver2-w3svc1 (the remote log folder).
For the local folders it works fine, but I am getting the "access denied" error when trying to call Directory.GetFiles on the symlinkd folder. I suspect this is some sort of permissions error, but I tried giving the symlinkd folder full permissions to "everyone" but I still get the same error.
Is this something to do with the fact that when I created the symlinkd I had to enter the username and password of the webserver2, and these credentials cannot be accessed/used by IIS when trying to get access to the folder?
Is there anything I can do allow IIS to access the contents of this symlinkd folder?
I don't think you need to use a symlink, you can create a virtual directory mapping to that directory in IIS, just map it to the target path. In IIS, right click on the website and select Add Virtual Directory.
For more information, please refer to this official document.
After much experimentation, the only way to do this is as follows:
Create a new user on the computer.
Run the AppPool in IIS under this new users' identity as opposed to the default IUSR account.
Give the folder you are sharing permissions to this user AND 'share' this folder with the new user.

How to freeze a folder in linux?

I wanna to freeze a folder in red hat so nobody (even root) can not add file into the folder or change files that exist in the folder already, i tried to make folder read only but this does not work and root user can add files normally as before, please somebody help me to solving this problem.
Create a filesystem in a file (eg: an iso file) containing the files you want in the directory then use a loopback mount to mount it read only onto the directory.
Anybody who tries to modify the filesystem normally (including root) will get a "read-only filesystem" error.
No. By design, in Linux, root ignores existing permissions on all entities. However, what you can do is encrypt files so that they can't be read and can't be modified by those who don't know the key. You can't prevent new files from being added, but with both encryption and decryption keys private, you can easily verify if any file is valid.
This also means you can't have either key on your computer!

Preventing user accesing Node.js application code

Assuming a user has access to all files within the public_html directory. Doesn't this mean they could have access the a node.js application code within it? Surely this is a massive security risk.
What is the normal way of handling this? Would you user files permissions to restrict the file, or place the node directory outside of the public_html and reference it somehow? If so, how?
Many thanks for any answers given!!
Yes your server scripts should live outside public_html. Only files that you want to make available to the public should be placed under public_html.
Your node server script can refer to the "./public_html" or "../public_html" folder if it is stored in or above the folder containing the script, or it can even refer to "/path/to/public_html" if it is stored elsewhere on your filesystem.

vftpd issue regarding file permissions and user rights

My system is:
Ubuntu 10.04 / Apache2
The question is related to the sofware vftpd - an ftp server for linux (https://security.appspot.com/vsftpd.html)
I have installed vftpd and it works fine. I am having an issue though trying to understand why users are able to delete files which are owned by root. I have set up the ftp server with the option "local_enable=YES" and also "chroot_local_user=YES" so that the users cannot navigate outside their home directory.
The strange thing is that if a file is owned by root, the ftp users are able to delete it. Is a user able to delete any file in the home directory regardless of who owns it?
I want to prevent users from being able to delete files, or allow other users to only have read access to the home directories of other users.
If anyone knows the vftpd software and can help i´d be most grateful,
yours,
Rob
Have you checked which is the chmod of the files? If all files belongs to the same group, and the group have read and write privileges, any user can modify the files through ftp.

KohanaException : Directory APPPATH\cache must be writable

i am trying to run a project of kohana-3 in wamp server but getting following error
Kohana_Exception [ 0 ]: Directory APPPATH\cache must be writable
please help.
Previously this was working fine.
You must set your cache folder to be writable.
Bare in mind that usually in WAMP the PHP user is 'nobody' which doesn't have access to your folders, therefore you must set your folders to be writable.
Check whether the file actually exists (application/cache), this folder comes empty with Kohana, and some versioning systems and other software usually delete and ignore empty folders.
If it does not exist, create the folder and insert a blank file in it (ie, empty.txt) if the error persists, give the appropriate permissions.
Oh yeah, I read an answer from someone yesterday but I only figured it out today. What I did was this:
Go inside application/
Create a new folder cache/
Go inside cache/
Create a empty textfile. (I created empty.txt)
Then thats it. hope it helps

Resources