Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
root unable to write/delete resolv.conf
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
addeej
n00b
n00b


Joined: 06 Jul 2014
Posts: 2

PostPosted: Sun Jul 06, 2014 2:51 am    Post subject: root unable to write/delete resolv.conf Reply with quote

I'm completely stumped - for some reason I'm not able to write or delete /etc/resolv.conf:

Code:

# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),26(tape),27(video)

# rm /etc/resolv.conf
rm: cannot remove ‘/etc/resolv.conf’: Operation not permitted


The file is owned by root, is writeable according to it's file permissions and is on a writeable filesystem:
Code:

# stat /etc/resolv.conf
  File: ‘/etc/resolv.conf’
  Size: 136             Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 5511820     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-07-05 22:35:18.995895494 -0400
Modify: 2014-07-05 22:36:59.402891018 -0400
Change: 2014-07-05 22:36:59.402891018 -0400
 Birth: -

# lsattr /etc/resolv.conf
-----a-------e-- /etc/resolv.conf

# df -P /etc/resolv.conf
Filesystem     1024-blocks     Used Available Capacity Mounted on
/dev/sda1        106989608 93695940   7835800      93% /

# mount | grep sda1
/dev/sda1 on / type ext4 (rw,noatime,discard,data=ordered)


...I can even copy the file to another name in the same directory and delete it's copy without any problems:

Code:

# cp -a /etc/resolv.conf /etc/resolv.conf.test
# rm /etc/resolv.conf.test


strace'ing the rm command shows this output:

Code:

# strace -f rm /etc/resolv.conf
execve("/bin/rm", ["rm", "/etc/resolv.conf"], [/* 71 vars */]) = 0
brk(0)                                  = 0x123a000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1abbf09000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=219797, ...}) = 0
mmap(NULL, 219797, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1abbed3000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\33\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1705128, ...}) = 0
mmap(NULL, 3811800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1abb947000
mprotect(0x7f1abbae0000, 2097152, PROT_NONE) = 0
mmap(0x7f1abbce0000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x199000) = 0x7f1abbce0000
mmap(0x7f1abbce6000, 14808, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1abbce6000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1abbed2000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1abbed1000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1abbed0000
arch_prctl(ARCH_SET_FS, 0x7f1abbed1700) = 0
mprotect(0x7f1abbce0000, 16384, PROT_READ) = 0
mprotect(0x611000, 4096, PROT_READ)     = 0
mprotect(0x7f1abbf0a000, 4096, PROT_READ) = 0
munmap(0x7f1abbed3000, 219797)          = 0
brk(0)                                  = 0x123a000
brk(0x125b000)                          = 0x125b000
open("/usr/lib64/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106082112, ...}) = 0
mmap(NULL, 106082112, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1ab541c000
close(3)                                = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=136, ...}, AT_SYMLINK_NOFOLLOW) = 0
geteuid()                               = 0
unlinkat(AT_FDCWD, "/etc/resolv.conf", 0) = -1 EPERM (Operation not permitted)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fstat(3, {st_mode=S_IFREG|0644, st_size=2492, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1abbf08000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2492
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f1abbf08000, 4096)            = 0
open("/usr/share/locale/en_GB.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_GB/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "rm: ", 4rm: )                     = 4
write(2, "cannot remove \342\200\230/etc/resolv.con"..., 36cannot remove ‘/etc/resolv.conf’) = 36
open("/usr/share/locale/en_GB.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_GB/LC_MESSAGES/libc.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1474, ...}) = 0
mmap(NULL, 1474, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1abbf08000
close(3)                                = 0
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1
)                       = 1
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++


What gives? Am I being stupid and missing something really obvious?! :x
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1655

PostPosted: Sun Jul 06, 2014 3:08 am    Post subject: Reply with quote

Code:
chattr -a /etc/resolv.conf

_________________
Donate to Gentoo
Back to top
View user's profile Send private message
addeej
n00b
n00b


Joined: 06 Jul 2014
Posts: 2

PostPosted: Sun Jul 06, 2014 3:14 am    Post subject: Reply with quote

Stupid indeed, I should have realised the "a" in the lsattr output. Thanks! :oops:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum