Compare commits

...

9 commits

5 changed files with 43 additions and 26 deletions

View file

@ -91,11 +91,13 @@
windows.users = mkOption { windows.users = mkOption {
type = types.attrsOf winUserType; type = types.attrsOf winUserType;
description = "The users to create on the Windows machine."; description = "The users to create on the Windows machine.";
default = (lib.attrsets.concatMapAttrs ( };
name: options: };
if builtins.elem name (builtins.attrNames linuxOptions) };
then {}
else { config = {
valhalla.windows.users = (lib.attrsets.concatMapAttrs (
name: options: {
${capitalize name} = (lib.attrsets.concatMapAttrs ( ${capitalize name} = (lib.attrsets.concatMapAttrs (
name: value: name: value:
if builtins.elem name (builtins.attrNames linuxOptions) if builtins.elem name (builtins.attrNames linuxOptions)
@ -108,6 +110,4 @@
}; };
}) cfg.users); }) cfg.users);
}; };
};
};
} }

View file

@ -39,6 +39,10 @@ $null = New-Module {
$result = Receive-Job -Wait $job; $result = Receive-Job -Wait $job;
if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) {
Write-Error "The result of the path conversion of ``$Path`` was unexpacted: ``$result``";
}
if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) { if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) {
Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``"; Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``";
} }

View file

@ -2,6 +2,7 @@
. "$PSScriptRoot/../Types/OneShotTask.ps1"; . "$PSScriptRoot/../Types/OneShotTask.ps1";
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1"; . "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1"; . "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
$null = New-Module { $null = New-Module {
. "$PSScriptRoot/../Types/OneShotTask.ps1"; . "$PSScriptRoot/../Types/OneShotTask.ps1";
@ -104,8 +105,10 @@ $null = New-Module {
}; };
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "Starting OneShot task ``$(Get-OneShotTask)``"; Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "Starting OneShot task ``$(Get-OneShotTask)``";
for ($i = 0; $i -lt 2; $i++) {
Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier; Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier;
$null = Wait-Event -SourceIdentifier $identifier; }
}; };
Set-Stage $currentStage; Set-Stage $currentStage;
@ -133,6 +136,7 @@ $null = New-Module {
} }
catch { catch {
Set-Content -Path $errorPath -Value $Error; Set-Content -Path $errorPath -Value $Error;
Set-UserPermissions $errorPath;
} }
finally { finally {
Set-Stage ([SetupStage]::Idle); Set-Stage ([SetupStage]::Idle);

View file

@ -26,7 +26,7 @@ $null = New-Module {
[string] $path; [string] $path;
if ($UserKey) { if ($UserKey) {
$path = "$($UserKey.PSPath)\$runOncePath"; $path = Join-Path ($UserKey.PSPath) $runOncePath;
} else { } else {
$path = $systemRunOncePath; $path = $systemRunOncePath;
} }
@ -153,21 +153,24 @@ $null = New-Module {
#> #>
function Restart-Intermediate { function Restart-Intermediate {
param( param(
[switch] $DefaultUser [Parameter(ParameterSetName="Default", Mandatory)]
[switch] $DefaultUser,
[Parameter(ParameterSetName="Current", Mandatory)]
[switch] $CurrentUser
) )
$register = { param($UserKey) Register-Setup @PSBoundParameters; }; if ($DefaultUser.ToBool()) {
if ($DefaultUser) {
Edit-DefaultUserKey { Edit-DefaultUserKey {
param( param(
[RegistryKey] $Key [RegistryKey] $Key
) )
& $register $Key; Register-Setup -UserKey $Key;
} }
} elseif ($CurrentUser.ToBool()) {
Register-Setup -User;
} else { } else {
& $register; Register-Setup;
} }
Restart-Computer -Force; Restart-Computer -Force;

View file

@ -55,7 +55,13 @@ $null = New-Module {
[FileSystemAccessRule]::new( [FileSystemAccessRule]::new(
[SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null), [SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null),
[FileSystemRights]::FullControl, [FileSystemRights]::FullControl,
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit, (& {
if (Test-Path -PathType Container $Path) {
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit
} else {
0
}
}),
[PropagationFlags]::InheritOnly, [PropagationFlags]::InheritOnly,
[AccessControlType]::Allow)); [AccessControlType]::Allow));