protected override void OnSessionChange(SessionChangeDescription changeDescription)
        {
            try
            {
                base.OnSessionChange(changeDescription);

                if (!GSDEnlistment.IsUnattended(tracer: null))
                {
                    if (changeDescription.Reason == SessionChangeReason.SessionLogon)
                    {
                        this.tracer.RelatedInfo("SessionLogon detected, sessionId: {0}", changeDescription.SessionId);
                        using (ITracer activity = this.tracer.StartActivity("LogonAutomount", EventLevel.Informational))
                        {
                            this.repoRegistry.AutoMountRepos(
                                GSDPlatform.Instance.GetUserIdFromLoginSessionId(changeDescription.SessionId, this.tracer),
                                changeDescription.SessionId);
                            this.repoRegistry.TraceStatus();
                        }
                    }
                    else if (changeDescription.Reason == SessionChangeReason.SessionLogoff)
                    {
                        this.tracer.RelatedInfo("SessionLogoff detected");
                    }
                }
            }
            catch (Exception e)
            {
                this.LogExceptionAndExit(e, nameof(this.OnSessionChange));
            }
        }
Exemple #2
0
        public GSDVerb(bool validateOrigin = true)
        {
            this.Output            = Console.Out;
            this.ReturnCode        = ReturnCode.Success;
            this.validateOriginURL = validateOrigin;
            this.ServiceName       = GSDConstants.Service.ServiceName;
            this.StartedByService  = false;
            this.Unattended        = GSDEnlistment.IsUnattended(tracer: null);

            this.InitializeDefaultParameterValues();
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            try
            {
                if (args.Length < 2)
                {
                    ExitWithError("Usage: gvfs.hooks.exe --git-pid=<pid> <hook> <git verb> [<other arguments>]");
                }

                bool unattended = GSDEnlistment.IsUnattended(tracer: null);

                string errorMessage;
                string normalizedCurrentDirectory;
                if (!GSDHooksPlatform.TryGetNormalizedPath(Environment.CurrentDirectory, out normalizedCurrentDirectory, out errorMessage))
                {
                    ExitWithError($"Failed to determine final path for current directory {Environment.CurrentDirectory}. Error: {errorMessage}");
                }

                if (!GSDHooksPlatform.TryGetGSDEnlistmentRoot(Environment.CurrentDirectory, out enlistmentRoot, out errorMessage))
                {
                    // Nothing to hook when being run outside of a GSD repo.
                    // This is also the path when run with --git-dir outside of a GSD directory, see Story #949665
                    Environment.Exit(0);
                }

                enlistmentPipename = GSDHooksPlatform.GetNamedPipeName(enlistmentRoot);

                switch (GetHookType(args))
                {
                case PreCommandHook:
                    CheckForLegalCommands(args);
                    RunPreCommands(args);
                    break;

                case PostCommandHook:
                    RunPostCommands(args, unattended);
                    break;

                default:
                    ExitWithError("Unrecognized hook: " + string.Join(" ", args));
                    break;
                }
            }
            catch (Exception ex)
            {
                ExitWithError("Unexpected exception: " + ex.ToString());
            }
        }
        public void Start()
        {
            if (!GSDEnlistment.IsUnattended(this.tracer))
            {
                TimeSpan startTime = TimeSpan.Zero;

                this.tracer.RelatedInfo("Starting auto upgrade checks.");
                this.timer = new Timer(
                    this.TimerCallback,
                    state: null,
                    dueTime: startTime,
                    period: TimeInterval);
            }
            else
            {
                this.tracer.RelatedInfo("No upgrade checks scheduled, GSD is running in unattended mode.");
            }
        }
Exemple #5
0
 protected virtual bool IsUnattended()
 {
     return(GSDEnlistment.IsUnattended(this.tracer));
 }