VBoxGuestR3LibCredentials.cpp revision 4fd422211bfa08d134940933274daafa9f2a3ef7
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, user credentials.
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * available from http://www.virtualbox.org. This file is free software;
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * you can redistribute it and/or modify it under the terms of the GNU
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * General Public License (GPL) as published by the Free Software
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * additional information or have any questions.
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync/*******************************************************************************
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync* Header Files *
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync*******************************************************************************/
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * Checks whether user credentials are available to the guest or not.
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * @returns true if credentials are available, false if not (or error occured).
a8e1fc1b96d1436189fdb4530d31f20b88b70ea1vboxsyncVBGLR3DECL(bool) VbglR3CredentialsAreAvailable(void)
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync vmmdevInitRequest((VMMDevRequestHeader*)&Req, VMMDevReq_QueryCredentials);
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync && (Req.u32Flags & VMMDEV_CREDENTIALS_PRESENT) != 0;
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync * Retrieves and clears the user credentials for logging into the guest OS.
bd44be5c996657f50cadcb987ee2879f4114d249vboxsync * @returns IPRT status value
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync * @param ppszUser Receives pointer of allocated user name string.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * The returned pointer must be freed using VbglR3CredentialsDestroy().
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync * @param ppszPassword Receives pointer of allocated user password string.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * The returned pointer must be freed using VbglR3CredentialsDestroy().
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync * @param ppszDomain Receives pointer of allocated domain name string.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * The returned pointer must be freed using VbglR3CredentialsDestroy().
bd44be5c996657f50cadcb987ee2879f4114d249vboxsyncVBGLR3DECL(int) VbglR3CredentialsRetrieve(char **ppszUser, char **ppszPassword, char **ppszDomain)
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync vmmdevInitRequest((VMMDevRequestHeader*)&Req, VMMDevReq_QueryCredentials);
f5663ddc90362ab5cfe32e277fa34f2b057e8cfdvboxsync Req.u32Flags |= VMMDEV_CREDENTIALS_READ | VMMDEV_CREDENTIALS_CLEAR;
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * Clears and frees the strings
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * @returns IPRT status value
4fd422211bfa08d134940933274daafa9f2a3ef7vboxsync * @param pszUser Receives pointer of the user name string to destroy.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * Optional.
4fd422211bfa08d134940933274daafa9f2a3ef7vboxsync * @param pszPassword Receives pointer of the password string to destroy.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * Optional.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * @param pszDomain Receives pointer of allocated domain name string.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * Optional.
940534f83612182a14887c7ccac92bfc43cbebd2vboxsync * @param u8NumPasses Number of wipe passes. The higher the better (and slower!).
940534f83612182a14887c7ccac92bfc43cbebd2vboxsyncVBGLR3DECL(void) VbglR3CredentialsDestroy(char *pszUser, char *pszPassword, char *pszDomain, uint8_t u8NumPasses)
4fd422211bfa08d134940933274daafa9f2a3ef7vboxsync if (u8NumPasses == 0) /* We at least want to have one wipe pass. */
4fd422211bfa08d134940933274daafa9f2a3ef7vboxsync /** @todo add some for-loop with randomized content instead of
4fd422211bfa08d134940933274daafa9f2a3ef7vboxsync * zero'ing out the string only one time. Use u8NumPasses for that. */