VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAutoLogon.cpp@ 58029

Last change on this file since 58029 was 57358, checked in by vboxsync, 9 years ago

*: scm cleanup run.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: VBoxGuestR3LibAutoLogon.cpp 57358 2015-08-14 15:16:38Z vboxsync $ */
2/** @file
3 * VBoxGuestR3LibAutoLogon - Ring-3 utility functions for auto-logon modules
4 * (VBoxGINA / VBoxCredProv / pam_vbox).
5 */
6
7/*
8 * Copyright (C) 2012-2015 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#ifdef RT_OS_WINDOWS
33# include <Windows.h>
34#endif
35
36#include "VBGLR3Internal.h"
37
38
39/**
40 * Reports the current auto-logon status to the host.
41 *
42 * This makes sure that the Failed state is sticky.
43 *
44 * @return IPRT status code.
45 * @param enmStatus Status to report to the host.
46 */
47VBGLR3DECL(int) VbglR3AutoLogonReportStatus(VBoxGuestFacilityStatus enmStatus)
48{
49 /*
50 * VBoxGuestFacilityStatus_Failed is sticky.
51 */
52 static VBoxGuestFacilityStatus s_enmLastStatus = VBoxGuestFacilityStatus_Inactive;
53 if (s_enmLastStatus != VBoxGuestFacilityStatus_Failed)
54 {
55 int rc = VbglR3ReportAdditionsStatus(VBoxGuestFacilityType_AutoLogon,
56 enmStatus, 0 /* Flags */);
57 if (rc == VERR_NOT_SUPPORTED)
58 {
59 /*
60 * To maintain backwards compatibility to older hosts which don't have
61 * VMMDevReportGuestStatus implemented we set the appropriate status via
62 * guest property to have at least something.
63 */
64#ifdef VBOX_WITH_GUEST_PROPS
65 uint32_t u32ClientId = 0;
66 rc = VbglR3GuestPropConnect(&u32ClientId);
67 if (RT_SUCCESS(rc))
68 {
69 const char *pszStatus;
70 switch (enmStatus)
71 {
72 case VBoxGuestFacilityStatus_Inactive: pszStatus = "Inactive"; break;
73 case VBoxGuestFacilityStatus_Paused: pszStatus = "Disabled"; break;
74 case VBoxGuestFacilityStatus_PreInit: pszStatus = "PreInit"; break;
75 case VBoxGuestFacilityStatus_Init: pszStatus = "Init"; break;
76 case VBoxGuestFacilityStatus_Active: pszStatus = "Active"; break;
77 case VBoxGuestFacilityStatus_Terminating: pszStatus = "Terminating"; break;
78 case VBoxGuestFacilityStatus_Terminated: pszStatus = "Terminated"; break;
79 case VBoxGuestFacilityStatus_Failed: pszStatus = "Failed"; break;
80 default: pszStatus = NULL;
81 }
82 if (pszStatus)
83 {
84 /*
85 * Use TRANSRESET when possible, fall back to TRANSIENT
86 * (generally sufficient unless the guest misbehaves).
87 */
88 static const char s_szPath[] = "/VirtualBox/GuestInfo/OS/AutoLogonStatus";
89 rc = VbglR3GuestPropWrite(u32ClientId, s_szPath, pszStatus, "TRANSRESET");
90 if (rc == VERR_PARSE_ERROR)
91 rc = VbglR3GuestPropWrite(u32ClientId, s_szPath, pszStatus, "TRANSIENT");
92 }
93 else
94 rc = VERR_INVALID_PARAMETER;
95
96 VbglR3GuestPropDisconnect(u32ClientId);
97 }
98#endif
99 }
100
101 s_enmLastStatus = enmStatus;
102 }
103 return VINF_SUCCESS;
104}
105
106
107/**
108 * Detects whether our process is running in a remote session or not.
109 *
110 * @return bool true if running in a remote session, false if not.
111 */
112VBGLR3DECL(bool) VbglR3AutoLogonIsRemoteSession(void)
113{
114#ifdef RT_OS_WINDOWS
115 return GetSystemMetrics(SM_REMOTESESSION) != 0 ? true : false;
116#else
117 return false; /* Not implemented. */
118#endif
119}
120
Note: See TracBrowser for help on using the repository browser.

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