[Fedora-directory-commits] adminserver/admserv/cgi-src40 config.c, 1.13, 1.14 config.properties, 1.3, 1.4

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Thu Nov 15 17:32:25 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31123/adminserver/admserv/cgi-src40

Modified Files:
	config.c config.properties 
Log Message:
Resolves: bug 368481
Bug Description: Unable to change Admin Server log paths in Console
Reviewed by: nkinder (Thanks!)
Fix Description: This is for the CGI part.  The CGI will now return one error if the input is not a valid filename (i.e. it is a path), and return a different error if the filename could not be opened.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none



Index: config.c
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/config.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- config.c	13 Jul 2007 19:47:15 -0000	1.13
+++ config.c	15 Nov 2007 17:32:22 -0000	1.14
@@ -84,13 +84,13 @@
 #define DBT_PORT_INUSE          resource_key(RESOURCE_FILE, "20")
 #define DBT_PORT_EACCESS        resource_key(RESOURCE_FILE, "21")
 #define DBT_PORT_NOT_AVAIL      resource_key(RESOURCE_FILE, "22")
-#define DBT_ACCESSLOG_INVALID   resource_key(RESOURCE_FILE, "23")
-#define DBT_ERRORLOG_INVALID    resource_key(RESOURCE_FILE, "24")
+#define DBT_ERROR_OPENING_LOG   resource_key(RESOURCE_FILE, "23")
+#define DBT_LOG_INVALID         resource_key(RESOURCE_FILE, "24")
 
 static char * read_conf(char *file, char *name);
 static int update_conf(char *file, char *name, char *val);
 static int validate_addr(char* ip);
-static int validate_logfile(char* name);
+static int validate_logfile(char *logdir, char* name);
 #ifdef XP_UNIX
 static int rename_pidlog_file(PsetHndl pset, char* newname);
 static int change_uid_all(char *dir, int curuid, int newuid);
@@ -538,15 +538,28 @@
 	
 	/* Check if access log file is being changed */
 	if (strcasecmp(nameptr,"configuration.nsaccesslog") == 0) {
-	  if (!validate_logfile(valptr)) {
+	  int rc = validate_logfile(logdir, valptr);
+	  if (rc == 2) {
 	    /* report error */
 	    psetDelete(pset);
 	    if (i18nResource) 
 	      PR_snprintf(error_info, sizeof(error_info), 
-		      res_getstring(i18nResource, DBT_ACCESSLOG_INVALID,
+		      res_getstring(i18nResource, DBT_LOG_INVALID,
 				    acceptLanguage, msgbuf, sizeof(msgbuf), NULL),
-		      nameptr);
-	    else PR_snprintf(error_info, sizeof(error_info), "Invalid access log file specified");
+		      "Access", nameptr);
+	    else PR_snprintf(error_info, sizeof(error_info), "%s log file name must be a valid file name and must not include the path.  [%s] is invalid.",
+                         "Access", nameptr);
+	    rpt_err(APP_ERROR, error_info, NULL, NULL);
+	  } else if (rc == 0) {
+	    /* report error */
+	    psetDelete(pset);
+	    if (i18nResource) 
+	      PR_snprintf(error_info, sizeof(error_info), 
+		      res_getstring(i18nResource, DBT_ERROR_OPENING_LOG,
+				    acceptLanguage, msgbuf, sizeof(msgbuf), NULL),
+		      "access", nameptr, strerror(errno));
+	    else PR_snprintf(error_info, sizeof(error_info), "Could not open %s log file [%s].  Error: %s",
+                         "access", nameptr, strerror(errno));
 	    rpt_err(APP_ERROR, error_info, NULL, NULL);
 	  }
 	  else {
@@ -558,15 +571,28 @@
 
 	/* Check if error log file is being changed */
 	if (strcasecmp(nameptr,"configuration.nserrorlog") == 0) {
-	  if (!validate_logfile(valptr)) {
+	  int rc = validate_logfile(logdir, valptr);
+	  if (rc == 2) {
 	    /* report error */
 	    psetDelete(pset);
 	    if (i18nResource) 
 	      PR_snprintf(error_info, sizeof(error_info), 
-		      res_getstring(i18nResource, DBT_ERRORLOG_INVALID,
+		      res_getstring(i18nResource, DBT_LOG_INVALID,
 				    acceptLanguage, msgbuf, sizeof(msgbuf), NULL),
-		      nameptr);
-	    else PR_snprintf(error_info, sizeof(error_info), "Invalid error log file specified"); 
+		      "Error", nameptr);
+	    else PR_snprintf(error_info, sizeof(error_info), "%s log file name must be a valid file name and must not include the path.  [%s] is invalid.",
+                         "Error", nameptr);
+	    rpt_err(APP_ERROR, error_info, NULL, NULL);
+	  } else if (rc == 0) {
+	    /* report error */
+	    psetDelete(pset);
+	    if (i18nResource) 
+	      PR_snprintf(error_info, sizeof(error_info), 
+		      res_getstring(i18nResource, DBT_ERROR_OPENING_LOG,
+				    acceptLanguage, msgbuf, sizeof(msgbuf), NULL),
+		      "error", nameptr, strerror(errno));
+	    else PR_snprintf(error_info, sizeof(error_info), "Could not open %s log file [%s].  Error: %s",
+                         "error", nameptr, strerror(errno));
 	    rpt_err(APP_ERROR, error_info, NULL, NULL);
 	  }
 	  else {
@@ -1042,16 +1068,16 @@
  *            0 error
  *           
  */
-static int validate_logfile(char *name)  {
+static int validate_logfile(char *logdir, char *name)  {
   FILE *f;
   char *fullname;
 
   if (!name || !*name ||
       !util_is_valid_path_string(name)) {
-    return 0; /* error */
+    return 2; /* error */
   }
 
-  fullname = PR_smprintf("%s/%s", LOGDIR, name);
+  fullname = PR_smprintf("%s/%s", logdir, name);
 
   f = fopen(fullname, "a+");
   PR_smprintf_free(fullname);


Index: config.properties
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/config.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- config.properties	18 Aug 2005 18:59:03 -0000	1.3
+++ config.properties	15 Nov 2007 17:32:22 -0000	1.4
@@ -46,7 +46,7 @@
 config20 { "Port is already in use" }
 config21 { "Inadequate permission. Port is protected." }
 config22 { "Port is not available" }
-config23 { "Invalid access log file specified" }
-config24 { "Invalid error log file specified" }
+config23 { "Could not open %s log file [%s].  Error: %s" }
+config24 { "%s log file name must be a valid file name and must not include the path.  [%s] is invalid." }
 
 }




More information about the Fedora-directory-commits mailing list