apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/user/unix Makefile.in userinfo.c homedir.c
Date Sun, 28 Jan 2001 00:04:05 GMT
wrowe       01/01/27 16:04:04

  Modified:    include  apr_user.h
               user/unix Makefile.in userinfo.c
  Removed:     user/unix homedir.c
  Log:
    Added apr_get_username to the former homedir.c (now userinfo.c).
  
    HAVE_GETPWNAM_R is likely the wrong test for HAVE_GETPWUID_R, but I have
    no clue if that featuretest is already compiled.  Unix folk, please
    adjust accordingly.
  
  Revision  Changes    Path
  1.3       +13 -3     apr/include/apr_user.h
  
  Index: apr_user.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_user.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_user.h	2000/11/26 03:00:04	1.2
  +++ apr_user.h	2001/01/28 00:04:01	1.3
  @@ -70,14 +70,24 @@
    */
   
   /***
  - * Get the home directory for a specified userid.
  - * @param dirname Pointer to new string containing directory name (on output)
  + * Get the user name for a specified userid
  + * @param dirname Pointer to new string containing user name (on output)
    * @param userid The userid
    * @param p The pool from which to allocate the string
  + * @deffunc apr_status_t apr_get_username(char **username, apr_uid_t userid, apr_pool_t
*p)
  + * @tip This function is available only if APR_HAS_USER is defined.
  + */
  +APR_DECLARE(apr_status_t) apr_get_userid(char **username, apr_uid_t userid, apr_pool_t
*p);
  +
  +/***
  + * Get the home directory for the named user
  + * @param dirname Pointer to new string containing directory name (on output)
  + * @param userid The named user
  + * @param p The pool from which to allocate the string
    * @deffunc apr_status_t apr_get_home_directory(char **dirname, const char *userid, apr_pool_t
*p)
    * @tip This function is available only if APR_HAS_USER is defined.
    */
  -apr_status_t apr_get_home_directory(char **dirname, const char *userid, apr_pool_t *p);
  +APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *userid, apr_pool_t
*p);
   
   #ifdef __cplusplus
   }
  
  
  
  1.5       +1 -1      apr/user/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/user/unix/Makefile.in,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Makefile.in	2001/01/09 11:06:28	1.4
  +++ Makefile.in	2001/01/28 00:04:02	1.5
  @@ -1,5 +1,5 @@
   
  -TARGETS = homedir.lo
  +TARGETS = userinfo.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.4       +19 -6     apr/user/unix/userinfo.c
  
  Index: userinfo.c
  ===================================================================
  RCS file: /home/cvs/apr/user/unix/userinfo.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- userinfo.c	2000/12/31 14:19:09	1.3
  +++ userinfo.c	2001/01/28 00:04:03	1.4
  @@ -63,24 +63,37 @@
   #include <sys/types.h>
   #endif
   
  -apr_status_t apr_get_home_directory(char **dirname, const char *userid, apr_pool_t *p)
  +APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *userid, apr_pool_t
*p)
   {
       struct passwd *pw;
   #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
       struct passwd pwd;
       char pwbuf[512];
  +
  +    if (getpwnam_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw)) {
  +#else
  +    if ((pw = getpwnam(userid)) == NULL) {
   #endif
  +        return errno;
  +    }
  +    *dirname = apr_pstrdup(p, pw->pw_dir);
  +    return APR_SUCCESS;
  +}
   
  +APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, apr_pool_t
*p)
  +{
  +    struct passwd *pw;
   #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
  -    if (!getpwnam_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw)) {
  +    struct passwd pwd;
  +    char pwbuf[512];
  +
  +    if (getpwuid_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw)) {
   #else
  -    if ((pw = getpwnam(userid)) != NULL) {
  +    if ((pw = getpwuid(userid)) == NULL) {
   #endif
  -        *dirname = apr_pstrdup(p, pw->pw_dir);
  -    }
  -    else {
           return errno;
       }
  +    *username = apr_pstrdup(p, pw->pw_name);
       return APR_SUCCESS;
   }
     
  
  
  

Mime
View raw message