timezone: Remove /etc/localtime if it's a symbolic link
authorYu A Wang <yu.a.wang@intel.com>
Fri, 8 Jul 2011 17:15:37 +0000 (19:15 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 8 Jul 2011 17:21:08 +0000 (19:21 +0200)
And copy the timezone file over.

Fixes BMC #18887

src/timezone.c

index c6d8d68..08f904f 100644 (file)
@@ -271,11 +271,17 @@ done:
 
 static int write_file(void *src_map, struct stat *src_st, const char *pathname)
 {
+       struct stat st;
        int fd;
        ssize_t written;
 
        DBG("pathname %s", pathname);
 
+       if (lstat(pathname, &st) == 0) {
+               if (S_ISLNK(st.st_mode))
+                       unlink(pathname);
+       }
+
        fd = open(pathname, O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (fd < 0)
                return -EIO;