VBoxAuthSimple.cpp revision b8908d384db2324f04a2f68a13e67ea32ebf609a
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * VBox Remote Desktop Protocol:
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * External Authentication Library:
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Simple Authentication.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Copyright (C) 2006-2010 Oracle Corporation
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * available from http://www.virtualbox.org. This file is free software;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * General Public License (GPL) as published by the Free Software
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d6aa6429f99fb7648883eb612f8a52b9aaf3bff4vboxsyncusing namespace com;
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/* If defined, debug messages will be written to the specified file. */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync//#define AUTH_DEBUG_FILE_NAME "/tmp/VBoxAuth.log"
b0dfb334954c0552bb583967a3077ec88fd00471vboxsyncDECLEXPORT(AuthResult) AUTHCALL AuthEntry(const char *szCaller,
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync const char *szUser,
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync const char *szDomain,
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync /* default is failed */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync /* only interested in logon */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync /* return value ignored */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync RTUuidToStr((PCRTUUID)pUuid, (char*)uuid, RTUUID_STR_LENGTH);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync /* the user might contain a domain name, split it */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync dprintf("VBoxAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user, szPassword);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync rc = virtualBox.createLocalObject(CLSID_VirtualBox);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Bstr key = BstrFmt("VBoxAuthSimple/users/%s", user);
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync /* lookup in VM's extra data? */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync virtualBox->FindMachine(Bstr(uuid).raw(), machine.asOutParam());
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync machine->GetExtraData(key.raw(), password.asOutParam());
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync /* lookup global extra data */
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync virtualBox->GetExtraData(key.raw(), password.asOutParam());
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync /* calculate hash */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync RTSha256(szPassword, strlen(szPassword), abDigest);
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest));
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync/* Verify the function prototype. */