this post was submitted on 16 Jul 2024
19 points (91.3% liked)

Linux

48328 readers
502 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Hi,

I've noticed something quite odd, but I don't know if the problem come from Linux itself or nginx..

In order to grant nginx access to a directory let say your static see: https://stackoverflow.com/questions/16808813/nginx-serve-static-file-and-got-403-forbidden

These parent directories "/", "/root", "/root/downloads" should give the execute(x) permission to 'www-data' or 'nobody'. i.e.

but it seem not only the direct parent need to be given XX5 but all the chain

for example

example
└── sub1
    └── sub2
        └── static

it seem you need to set allow others to read and execute 5 all the parents example, sub1, sub2 Why is that !?? I've found it so akward and unsecure ! is there a workaround ?

Thanks.

top 4 comments
sorted by: hot top controversial new old
[–] bionicjoey@lemmy.ca 23 points 4 months ago

It's a property of how Linux permissions work when applied to a directory.

See this SE post for more info: https://unix.stackexchange.com/a/21252

[–] Markaos@lemmy.one 22 points 4 months ago* (last edited 4 months ago)

~~Probably a bit of a TL:DR of the other answer, but the short answer is:~~ the execute bit has a different meaning for directories - it allows you to keep going down the filesystem tree (open a file or another directory in the directory). The read bit only allows you to see the names of the files in the directory (and maybe some other metadata), but you cannot open them without x bit.

Fun fact, it makes sense to have a directory with --x or -wx permissions - you can access the files inside if you already know their names.

Edit: not a short answer, apparently

[–] scott@lem.free.as 2 points 4 months ago

The execute bit on directories allows for traversal of the directory (i.e. allows you to cd in), while the read bit allows for listing the directory contents (e.g. ls).

[–] Rick_C137@programming.dev 1 points 4 months ago

Thank you all !

Indeed setting execute perm on example, sub1, sub2, static

The program/user have now access to the directory.

In order words all the parents directory need at least execute in order to have access in the targeted directory...

Now I gave 751 for static. Meaning than others (here nginx) cannot list the files within. But never the less it works
the static files are appearing when requested (HTTP) but forbidding nginx to list the directory is changing something ? (performance/security)

Thanks