Is it possible to automatically have the same permissions as the directory when creating and copying files?

Asked 2 years ago, Updated 2 years ago, 48 views

On Linux, assume that the directory permissions are as follows:

drwxrwxr-x2 root test 9999 July 12 11:52


when a file is created or copied to a directory below this file Is it possible to automatically have the same permissions as the directory?

If anyone knows how to set it up, please let me know.

linux

2022-09-29 21:26

5 Answers

Ask /usr/local/bin to install your own tool and use it for all users

For example, when building and installing GNU-related tools normally,

$./configure [options]
$ make
$ sudo make install (or su make install)

The rootowner binaries should then be copied to /usr/local/bin with -rwxr-xr-x privileges (and more appropriate privileges) so that all users can run them.

So if you want to write the answer to this question,

Most GNU tools are automatically authorized by the installation script, so you don't have to do anything.

Non-GNU tools, such as self-made shell scripts, installed in /usr/local/bin and used by all users

$cp myscript/usr/local/bin/myscript
$ chmod [Appropriate Permissions] /usr/local/bin/myscript
$ chown [appropriate user] /usr/local/bin/myscript

It will be.Where [appropriate] is case by case and not one correct answer.

What is appropriate is determined by security policies, and if you want to start the discussion
- Include /usr/local/bin in PATH or, if so, where to put it
- sudo to the general public
- /usr/local/bin to allow general users to write files to
- Whether to allow the use of wild-built tools (e.g., not including packages)
- Allowing others to use tools created by a particular user
It will start from around.

That's a policy that the organization should operate, so it's better to discuss and decide.


2022-09-29 21:26

Well, let's leave it alone whether it's good or bad, or whether it's bad or not.

if you want to achieve what is described in the title Monitor specific directories in inotify-tools and
In chown, why don't you change the permission to specify per parent directory?

...and I noticed that there was already an article in qiita.
If I paste the event on CREATE or MOVED_TO, wouldn't it be possible to use it other than downloading it?

I don't know the details, but
Do you want to play with root and make it a permission for another process?
I always touch root and it would be terrible if an accident happened...
Do you want to create a user for upload and give them permission to execute the process...


2022-09-29 21:26

Doesn't it matter what kind of permissions you have to take a step further to "You can do it by having the same permissions as a directory"?

It also leads to the fact that I commented that

Depending on the possible/non-executable reasons, it may be resolved by specifying chmodg+sdir for the directory.
g+s (setgid) When you create a file in a directory, the group of files that are created takes over the value of the directory.For questions, the directory is the test group, so the files created are also the test group.

Even if you can't solve it directly, you might be able to design a group permission with the assumption that the group will be taken over.

After all, we have no choice but to sort out the problem, identify the cause, and solve it, and even if we ask a dark question, we can only answer the right answer.Also note that it can be closed as "Question is not clear".


2022-09-29 21:26

If the purpose is to "make sure that the /usr/local/bin command is executed even if you change the user", I think the install command should be used when installing the command on /usr/local/bin.By default, you can specify permissions with the -rwxr-xr-x option.


2022-09-29 21:26

What I really want to do is to run the /usr/local/bin command even if I change the user

$sudo chmod+x/usr/local/bin/*


2022-09-29 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.