You've already forked lazarus-ccr
Routine added that prevents non-admin Windows users from updating
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5665 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,11 +4,11 @@
|
|||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<Version Value="10"/>
|
<Version Value="10"/>
|
||||||
<BuildModes Active="Win32"/>
|
<BuildModes Active="Win32"/>
|
||||||
<Units Count="17">
|
<Units Count="18">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="testapp.lpr"/>
|
<Filename Value="testapp.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<EditorIndex Value="5"/>
|
<EditorIndex Value="6"/>
|
||||||
<CursorPos X="33" Y="27"/>
|
<CursorPos X="33" Y="27"/>
|
||||||
<UsageCount Value="44"/>
|
<UsageCount Value="44"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
@ -19,7 +19,6 @@
|
|||||||
<ComponentName Value="mainform"/>
|
<ComponentName Value="mainform"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<IsVisibleTab Value="True"/>
|
|
||||||
<TopLine Value="64"/>
|
<TopLine Value="64"/>
|
||||||
<CursorPos X="19" Y="103"/>
|
<CursorPos X="19" Y="103"/>
|
||||||
<UsageCount Value="44"/>
|
<UsageCount Value="44"/>
|
||||||
@ -38,7 +37,7 @@
|
|||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="..\lazautoupdate_httpclient.pas"/>
|
<Filename Value="..\lazautoupdate_httpclient.pas"/>
|
||||||
<EditorIndex Value="2"/>
|
<EditorIndex Value="3"/>
|
||||||
<CursorPos X="97" Y="12"/>
|
<CursorPos X="97" Y="12"/>
|
||||||
<UsageCount Value="21"/>
|
<UsageCount Value="21"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
@ -47,13 +46,13 @@
|
|||||||
<Filename Value="..\ulazautoupdate.pas"/>
|
<Filename Value="..\ulazautoupdate.pas"/>
|
||||||
<IsVisibleTab Value="True"/>
|
<IsVisibleTab Value="True"/>
|
||||||
<WindowIndex Value="1"/>
|
<WindowIndex Value="1"/>
|
||||||
<TopLine Value="352"/>
|
<TopLine Value="1766"/>
|
||||||
<CursorPos X="46" Y="373"/>
|
<CursorPos X="111" Y="1791"/>
|
||||||
<ExtraEditorCount Value="2"/>
|
<ExtraEditorCount Value="2"/>
|
||||||
<ExtraEditor1>
|
<ExtraEditor1>
|
||||||
<EditorIndex Value="3"/>
|
<EditorIndex Value="4"/>
|
||||||
<TopLine Value="1145"/>
|
<TopLine Value="1163"/>
|
||||||
<CursorPos X="11" Y="1235"/>
|
<CursorPos X="11" Y="1253"/>
|
||||||
</ExtraEditor1>
|
</ExtraEditor1>
|
||||||
<ExtraEditor2>
|
<ExtraEditor2>
|
||||||
<EditorIndex Value="-1"/>
|
<EditorIndex Value="-1"/>
|
||||||
@ -102,7 +101,7 @@
|
|||||||
</Unit9>
|
</Unit9>
|
||||||
<Unit10>
|
<Unit10>
|
||||||
<Filename Value="..\..\..\..\applications\foobot\monitor\umainform.pas"/>
|
<Filename Value="..\..\..\..\applications\foobot\monitor\umainform.pas"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="2"/>
|
||||||
<TopLine Value="25"/>
|
<TopLine Value="25"/>
|
||||||
<CursorPos X="25" Y="55"/>
|
<CursorPos X="25" Y="55"/>
|
||||||
<UsageCount Value="19"/>
|
<UsageCount Value="19"/>
|
||||||
@ -117,7 +116,7 @@
|
|||||||
<Unit12>
|
<Unit12>
|
||||||
<Filename Value="..\versionsupport.pas"/>
|
<Filename Value="..\versionsupport.pas"/>
|
||||||
<UnitName Value="VersionSupport"/>
|
<UnitName Value="VersionSupport"/>
|
||||||
<EditorIndex Value="4"/>
|
<EditorIndex Value="5"/>
|
||||||
<TopLine Value="25"/>
|
<TopLine Value="25"/>
|
||||||
<CursorPos X="71" Y="44"/>
|
<CursorPos X="71" Y="44"/>
|
||||||
<UsageCount Value="16"/>
|
<UsageCount Value="16"/>
|
||||||
@ -153,6 +152,16 @@
|
|||||||
<UsageCount Value="11"/>
|
<UsageCount Value="11"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit16>
|
</Unit16>
|
||||||
|
<Unit17>
|
||||||
|
<Filename Value="C:\NewPascal\projects\snippets\usefulunits\uuser.pas"/>
|
||||||
|
<UnitName Value="uUser"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<TopLine Value="6"/>
|
||||||
|
<CursorPos Y="25"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit17>
|
||||||
</Units>
|
</Units>
|
||||||
<General>
|
<General>
|
||||||
<ActiveWindowIndexAtStart Value="1"/>
|
<ActiveWindowIndexAtStart Value="1"/>
|
||||||
|
@ -127,6 +127,12 @@ const
|
|||||||
C_LOCALUPDATER = 'lauupdatewin32.exe';{$ENDIF}
|
C_LOCALUPDATER = 'lauupdatewin32.exe';{$ENDIF}
|
||||||
{$IFDEF CPU64}C_UPDATER = 'updatehmwin64.exe';
|
{$IFDEF CPU64}C_UPDATER = 'updatehmwin64.exe';
|
||||||
C_LOCALUPDATER = 'lauupdatewin64.exe';{$ENDIF}
|
C_LOCALUPDATER = 'lauupdatewin64.exe';{$ENDIF}
|
||||||
|
// Windows Constants
|
||||||
|
CONST
|
||||||
|
GENERIC_READ = $80000000;
|
||||||
|
GENERIC_WRITE = $40000000;
|
||||||
|
GENERIC_EXECUTE = $20000000;
|
||||||
|
GENERIC_ALL = $10000000;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
{$IFDEF CPU32}C_UPDATER = 'updatehmlinux32';
|
{$IFDEF CPU32}C_UPDATER = 'updatehmlinux32';
|
||||||
@ -339,7 +345,6 @@ type
|
|||||||
// Set this property before using methods
|
// Set this property before using methods
|
||||||
property SFProjectName: string read fSourceForgeProjectName
|
property SFProjectName: string read fSourceForgeProjectName
|
||||||
write SetSourceForgeProjectName;
|
write SetSourceForgeProjectName;
|
||||||
// Only auSourceForge at V0.0.1
|
|
||||||
// For when fProjectType = auOther
|
// For when fProjectType = auOther
|
||||||
// Fully qualified URL (not including the filename).
|
// Fully qualified URL (not including the filename).
|
||||||
property auOtherSourceURL: string read fauOtherSourceURL write SetauOtherSourceURL;
|
property auOtherSourceURL: string read fauOtherSourceURL write SetauOtherSourceURL;
|
||||||
@ -353,9 +358,9 @@ type
|
|||||||
property AutoUpdateVersion: string read fComponentVersion;
|
property AutoUpdateVersion: string read fComponentVersion;
|
||||||
// Zipfile contains a whole directory tree (relative to App Directory)
|
// Zipfile contains a whole directory tree (relative to App Directory)
|
||||||
property CopyTree: boolean read fCopyTree write fCopyTree default True;
|
property CopyTree: boolean read fCopyTree write fCopyTree default True;
|
||||||
// Default is 'updates' *must be the same in SourceForge file section*
|
// Default is 'updates' *must be the same in SourceForge file section or GitHub Branch subfolder*
|
||||||
property UpdatesFolder: string read fUpdatesFolder write fUpdatesFolder;
|
property UpdatesFolder: string read fUpdatesFolder write fUpdatesFolder;
|
||||||
// Default=versions.ini File in SourceForge /updates folder
|
// Default=versions.ini File in SourceForge/GitHub /updates folder
|
||||||
property VersionsININame: string read fVersionsININame write fVersionsININame;
|
property VersionsININame: string read fVersionsININame write fVersionsININame;
|
||||||
// Default is to modify parent form's caption during downloads
|
// Default is to modify parent form's caption during downloads
|
||||||
property ShowUpdateInCaption: boolean read fShowUpdateInCaption
|
property ShowUpdateInCaption: boolean read fShowUpdateInCaption
|
||||||
@ -370,10 +375,15 @@ type
|
|||||||
write fDownloadCountLimit;
|
write fDownloadCountLimit;
|
||||||
// Default is application filename.zip
|
// Default is application filename.zip
|
||||||
property ZipfileName: string read fZipfileName write fZipfileName;
|
property ZipfileName: string read fZipfileName write fZipfileName;
|
||||||
|
// Name of Console app
|
||||||
property UpdateExe:String read fUpdateExe;
|
property UpdateExe:String read fUpdateExe;
|
||||||
|
// Name of Console app
|
||||||
property UpdateExeSilent:String read fUpdateSilentExe;
|
property UpdateExeSilent:String read fUpdateSilentExe;
|
||||||
|
// Main project name/UserName
|
||||||
property GitHubProjectname:String read fGitHubProjectName write fGitHubProjectName;
|
property GitHubProjectname:String read fGitHubProjectName write fGitHubProjectName;
|
||||||
|
// Name of your GitHub repository within the project/username
|
||||||
Property GitHubRepositoryName:String read fGitHubRepositoryName write fGitHubRepositoryName;
|
Property GitHubRepositoryName:String read fGitHubRepositoryName write fGitHubRepositoryName;
|
||||||
|
// Default=master but any branchname is OK
|
||||||
Property GitHubBranch:String read fGitHubBranch write fGitHubBranch;
|
Property GitHubBranch:String read fGitHubBranch write fGitHubBranch;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -471,7 +481,19 @@ procedure TLazAutoUpdate.DebugTest;
|
|||||||
begin
|
begin
|
||||||
ShowMessage(fApplicationVersionString);
|
ShowMessage(fApplicationVersionString);
|
||||||
end;
|
end;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
function IsWindowsAdmin: boolean;
|
||||||
|
var
|
||||||
|
hSC: THandle;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
hSC := OpenSCManager(nil, nil, GENERIC_READ or GENERIC_WRITE or GENERIC_EXECUTE);
|
||||||
|
|
||||||
|
if (hSC = 0) then
|
||||||
|
Result := False;
|
||||||
|
CloseServiceHandle(hSC);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
constructor TLazAutoUpdate.Create(AOwner: TComponent);
|
constructor TLazAutoUpdate.Create(AOwner: TComponent);
|
||||||
var
|
var
|
||||||
sz: string;
|
sz: string;
|
||||||
@ -1762,6 +1784,17 @@ var
|
|||||||
szParams: string;
|
szParams: string;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
If NOT IsWindowsAdmin then
|
||||||
|
begin
|
||||||
|
szParams:='Only Windows users whith Administrator status can update this application.' + lineending;
|
||||||
|
szParams+='Please log off, then log on as an administrator (or switch users to an administrator account),' + lineending;
|
||||||
|
szParams+='then try again. This restriction is for the safety and security of your Windows system.' + lineending;
|
||||||
|
szParams+='Click OK to continue';
|
||||||
|
MessageDlg('Application update',szParams,mtInformation,[MBOK],0);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
szAppDir := AppendPathDelim(ExtractFilePath(fAppFilename));
|
szAppDir := AppendPathDelim(ExtractFilePath(fAppFilename));
|
||||||
|
|
||||||
// read the VMT once
|
// read the VMT once
|
||||||
|
Reference in New Issue
Block a user