Compare commits

...

9 commits

5 changed files with 43 additions and 26 deletions

View file

@ -91,11 +91,13 @@
windows.users = mkOption {
type = types.attrsOf winUserType;
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 (
name: value:
if builtins.elem name (builtins.attrNames linuxOptions)
@ -108,6 +110,4 @@
};
}) cfg.users);
};
};
};
}

View file

@ -39,6 +39,10 @@ $null = New-Module {
$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)) {
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/../../Windows/Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
$null = New-Module {
. "$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)``";
for ($i = 0; $i -lt 2; $i++) {
Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier;
$null = Wait-Event -SourceIdentifier $identifier;
}
};
Set-Stage $currentStage;
@ -133,6 +136,7 @@ $null = New-Module {
}
catch {
Set-Content -Path $errorPath -Value $Error;
Set-UserPermissions $errorPath;
}
finally {
Set-Stage ([SetupStage]::Idle);

View file

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

View file

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