VirtualBox

Changeset 35943 in vbox for trunk/src/VBox/HostServices/auth


Ignore:
Timestamp:
Feb 11, 2011 1:04:47 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69996
Message:

VBoxAuth samples: updated to the new generic auth interface.

Location:
trunk/src/VBox/HostServices/auth
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/auth/directoryservice/directoryservice.cpp

    r34563 r35943  
    11/** @file
    22 *
    3  * VBox Remote Desktop Protocol:
    4  * External Authentication Library:
     3 * VirtualBox External Authentication Library:
    54 * Mac OS X Authentication. This is based on
    65 * http://developer.apple.com/mac/library/samplecode/CryptNoMore/
     
    87
    98/*
    10  * Copyright (C) 2009-2010 Oracle Corporation
     9 * Copyright (C) 2009-2011 Oracle Corporation
    1110 *
    1211 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    258257
    259258RT_C_DECLS_BEGIN
    260 DECLEXPORT(AuthResult) AUTHCALL VRDPAuth(PAUTHUUID pUuid,
    261                                          AuthGuestJudgement guestJudgement,
    262                                          const char *pszUser,
    263                                          const char *pszPassword,
    264                                          const char *pszDomain)
     259DECLEXPORT(AuthResult) AUTHCALL AuthEntry(const char *szCaller,
     260                                          PAUTHUUID pUuid,
     261                                          AuthGuestJudgement guestJudgement,
     262                                          const char *szUser,
     263                                          const char *szPassword,
     264                                          const char *szDomain,
     265                                          int fLogon,
     266                                          unsigned clientId)
    265267{
    266268    /* Validate input */
     
    270272    /* Result to a default value */
    271273    AuthResult result = AuthResultAccessDenied;
     274
     275    /* Only process logon requests. */
     276    if (!fLogon)
     277        return result; /* Return value is ignored by the caller. */
    272278
    273279    tDirStatus dsErr = eDSNoErr;
     
    317323RT_C_DECLS_END
    318324
    319 static PAUTHENTRY gpfnAuthEntry = VRDPAuth;
    320 
     325static PAUTHENTRY3 gpfnAuthEntry = AuthEntry;
     326
  • trunk/src/VBox/HostServices/auth/pam/VBoxAuthPAM.c

    r34563 r35943  
    11/** @file
    22 *
    3  * VBox Remote Desktop Protocol:
    4  * External Authentication Library:
     3 * VirtualBox External Authentication Library:
    54 * Linux PAM Authentication.
    65 */
    76
    87/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    109 *
    1110 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2928 *
    3029 * The Auth module takes the PAM service name from the
    31  * environment variable VRDP_AUTH_PAM_SERVICE. If the variable
     30 * environment variable VBOX_AUTH_PAM_SERVICE. If the variable
    3231 * is not specified, then the 'login' PAM service is used.
    3332 */
    34 #define VRDP_AUTH_PAM_SERVICE_NAME_ENV "VRDP_AUTH_PAM_SERVICE"
    35 #define VRDP_AUTH_PAM_DEFAULT_SERVICE_NAME "login"
     33#define VBOX_AUTH_PAM_SERVICE_NAME_ENV_OLD "VRDP_AUTH_PAM_SERVICE"
     34#define VBOX_AUTH_PAM_SERVICE_NAME_ENV "VBOX_AUTH_PAM_SERVICE"
     35#define VBOX_AUTH_PAM_DEFAULT_SERVICE_NAME "login"
    3636
    3737
     
    3939 *
    4040 * If defined, debug messages will be written to the file specified in the
    41  * VRDP_AUTH_DEBUG_FILENAME environment variable:
    42  *
    43  * export VRDP_AUTH_DEBUG_FILENAME=pam.log
     41 * VBOX_AUTH_DEBUG_FILENAME (or deprecated VRDP_AUTH_DEBUG_FILENAME) environment
     42 * variable:
     43 *
     44 * export VBOX_AUTH_DEBUG_FILENAME=pam.log
    4445 *
    4546 * The above will cause writing to the pam.log.
    4647 */
    47 #define VRDP_AUTH_DEBUG_FILENAME_ENV "VRDP_AUTH_DEBUG_FILENAME"
     48#define VBOX_AUTH_DEBUG_FILENAME_ENV_OLD "VRDP_AUTH_DEBUG_FILENAME"
     49#define VBOX_AUTH_DEBUG_FILENAME_ENV "VBOX_AUTH_DEBUG_FILENAME"
    4850
    4951
     
    5456 * and does not harm.
    5557 */
    56 #define VRDP_PAM_DLLOAD
    57 
    58 
    59 #ifdef VRDP_PAM_DLLOAD
     58#define VBOX_AUTH_USE_PAM_DLLOAD
     59
     60
     61#ifdef VBOX_AUTH_USE_PAM_DLLOAD
    6062/* The name of the PAM library */
    6163# ifdef RT_OS_SOLARIS
    62 #  define VRDP_PAM_LIB "libpam.so.1"
     64#  define PAM_LIB_NAME "libpam.so.1"
    6365# else
    64 #  define VRDP_PAM_LIB "libpam.so.0"
     66#  define PAM_LIB_NAME "libpam.so.0"
    6567# endif
    66 #endif /* VRDP_PAM_DLLOAD */
     68#endif /* VBOX_AUTH_USE_PAM_DLLOAD */
    6769
    6870
     
    7981#include <VBox/VBoxAuth.h>
    8082
    81 #ifdef VRDP_PAM_DLLOAD
     83#ifdef VBOX_AUTH_USE_PAM_DLLOAD
    8284#include <dlfcn.h>
    8385
     
    9698#define fn_pam_end          pam_end
    9799#define fn_pam_strerror     pam_strerror
    98 #endif /* VRDP_PAM_DLLOAD */
     100#endif /* VBOX_AUTH_USE_PAM_DLLOAD */
    99101
    100102static void debug_printf(const char *fmt, ...)
    101103{
    102 #ifdef VRDP_AUTH_DEBUG_FILENAME_ENV
     104#if defined(VBOX_AUTH_DEBUG_FILENAME_ENV) || defined(VBOX_AUTH_DEBUG_FILENAME_ENV_OLD)
    103105    va_list va;
    104106
    105107    char buffer[1024];
    106108
    107     const char *filename = getenv (VRDP_AUTH_DEBUG_FILENAME_ENV);
     109    const char *filename = NULL;
    108110
    109111    va_start(va, fmt);
     112
     113#if defined(VBOX_AUTH_DEBUG_FILENAME_ENV)
     114    filename = getenv (VBOX_AUTH_DEBUG_FILENAME_ENV);
     115#endif /* VBOX_AUTH_DEBUG_FILENAME_ENV */
     116
     117#if defined(VBOX_AUTH_DEBUG_FILENAME_ENV_OLD)
     118    if (filename == NULL)
     119    {
     120        filename = getenv (VBOX_AUTH_DEBUG_FILENAME_ENV_OLD);
     121    }
     122#endif /* VBOX_AUTH_DEBUG_FILENAME_ENV_OLD */
    110123
    111124    if (filename)
     
    124137
    125138    va_end (va);
    126 #endif /* VRDP_AUTH_DEBUG_FILENAME_ENV */
    127 }
    128 
    129 #ifdef VRDP_PAM_DLLOAD
     139#endif /* VBOX_AUTH_DEBUG_FILENAME_ENV || VBOX_AUTH_DEBUG_FILENAME_ENV_OLD */
     140}
     141
     142#ifdef VBOX_AUTH_USE_PAM_DLLOAD
    130143
    131144static void *gpvLibPam = NULL;
     
    151164    SymMap *iter;
    152165
    153     gpvLibPam = dlopen(VRDP_PAM_LIB, RTLD_LAZY | RTLD_GLOBAL);
     166    gpvLibPam = dlopen(PAM_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
    154167
    155168    if (!gpvLibPam)
    156169    {
    157         debug_printf("auth_pam_init: dlopen %s failed\n", VRDP_PAM_LIB);
     170        debug_printf("auth_pam_init: dlopen %s failed\n", PAM_LIB_NAME);
    158171        return PAM_SYSTEM_ERR;
    159172    }
     
    203216    return;
    204217}
    205 #endif /* VRDP_PAM_DLLOAD */
     218#endif /* VBOX_AUTH_USE_PAM_DLLOAD */
    206219
    207220static const char *auth_get_pam_service (void)
    208221{
    209     const char *service = getenv (VRDP_AUTH_PAM_SERVICE_NAME_ENV);
     222    const char *service = getenv (VBOX_AUTH_PAM_SERVICE_NAME_ENV);
    210223
    211224    if (service == NULL)
    212225    {
    213         service = VRDP_AUTH_PAM_DEFAULT_SERVICE_NAME;
     226        service = service = getenv (VBOX_AUTH_PAM_SERVICE_NAME_ENV_OLD);
     227
     228        if (service == NULL)
     229        {
     230            service = VBOX_AUTH_PAM_DEFAULT_SERVICE_NAME;
     231        }
    214232    }
    215233
     
    285303
    286304/* prototype to prevent gcc warning */
    287 DECLEXPORT(AuthResult) AUTHCALL VRDPAuth (PAUTHUUID pUuid,
     305DECLEXPORT(AuthResult) AUTHCALL AuthEntry(const char *szCaller,
     306                                          PAUTHUUID pUuid,
    288307                                          AuthGuestJudgement guestJudgement,
    289308                                          const char *szUser,
    290309                                          const char *szPassword,
    291                                           const char *szDomain);
    292 DECLEXPORT(AuthResult) AUTHCALL VRDPAuth (PAUTHUUID pUuid,
     310                                          const char *szDomain,
     311                                          int fLogon,
     312                                          unsigned clientId);
     313DECLEXPORT(AuthResult) AUTHCALL AuthEntry(const char *szCaller,
     314                                          PAUTHUUID pUuid,
    293315                                          AuthGuestJudgement guestJudgement,
    294316                                          const char *szUser,
    295317                                          const char *szPassword,
    296                                           const char *szDomain)
     318                                          const char *szDomain,
     319                                          int fLogon,
     320                                          unsigned clientId)
    297321{
    298322    AuthResult result = AuthResultAccessDenied;
     
    304328
    305329    pam_handle_t *pam_handle = NULL;
     330
     331    /* Only process logon requests. */
     332    if (!fLogon)
     333        return result; /* Return value is ignored by the caller. */
    306334
    307335    debug_printf("u[%s], d[%s], p[%d]\n", szUser, szDomain, szPassword? strlen (szPassword): 0);
     
    376404
    377405/* Verify the function prototype. */
    378 static PAUTHENTRY gpfnAuthEntry = VRDPAuth;
     406static PAUTHENTRY3 gpfnAuthEntry = AuthEntry;
  • trunk/src/VBox/HostServices/auth/simple/VBoxAuthSimple.cpp

    r34563 r35943  
    11/** @file
    22 *
    3  * VBox Remote Desktop Protocol:
    4  * External Authentication Library:
     3 * VirtualBox External Authentication Library:
    54 * Simple Authentication.
    65 */
    76
    87/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    109 *
    1110 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/HostServices/auth/winlogon/winlogon.cpp

    r34563 r35943  
    11/** @file
    22 *
    3  * VBox Remote Desktop Protocol:
    4  * External Authentication Library:
     3 * VirtualBox External Authentication Library:
    54 * Windows Logon Authentication.
    65 */
    76
    87/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    109 *
    1110 * This file is part of VirtualBox Open Source Edition (OSE), as
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette