# can't delete 777 files via SFTP



## wonslung (Oct 18, 2009)

I have a machine with a basic setup, it has 3 users.  one of the users has everything set at 777 so anyone should be able to delete it...


shouldnt' anyone be able to delete folders that are 777?

The owner has no problem deleting the files...this is making me feel quite stupid.


----------



## honk (Oct 18, 2009)

Maybe there are flags set? http://www.freebsd.org/doc/handbook/permissions.html


----------



## DutchDaemon (Oct 18, 2009)

Folders with permissions 777 can only be deleted by someone else if the parent folder allows it.

Example:
/home/user = 755
/home/user/tmp = 777
/home/user/tmp/temp = 777

A different user can only delete /home/user/tmp/temp, not /home/user/tmp. 

Note: removing a directory is performing a *write* action in its *parent* directory.
Note also: any file in /home/user/tmp/temp can be removed, even if it has permissions 600; rm will ask to confirm the override, but it will be granted.


----------



## honk (Oct 18, 2009)

Oh, we are talking about (empty) directories... So forget about the flags, they apply to files, not directories.


----------



## DutchDaemon (Oct 18, 2009)

chflags apply to directories as well as files (which is why chflags has a -R switch). E.g. [cmd=]chflags schg /tmp[/cmd] will flag the directory only, whereas [cmd=]chflags -R schg /tmp[/cmd] will flag /tmp and contents, and [cmd=]chflags schg /tmp/file[/cmd] will only flag that file. Flags can be seen using the -o switch to ls.


----------



## wonslung (Oct 18, 2009)

ok, i wasn't aware of that rule, thanks dutch, that was the problem.

all the 777 dir's lived in a 755 dir


----------

