[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-server-cvs
Subject:    [Server-cvs] engine/config uasconfig.cpp,1.7.4.6,1.7.4.6.6.1
From:       svaidhya () helixcommunity ! org
Date:       2008-05-19 22:50:09
Message-ID: 200805192250.m4JMoQwU004098 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/server/engine/config
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv14324

Modified Files:
      Tag: SERVER_12_1
	uasconfig.cpp 
Log Message:
Synopsis
========
Fixes PR 216145 - False error reported on server startup

Branches: SERVER_12_1, SERVER_CURRENT (HEAD)
Reviewed: Dean

Description
===========

Problem: On startup, the server falsely reports the following error messages.
E: UASPath <Path Name> cannot be read from
E: UASPath <Path Name> cannot be written to; Admin System updates can only be written \
to the Helix configuration file This is a windows-specific issue.

Cause: The stat() system call is used to retrieve the permissions/attributes of the \
given directory. The path name of the directory, which we pass as an argument to \
stat(), contained a "\" at the end because of which the stat() call failed (only on \
windows). It returned with a "failure code" which was un-handled and hence the server \
falsely reported as "permissions not available" rather than something like "call \
failed". The stat() worked fine on Linux and Solaris with the trailing "/".

Solution: Passed the pathname without the trailing slash, only for windows. Handled \
the return status of the stat() call.

Files Affected
==============
server/engine/sonfig/uaspathconfig.cpp

Testing Performed
=================
Unit Tests:
- None

Integration Tests:
- Check if the following messages are NOT reported when the server is started.
   E: UASPath <Path Name> cannot be read from
   E: UASPath <Path Name> cannot be written to; Admin System updates can only be \
                written to the Helix configuration file
- Rename the ClientProfiles directory and then start the server. The server should \
NOT report the above messages  It should just report the following message
   E: UASPath is not a valid directory or Empty directory
- Explicitly remove "write permission" to the ClientProfiles directory and then start \
the server. Try adding new profiles from  admin page.
  The following message should be reported on server startup
   E: UASPath <Path Name> cannot be written to; Admin System updates can only be \
written to the Helix configuration file  The new profiles should not be added to the \
ClientProfiles directory.

Leak Tests:
- None

Performance Tests:
- None

Platforms Tested: linux-rhel4-i686, win32-i386-vc7, sunos-5.10-sparc-server

Build verified: linux-rhel4-i686, win32-i386-vc7, sunos-5.10-sparc-server

QA Hints
========
- Check if the following messages are NOT reported when the server is started.
   E: UASPath <Path Name> cannot be read from
   E: UASPath <Path Name> cannot be written to; Admin System updates can only be \
                written to the Helix configuration file
- Rename the ClientProfiles directory and then start the server. The server should \
NOT report the above messages  It should just report the following message
   E: UASPath is not a valid directory or Empty directory
- Explicitly remove "write permission" to the ClientProfiles directory and then start \
the server. Try adding new profiles from  admin page.
  The following message should be reported on server startup
   E: UASPath <Path Name> cannot be written to; Admin System updates can only be \
written to the Helix configuration file  The new profiles should not be added to the \
ClientProfiles directory.




Index: uasconfig.cpp
===================================================================
RCS file: /cvsroot/server/engine/config/uasconfig.cpp,v
retrieving revision 1.7.4.6
retrieving revision 1.7.4.6.6.1
diff -u -d -r1.7.4.6 -r1.7.4.6.6.1
--- uasconfig.cpp	5 Mar 2008 06:18:09 -0000	1.7.4.6
+++ uasconfig.cpp	19 May 2008 22:50:06 -0000	1.7.4.6.6.1
@@ -224,22 +224,45 @@
 {
     HX_RESULT hResult = HXR_OK;
     struct stat st;
+    INT8 nReturnCode = 0;
 
     if(!m_pszBasePath)
     {
         return hResult;
     }
+ 
+    /*
+     * The stat(), in windows, fails if there is a "\" at the end of the Path name. 
+     * So, we need to eliminate the trailing "\" (windows) and "/" (in other cases) \
from the path and then +     * pass it to stat().  
+     */
+      
+    char* szBasePath = new char [FileIO::MAXPATH];
+    HX_ASSERT(szBasePath);
 
-    //Check READ and WRITE permissions for the base path.
-    stat(m_pszBasePath, &st);
-
-    if(!(st.st_mode & S_IREAD))
+    INT8 nLength = strlen(m_pszBasePath);
+    
+    strcpy(szBasePath, m_pszBasePath);   
+    if (m_pszBasePath[nLength-1] == FileIO::PATH_SEP)
     {
-        ERRMSG(m_pMessages, "UASPath %s cannot be read from", m_pszBasePath);
+        szBasePath[nLength - 1] = '\0';
     }
-    if(!(st.st_mode & S_IWRITE))
+
+    //Check READ and WRITE permissions for the base path.
+    nReturnCode = stat(szBasePath, &st);
+    delete[] szBasePath;
+    
+    //Check for permissions only if the stat() call has been successful
+    if (nReturnCode == 0)
     {
-        ERRMSG(m_pMessages, "UASPath %s cannot be written to; Admin System updates \
can only be written to the Helix configuration file", m_pszBasePath); +        if \
(!(st.st_mode & S_IREAD)) +        {
+            ERRMSG(m_pMessages, "UASPath %s cannot be read from", m_pszBasePath);
+        }
+        if (!(st.st_mode & S_IWRITE))
+        {
+            ERRMSG(m_pMessages, "UASPath %s cannot be written to; Admin System \
updates can only be written to the Helix configuration file", m_pszBasePath); +       \
}  }
 
     //Root Node


_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic