X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fmacros.c;h=a26864bf483ba1d0abb54716d49f14c9592483c3;hb=3a9e0ee575cdcb3303c0fd69a209b968f97b9295;hp=c763a7ca2f8719d442cda74e017ee846fedf4fa8;hpb=24a7667524f1e4b5d722c45cd69e63a9f905cf56;p=mono.git diff --git a/support/macros.c b/support/macros.c index c763a7ca2f8..a26864bf483 100644 --- a/support/macros.c +++ b/support/macros.c @@ -7,6 +7,7 @@ #include #include #include +#include int wifexited (int status) { @@ -46,12 +47,12 @@ int helper_Mono_Posix_Stat(char *filename, int dereference, int *uid, int *gid, int *rdev, - long *size, - long *blksize, - long *blocks, - long *atime, - long *mtime, - long *ctime + gint64 *size, + gint64 *blksize, + gint64 *blocks, + gint64 *atime, + gint64 *mtime, + gint64 *ctime ) { int ret; struct stat buf; @@ -95,3 +96,50 @@ char *helper_Mono_Posix_readdir(DIR *dir) { if (e == NULL) return NULL; return strdup (e->d_name); } + +int helper_Mono_Posix_getpwnamuid (int mode, char *in_name, int in_uid, + char **account, + char **password, + int *uid, + int *gid, + char **name, + char **home, + char **shell + ) { + + struct passwd pw, *pwp; + char buf[4096]; + int ret; + + if (mode == 0) + ret = getpwnam_r (in_name, &pw, buf, 4096, &pwp); + else + ret = getpwuid_r (in_uid, &pw, buf, 4096, &pwp); + + if (ret == 0 && pwp == NULL) { + // Don't know why this happens, but it does. + // ret == 0, errno == 0, but no record was found. + ret = ENOENT; + } + + if (ret) { + *account = NULL; // prevent marshalling unset pointers + *password = NULL; + *uid = 0; + *gid = 0; + *name = NULL; + *home = NULL; + *shell = NULL; + return ret; + } + + *account = pwp->pw_name; + *password = pwp->pw_passwd; + *uid = pwp->pw_uid; + *gid = pwp->pw_gid; + *name = pwp->pw_gecos; + *home = pwp->pw_dir; + *shell = pwp->pw_shell; + + return 0; +}