Re: rm files owned by root?

2005-01-03 Thread Florian Weimer
* Thomas Bushnell:

 Only if it's empty.  You could rename it to /tmp on most
 installations, where it would be deleted after the next reboot.

 Both wrong.  

 Removing a directory requires write permission on the directory
 itself, because you have to delete the . and .. links inside the
 directory.

Apparently not true.

 Renaming a directory requires write permission on the directory if its
 parent changes, because you have to rewrite the .. link.

This indeed requires write permissions on the target directory, at
least on ext3.  It would be interesting to try it on a file system
which doesn't have the . and .. entries.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2005-01-02 Thread Ulrich Fürst
Bernd Eckenfels [EMAIL PROTECTED] wrote: 
 This is a Unix FAQ. You can delete any file if you have write access
 to the directory. Actually you dont delete the file, you remove the
 link to the

So if my /home/ is 775 and root.users and I'm in the group users I can
delete everybody's home directory?

Ulrich


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2005-01-02 Thread Florian Weimer
* Ulrich Fürst:

 Bernd Eckenfels [EMAIL PROTECTED] wrote: 
 This is a Unix FAQ. You can delete any file if you have write access
 to the directory. Actually you dont delete the file, you remove the
 link to the

 So if my /home/ is 775 and root.users and I'm in the group users I can
 delete everybody's home directory?

Only if it's empty.  You could rename it to /tmp on most
installations, where it would be deleted after the next reboot.



Re: rm files owned by root?

2005-01-02 Thread Bernd Eckenfels
In article [EMAIL PROTECTED] you wrote:
 So if my /home/ is 775 and root.users and I'm in the group users I can
 delete everybody's home directory?

You need write access to the /home dir, then you can delete other uses
homes. But to delete a directory, it must be empty. And you cant empty it if
you cant get into it or have write access inside.

However you can delete empty dirs and files if you dont own them or have
write access to them, yes.

Greetings
Bernd


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2005-01-02 Thread David Mandelberg
Bernd Eckenfels wrote:
 But to delete a directory, it must be empty.
That's not completely true. You can unlink() (delete) a directory without it
being empty. rmdir won't do it, but it's possible. Note: don't do this unless
absolutely necessary, and always remount the volume ro and fsck it after
unlink()ing a non empty directory.



-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/CM$/CS$/CC/IT$/M/S/O/U dpu s+:++ !a C++$C+++$
UB+++$L$*-- P+++$ L+++()$ E-(---) W+++$ N(+) o? K-
w--(---) O? M V? PS++@ PE-@ Y+@ PGP++(+++)$ t? 5? X? R tv--(-)
b++(+++)@ DI? D? G e- h* r? z*
--END GEEK CODE BLOCK--

David Mandelberg
[EMAIL PROTECTED]


signature.asc
Description: OpenPGP digital signature


Re: rm files owned by root?

2005-01-02 Thread Michael Stone
On Sun, Jan 02, 2005 at 10:33:00AM -0500, David Mandelberg wrote:
Bernd Eckenfels wrote:
But to delete a directory, it must be empty.
That's not completely true. You can unlink() (delete) a directory without it
being empty. rmdir won't do it, but it's possible.
Not on linux.
Mike Stone
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]


Re: rm files owned by root?

2005-01-02 Thread Bernd Eckenfels
In article [EMAIL PROTECTED] you wrote:
 Not on linux.

Well, he can of course remove the directory entry with a fs debug tool or
disk editor. But thats not possible with user rights w/o raw access richts
to the device. However I think sys_unlink wont do it. I was looking for the
source but this special policy is a bit hidden in all filesystems.

Gruss
Bernd


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2005-01-02 Thread Thomas Bushnell BSG
Florian Weimer [EMAIL PROTECTED] writes:

 * Ulrich Frst:
 
  Bernd Eckenfels [EMAIL PROTECTED] wrote: 
  This is a Unix FAQ. You can delete any file if you have write access
  to the directory. Actually you dont delete the file, you remove the
  link to the
 
  So if my /home/ is 775 and root.users and I'm in the group users I can
  delete everybody's home directory?
 
 Only if it's empty.  You could rename it to /tmp on most
 installations, where it would be deleted after the next reboot.

Both wrong.  

Removing a directory requires write permission on the directory
itself, because you have to delete the . and .. links inside the
directory.

Renaming a directory requires write permission on the directory if its
parent changes, because you have to rewrite the .. link.

Thomas



Re: rm files owned by root?

2005-01-02 Thread Bernd Eckenfels
In article [EMAIL PROTECTED] you wrote:
 Removing a directory requires write permission on the directory
 itself, because you have to delete the . and .. links inside the
 directory.

no:

[EMAIL PROTECTED]:~# mkdir /home/test
[EMAIL PROTECTED]:~# chmod 0 /home/test
[EMAIL PROTECTED]:~# ls -ld /home /home/test
drwxrwxr-x  12 root adm 123 Jan  2 22:12 /home/
d-  2  root root  6 Jan  2 22:14 /home/test/
[EMAIL PROTECTED]:~# exit
[EMAIL PROTECTED]:~ id
uid=1001(ecki) gid=1001(ecki) 
groups=0(root),4(adm),20(dialout),24(cdrom),29(audio),38(list),1001(ecki)
[EMAIL PROTECTED]:~ rmdir /home/test

Greetings
Bernd


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2005-01-02 Thread Luis M
if you are in group adm and the /home allows adm group to write to it,
you will be able to remove the directory test? inside /home/

to be right you will need to do this:

as root:
chmod 0700 /home
mkdir /home/test
chmod 0 /home/test
ls -ld /home/test

should show root:root owner of /home/test and /home is owned by root:adm 
the permissions of /home 0700
the permissions of /home/test same as before.

now login with id 1001 and try to remove the directory.


On Sun, 02 Jan 2005 22:14:56 +0100, Bernd Eckenfels
[EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED] you wrote:
  Removing a directory requires write permission on the directory
  itself, because you have to delete the . and .. links inside the
  directory.
 
 no:
 
 [EMAIL PROTECTED]:~# mkdir /home/test
 [EMAIL PROTECTED]:~# chmod 0 /home/test
 [EMAIL PROTECTED]:~# ls -ld /home /home/test
 drwxrwxr-x  12 root adm 123 Jan  2 22:12 /home/
 d-  2  root root  6 Jan  2 22:14 /home/test/
 [EMAIL PROTECTED]:~# exit
 [EMAIL PROTECTED]:~ id
 uid=1001(ecki) gid=1001(ecki) 
 groups=0(root),4(adm),20(dialout),24(cdrom),29(audio),38(list),1001(ecki)
 [EMAIL PROTECTED]:~ rmdir /home/test
 
 Greetings
 Bernd
 
 --
 To UNSUBSCRIBE, email to [EMAIL PROTECTED]
 with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
 
 


-- 
)(- 
Luis M
System Administrator
LatinoMixed.com 

We think basically you watch television to turn your brain off, and
you work on your computer when you want to turn your brain on --
Steve Jobs in an interview for MacWorld Magazine 2004-Feb

No .doc: http://www.fsf.org/philosophy/no-word-attachments.es.html


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2005-01-02 Thread Stephen Gran
This one time, at band camp, Luis M said:
 if you are in group adm and the /home allows adm group to write to it,
 you will be able to remove the directory test? inside /home/
 
 to be right you will need to do this:
 
 as root:
 chmod 0700 /home
 mkdir /home/test
 chmod 0 /home/test
 ls -ld /home/test
 
 should show root:root owner of /home/test and /home is owned by root:adm 
 the permissions of /home 0700
 the permissions of /home/test same as before.
 
 now login with id 1001 and try to remove the directory.

No, you have made the parent directory no longer group writable.  There
is a difference between who owns it, and what their permissions are.
Basic *nix stuff here, people.
-- 
 -
|   ,''`.Stephen Gran |
|  : :' :[EMAIL PROTECTED] |
|  `. `'Debian user, admin, and developer |
|`- http://www.debian.org |
 -


pgpAFqoB6Jp2u.pgp
Description: PGP signature


Re: rm files owned by root?

2005-01-02 Thread Bernd Eckenfels
In article [EMAIL PROTECTED] you wrote:
 if you are in group adm and the /home allows adm group to write to it,
 you will be able to remove the directory test? inside /home/

Yes, thats what this thread is about. I can remove an *empty* dir, even if i
dont have permissions inside the dir. All I need is write access to the
parent. If it is not empty, I need to be able to empty it up, before, which
requires write and execute access to the dir (and childs)

Greetings
Bernd


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



rm files owned by root?

2004-12-29 Thread dekkker
Hi all,

I'm seriously troubled by behaviour of my system I just encountered:

If i do (as root):
touch /home/user/a 

Then (as user);
rm /home/user/a

It asks if I want to remove this file, since it's write protected. If I say 
y, then the file gets deleted. But it shouldn't be! Should it? 

(Sorry if this is a dumb question.)

Hope you can help,

Raphael from Swizerland

-- 
dekkker at gmx dot ch


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2004-12-29 Thread Bartosz Fenski aka fEnIo
On Wed, Dec 29, 2004 at 08:22:08PM +0100, dekkker wrote:
 I'm seriously troubled by behaviour of my system I just encountered:
 
 If i do (as root):
 touch /home/user/a 
 
 Then (as user);
 rm /home/user/a
 
 It asks if I want to remove this file, since it's write protected. If I say 
 y, then the file gets deleted. But it shouldn't be! Should it? 
 
 (Sorry if this is a dumb question.)

User can delete files in his own directory cause he has rwx permissions, so
he can read files from that directory, list that directory and _remove_
files from that directory. 

So this behaviour is usual.

regards
fEnIo

-- 
  _  Bartosz Fenski | mailto:[EMAIL PROTECTED] | pgp:0x13fefc40 | 
IRC:fEnIo
_|_|_ 32-050 Skawina - Glowackiego 3/15 - w. malopolskie - Polska
(0 0)  phone:+48602383548 | Slackware - the weakest link
ooO--(_)--Ooo  http://skawina.eu.org | JID:[EMAIL PROTECTED] | RLU:172001


signature.asc
Description: Digital signature


Re: rm files owned by root?

2004-12-29 Thread Robert Vangel
afaik, its because the owner of the folder the file is located is has w 
permission.

I could be wrong, but I was thinking about this myself a few days ago.
dekkker wrote:
Hi all,
I'm seriously troubled by behaviour of my system I just encountered:
If i do (as root):
touch /home/user/a 

Then (as user);
rm /home/user/a
It asks if I want to remove this file, since it's write protected. If I say y, then the file gets deleted. But it shouldn't be! Should it? 

(Sorry if this is a dumb question.)
Hope you can help,
Raphael from Swizerland


smime.p7s
Description: S/MIME Cryptographic Signature


Re: rm files owned by root?

2004-12-29 Thread Bernd Eckenfels
In article [EMAIL PROTECTED] you wrote:
 It asks if I want to remove this file, since it's write protected. If I
 say y, then the file gets deleted. But it shouldn't be! Should it?

This is a Unix FAQ. You can delete any file if you have write access to the
directory. Actually you dont delete the file, you remove the link to the
file from the dir. Only if it is the last link to the directory structure,
the file will be removed and the area freed.

Greetings
Bernd


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: rm files owned by root?

2004-12-29 Thread Richard Atterer
On Wed, Dec 29, 2004 at 08:22:08PM +0100, dekkker wrote:
 It asks if I want to remove this file, since it's write protected. If I
 say y, then the file gets deleted. But it shouldn't be! Should it? 

As the others have said, this behaviour is to be expected.

If your filesystem is ext2 or ext3, you can achieve what you want by using
chattr as root to set the file's immutable bit. According to the
manpage:

  A file with the `i' attribute cannot be modified: it cannot be deleted or
  renamed, no link can be created to this file and no data can be written
  to the file.  Only the superuser or a process possessing the
  CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

Is something similar also available for other filing systems?

Cheers,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer |  GnuPG key:
  | \/¯|  http://atterer.net  |  0x888354F7
  ¯ '` ¯


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]