-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from gerardog/dev
Release 0.6
- Loading branch information
Showing
25 changed files
with
444 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using gsudo.Helpers; | ||
using System.Diagnostics; | ||
|
||
namespace gsudo.Commands | ||
{ | ||
/// <summary> | ||
/// We can only spawn a process as system account if we were elevated first. | ||
/// So, | ||
/// Non-elevated Gsudo client -(elevates)-> Gsudo SystemService -(runs as System)-> Gsudo Service. | ||
/// Then.. | ||
/// Non-elevated Gsudo client connects to Gsudo Service running as system. | ||
/// </summary> | ||
class SystemServiceCommand : ICommand | ||
{ | ||
public int allowedPid { get; set; } | ||
public string allowedSid { get; set; } | ||
|
||
public LogLevel? LogLvl { get; set; } | ||
|
||
public Task<int> Execute() | ||
{ | ||
// service mode | ||
if (LogLvl.HasValue) GlobalSettings.LogLevel.Value = LogLvl.Value; | ||
|
||
var dbg = GlobalSettings.Debug ? "--debug " : string.Empty; | ||
|
||
if (ProcessExtensions.IsAdministrator()) | ||
{ | ||
var process = ProcessFactory.StartAsSystem(Process.GetCurrentProcess().MainModule.FileName, $"{dbg}-s gsudoservice {allowedPid} {allowedSid} {GlobalSettings.LogLevel}", Environment.CurrentDirectory, !GlobalSettings.Debug); | ||
if (process == null) | ||
{ | ||
Logger.Instance.Log("Failed to start elevated instance.", LogLevel.Error); | ||
return Task.FromResult(Constants.GSUDO_ERROR_EXITCODE); | ||
} | ||
|
||
Logger.Instance.Log("Elevated instance started.", LogLevel.Debug); | ||
} | ||
|
||
return Task.FromResult(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.