SCIENTIFIC-LINUX-USERS Archives

March 2016

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Benjamin Lefoul <[log in to unmask]>
Reply To:
Benjamin Lefoul <[log in to unmask]>
Date:
Thu, 31 Mar 2016 05:58:18 +0000
Content-Type:
multipart/alternative
Parts/Attachments:
text/plain (5 kB) , text/html (34 kB)
Well, if you bare along these few lines, you will see that the inode number changes whether I edit with emacs or sed (also works with vi).

NetworkManager only picks it up after the editor change. In the last use of vi, I changed nothing, just entered and quit immediately with ":wq".


[root@server0 ~]# grep "monitor" /etc/NetworkManager/NetworkManager.conf
monitor-connection-files=true
[root@server0 ~]# systemctl restart NetworkManager
[root@server0 ~]# ls -li /etc/sysconfig/network-scripts/ifcfg-eth0
712059 -rw-r--r--. 1 root root 357 Mar 31 07:20 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# grep "IPADDR" /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.4.155
[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.155/24 brd 192.168.4.255 scope global eth0
[root@server0 ~]# emacs /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# grep "IPADDR" /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.4.166
[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.166/24 brd 192.168.4.255 scope global eth0
[root@server0 ~]# ls -li /etc/sysconfig/network-scripts/ifcfg-eth0
712052 -rw-r--r--. 1 root root 357 Mar 31 07:24 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# grep "166" /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.4.166
[root@server0 ~]# sed -i 's/166/177/g' /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# ls -li /etc/sysconfig/network-scripts/ifcfg-eth0
590635 -rw-r--r--. 1 root root 357 Mar 31 07:28 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# grep "166" /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# grep "177" /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.4.177
[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.166/24 brd 192.168.4.255 scope global eth0

[root@server0 ~]# nmcli con reload

[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.166/24 brd 192.168.4.255 scope global eth0

[root@server0 ~]# nmcli con load /etc/sysconfig/network-scripts/ifcfg-eth0

[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.166/24 brd 192.168.4.255 scope global eth0

[root@server0 ~]# systemctl restart NetworkManager

[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.166/24 brd 192.168.4.255 scope global eth0

[root@server0 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# ls -li /etc/sysconfig/network-scripts/ifcfg-eth0
590639 -rw-r--r--. 1 root root 357 Mar 31 07:41 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@server0 ~]# ip a | grep "eth0"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.4.177/24 brd 192.168.4.255 scope global eth0



________________________________________
From: David Sommerseth <[log in to unmask]>
Sent: 31 March 2016 00:55
To: Benjamin Lefoul; Tom H; SL Users
Subject: Re: How does NetworkManager monitor the connection files?

On 31/03/16 00:10, Benjamin Lefoul wrote:
> But sed -i ALSO changes the inode, and as I said it doesn't work:
>
> root@hoptop:~# touch a
> root@hoptop:~# ls -i a
> 9700011 a
> root@hoptop:~# sed -i 's/q/a/g' a
> root@hoptop:~# ls -i a
> 9700013 a
>

I've not looked into the NM code.  But it wouldn't surprise me that much
if inotify is used.  But it might be it doesn't catch all the events
which sed would trigger, but only modification triggered by editors.

Can you also check what happens to the inode on a file if you use vim/emacs?


--
kind regards,

David Sommerseth



> ________________________________________
> From: [log in to unmask] <[log in to unmask]> on behalf of Tom H <[log in to unmask]>
> Sent: 30 March 2016 23:00
> To: SL Users
> Subject: Re: How does NetworkManager monitor the connection files?
>
> On Wed, Mar 30, 2016 at 3:49 PM, Benjamin Lefoul
> <[log in to unmask]> wrote:
>>
>> I have set monitor-connection-files=true in my
>> /etc/NetworkManager/NetworkManager.conf
>>
>> It works fine (in fact, instantly) if I edit
>> /etc/sysconfig/network-scripts/ifcfg-eth0 with emacs or vi (for instance,
>> changing the IP).
>>
>> It fails miserably if I use sudoedit, or sed:
>>
>> # grep 100 /etc/sysconfig/network-scripts/ifcfg-eth0
>> IPADDR=192.168.4.100
>>
>> # sed -i 's/100/155/g' /etc/sysconfig/network-scripts/ifcfg-eth0
>>
>> Even though all stats (access modify and change) are renewed.
>>
>> It's worse than that: even nmcli con reload afterwards fails.
>>
>> In fact, the only way to get the ip to change is by entering the file with
>> vi, not touching it, and leave with ":wq" (not just ":q").
>>
>> Why is that? What is going on here?
>>
>> I know, I know, I can use nmcli in scripts, and not string-manipulation
>> tools, but say I don't want to... :)
>>
>> And still, during operations, I'd rather edit the files with sudoedit...
>
> "sudo -e ifcfg-file" doesn't change the inode. Can you use "sudo vi
> ifcfg-file"? (Or whichever editor you prefer.)
>


ATOM RSS1 RSS2