Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 85133 invoked by uid 500); 20 Nov 2001 23:31:06 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 85113 invoked from network); 20 Nov 2001 23:31:06 -0000 Subject: Re: cvs commit: apr/include apr_user.h From: Ian Holsman To: dev@apr.apache.org Cc: apr-cvs@apache.org In-Reply-To: <20011120224446.20625.qmail@icarus.apache.org> References: <20011120224446.20625.qmail@icarus.apache.org> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/0.99.2 (Preview Release) Date: 20 Nov 2001 15:31:12 -0800 Message-Id: <1006299072.24294.51.camel@griffon.cnet.com> Mime-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Tue, 2001-11-20 at 14:44, wrowe@apache.org wrote: > wrowe 01/11/20 14:44:46 > > Modified: user/unix groupinfo.c > include apr_user.h > Log: > Implement apr_get_groupid [to mirror apr_get_userid] > > Revision Changes Path > 1.6 +19 -0 apr/user/unix/groupinfo.c > > Index: groupinfo.c > =================================================================== > RCS file: /home/cvs/apr/user/unix/groupinfo.c,v > retrieving revision 1.5 > retrieving revision 1.6 > diff -u -r1.5 -r1.6 > --- groupinfo.c 2001/07/20 12:36:13 1.5 > +++ groupinfo.c 2001/11/20 22:44:46 1.6 > @@ -86,3 +86,22 @@ > return APR_SUCCESS; > } > > +APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, const char *groupname, apr_pool_t *p) > +{ > + struct group *gr; > +#ifndef BEOS > + > +#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) > + struct group grp; > + char grbuf[512]; > + > + if (getgrnam_r(&grpname, &gr, grbuf, sizeof(grbuf))) { linux needs another parameter on this.. something about restricting groups.. (the man page doesn't seem to come up so I'm not sure what the parameter does) > +#else > + if ((gr = getgrnam(groupname)) == NULL) { > +#endif > + return errno; > + } > + *groupid = gr->gr_gid; > +#endif > + return APR_SUCCESS; > +} > > > > 1.16 +13 -4 apr/include/apr_user.h > > Index: apr_user.h > =================================================================== > RCS file: /home/cvs/apr/include/apr_user.h,v > retrieving revision 1.15 > retrieving revision 1.16 > diff -u -r1.15 -r1.16 > --- apr_user.h 2001/08/24 17:55:45 1.15 > +++ apr_user.h 2001/11/20 22:44:46 1.16 > @@ -144,19 +144,28 @@ > #if defined(WIN32) > APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right); > #else > -#define apr_compare_users(left,right) ((left == right) ? APR_SUCCESS : APR_EMISMATCH) > +#define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) > #endif > > /** > * Get the group name for a specified groupid > - * @param dirname Pointer to new string containing group name (on output) > - * @param userid The groupid > + * @param groupname Pointer to new string containing group name (on output) > + * @param groupid The groupid > * @param p The pool from which to allocate the string > * @remark This function is available only if APR_HAS_USER is defined. > */ > APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, apr_gid_t groupid, apr_pool_t *p); > > /** > + * Get the groupid for a specified group name > + * @param groupid Pointer to the group id (on output) > + * @param groupname The group name to look up > + * @param p The pool from which to allocate the string > + * @remark This function is available only if APR_HAS_USER is defined. > + */ > +APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, const char *groupname, apr_pool_t *p); > + > +/** > * Compare two group identifiers for equality. > * @param left One gid to test > * @param right Another gid to test > @@ -167,7 +176,7 @@ > #if defined(WIN32) > APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right); > #else > -#define apr_compare_groups(left,right) ((left == right) ? APR_SUCCESS : APR_EMISMATCH) > +#define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) > #endif > > #endif /* ! APR_HAS_USER */ > > > -- Ian Holsman IanH@cnet.com Performance Measurement & Analysis CNET Networks - (415) 344-2608