static int Main(string[] args) { if (SecurityAPI.is_user_admin()) { ZeroDayPatch automate = new ZeroDayPatch(); automate.config = new CliConfig(config_types.ZeroDayPatch); CliInit init; if (args.Length == 1 && args[0].StartsWith("/config=")) { init = new CliInit(CliInit.GetConfigFromFile(ref args), ref automate.config); } else { init = new CliInit(args, ref automate.config); } #region If we can initialise run the automate if (init.ParseArgs()) { Console.WriteLine("ZeroDayPatch {0} starting.", Constant.VERSION); GuidCollection bulletins = new GuidCollection(); bulletins = automate.GetSoftwareBulletins(); int i = automate.RunAutomation(bulletins); if (i != -1) { Console.WriteLine("\n{0} software update policy creation tasks were started.", i.ToString()); Console.WriteLine("ZeroDayPatch execution completed now. See you soon..."); return(0); } return(i); } #endregion #region else display the help message else { if (automate.config.Print_Version) { Console.WriteLine("{{CWoC}} ZeroDayPatch version {0}", Constant.VERSION); return(0); } Console.WriteLine(Constant.ZERO_DAY_HELP); if (!automate.config.Help_Needed) { return(0); } return(-1); } #endregion } else { Console.WriteLine("Access denied - Only Altiris administrators are allowed to use this tool"); } return(-1); }
public static int Main(string[] Args) { if (Args.Length == 0) { help(); return(-1); } else { if (SecurityAPI.is_user_admin()) { try { DatabaseAPI.ExecuteNonQuery(Constant.PATCH_EXCLUSION_CREATION); } catch { Console.WriteLine("Failed to access the Symantec CMDB... Patch Exclusion will stop now."); return(-1); } switch (Args[0]) { case "version": return(version()); case "++": case "add": return(add(Args)); case "--": case "del": return(del(Args)); case "ls": case "list": return(list()); case "reset": return(rst()); case "forceinit": return(forceinit()); case "help": case "/?": help(); return(0); default: help(); return(-1); } } else { Console.WriteLine("Access denied - Only Administrators are allowed to use this tool."); return(-1); } } }
static int Main(string[] args) { int rc = 0; if (SecurityAPI.is_user_admin()) { PatchAutomate automate = new PatchAutomate(); automate.config = new CliConfig(config_types.PatchAutomation); CliInit init; if (args.Length == 1 && args[0].StartsWith("/config=")) { init = new CliInit(CliInit.GetConfigFromFile(ref args), ref automate.config); } else { init = new CliInit(args, ref automate.config); } EventLog.ReportInfo(init.DumpConfig(config_types.PatchAutomation)); if (init.ParseArgs()) { _debug = automate.config.Debug; Console.WriteLine("PatchAutomate starting."); EventLog.ReportInfo("Symantec BCS PatchAutomate is starting."); try { rc = automate.RunAutomation(); } catch (Exception e) { LoggingAPI.ReportException(e); rc = -2; } } else { if (automate.config.Print_Version) { Console.WriteLine("{{CWoC}} PatchAutomation version {0}", Constant.VERSION); return(0); } Console.WriteLine(Constant.PATCH_AUTOMATE_HELP); if (!automate.config.Help_Needed) { EventLog.ReportInfo("PatchAutomate invocation incorrect. Printed command line help and returned -1."); return(-1); } return(0); } if (rc == 0) { LoggingAPI.ReportInfo("PatchAutomate execution completed. See you soon..."); } } else { LoggingAPI.ReportInfo("Access denied - Only Administrators are allowed to use this tool. This entry will be recorded in the Altiris Server logs."); rc = -1; } return(rc); }