You are not logged in.

#1 2008-01-16 19:45:22

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Aventures in stupidity with chmod and chattr [SOLVED]

Well, I somehow managed chmod my /etc/resolv.conf so that not even when su-ing root can I delete / chmod / chown it. Any ideas?

Last edited by underpenguin (2008-01-17 19:19:02)

Offline

#2 2008-01-16 19:47:40

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

who owns it?  ls -l /etc/resolv.conf

Offline

#3 2008-01-16 20:00:53

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

4 -rw-r--r-- 1 root root 68 2008-01-04 21:23 /etc/resolv.conf

Last edited by underpenguin (2008-01-16 20:01:42)

Offline

#4 2008-01-16 20:06:08

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Those perms are fine - what about /etc?  ls -ld /etc

Are you using ACLs?

Offline

#5 2008-01-16 20:14:00

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

drwxr-xr-x 61 root root 4096 2008-01-16 13:42 /etc

(my problem is that my internet is super slow, issues with dorm 'net, so it takes me like 5 min to refresh/google etc)

acl is a filesystem? I'm not that I know of.

Offline

#6 2008-01-16 21:19:11

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

ACLs are access control lists - it's another way to specify permissions.  You're probably not using them if you don't know what they are.

What's the exact output trying to chmod /etc/resolv.conf as root?

Offline

#7 2008-01-16 23:31:34

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

$ su
Password:
# chmod 777 resolv.conf
chmod: changing permissions of `resolv.conf': Operation not permitted

Offline

#8 2008-01-17 02:25:42

_adam_
Member
From: Dora, Alabama
Registered: 2006-05-18
Posts: 94

Re: Aventures in stupidity with chmod and chattr [SOLVED]

can you edit the file?
the perms are fine, why do you want to change them? but the fact that you cant change them as root is quite strange.

Offline

#9 2008-01-17 15:04:11

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

I know, its really wierd, I have no idea how I did it. I can open/read the file but I can't write to it. And a touch'ed a test file in /etc/ just to make sure it would work, and it did.

Offline

#10 2008-01-17 15:14:00

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

can you chmod the touch'ed file?  What're the perms on chmod?

Offline

#11 2008-01-17 15:37:09

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

[ben@hoth ~]$ ls -la `which chmod`
-rwxr-xr-x 1 root root 39376 2007-11-15 10:13 /bin/chmod
[ben@hoth ~]$ touch /etc/test
touch: cannot touch `/etc/test': Permission denied
[ben@hoth ~]$ sudo touch /etc/test
[ben@hoth ~]$ sudo chmod 777 /etc/test

[ben@hoth ~]$ ls -la /etc/test
-rwxrwxrwx 1 root root 0 2008-01-17 09:35 /etc/test

[ben@hoth ~]$ ls -la /etc/resolv.conf
-rw-r--r-- 1 root root 68 2008-01-04 21:23 /etc/resolv.conf

Offline

#12 2008-01-17 15:46:10

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

... well I'm totally baffled.

Offline

#13 2008-01-17 15:49:06

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Ha, well, thank you for your help. Maybe another l33t hax0r will come by and help smile

Offline

#14 2008-01-17 18:24:36

mr.MikyMaus
Member
From: disabled
Registered: 2006-03-31
Posts: 285

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Just a quickshot: make sure the file /etc/resolv.conf is not opened by any program/process. You can use the lsof utility (pacman -S lsof) to see all opened files. Just run lsof | grep /etc/resolv.conf to see whether the file is opened by some program or not..

-m.


What happened to Arch's KISS? systemd sure is stupid but I must have missed the simple part ...

... and who is general Failure and why is he reading my harddisk?

Offline

#15 2008-01-17 18:55:01

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Woah. What filesystem do you have? I can think of two possible things here.

a) Your FS is mounted read only
b) You set file attributes to block you from deleting it (such as ext2/3's immutable bit)

Offline

#16 2008-01-17 19:01:34

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Can you try the following commands as root??

lsattr /etc/resolv.conf # will show you what special attributes are set.

If you see an i or an a surrounded by hyphens, run the respective command:

chattr -i /etc/resolv.conf
chattr -a /etc/resolv.conf

Thank you, and please come again.

Offline

#17 2008-01-17 19:18:18

underpenguin
Member
Registered: 2007-02-01
Posts: 116

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Wow. Phrakture was right (and thanks for saving me the googlin' to find out how to fix it codemac). I probably did that while trying to get various programs from editing it (wanted to use static dns). Thank you very much everyone.

Offline

#18 2008-01-17 19:31:02

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Huh - cool.  I wasn't even aware of chattr.  I fail.

Offline

#19 2008-01-17 21:41:39

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Well, I guess you do learn something new every day. And by you I mean me and Cerebral.

Offline

#20 2008-01-17 21:50:16

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

underpenguin wrote:

Wow. Phrakture was right

Pff, this surprises you?!

Hah, kidding!

Offline

#21 2008-01-18 02:03:01

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: Aventures in stupidity with chmod and chattr [SOLVED]

phrakture wrote:
underpenguin wrote:

Wow. Phrakture was right

Pff, this surprises you?!

Hah, kidding!

LMAO!

Offline

#22 2008-01-18 03:38:22

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,395
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Cerebral wrote:

Huh - cool.  I wasn't even aware of chattr.  I fail.

I didn't know about this either.  And thanks to this thread, I can now fix what I am about to break playing around with it!

Offline

#23 2008-01-18 06:56:53

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Aventures in stupidity with chmod and chattr [SOLVED]

Allan wrote:
Cerebral wrote:

Huh - cool.  I wasn't even aware of chattr.  I fail.

I didn't know about this either.  And thanks to this thread, I can now fix what I am about to break playing around with it!

There's a long standing pacman bug regarding "immutable files". It's a chattr thing. I can't recall all the details, but basically the only way to change an immutable file (even as root) is to get rid of the immutable bit first. It's scary

Offline

Board footer

Powered by FluxBB