Author: nhosoi
Update of /cvs/dirsec/adminserver/lib/libadmin
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22940/lib/libadmin
Modified Files:
util.c
Log Message:
Resolves: #357501
Summary: Console/admin express: can't view log files
Description: Implemented getLogDir to get the log dir from the server's
config info. To share psetHasObjectClass, moved it from security.c to
lib/libadmin/util.c.
Index: util.c
===================================================================
RCS file: /cvs/dirsec/adminserver/lib/libadmin/util.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- util.c 11 May 2007 19:44:05 -0000 1.9
+++ util.c 31 Oct 2007 05:30:54 -0000 1.10
@@ -1349,72 +1349,90 @@
PRStatus status = PR_GetFileInfo(name, &fileinfo);
ret = ((status == PR_SUCCESS) && (fileinfo.type == filetype));
if (ret) {
- /* checks out ok - let's split it into the base name and the parent dir,
- open the parent dir, and see if the base name exists in the parent dir
- */
- char *copy = PL_strdup(name);
- size_t len = strlen(copy);
- char *ptr = ©[len-1];
- /* get the basename - a really bad name may look like
- /path/foo/// or even ///////////////// */
- for (; (ptr > copy) && (*ptr == '/'); --ptr) {
- /* do nothing */
- }
- if ((ptr == copy) && (*ptr == '/')) {
- /* bad - string consists of nothing but '/' */
- ptr = NULL;
- ret = 0;
- } else {
- PRDir *pdir;
- PRDirEntry *pent;
+ /* checks out ok - let's split it into the base name and the parent dir,
+ open the parent dir, and see if the base name exists in the parent dir
+ */
+ char *copy = PL_strdup(name);
+ size_t len = strlen(copy);
+ char *ptr = ©[len-1];
+ /* get the basename - a really bad name may look like
+ /path/foo/// or even ///////////////// */
+ for (; (ptr > copy) && (*ptr == '/'); --ptr) {
+ /* do nothing */
+ }
+ if ((ptr == copy) && (*ptr == '/')) {
+ /* bad - string consists of nothing but '/' */
+ ptr = NULL;
+ ret = 0;
+ } else {
+ PRDir *pdir;
+ PRDirEntry *pent;
- ret = 0;
- if (*ptr == '/') {
- *ptr = 0; /* terminate the string at the first trailing '/' */
- }
- ptr = strrchr(copy, '/');
- if (!ptr) {
- ptr = copy;
- copy = PL_strdup(".");
- } else {
- *ptr = 0;
- ++ptr;
- ptr = PL_strdup(ptr);
- }
- /* copy now points at the parent, ptr at the child */
- if (pdir = PR_OpenDir(copy)) {
- for(pent = PR_ReadDir(pdir, PR_SKIP_BOTH); pent && !ret;
- pent = PR_ReadDir(pdir, PR_SKIP_BOTH)) {
- ret = !strcmp(pent->name, ptr);
- }
- PR_CloseDir(pdir);
- }
- if (ret && childname && (filetype == PR_FILE_DIRECTORY)) {
- ret = 0;
- /* we've verified that name is a valid directory - see if
- the given filename exists in that directory */
- if (pdir = PR_OpenDir(name)) {
- for(pent = PR_ReadDir(pdir, PR_SKIP_BOTH); pent && !ret;
- pent = PR_ReadDir(pdir, PR_SKIP_BOTH)) {
- if (childlen > 0) {
- ret = !strncmp(pent->name, childname, childlen);
- } else {
- ret = !strcmp(pent->name, childname);
- }
- }
- PR_CloseDir(pdir);
- if (ret) {
- /* child exists - check type */
- char *fullname = PR_smprintf("%s%c%s", name, FILE_PATHSEP, childname);
- status = PR_GetFileInfo(fullname, &fileinfo);
- ret = ((status == PR_SUCCESS) && (fileinfo.type == childtype));
- PR_smprintf_free(fullname);
- }
- }
- }
- }
- PL_strfree(copy);
- PL_strfree(ptr);
+ ret = 0;
+ if (*ptr == '/') {
+ *ptr = 0; /* terminate the string at the first trailing '/' */
+ }
+ ptr = strrchr(copy, '/');
+ if (!ptr) {
+ ptr = copy;
+ copy = PL_strdup(".");
+ } else {
+ *ptr = 0;
+ ++ptr;
+ ptr = PL_strdup(ptr);
+ }
+ /* copy now points at the parent, ptr at the child */
+ if (pdir = PR_OpenDir(copy)) {
+ for(pent = PR_ReadDir(pdir, PR_SKIP_BOTH); pent && !ret;
+ pent = PR_ReadDir(pdir, PR_SKIP_BOTH)) {
+ ret = !strcmp(pent->name, ptr);
+ }
+ PR_CloseDir(pdir);
+ }
+ if (ret && childname && (filetype == PR_FILE_DIRECTORY)) {
+ ret = 0;
+ /* we've verified that name is a valid directory - see if
+ the given filename exists in that directory */
+ if (pdir = PR_OpenDir(name)) {
+ for(pent = PR_ReadDir(pdir, PR_SKIP_BOTH); pent && !ret;
+ pent = PR_ReadDir(pdir, PR_SKIP_BOTH)) {
+ if (childlen > 0) {
+ ret = !strncmp(pent->name, childname, childlen);
+ } else {
+ ret = !strcmp(pent->name, childname);
+ }
+ }
+ PR_CloseDir(pdir);
+ if (ret) {
+ /* child exists - check type */
+ char *fullname = PR_smprintf("%s%c%s", name,
FILE_PATHSEP, childname);
+ status = PR_GetFileInfo(fullname, &fileinfo);
+ ret = ((status == PR_SUCCESS) && (fileinfo.type ==
childtype));
+ PR_smprintf_free(fullname);
+ }
+ }
+ }
+ }
+ PL_strfree(copy);
+ PL_strfree(ptr);
}
return ret;
}
+
+NSAPI_PUBLIC int
+util_psetHasObjectClass(PsetHndl pset, const char *ocname)
+{
+ int rval = 0;
+ char *val = NULL;
+ ValueType nodeObjectClass = psetGetObjectClass(pset, "" /* use root node
*/, &rval);
+ ValueType iter = nodeObjectClass;
+
+ rval = 0;
+ while ((!rval) && ((val = *iter++))) {
+ rval = !PL_strcasecmp(ocname, val);
+ }
+
+ deleteValue(nodeObjectClass);
+ return rval;
+}
+
Show replies by date