[PATCH rhel6-branch] Write directly to /etc/sysconfig/network so that inotify works (#845572)

Vratislav Podzimek vpodzime at redhat.com
Fri Jun 28 08:20:43 UTC 2013


On Thu, 2013-06-27 at 17:07 +0200, Radek Vykydal wrote:
> Resolves: rhbz#845572
> 
> Calling rename() on new temporary /etc/sysconfig/.network file used to break
> inotify (IN_CLOSE_WRITE) mechanism on /etc/sysconfig/network file and therefore
> update of system hostname by NM didn't work.
> ---
>  loader/net.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/loader/net.c b/loader/net.c
> index 93a9c6f..ee83860 100644
> --- a/loader/net.c
> +++ b/loader/net.c
> @@ -1579,7 +1579,7 @@ int writeEnabledNetInfo(iface_t *iface) {
>      }
>  
>      /* Global settings */
> -    if ((fp = fopen(SYSCONFIG_PATH"/.network", "w")) == NULL) {
> +    if ((fp = fopen(SYSCONFIG_PATH"/network", "w")) == NULL) {
>          return 9;
>      }
>  
> @@ -1619,15 +1619,11 @@ int writeEnabledNetInfo(iface_t *iface) {
>      }
>  #endif
>  
> +    /* This triggers NM's inotify mechanism for updating system hostname */
>      if (fclose(fp) == EOF) {
>          return 12;
>      }
>  
> -    if (rename(SYSCONFIG_PATH"/.network",
> -               SYSCONFIG_PATH"/network") == -1) {
> -        return 15;
> -    }
> -
>      return 0;
>  }
>  
ACK.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list