From c4a1d45818d670e956c4107f607fbc5325d0dd3b Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 27 Nov 2018 21:29:16 +0000 Subject: [PATCH] Do not allow device-report command to be run without administrative privileges. --- DiscImageChef/Commands/DeviceReport.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/DeviceReport.cs index f1c38ebbb..3e8e6b4d6 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/DeviceReport.cs @@ -35,6 +35,7 @@ using System.Collections.Generic; using System.IO; using System.Threading; using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Interop; using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.Console; using DiscImageChef.Core; @@ -55,6 +56,13 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Report command", "--verbose={0}", options.Verbose); DicConsole.DebugWriteLine("Device-Report command", "--device={0}", options.DevicePath); + if(!DetectOS.IsAdmin) + { + DicConsole.ErrorWriteLine("Because of the commands sent to a device, device report must be run with administrative privileges."); + DicConsole.ErrorWriteLine("Not continuing."); + return; + } + if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':';