summaryrefslogtreecommitdiffstats
path: root/solve/PhotoEditor/Controllers/BaseAPIController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'solve/PhotoEditor/Controllers/BaseAPIController.cs')
-rw-r--r--solve/PhotoEditor/Controllers/BaseAPIController.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/solve/PhotoEditor/Controllers/BaseAPIController.cs b/solve/PhotoEditor/Controllers/BaseAPIController.cs
new file mode 100644
index 0000000..0c2acf3
--- /dev/null
+++ b/solve/PhotoEditor/Controllers/BaseAPIController.cs
@@ -0,0 +1,32 @@
+using System.Diagnostics;
+using Microsoft.AspNetCore.Mvc;
+using PhotoEditor.Models;
+
+namespace PhotoEditor.Controllers;
+
+public class BaseAPIController : ControllerBase
+{
+ public String GetUsername(Dictionary<String,String> env) {
+ Process process = new Process();
+ process.StartInfo.FileName = "bash";
+ process.StartInfo.Arguments = "-c 'whoami'";
+
+ foreach (var kv in env)
+ {
+ Console.WriteLine(kv.Key + ":" + kv.Value);
+ process.StartInfo.EnvironmentVariables[kv.Key] = kv.Value;
+ }
+
+ process.StartInfo.UseShellExecute = false;
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.RedirectStandardError = true;
+ process.Start();
+ string output = process.StandardOutput.ReadToEnd();
+ Console.WriteLine(output);
+ string err = process.StandardError.ReadToEnd();
+ Console.WriteLine(err);
+ process.WaitForExit();
+
+ return output + err;
+ }
+} \ No newline at end of file