From 3373742327451a83f03946e47d0dd512295303f0 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 13 Aug 2002 13:24:57 +0000 Subject: Switched to the new authentication/authorization functions. --- libmu_scm/mu_util.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'libmu_scm') diff --git a/libmu_scm/mu_util.c b/libmu_scm/mu_util.c index 606256c6f..0b973fed4 100644 --- a/libmu_scm/mu_util.c +++ b/libmu_scm/mu_util.c @@ -16,54 +16,52 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "mu_scm.h" -#include +#include -SCM_DEFINE (mu_scm_getpwuid, "mu_getpwuid", 0, 1, 0, +SCM_DEFINE (mu_scm_getpwuid, "mu-getpwuid", 1, 0, 0, (SCM USER), "Look up an entry in the user database. USER can be an integer,\n" - "a string, or omitted, giving the behaviour of mu_getpwuid, mu_getpwnam\n" - "or (system) getpwent respectively.\n" - "Returns a vector with fields corresponding to those of the passwd\n" + "or a string, giving the behaviour of mu_get_auth_by_uid or mu_get_auth_by_name\n" + "respectively.\n" + "Returns a vector with fields corresponding to those of the mu_auth_data\n" "entry in question. If no matching entry was found, returns #f.\n") #define FUNC_NAME s_mu_scm_getpwuid { SCM result; - struct passwd *entry; + struct mu_auth_data *entry; SCM *ve; - result = scm_make_vector (SCM_MAKINUM (7), SCM_UNSPECIFIED); + result = scm_make_vector (SCM_MAKINUM (8), SCM_UNSPECIFIED); ve = SCM_VELTS (result); - if (SCM_UNBNDP (USER) || SCM_FALSEP (USER)) + if (SCM_INUMP (USER)) { - entry = getpwent (); - } - else if (SCM_INUMP (USER)) - { - entry = mu_getpwuid (SCM_INUM (USER)); + entry = mu_get_auth_by_uid (SCM_INUM (USER)); } else { SCM_VALIDATE_ROSTRING (1, USER); if (SCM_SUBSTRP (USER)) USER = scm_makfromstr (SCM_ROCHARS (USER), SCM_ROLENGTH (USER), 0); - entry = mu_getpwnam (SCM_ROCHARS (USER)); + entry = mu_get_auth_by_name (SCM_ROCHARS (USER)); } if (!entry) return SCM_BOOL_F; - ve[0] = scm_makfrom0str (entry->pw_name); - ve[1] = scm_makfrom0str (entry->pw_passwd); - ve[2] = scm_ulong2num ((unsigned long) entry->pw_uid); - ve[3] = scm_ulong2num ((unsigned long) entry->pw_gid); - ve[4] = scm_makfrom0str (entry->pw_gecos); - if (!entry->pw_dir) + ve[0] = scm_makfrom0str (entry->name); + ve[1] = scm_makfrom0str (entry->passwd); + ve[2] = scm_ulong2num ((unsigned long) entry->uid); + ve[3] = scm_ulong2num ((unsigned long) entry->gid); + ve[4] = scm_makfrom0str (entry->gecos); + if (!entry->dir) ve[5] = scm_makfrom0str (""); else - ve[5] = scm_makfrom0str (entry->pw_dir); - if (!entry->pw_shell) + ve[5] = scm_makfrom0str (entry->dir); + if (!entry->shell) ve[6] = scm_makfrom0str (""); else - ve[6] = scm_makfrom0str (entry->pw_shell); + ve[6] = scm_makfrom0str (entry->shell); + ve[7] = scm_makfrom0str (entry->mailbox); + mu_auth_data_free (entry); return result; } #undef FUNC_NAME -- cgit v1.2.1