You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by David Reid <da...@jetnet.co.uk> on 2007/02/19 12:56:16 UTC

[PATCH] user/group functions

The following patch allows NULL to be passed for either the uid or gid
(or both) should the caller only be interested in one or the other.

If folks think this is OK I'll adjust the docs when I commit.

Index: user/unix/userinfo.c
===================================================================
--- user/unix/userinfo.c        (revision 508704)
+++ user/unix/userinfo.c        (working copy)
@@ -92,8 +92,10 @@
                                           apr_gid_t *gid,
                                           apr_pool_t *p)
 {
-    *uid = getuid();
-    *gid = getgid();
+    if (uid)
+        *uid = getuid();
+    if (gid)
+        *gid = getgid();

     return APR_SUCCESS;
 }
@@ -111,8 +113,10 @@
     if ((rv = getpwnam_safe(username, &pw, pwbuf)) != APR_SUCCESS)
         return rv;

-    *uid = pw.pw_uid;
-    *gid = pw.pw_gid;
+    if (uid)
+        *uid = pw.pw_uid;
+    if (gid)
+        *gid = pw.pw_gid;

     return APR_SUCCESS;
 }