Ejemplo n.º 1
0
 ExecuteResult ExecuteHandlerProcessExternal(SecurityContext parentSecurityContext, ActionItem a,
                                             Dictionary <string, string> dynamicData, object parentExitData, bool dryRun = false)
 {
     if (!WantsStopOrPause())
     {
         try
         {
             //if( !a.HasRunAs ) a.RunAs = parentSecurityContext;
             a.IngestParentSecurityContext(parentSecurityContext);
             a.Result = SpawnExternal(a, dynamicData, parentExitData, dryRun);
             return(a.Result);
         }
         catch (Exception ex)
         {
             WriteUnhandledActionException(a, ex);
             return(new ExecuteResult()
             {
                 Status = StatusType.Failed
             });
         }
     }
     else
     {
         return(new ExecuteResult());
     }
 }
Ejemplo n.º 2
0
        ExecuteResult ExecuteHandlerProcessInProc(SecurityContext parentSecurityContext, ActionItem a,
                                                  Dictionary <string, string> dynamicData, object parentExitData, bool dryRun = false)
        {
            try
            {
                //string parms = ResolveConfigAndParameters( a, dynamicData );
                string parms = a.Parameters.GetSerializedValues(Crypto, out string safeSerializedValues);

                IHandlerRuntime rt = CreateHandlerRuntime(a);
                rt.Progress   += rt_Progress;
                rt.LogMessage += rt_LogMessage;

                if (!WantsStopOrPause())
                {
                    a.IngestParentSecurityContext(parentSecurityContext);
                    SecurityContext sc = a.RunAs; //just an alias
                    sc?.Crypto?.InheritSettingsIfRequired(Crypto);

                    HandlerStartInfo startInfo = new HandlerStartInfo(StartInfo)
                    {
                        Parameters     = parms,
                        IsDryRun       = dryRun,
                        PlanInstanceId = InstanceId,
                        InstanceId     = a.InstanceId,
                        ParentExitData = parentExitData,
                        RunAs          = sc,
                        Crypto         = a.Parameters?.Crypto
                    };
                    a.Handler.StartInfo = new HandlerStartInfoData(startInfo);

                    sc?.Impersonate(Crypto);

                    a.Result = rt.Execute(startInfo);

                    a.Handler.StartInfo.Parameters = safeSerializedValues; //avoids serializing decrypted values to the History Plan (bug #93)
                    a.Result.BranchStatus          = a.Result.Status;
                    a.Result.SecurityContext       = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                    SaveExitDataAs(a);

                    sc?.Undo();
                }

                return(a.Result);
            }
            catch (Exception ex)
            {
                WriteUnhandledActionException(a, ex);
                return(new ExecuteResult()
                {
                    Status = StatusType.Failed, ExitData = ex.Message
                });
            }
        }