apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Southern <the_angry_an...@blueyonder.co.uk>
Subject apr_uid_homepath_get failing
Date Fri, 05 Jan 2007 19:09:11 GMT
Hi guys and gals,

Just to set the scene; I'm currently using the latest SVN version of APR
(as of a few hours ago), and using MinGW/Msys to compile both APR and my
test application. I know it's a little arse about tit doing that.

I've been playing around with the user info module of APR in the last
few hours and seem to have come across a bit of a problem concerning
apr_uid_homepath_get; it fails under WinXP (all I've tested so far, I'm
afraid), returning APR_ENOENT. When I apply APR_TO_OS_ERROR I end up
with a return code of 2, which I believe to be "file/path not found".

I've fished into the process as it's running and it appears to be
stepping into line 95 of win32/userinfo.c, which looks at the pre-NT key
- which doesn't exist under XP. I've tried changing the key to point at
the correct place, and recompiled APR but I still seem to get the same
problem. Unfortunately my debugging skills aren't that "leet" and I
can't see where it goes after line 98. Am I barking up the wrong tree or
doing something obviously wrong? The source of my test is below:

#include "apr_pools.h"
#include "apr_user.h"

int main()
    apr_pool_t *p;
    apr_status_t e;

    char *uname = NULL;
    char *gname = NULL;
    char *hpath = NULL;

    apr_pool_create(&p, NULL);

    apr_uid_t uid;
    apr_gid_t gid;
    apr_uid_current(&uid, &gid, p);

    apr_uid_name_get(&uname, uid, p);
    apr_gid_name_get(&gname, gid, p);
    e = apr_uid_homepath_get(&hpath, uname, p);

    printf ("%d\n", APR_TO_OS_ERROR(e));

    printf("hello %s, member of %s, home at '%s'\n", uname, gname, hpath);


    return 0;

Since I'm on the subject of apr_uid_homepath_get, I was trying to find
if there was a reason that its arguments are as they are. In terms of
what I'm aiming at, I want to know the homepath of the user running the
program, which means I have to go through the convoluted process above
(plus error checking); where I get the current processes uid, then find
the name, then pass the name to the homepath function, which in turn
looks up the uid from the username and then gets the path. Would it be
appropriate to propose/submit a patch for an additional function to look
up via uid, or would it be more appropriate to patch and maintain a
custom version of APR?

Thanks in advance,

View raw message