Operating System - HP-UX
1833864 Members
2432 Online
110063 Solutions
New Discussion

Is it possible to allow dir creation but NOT file creation in a dir

 
V. Nyga
Honored Contributor

Is it possible to allow dir creation but NOT file creation in a dir

Hi gurus,

is it possible to allow a user to create a directory in one directory but disable file creation in this dir?

Volkmar
*** Say 'Thanks' with Kudos ***
13 REPLIES 13
Dave La Mar
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Why would not changing ownership and removing write priviledge not work?

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
V. Nyga
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Hi,

because they shall create directories there

V.
*** Say 'Thanks' with Kudos ***
Dave La Mar
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Now I've got the picture. Tough one since to Unix a directory is simply a file as well.

Best of luck on this.

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
Robert-Jan Goossens_1
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Hi Vo,

No not possible, if you (the user) is allowed to write inside a directory unix will allow the creation of files and directories.

Education of the users is only option :-)

Gruss.
Robert-Jan
Dave Hutton
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Probably ugly, but you might be able to sudo mkdir as root, so the permissions on the directory they wouldn't have.

Only way I think it may be remotely possible.
Peter Godron
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Volkmar,
quick, but not very permanent way is to set the umask of user to 222.

That way they can create the dir (r-xr-xr-x), but within the dir they can not create a file as no write permission.
They user however could override by doing a chmod on the dir first.
V. Nyga
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Well RJ,

then any good suggestions for an applicable user education? *49*

;-) V.
*** Say 'Thanks' with Kudos ***
Dave La Mar
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

"then any good suggestions for an applicable user education? *49*"

Well, a bit nasty, but we have had to resort to this in the past; run a cron job (or daemon) to check the directory for regular (and binary) files periodicaly, change ownership and permission.
This forces the user to come to you to help release his/her "unauthorized" file.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
V. Nyga
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

dl,

not bad - do you have more informations (cron command)?

V.

*** Say 'Thanks' with Kudos ***
Court Campbell
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

I like the sudo idea. make the directory owned by some account other than the users. this keeps them from creating any file without using sudo. then write a script to mkdir under that directory. ex. put the following in file:

#!/bin/sh
sudo -u dir_owner mkir /path/to/dir/${1}

then just have the users run that script when they need to make a directory under that specific directory.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Dave La Mar
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Ok.
Here's a down and dirty that can be edited to fit your needs.

for i in `ls /directory/path/`
do
if [ -f $i ]
then
chown someone:whatever /directory/path/$i
chmod 400 /directory/path/$i
fi
done

Best of luck.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
V. Nyga
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

Thanks all

sudo will not work, because the directory creation is made by an application (not mine).
Nevertheless it's a nice idea ...

This application is also the reason for my question - it creates the (sub-)dir's for the user, but sometimes something fails, so the application lays the files in this dir instead of creating the subdir and laying the files in the subdir.
Maybe the vendor can do something ...

Thanks again!
*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: Is it possible to allow dir creation but NOT file creation in a dir

see above
*** Say 'Thanks' with Kudos ***