0

I am using some webpages in my remote server(RHEL 8) and the directory is var/www/html/project. In the project files I have a charts folder and the .js files inside that folder will be update time to time.

So I am always make permissions for that directory files to be what I wanted. I need to find a method to make the default permission as 777 for all these files.

So my target directory is var/www/html/project/charts and I need to set any files(even though it deleted and recreated inside) with the permission to read,write and execute by anyone?

As an example I need to make this directory as default permission as 777. Is this possible?

chmod 777 var/www/html/project/charts/

I have found answers there. But I am confused where to add 777. How to set default file permissions for all folders/files in a directory?

edublog
  • 83
  • 3
    The answer to the question you ask is "sticky bits". But: No. Setting a bunch of charting javascript files as 777 is definitely a bad idea in a served directory and you should not be doing it. There is a different solution to the problem you assume you'll be solving with this! So, why do you want to set the files' permissions to 777, although that definitely means that even the least privileged user (e.g. your web server scripts, a hijacked logging daemon…) can modify a file that then any high-privileged user would execute? (or if they wouldn't, why the 7?) – Marcus Müller Jun 14 '22 at 11:12
  • Not 777 exactly! I just need to make browser to read that file from the given path. @MarcusMüller – edublog Jun 14 '22 at 11:16
  • @ArtemS.Tashkinov where to add that number for the permission? setfacl 644 /? – edublog Jun 14 '22 at 11:17
  • You should consider using suExec for Apache2 or a similar mechanism if your webserver is nginx. – gerhard d. Jun 14 '22 at 11:21
  • @MarcusMüller, huh? AFAIK the sticky bit only controls who can delete files (in world-writable directories). It doesn't do anything about the permissions of new files. And while the setgid bit would affect the group owner of new files, it still doesn't affect the permissions. – ilkkachu Jun 14 '22 at 11:21
  • @ilkkachu see my question. I have already found this. All I need an example...May be very silly but I am confused.. – edublog Jun 14 '22 at 11:26
  • 1
    @edublog, (ok sigh I need more coffee). I don't think you can use numeric permissions with setfacl, and instead you have to spell the permissions out. (Partly because ACL entries come separately for users and groups, not in one single block.) setfacl -d -m u::rwx,g::rwx,o::rwx dir should do to set the default ACL to what basically amounts to 0777. But that will still be modified by the permissions given in the open() system call, so you probably get e.g. 0666 for text files etc. And maybe you should leave the write permission off for "others" – ilkkachu Jun 14 '22 at 11:35
  • @edublog but for reading you need neither the write (2) nor the execute (1) permission, so it should be 4, not 7! And: you shouldn't need to give that permission to every user, you need to give this permission to whatever user is running the webserver (which I honestly don't know on rhel, but chances are there are other folders where you can glimpse the "group" ownership off and use that instead) – Marcus Müller Jun 14 '22 at 12:00

1 Answers1

0

If directory permissions you want are really 777(which is very unlikely), than you need to set umask 0. It's more probable, that your question is wrong, and there is better solution for your permission problem, e. g. "the right" user (owner) and/or group and proper permissions for that.

d.c.
  • 887