Documentation ¶
Overview ¶
Package session interacts with session_manager.
Index ¶
- Constants
- func BuildPolicy(user string, key, oldKey *rsa.PrivateKey, ...) (*enterprise_management_proto.PolicyFetchResponse, error)
- func ClearDeviceOwnership(ctx context.Context) error
- func DevicePolicyDescriptor() *lm.PolicyDescriptor
- func ExtractPrivKey(path string) (*rsa.PrivateKey, error)
- func GetSessionManagerPID() (int, error)
- func NormalizeEmail(email string, removeDots bool) (string, error)
- func PrepareChromeForPolicyTesting(ctx context.Context, m *SessionManager) error
- func RetrieveSettings(ctx context.Context, sm *SessionManager) (*enterprise_management_proto.ChromeDeviceSettingsProto, error)
- func SetUpDevice(ctx context.Context) error
- func StoreSettings(ctx context.Context, sm *SessionManager, user string, ...) error
- type SessionManager
- func (m *SessionManager) EnableChromeTesting(ctx context.Context, forceRelaunch bool, ...) (filepath string, err error)
- func (m *SessionManager) EnableChromeTestingAndWait(ctx context.Context, forceRelaunch bool, ...) (filepath string, err error)
- func (m *SessionManager) GetArcStartTimeTicks(ctx context.Context) (time.Time, error)
- func (m *SessionManager) HandleSupervisedUserCreationFinished(ctx context.Context) error
- func (m *SessionManager) HandleSupervisedUserCreationStarting(ctx context.Context) error
- func (m *SessionManager) IsScreenLocked(ctx context.Context) (screenLocked bool, err error)
- func (m *SessionManager) LockScreen(ctx context.Context) error
- func (m *SessionManager) RetrieveActiveSessions(ctx context.Context) (map[string]string, error)
- func (m *SessionManager) RetrievePolicyEx(ctx context.Context, descriptor *lm.PolicyDescriptor) (*enterprise_management_proto.PolicyFetchResponse, error)
- func (m *SessionManager) RetrievePrimarySession(ctx context.Context) (username, hash string, err error)
- func (m *SessionManager) RetrieveSessionState(ctx context.Context) (string, error)
- func (m *SessionManager) StartSession(ctx context.Context, accountID, uniqueIdentifier string) error
- func (m *SessionManager) StorePolicyEx(ctx context.Context, descriptor *lm.PolicyDescriptor, ...) error
- func (m *SessionManager) WatchPropertyChangeComplete(ctx context.Context) (*dbusutil.SignalWatcher, error)
- func (m *SessionManager) WatchScreenIsLocked(ctx context.Context) (*dbusutil.SignalWatcher, error)
- func (m *SessionManager) WatchScreenIsUnlocked(ctx context.Context) (*dbusutil.SignalWatcher, error)
- func (m *SessionManager) WatchSessionStateChanged(ctx context.Context, state string) (*dbusutil.SignalWatcher, error)
- func (m *SessionManager) WatchSetOwnerKeyComplete(ctx context.Context) (*dbusutil.SignalWatcher, error)
Constants ¶
const (
// PolicyPath is a directory containing policy files.
PolicyPath = "/var/lib/devicesettings"
)
Variables ¶
This section is empty.
Functions ¶
func BuildPolicy ¶
func BuildPolicy(user string, key, oldKey *rsa.PrivateKey, s *enterprise_management_proto.ChromeDeviceSettingsProto) (*enterprise_management_proto.PolicyFetchResponse, error)
BuildPolicy creates PolicyFetchResponse used in session_manager from the given parameters.
func ClearDeviceOwnership ¶
ClearDeviceOwnership deletes DUT's ownership infomation.
func DevicePolicyDescriptor ¶
func DevicePolicyDescriptor() *lm.PolicyDescriptor
DevicePolicyDescriptor creates a PolicyDescriptor suitable for storing and retrieving device policy using session_manager's policy storage interface.
func ExtractPrivKey ¶
func ExtractPrivKey(path string) (*rsa.PrivateKey, error)
ExtractPrivKey reads a PKCS #12 format file at path, then extracts and returns RSA private key.
func GetSessionManagerPID ¶
GetSessionManagerPID returns the PID of the session_manager.
func NormalizeEmail ¶
NormalizeEmail normalizes the supplied email address as would be done for GAIA login. The address is lowercased, periods in the username are removed, and a gmail.com domain is appended if needed.
func PrepareChromeForPolicyTesting ¶
func PrepareChromeForPolicyTesting(ctx context.Context, m *SessionManager) error
PrepareChromeForPolicyTesting prepares Chrome for ownership or policy tests. This prevents a crash on startup due to synchronous profile creation and not knowing whether to expect policy, see https://crbug.com/950812. Waits for the new chrome browser to start so that when test calls StartSession, it is not picked up by chrome. Otherwise, chrome crashes because it does not know the test user. See https://crbug.com/1166265.
func RetrieveSettings ¶
func RetrieveSettings(ctx context.Context, sm *SessionManager) (*enterprise_management_proto.ChromeDeviceSettingsProto, error)
RetrieveSettings requests to given SessionManager to return the currently stored ChromeDeviceSettingsProto.
func SetUpDevice ¶
SetUpDevice prepares the device for ownership & policy related tests.
func StoreSettings ¶
func StoreSettings(ctx context.Context, sm *SessionManager, user string, key, oldKey *rsa.PrivateKey, s *enterprise_management_proto.ChromeDeviceSettingsProto) error
StoreSettings requests given SessionManager to store the ChromeDeviceSettingsProto data for the user with key.
Types ¶
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager is used to interact with the session_manager process over D-Bus. For detailed spec of each D-Bus method, please find src/platform2/login_manager/dbus_bindings/org.chromium.SessionManagerInterface.xml
func NewSessionManager ¶
func NewSessionManager(ctx context.Context) (*SessionManager, error)
NewSessionManager connects to session_manager via D-Bus and returns a SessionManager object.
func (*SessionManager) EnableChromeTesting ¶
func (m *SessionManager) EnableChromeTesting(ctx context.Context, forceRelaunch bool, extraArguments, extraEnvironmentVariables []string) (filepath string, err error)
EnableChromeTesting calls SessionManager.EnableChromeTesting D-Bus method.
func (*SessionManager) EnableChromeTestingAndWait ¶
func (m *SessionManager) EnableChromeTestingAndWait(ctx context.Context, forceRelaunch bool, extraArguments, extraEnvironmentVariables []string) (filepath string, err error)
EnableChromeTestingAndWait calls EnableChromeTesting and waits for the new chrome process to start up.
func (*SessionManager) GetArcStartTimeTicks ¶
GetArcStartTimeTicks calls SessionManager.GetArcStartTimeTicks D-Bus method.
func (*SessionManager) HandleSupervisedUserCreationFinished ¶
func (m *SessionManager) HandleSupervisedUserCreationFinished( ctx context.Context) error
HandleSupervisedUserCreationFinished calls SessionManager.HandleSupervisedUserCreationFinished D-Bus method.
func (*SessionManager) HandleSupervisedUserCreationStarting ¶
func (m *SessionManager) HandleSupervisedUserCreationStarting( ctx context.Context) error
HandleSupervisedUserCreationStarting calls SessionManager.HandleSupervisedUserCreationStarting D-Bus method.
func (*SessionManager) IsScreenLocked ¶
func (m *SessionManager) IsScreenLocked(ctx context.Context) (screenLocked bool, err error)
IsScreenLocked calls SessionManager.IsScreenLocked D-Bus method.
func (*SessionManager) LockScreen ¶
func (m *SessionManager) LockScreen(ctx context.Context) error
LockScreen calls SessionManager.LockScreen D-Bus method.
func (*SessionManager) RetrieveActiveSessions ¶
RetrieveActiveSessions calls SessionManager.RetrieveActiveSessions D-Bus method.
func (*SessionManager) RetrievePolicyEx ¶
func (m *SessionManager) RetrievePolicyEx(ctx context.Context, descriptor *lm.PolicyDescriptor) (*enterprise_management_proto.PolicyFetchResponse, error)
RetrievePolicyEx calls SessionManager.RetrievePolicyEx D-Bus method.
func (*SessionManager) RetrievePrimarySession ¶
func (m *SessionManager) RetrievePrimarySession(ctx context.Context) (username, hash string, err error)
RetrievePrimarySession calls SessionManager.RetrievePrimarySession D-Bus method.
func (*SessionManager) RetrieveSessionState ¶
func (m *SessionManager) RetrieveSessionState(ctx context.Context) (string, error)
RetrieveSessionState calls SessionManager.RetrieveSessionState D-Bus method.
func (*SessionManager) StartSession ¶
func (m *SessionManager) StartSession(ctx context.Context, accountID, uniqueIdentifier string) error
StartSession calls SessionManager.StartSession D-Bus method.
func (*SessionManager) StorePolicyEx ¶
func (m *SessionManager) StorePolicyEx(ctx context.Context, descriptor *lm.PolicyDescriptor, policy *enterprise_management_proto.PolicyFetchResponse) error
StorePolicyEx calls SessionManager.StorePolicyEx D-Bus method.
func (*SessionManager) WatchPropertyChangeComplete ¶
func (m *SessionManager) WatchPropertyChangeComplete(ctx context.Context) (*dbusutil.SignalWatcher, error)
WatchPropertyChangeComplete returns a SignalWatcher to observe "PropertyChangeComplete" signal.
func (*SessionManager) WatchScreenIsLocked ¶
func (m *SessionManager) WatchScreenIsLocked(ctx context.Context) (*dbusutil.SignalWatcher, error)
WatchScreenIsLocked returns a SignalWatcher to observe the "ScreenIsLocked" signal.
func (*SessionManager) WatchScreenIsUnlocked ¶
func (m *SessionManager) WatchScreenIsUnlocked(ctx context.Context) (*dbusutil.SignalWatcher, error)
WatchScreenIsUnlocked returns a SignalWatcher to observe the "ScreenIsUnlocked" signal.
func (*SessionManager) WatchSessionStateChanged ¶
func (m *SessionManager) WatchSessionStateChanged(ctx context.Context, state string) (*dbusutil.SignalWatcher, error)
WatchSessionStateChanged returns a SignalWatcher to observe "SessionStateChanged" signal for the given state. If state is empty, it matches with any "SessionStateChanged" signals.
func (*SessionManager) WatchSetOwnerKeyComplete ¶
func (m *SessionManager) WatchSetOwnerKeyComplete(ctx context.Context) (*dbusutil.SignalWatcher, error)
WatchSetOwnerKeyComplete returns a SignalWatcher to observe "SetOwnerKeyComplete" signal.