[Fedora-directory-commits] adminutil/include/libadminutil admutil.h, 1.5, 1.6 distadm.h, 1.3, 1.4 psetc.h, 1.2, 1.3 resource.h, 1.2, 1.3

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Wed Apr 4 19:37:48 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/adminutil/include/libadminutil
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30346/adminutil/include/libadminutil

Modified Files:
	admutil.h distadm.h psetc.h resource.h 
Log Message:
Resolves: bug 234420
Bug Description: adminutil: Use FHS paths and general code cleanup
Reviewed by: nkinder (Thanks!)
Fix Description:
1) Added a propertydir parameter to Makefile.am.  This is where the .res files go.  This also gets baked into the code so that the library knows where to find them.
2) The icu code expects the .res files to be in a packagename directory - packagename/foo.res not packagename_foo.res.  I don't know how this ever worked.  I also added en_US.res and en.res - icu recommends having the actual locale file rather than just falling back to the default root.res - see http://icu-project.org/userguide/ResourceManagement.html
3) There was quite a bit of dead code that I got rid of
4) Fixed many compiler warnings
5) There were quite a few memory leaks.  The biggest one was probably in psetDelete, which did not actually delete the pset.  Another one was the resource string handling - this returns malloc'd memory, and was never freed.  I added the option to pass in a static sized buffer to hold the resource string - this may be truncated but we usually won't care.  There were several places where the code was calling PR_Free on a data structure pointer - doing a "shallow" free rather than a "deep" free of all of the pointers in the data structure.
6) I merged in configuration from dbswitch.conf and other config files so that we could get rid of them and just have adm.conf.  We'll have to take care of this during migration.
Platforms tested: RHEL4, FC6
Flag Day: no
Doc impact: no



Index: admutil.h
===================================================================
RCS file: /cvs/dirsec/adminutil/include/libadminutil/admutil.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- admutil.h	11 May 2006 23:30:31 -0000	1.5
+++ admutil.h	4 Apr 2007 19:37:41 -0000	1.6
@@ -55,6 +55,15 @@
 #define BIG_LINE 1024
 #endif
 
+/* This environment variable holds the name of the directory
+   containing adm.conf, admpw, and other
+   adminutil config files - if this env var is set,
+   IT WILL OVERRIDE NETSITE_ROOT AND FUNCTION ARGUMENTS to
+   functions such as admGetLocalAdmin and admldapBuildInfo
+   This was done to minimize coding changes to other modules.
+*/
+#define ADMINUTIL_CONFDIR_ENV_VAR "ADMINUTIL_CONF_DIR"
+
 /* safs/cgi.h */
 
 #ifdef __cplusplus
@@ -90,6 +99,8 @@
 PR_IMPLEMENT(void)
 deleteAttrNameList(AttrNameList nl);
 
+PR_IMPLEMENT(void)
+deleteValue(ValueType val);
 
 typedef AttributePtr* AttributeList;
 PR_IMPLEMENT(AttributeList)
@@ -116,9 +127,25 @@
 
 typedef void* AdmldapInfo;
 
+PR_IMPLEMENT(int)
+admldapWriteInfoFile(AdmldapInfo info);
+
+/*
+ * Just read the ldap information from the file, without also opening a connection
+ */
+PR_IMPLEMENT(AdmldapInfo)
+admldapBuildInfoOnly(char* configRoot, int *errorcode);
+
+/*
+ * Read the ldap info, open a connection, and bind, and specify a callback function
+ * that returns the ldap password
+ */
 PR_IMPLEMENT(AdmldapInfo)
 admldapBuildInfoCbk(char* configRoot, char* (*cbk)(),  int *errorcode);
 
+/*
+ * Read the ldap info, open a connection, and bind
+ */
 PR_IMPLEMENT(AdmldapInfo)
 admldapBuildInfo(char* configRoot, int *errorcode);
 
@@ -135,10 +162,10 @@
 admldapGetSecurity(AdmldapInfo info);
 
 PR_IMPLEMENT(char*)
-admldapGetCertDBFile(AdmldapInfo info);
+admldapGetSecurityDir(AdmldapInfo info);
 
-PR_IMPLEMENT(char*)
-admldapGetKeyDBFile(AdmldapInfo info);
+PR_IMPLEMENT(int)
+admldapSetSecurityDir(AdmldapInfo info, const char *securityDir);
 
 PR_IMPLEMENT(char*)
 admldapGetBaseDN(AdmldapInfo info);
@@ -158,9 +185,45 @@
 PR_IMPLEMENT(char *)
 admldapGetDirectoryURL(AdmldapInfo info);
 
+PR_IMPLEMENT(int)
+admldapSetDirectoryUrl(AdmldapInfo info, const char *ldapurl);
+
+PR_IMPLEMENT(int)
+admldapSetSIEDN(AdmldapInfo info, const char *sieDN);
+
+PR_IMPLEMENT(int)
+admldapSetISIEDN(AdmldapInfo info, const char *isieDN);
+
 PR_IMPLEMENT(char *)
 admldapGetUserDN(AdmldapInfo info, char *uid);
 
+PR_IMPLEMENT(char *)
+admldapGetSysUser(AdmldapInfo info);
+
+PR_IMPLEMENT(char *)
+admldapGetSysGroup(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetAdminDomain(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetExpressRefreshRate(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetExpressCGITimeout(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetLdapStart(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetConfigFileName(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetAdmpwFilePath(AdmldapInfo info);
+
+PR_IMPLEMENT(char*)
+admldapGetLocalAdminName(AdmldapInfo info);
+
 #define UG_OP_OK  0
 #define UG_NO_SSL_SUPPORT 1
 #define UG_AUTH_FAIL 2
@@ -419,73 +482,6 @@
 /* form_post.c */
 PR_IMPLEMENT(char) * compress_and_replace(char *source);
 
-/****************************************************************************/
-/*                                                                          */
-/* Migrate cron_conf related stuff to libadminutil                          */
-/*                                                                          */
-/****************************************************************************/
-
-/* read and write to cron.conf, cron_conf.c */
-/* Alex Feygin, 3/22/96                     */
-typedef struct cron_conf_obj
-{
-  char *name;
-  char *command;
-  char *dir;
-  char *user;
-  char *start_time;
-  char *days;
-} 
-cron_conf_obj;
- 
-typedef struct cron_conf_list
-{
-  char *name;
-  cron_conf_obj *obj;
-  struct cron_conf_list *next;
-} 
-cron_conf_list;
- 
-/* Reads cron.conf to a null terminated list of cron_conf_objects; returns
-   0 if unable to do a read; 1 otherwise */
-PR_IMPLEMENT(int) cron_conf_read();
- 
-/* gets a cron object, NULL if it doesnt exist */
-PR_IMPLEMENT(cron_conf_obj) *cron_conf_get(char *name);
- 
-/* returns a NULL-terminated cron_conf_list of all the cron conf objects */
-PR_IMPLEMENT(cron_conf_list) *cron_conf_get_list();
- 
-/* Creates a cron conf object; all these args get STRDUP'd in the function
-   so make sure to free up the space later if need be */
-PR_IMPLEMENT(cron_conf_obj) *cron_conf_create_obj(char *name, char *command,
-						 char *dir,  char *user, 
-						 char *start_time, char *days);
- 
-/* Puts a cron conf object into list or updates it if it already in there.
-   Returns either the object passed or the object in there already;
-   cco may be FREE'd during this operation so if you need the object
-   back, call it like so:
-   
-   cco = cron_conf_set(cco->name, cco);  
- 
-   calling cron_conf_set with a NULL cco will cause the 'name' object
-   to be deleted.
-*/
-PR_IMPLEMENT(cron_conf_obj) *cron_conf_set(char *name, cron_conf_obj *cco);
- 
-/* write out current list of cron_conf_objects to cron.conf file */
-PR_IMPLEMENT(void) cron_conf_write();
- 
-/* free all cron conf data structures */
-PR_IMPLEMENT(void) cron_conf_free();
-
-/****************************************************************************/
-/*                                                                          */
-/* End of cron_conf related stuff                                           */
-/*                                                                          */
-/****************************************************************************/
-
 #ifdef __cplusplus
 }
 #endif


Index: distadm.h
===================================================================
RCS file: /cvs/dirsec/adminutil/include/libadminutil/distadm.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- distadm.h	6 Dec 2005 18:38:31 -0000	1.3
+++ distadm.h	4 Apr 2007 19:37:41 -0000	1.4
@@ -53,11 +53,6 @@
 #define ADM_SIEPWD_STRING "SIEPWD: "
 #endif
 
-/* Initialize libadminutil, for setting up libnls relsted stuff only 
-   Used by non-CGI situation */
-PR_IMPLEMENT(int) 
-ADMUTIL_InitSimple(char* sr, char* lang);
-
 /* Initialize libadminutil.  Should be called by EVERY CGI. */
 /* util.c */
 PR_IMPLEMENT(int) ADMUTIL_Init(void);


Index: psetc.h
===================================================================
RCS file: /cvs/dirsec/adminutil/include/libadminutil/psetc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- psetc.h	6 Dec 2005 18:38:31 -0000	1.2
+++ psetc.h	4 Apr 2007 19:37:41 -0000	1.3
@@ -61,6 +61,7 @@
 #define PSET_PARTIAL_OP  22
 #define PSET_ILLEGAL_OP 23
 #define PSET_NOT_IMPLEMENT 24
+#define PSET_ATTR_NOT_ALLOWED 25
 
 
 /*
@@ -153,7 +154,7 @@
 
 /* Retrieve the object type of one LDAP entry */
 PR_IMPLEMENT(ValueType)
-psetGetObjectType(PsetHndl pseth, NameType name, int* errorcode);
+psetGetObjectClass(PsetHndl pseth, NameType name, int* errorcode);
 
 /* Set the value of given attribute */
 PR_IMPLEMENT(int)
@@ -199,9 +200,32 @@
 PR_IMPLEMENT(int)
 psetDeleteEntry(PsetHndl pseth, NameType name);
 
-/* Generate pset error string by given pset error number */
-PR_IMPLEMENT(const char*)
-psetErrorString(int errorNum, char* lang);
+/* Generate pset error string by given pset error number
+   If buffer is NULL, the return value will be allocated by malloc and
+   must be free'd by the caller.  Even in an error condition, if
+   buffer is NULL, a malloc'd empty string will be returned.  The
+   value will be returned in buffer, if given.  buffer will be
+   properly NULL terminated, even if bufsize is not large enough to
+   accomodate the entire string (i.e. it's truncated).  Buffer will
+   always be NULL terminated, so that even if an error occurred,
+   buffer will be initialized to an empty string, so you do not have
+   to worry about initializing it first.  If buffer is given, the
+   return value will point to buffer, so that you can use the return
+   value directly:
+   char buf[BUFSIZE];
+   int rc = 0;
+   ...
+   fprintf(stderr, "Error: %s\n",
+           psetErrorString(num, lang, buf, sizeof(buf), &rc));
+
+   The rc parameter may be used to determine if there was an overflow
+   condition or some other error.  If rc == 0, the operation was
+   successful.  If rc == 1, an overflow occurred - the given buffer
+   was too small to hold the contents.  If rc == -1 or some other
+   value, some other error occurred,
+ */
+PR_IMPLEMENT(char*)
+psetErrorString(int errorNum, char* lang, char *buffer, size_t bufsize, int *rc);
 
 /* Setting up LDAP referal */
 PR_IMPLEMENT(int)


Index: resource.h
===================================================================
RCS file: /cvs/dirsec/adminutil/include/libadminutil/resource.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- resource.h	6 Dec 2005 18:38:31 -0000	1.2
+++ resource.h	4 Apr 2007 19:37:41 -0000	1.3
@@ -44,14 +44,6 @@
     void *propset;
 } Resource;
 
-/* Set the search root for NLS property file
-   return: 1 - OK
-           0 - Failed
-   */
-PR_IMPLEMENT(int)
-res_init_path(const char* path);
-
-
 /* Initialization routine.  Checks for the existence of a resourcebundle
    with the default encoding -  
 
@@ -75,18 +67,72 @@
 	     For example, if you have Resdef(my_key, 1, "this is a test") in dbt*.h
 		 file for your source, your key will be my_key.  
 
-	return value: NULL if the property file cannot be located
-				  NULL if any memory allocation fails.
-				  const char* containing the string if all goes well.
+    If buffer is NULL, the return value will be allocated by malloc and must be free'd by
+    the caller.  Even in an error condition, a malloc'd empty string will be returned.
+    The value will be returned in buffer, if given.  buffer will be properly NULL terminated,
+    even if bufsize is not large enough to accomodate the entire string (i.e. it's truncated).
+    Buffer will always be NULL terminated, so that even if an error occurred, buffer will be
+    initialized to an empty string, so you do not have to worry about initializing it first.
+    If buffer is given, the return value will point to buffer, so that you can use the return
+    value directly:
+    char buf[BUFSIZE];
+    int rc = 0;
+    ...
+    fprintf(stderr, "Error: %s\n",
+    	    res_getstring(source, MY_ERROR_KEY, lang, buf, sizeof(buf), &rc));
+
+    The rc parameter may be used to determine if there was an overflow condition or some other error.
+    If rc == 0, the operation was successful.  If rc == 1, an overflow occurred - the given buffer was
+    too small to hold the contents.  If rc == -1 or some other value, some other error occurred, 
 */
-PR_IMPLEMENT(const char*) 
-res_getstring(Resource* source, char *key, char *accept_language);
+PR_IMPLEMENT(char*) 
+res_getstring(Resource* source, char *key, char *accept_language, char *buffer, size_t bufsize, int *rc);
 
 /* frees Resource* from initialization routine.
 */
 PR_IMPLEMENT(void)
 res_destroy_resource(Resource* to_destroy);
 
+/*
+  ----------------------------------------------------------------
+  res_find_and_init_resource
+
+  Initializes a property file path.  Looks for the package directory
+  in a variety of well known locations, in order, and stops after
+  the first successful attempt to stat the directory.
+  1) the given path, if any
+  2) the current working directory + "/property"
+  3) getenv("ADMINUTIL_CONF_DIR") + "/property"
+  It is expected that applications will have their default property
+  directory compiled in (via configure ; make) and that's what they
+  will pass in as their first argument.  The other path lookup stuff
+  is really for legacy apps or apps in which the user wants to change
+  the property directory at runtime.  The package argument may be
+  NULL, if path is already package specific e.g. /usr/share/adminutil,
+  in which case path should contain the .res files.
+  -----------------------------------------------------------------
+ */
+PR_IMPLEMENT(Resource*)
+res_find_and_init_resource(const char *path, const char *package);
+
+/********************/
+/* XP_AccLangList() */
+/********************/
+
+#define MAX_ACCEPT_LANGUAGE 16
+#define MAX_ACCEPT_LENGTH 18
+
+typedef char ACCEPT_LANGUAGE_LIST[MAX_ACCEPT_LANGUAGE][MAX_ACCEPT_LENGTH];
+
+/* Given an AcceptLanguage string in the HTTP_ACCEPT_LANGUAGE format, return
+   an array of languages, sorted by the quality values (if any).  If the given
+   string is empty, the list will consist of one value, "en", the default language.
+*/
+PR_EXTERN( int )
+XP_AccLangList(char* AcceptLanguage,
+               ACCEPT_LANGUAGE_LIST AcceptLanguageList);
+
+
 #ifdef __cplusplus
 }
 #endif
@@ -141,7 +187,7 @@
  
 #ifdef  RESOURCE_STR
 #define BEGIN_STR(argLibraryName) \
-                          RESOURCE_TABLE argLibraryName[] = { 0, #argLibraryName,
+                          res_RESOURCE_TABLE argLibraryName[] = { 0, #argLibraryName,
 #define ResDef(argToken,argID,argString) \
                           argID, argString,
 #define END_STR(argLibraryName) \




More information about the Fedora-directory-commits mailing list