Scheduled PSN downtime tomorrow in Back Page News

Help?!


13 replies to this topic - - - - -

#1 Allan®

    Still Unbanned

  • 6,494 posts
  • Joined: 02-May 04
  • Location: U[universe]:\Milky Way\Sol\Terra\North America\Canada\Ontario\Toronto.city

Posted 09 February 2012 - 01:40

Quote

what command would you use to make sure that you cannot easily delete a file called backup (which you own) without affecting other permissions?

This is a question in a lab I'm doing. I've racked my brain, I've racked Google's brain. I've tried a TON of other things, and I can't seem to figure it out... can anyone help?


#2 xendrome

    In God We Trust; All Others We Monitor

  • 3,942 posts
  • Joined: 05-December 01

Posted 09 February 2012 - 01:45

The question doesn't really make any sense.... "command"? Do they mean attribute? is this talking about security permissions?

#3 Allan®

    Still Unbanned

  • 6,494 posts
  • Joined: 02-May 04
  • Location: U[universe]:\Milky Way\Sol\Terra\North America\Canada\Ontario\Toronto.city

Posted 09 February 2012 - 01:47

I'm assuming the professor is asking what chmod stuff I'd do. It's very badly written, though.

#4 zoheb

    Neowinian²

  • 217 posts
  • Joined: 02-January 10
  • Location: haLLuNicaTeD pAradISe

Posted 09 February 2012 - 12:56

have a look at chattr command

e.g : chattr +i filename.

with this command the permissions does not change and nor you can edit or delete the file unless >>>> chattr -i filename

#5 -Alex-

    Noob Hunter

  • 2,551 posts
  • Joined: 08-August 06
  • Location: Liverpool / Amsterdam

Posted 09 February 2012 - 17:38

View Postzoheb, on 09 February 2012 - 12:56, said:

have a look at chattr command

e.g : chattr +i filename.

with this command the permissions does not change and nor you can edit or delete the file unless >>>> chattr -i filename
Good command, but chattr +u backup is probably better (makes the file only undeleteable).

http://linux.about.c...mdl1_chattr.htm

#6 Allan®

    Still Unbanned

  • 6,494 posts
  • Joined: 02-May 04
  • Location: U[universe]:\Milky Way\Sol\Terra\North America\Canada\Ontario\Toronto.city

Posted 09 February 2012 - 17:43

Neither command worked.

#7 -Alex-

    Noob Hunter

  • 2,551 posts
  • Joined: 08-August 06
  • Location: Liverpool / Amsterdam

Posted 09 February 2012 - 18:52

Upon closer inspection of the man page for chattr, +u would appear to be wrong:

Quote

When a file with the `u' attribute set is deleted, its contents are saved. This allows the user to ask for its undeletion.

But +i should work:

Quote

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 pessessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.


#8 ichi

    Akihabara Style

  • 3,456 posts
  • Joined: 20-December 04

Posted 09 February 2012 - 20:12

rm /bin/rm :D

But then again if you don't want to screw the system, chattr +i is the way to go.
AFAIK you must execute it as root, though, and root still can delete the file. It just prevents plain users from modifying it in any way.

You could also make the file undeletable for every user including root using SELinux, or replace rm with the safe-rm wrapper and add your backup file to the blacklist.

#9 zoheb

    Neowinian²

  • 217 posts
  • Joined: 02-January 10
  • Location: haLLuNicaTeD pAradISe

Posted 10 February 2012 - 04:39

With chattr +i , not even root cannot delete it.
You need to use -i attribute

#10 -Alex-

    Noob Hunter

  • 2,551 posts
  • Joined: 08-August 06
  • Location: Liverpool / Amsterdam

Posted 10 February 2012 - 04:56

View Postzoheb, on 10 February 2012 - 04:39, said:

With chattr +i , not even root cannot delete it.
You need to use -i attribute
You had it right first time, it's +i

Quote

The operator `+' causes the selected attributes to be added to the existing attributes of the files; `-' causes them to be removed


#11 Allan®

    Still Unbanned

  • 6,494 posts
  • Joined: 02-May 04
  • Location: U[universe]:\Milky Way\Sol\Terra\North America\Canada\Ontario\Toronto.city

Posted 10 February 2012 - 17:07

Correct answer is
Chmod u-w backup

#12 cybertimber2008

    Resident Elite

  • 1,380 posts
  • Joined: 02-December 08

Posted 10 February 2012 - 18:07

View PostAllan®, on 10 February 2012 - 17:07, said:

Correct answer is
Chmod u-w backup
That removes write permissions, but that doesn't prevent you from deleting the file, even in a regular, non-root account.
[nick@fedora16vm ~]$ touch file.txt
[nick@fedora16vm ~]$ ll file.txt
-rw-rw-r-- 1 nick nick 0 Feb 10 13:06 file.txt
[nick@fedora16vm ~]$ chmod u-w file.txt
[nick@fedora16vm ~]$ ll file.txt
-r--rw-r-- 1 nick nick 0 Feb 10 13:06 file.txt
[nick@fedora16vm ~]$ rm file.txt
rm: remove write-protected regular empty file `file.txt'? y
[nick@fedora16vm ~]$ ll file.txt
ls: cannot access file.txt: No such file or directory

Edit:
/threadhijack: I'm unfamilar with the chattr, but highly interested... but I can't get it work. Any ideas? (Fedora 16)
[nick@fedora16vm ~]$ chattr +i file.txt
chattr: Operation not permitted while setting flags

Edited by cybertimber2008, 10 February 2012 - 18:09.


#13 Allan®

    Still Unbanned

  • 6,494 posts
  • Joined: 02-May 04
  • Location: U[universe]:\Milky Way\Sol\Terra\North America\Canada\Ontario\Toronto.city

Posted 10 February 2012 - 19:01

That was the answer the Professor gave me, and the program he wrote to check answers said it was correct... thus I have to accept it's wrong, even if it isn't. :s

#14 -Alex-

    Noob Hunter

  • 2,551 posts
  • Joined: 08-August 06
  • Location: Liverpool / Amsterdam

Posted 10 February 2012 - 20:07

Print out this thread and give it to him :p






Similar Topics Collapse