Ejemplo n.º 1
0
        // Does this cover sudo?
        public static bool IsRunningAsRoot()
        {
            var runner   = new ExternalCommandRunner();
            var username = runner.RunExternalCommand("whoami");

            return(username != null?username.Contains("root") : false);
        }
 public static bool IsRunningAsRoot()
 {
     if (ExternalCommandRunner.RunExternalCommand("whoami", string.Empty, out string username, out string _) == 0)
     {
         return(username.Trim().Equals("root"));
     }
     return(false);
 }
Ejemplo n.º 3
0
 public static string GetOsVersion()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         return(System.Environment.OSVersion.VersionString);
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
     {
         return(ExternalCommandRunner.RunExternalCommand("uname", "-r"));
     }
     return("");
 }
Ejemplo n.º 4
0
 public static string GetOsName()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         return(Helpers.RuntimeString());
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
     {
         return(ExternalCommandRunner.RunExternalCommand("uname", "-s"));
     }
     return("");
 }
Ejemplo n.º 5
0
 public static bool IsRunningAsRoot()
 {
     var username = "******";
     try
     {
         username = ExternalCommandRunner.RunExternalCommand("whoami");
     }
     catch (Exception)
     {
         Log.Fatal("Couldn't run 'whoami' to determine root.");
     }
     return username != null ? username.Equals("root") : false;
 }
Ejemplo n.º 6
0
 public static string GetOsName()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         return(AsaHelpers.GetPlatformString());
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
     {
         if (ExternalCommandRunner.RunExternalCommand("uname", "-s", out string StdOut, out string _) == 0)
         {
             return(StdOut);
         }
     }
     return("");
 }