WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [IA64] Add error checking to nvram store

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [IA64] Add error checking to nvram store mkdir
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 16 Jun 2007 05:56:09 -0700
Delivery-date: Sat, 16 Jun 2007 05:54:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1181928874 21600
# Node ID fd0103b55504bac392864de87d21506e18ba2d6b
# Parent  33cc64dcaead095d4f8115a5b7f8565f5becaf1c
[IA64] Add error checking to nvram store mkdir

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---
 tools/libxc/ia64/xc_ia64_hvm_build.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff -r 33cc64dcaead -r fd0103b55504 tools/libxc/ia64/xc_ia64_hvm_build.c
--- a/tools/libxc/ia64/xc_ia64_hvm_build.c      Fri Jun 15 09:25:09 2007 -0600
+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c      Fri Jun 15 11:34:34 2007 -0600
@@ -578,7 +578,7 @@ nvram_init(const char *nvram_path)
 nvram_init(const char *nvram_path)
 {
     uint64_t fd = 0;
-    fd = open(nvram_path, O_CREAT|O_RDWR, 0666);
+    fd = open(nvram_path, O_CREAT|O_RDWR, 0644);
 
     if ( fd < 0 )
     {
@@ -736,12 +736,34 @@ int xc_ia64_save_to_nvram(int xc_handle,
 }
 
 #define NVRAM_DIR       "/usr/lib/xen/boot/"
-#define NVRAM_FILE_PATH        "/usr/lib/xen/boot/nvram_"
+#define NVRAM_FILE_PATH "/usr/lib/xen/boot/nvram_"
+
 int xc_ia64_nvram_init(int xc_handle, char *dom_name, uint32_t dom)
 {
     int file_path_len = strlen(NVRAM_FILE_PATH);
     uint64_t nvram_fd = 0;
     char nvram_path[100] = {0};
+    struct stat stat_buf;
+
+    if ( stat(NVRAM_DIR, &stat_buf) == -1 ) {
+        if ( errno != ENOENT )
+        {
+            PERROR("Error stat'ing NVRAM dir %s.", NVRAM_DIR);
+            return -1;
+        }
+        if ( mkdir(NVRAM_DIR, 0755) == -1 )
+        {
+            PERROR("Unable to create NVRAM store directory %s.", NVRAM_DIR);
+            return -1;
+        }
+    }
+
+    if ( !(stat_buf.st_mode & S_IRUSR) || !(stat_buf.st_mode & S_IWUSR) )
+    {
+        errno = EACCES;
+        PERROR("No R/W permission to NVRAM store directory %s.", NVRAM_DIR);
+        return -1;
+    }
 
     strncpy(nvram_path, NVRAM_FILE_PATH, file_path_len);
     if ( file_path_len + strlen(dom_name) + 1 > sizeof(nvram_path) )
@@ -750,7 +772,6 @@ int xc_ia64_nvram_init(int xc_handle, ch
         return -1;
     }
     strcpy(nvram_path + file_path_len, dom_name);
-    mkdir(NVRAM_DIR, 0765);
 
     nvram_fd = nvram_init(nvram_path);
     if ( nvram_fd == (uint64_t)(-1) )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [IA64] Add error checking to nvram store mkdir, Xen patchbot-unstable <=