apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr/include apr_user.h
Date Wed, 21 Feb 2001 18:41:32 GMT
jwoolley    01/02/21 10:41:31

  Modified:    user/unix userinfo.c
               user/win32 userinfo.c
               include  apr_user.h
  Log:
  Added apr_get_userid() as a companion to apr_get_username().
  PR: Needed to fix Apache PR7271.
  
  Revision  Changes    Path
  1.8       +32 -4     apr/user/unix/userinfo.c
  
  Index: userinfo.c
  ===================================================================
  RCS file: /home/cvs/apr/user/unix/userinfo.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -d -u -r1.7 -r1.8
  --- userinfo.c	2001/02/16 04:16:24	1.7
  +++ userinfo.c	2001/02/21 18:41:24	1.8
  @@ -63,25 +63,53 @@
   #include <sys/types.h>
   #endif
   
  -APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *userid, apr_pool_t
*p)
  +static apr_status_t getpwnam_safe(const char *username,
  +                                  struct passwd **pw)
   {
  -    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)) {
  +    if (getpwnam_r(username, &pwd, pwbuf, sizeof(pwbuf), pw)) {
   #else
  -    if ((pw = getpwnam(userid)) == NULL) {
  +    if ((*pw = getpwnam(username)) == NULL) {
   #endif
           return errno;
       }
  +    return APR_SUCCESS;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname,
  +                                                 const char *username,
  +                                                 apr_pool_t *p)
  +{
  +    struct passwd *pw;
  +    apr_status_t rv;
  +
  +    if ((rv = getpwnam_safe(username, &pw)) != APR_SUCCESS)
  +        return rv;
  +
   #ifdef OS2
       /* Need to manually add user name for OS/2 */
       *dirname = apr_pstrcat(p, pw->pw_dir, pw->pw_name, NULL);
   #else
       *dirname = apr_pstrdup(p, pw->pw_dir);
   #endif
  +    return APR_SUCCESS;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
  +                                         const char *username)
  +{
  +    struct passwd *pw;
  +    apr_status_t rv;
  +        
  +    if ((rv = getpwnam_safe(username, &pw)) != APR_SUCCESS)
  +        return rv;
  +
  +    *uid = pw->pw_uid;
  +    *gid = pw->pw_gid;
  +
       return APR_SUCCESS;
   }
   
  
  
  
  1.4       +8 -1      apr/user/win32/userinfo.c
  
  Index: userinfo.c
  ===================================================================
  RCS file: /home/cvs/apr/user/win32/userinfo.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -d -u -r1.3 -r1.4
  --- userinfo.c	2001/02/16 04:16:24	1.3
  +++ userinfo.c	2001/02/21 18:41:27	1.4
  @@ -60,8 +60,15 @@
   #include <sys/types.h>
   #endif
   
  -APR_DECLARE(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 *username,
apr_pool_t *p)
   {
  +    return APR_ENOTIMPL;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
  +                                         const char *username)
  +{
  +    /* XXX: could someone please implement this for me? */
       return APR_ENOTIMPL;
   }
   
  
  
  
  1.10      +22 -10    apr/include/apr_user.h
  
  Index: apr_user.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_user.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -d -u -r1.9 -r1.10
  --- apr_user.h	2001/02/16 04:15:47	1.9
  +++ apr_user.h	2001/02/21 18:41:29	1.10
  @@ -91,31 +91,42 @@
   
   /***
    * Get the user name for a specified userid
  - * @param dirname Pointer to new string containing user name (on output)
  + * @param username 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.
  + * @deffunc apr_status_t apr_get_username(char **username, apr_uid_t userid, apr_pool_t
*p)
    */
   APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, apr_pool_t
*p);
   
   /***
  + * Get the userid (and groupid) for the specified username
  + * @param userid   Returns the user id
  + * @param groupid  Returns the user's group id
  + * @param username The username to lookup
  + * @tip This function is available only if APR_HAS_USER is defined.
  + * @deffunc apr_status_t apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid, const char
*username)
  + */
  +APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid, const char
*username);
  +
  +/***
    * 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 username 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.
  + * @deffunc apr_status_t apr_get_home_directory(char **dirname, const char *username, apr_pool_t
*p)
    */
  -APR_DECLARE(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 *username,
apr_pool_t *p);
   
   /***
    * Compare two user identifiers for equality.
    * @param left One uid to test
    * @param right Another uid to test
  - * @deffunc apr_status_t apr_compare_users(apr_uid_t left, apr_uid_t right)
  - * @tip Returns APR_SUCCESS if the apr_uid_t strutures identify the same user,
  + * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
    * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
  + * @tip This function is available only if APR_HAS_USER is defined.
  + * @deffunc apr_status_t apr_compare_users(apr_uid_t left, apr_uid_t right)
    */
   #if defined(WIN32)
   APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right);
  @@ -128,8 +139,8 @@
    * @param dirname Pointer to new string containing group name (on output)
    * @param userid The groupid
    * @param p The pool from which to allocate the string
  - * @deffunc apr_status_t apr_get_groupname(char **groupname, apr_gid_t userid, apr_pool_t
*p);
    * @tip This function is available only if APR_HAS_USER is defined.
  + * @deffunc apr_status_t apr_get_groupname(char **groupname, apr_gid_t userid, apr_pool_t
*p);
    */
   APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, apr_gid_t groupid, apr_pool_t
*p);
   
  @@ -137,9 +148,10 @@
    * Compare two group identifiers for equality.
    * @param left One gid to test
    * @param right Another gid to test
  - * @deffunc apr_status_t apr_compare_groups(apr_gid_t left, apr_gid_t right)
  - * @tip Returns APR_SUCCESS if the apr_gid_t strutures identify the same group,
  + * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
    * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
  + * @tip This function is available only if APR_HAS_USER is defined.
  + * @deffunc apr_status_t apr_compare_groups(apr_gid_t left, apr_gid_t right)
    */
   #if defined(WIN32)
   APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right);
  
  
  

Mime
View raw message