Ejemplo n.º 1
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            Text = string.Format(Messages.EVACUATE_HOST_DIALOG_TITLE, host.Name());

            //This dialog uses several different actions all of which might need an elevated session
            //We sudo once for all of them and store the session, or close the dialog.
            List <Role> validRoles = new List <Role>();

            if (!connection.Session.IsLocalSuperuser &&
                !Registry.DontSudo &&
                !Role.CanPerform(new RbacMethodList(rbacMethods), connection, out validRoles))
            {
                using (var d = new RoleElevationDialog(connection, connection.Session, validRoles, Text))
                    if (d.ShowDialog(this) == DialogResult.OK)
                    {
                        elevatedPass    = d.elevatedPassword;
                        elevatedUName   = d.elevatedUsername;
                        elevatedSession = d.elevatedSession;
                    }
                    else
                    {
                        Close();
                        return;
                    }
            }

            update();
        }
Ejemplo n.º 2
0
        private AsyncAction.SudoElevationResult SudoDialog(List <Role> rolesAbleToCompleteAction,
                                                           IXenConnection connection, string actionTitle)
        {
            var d = new Dialogs.RoleElevationDialog(connection, connection.Session, rolesAbleToCompleteAction,
                                                    actionTitle);

            DialogResult result = DialogResult.None;

            Program.Invoke(Program.MainWindow, delegate
            {
                result = d.ShowDialog(Program.MainWindow);
            });

            return(new AsyncAction.SudoElevationResult(result == DialogResult.OK, d.elevatedUsername,
                                                       d.elevatedPassword, d.elevatedSession));
        }
        private AsyncAction.SudoElevationResult SudoDialog(List<Role> rolesAbleToCompleteAction,
            IXenConnection connection, string actionTitle)
        {
            var d = new Dialogs.RoleElevationDialog(connection, connection.Session, rolesAbleToCompleteAction,
                                                    actionTitle);

            DialogResult result = DialogResult.None;
            Program.Invoke(Program.MainWindow, delegate
                                                   {
                                                       result = d.ShowDialog(Program.MainWindow);
                                                   });

            return new AsyncAction.SudoElevationResult(result == DialogResult.OK, d.elevatedUsername, 
                                                                 d.elevatedPassword, d.elevatedSession);

        }