@remoteshell/device 0.1.0-beta.8 → 0.1.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/device.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import {windowsInstallLayout} from './windows-install-layout.mjs';
|
|
|
28
28
|
import {installWindowsNative,statusWindowsNative,uninstallWindowsNative} from './windows-native-installer.mjs';
|
|
29
29
|
import {ensureWindowsPrivateStore} from './windows-private-store.mjs';
|
|
30
30
|
import {directPaths,directRegister,directRun} from './direct-npx-runtime.mjs';
|
|
31
|
+
import {enableDirectAutostart,disableDirectAutostart,directAutostartStatus} from './windows-direct-autostart.mjs';
|
|
31
32
|
const require=createRequire(import.meta.url);
|
|
32
33
|
const pkg=require('../package.json');
|
|
33
34
|
const packageRoot=resolve(dirname(fileURLToPath(import.meta.url)),'..');
|
|
@@ -167,6 +168,18 @@ try{
|
|
|
167
168
|
else if(action==='register'&&process.argv.length===3){
|
|
168
169
|
console.log(JSON.stringify(await directRegister(directPaths())));
|
|
169
170
|
}
|
|
171
|
+
else if(action==='autostart-enable'&&process.argv.length===3){
|
|
172
|
+
if(platform()!=='win32')deny('DEVICE_PLATFORM_UNSUPPORTED');
|
|
173
|
+
console.log(JSON.stringify(enableDirectAutostart({version:pkg.version})));
|
|
174
|
+
}
|
|
175
|
+
else if(action==='autostart-disable'&&process.argv.length===3){
|
|
176
|
+
if(platform()!=='win32')deny('DEVICE_PLATFORM_UNSUPPORTED');
|
|
177
|
+
console.log(JSON.stringify(disableDirectAutostart()));
|
|
178
|
+
}
|
|
179
|
+
else if(action==='autostart-status'&&process.argv.length===3){
|
|
180
|
+
if(platform()!=='win32')deny('DEVICE_PLATFORM_UNSUPPORTED');
|
|
181
|
+
console.log(JSON.stringify(directAutostartStatus()));
|
|
182
|
+
}
|
|
170
183
|
else if(action==='install-preflight'&&process.argv.length===3){
|
|
171
184
|
let wsl=false;
|
|
172
185
|
if(platform()==='linux'){try{wsl=/microsoft|wsl/i.test(readFileSync('/proc/version','utf8'));}catch{}}
|
|
@@ -365,7 +378,7 @@ try{
|
|
|
365
378
|
process.exitCode=2;
|
|
366
379
|
}else{console.error('Usage: remoteshell-device version|install|setup https://host/dev/ [foreground|manual|login|boot --confirm-linger]|dev-run-once|dev-mode manual|login|boot [--confirm-linger]|dev-start|dev-stop|dev-status|dev-autostart-enable|dev-autostart-disable|status|dev-service-uninstall|uninstall|dev-check https://host/dev/|dev-enroll https://host/dev/ ENROLLMENT_ID < capability-file|dev-heartbeat|dev-heartbeat-once|dev-agent-run GATEWAY_URL ROOT_ID ABSOLUTE_ROOT');process.exitCode=2;}
|
|
367
380
|
}catch(e){
|
|
368
|
-
const codes=new Set(['DEVICE_INSTALL_DENIED','DEVICE_INSTALL_MANIFEST_DENIED','DEVICE_INSTALL_TRUST_ANCHOR_INVALID','DEVICE_INSTALL_TRUST_ANCHOR_MISSING','DEVICE_INSTALL_SIGNATURE_DENIED','DEVICE_INSTALL_CHECKSUM_DENIED','DEVICE_INSTALL_ARTIFACT_DENIED','DEVICE_INSTALL_VERSION_DENIED','DEVICE_INSTALL_VERSION_REVIEW_REQUIRED','DEVICE_INSTALL_DOWNGRADE_DENIED','DEVICE_INSTALL_DOWNLOAD_DENIED','DEVICE_INSTALL_DOWNLOAD_TIMEOUT','DEVICE_INSTALL_DOWNLOAD_TOO_LARGE','DEVICE_INSTALL_STATE_DENIED','DEVICE_PLATFORM_UNSUPPORTED','DEVICE_INSTALL_OS_UNSUPPORTED','DEVICE_INSTALL_WSL_BETA_EXCLUDED','DEVICE_INSTALL_NODE_UNSUPPORTED','DEVICE_ALREADY_INSTALLED','DEVICE_DEPENDENCY_INVALID','DEVICE_INSTALL_DEPENDENCY_FAILED','DEVICE_INSTALL_PACKAGE_FAILED','DEVICE_LIFECYCLE_DENIED','DEVICE_WINDOWS_LIFECYCLE_DENIED','DEVICE_WINDOWS_WORKER_NOT_READY','DEVICE_WINDOWS_LAYOUT_DENIED','DEVICE_WINDOWS_PRIVATE_STORE_DENIED','DEVICE_ALREADY_REGISTERED','DEVICE_WINDOWS_INSTALL_DENIED','DEVICE_ENROLLMENT_DENIED','DEVICE_DEV_PROBE_DENIED','DEVICE_DEV_AGENT_DENIED','DEVICE_DEV_ENROLLMENT_INPUT_DENIED','DEVICE_UNIT_MUST_BE_REMOVED_FIRST','DEVICE_PAIRING_DENIED','DEVICE_REREGISTRATION_CONFIRM_REQUIRED','DEVICE_REREGISTRATION_CANCELLED','DEVICE_DEV_CREDENTIAL_REVOKED','DEVICE_DEV_SERVICE_DENIED','L2_DEV_CREDENTIAL_DENIED','DEVICE_DIRECT_PLATFORM_DENIED','DEVICE_DIRECT_LEGACY_INSTALLED','DEVICE_DIRECT_OWNER_DENIED','DEVICE_DIRECT_LOCK_DENIED','DEVICE_DIRECT_ALREADY_RUNNING','DEVICE_DIRECT_STALE_LOCK','DEVICE_DIRECT_REGISTRATION_REQUIRED','DEVICE_DIRECT_PACKAGE_INVALID','DEVICE_DIRECT_EXISTING_SERVICE','DEVICE_DIRECT_SERVICE_UNVERIFIED']);
|
|
381
|
+
const codes=new Set(['DEVICE_INSTALL_DENIED','DEVICE_INSTALL_MANIFEST_DENIED','DEVICE_INSTALL_TRUST_ANCHOR_INVALID','DEVICE_INSTALL_TRUST_ANCHOR_MISSING','DEVICE_INSTALL_SIGNATURE_DENIED','DEVICE_INSTALL_CHECKSUM_DENIED','DEVICE_INSTALL_ARTIFACT_DENIED','DEVICE_INSTALL_VERSION_DENIED','DEVICE_INSTALL_VERSION_REVIEW_REQUIRED','DEVICE_INSTALL_DOWNGRADE_DENIED','DEVICE_INSTALL_DOWNLOAD_DENIED','DEVICE_INSTALL_DOWNLOAD_TIMEOUT','DEVICE_INSTALL_DOWNLOAD_TOO_LARGE','DEVICE_INSTALL_STATE_DENIED','DEVICE_PLATFORM_UNSUPPORTED','DEVICE_INSTALL_OS_UNSUPPORTED','DEVICE_INSTALL_WSL_BETA_EXCLUDED','DEVICE_INSTALL_NODE_UNSUPPORTED','DEVICE_ALREADY_INSTALLED','DEVICE_DEPENDENCY_INVALID','DEVICE_INSTALL_DEPENDENCY_FAILED','DEVICE_INSTALL_PACKAGE_FAILED','DEVICE_LIFECYCLE_DENIED','DEVICE_WINDOWS_LIFECYCLE_DENIED','DEVICE_WINDOWS_WORKER_NOT_READY','DEVICE_WINDOWS_LAYOUT_DENIED','DEVICE_WINDOWS_PRIVATE_STORE_DENIED','DEVICE_ALREADY_REGISTERED','DEVICE_WINDOWS_INSTALL_DENIED','DEVICE_ENROLLMENT_DENIED','DEVICE_DEV_PROBE_DENIED','DEVICE_DEV_AGENT_DENIED','DEVICE_DEV_ENROLLMENT_INPUT_DENIED','DEVICE_UNIT_MUST_BE_REMOVED_FIRST','DEVICE_PAIRING_DENIED','DEVICE_REREGISTRATION_CONFIRM_REQUIRED','DEVICE_REREGISTRATION_CANCELLED','DEVICE_DEV_CREDENTIAL_REVOKED','DEVICE_DEV_SERVICE_DENIED','L2_DEV_CREDENTIAL_DENIED','DEVICE_DIRECT_PLATFORM_DENIED','DEVICE_DIRECT_LEGACY_INSTALLED','DEVICE_DIRECT_OWNER_DENIED','DEVICE_DIRECT_LOCK_DENIED','DEVICE_DIRECT_ALREADY_RUNNING','DEVICE_DIRECT_STALE_LOCK','DEVICE_DIRECT_REGISTRATION_REQUIRED','DEVICE_DIRECT_PACKAGE_INVALID','DEVICE_DIRECT_EXISTING_SERVICE','DEVICE_DIRECT_SERVICE_UNVERIFIED','DEVICE_DIRECT_AUTOSTART_DENIED']);
|
|
369
382
|
console.error(codes.has(e.message)?e.message:'DEVICE_INSTALL_DENIED');
|
|
370
383
|
process.exitCode=1;
|
|
371
384
|
}
|
|
@@ -6,8 +6,9 @@ import {spawnSync} from 'node:child_process';
|
|
|
6
6
|
import {homedir,platform} from 'node:os';
|
|
7
7
|
import {devOfficialRegistration} from './dev-agent-client.mjs';
|
|
8
8
|
import {devPairDevice} from './dev-pairing-client.mjs';
|
|
9
|
-
import {ensureWindowsPrivateStore} from './windows-private-store.mjs';
|
|
9
|
+
import {ensureWindowsPrivateStore,sealWindowsPrivateFile} from './windows-private-store.mjs';
|
|
10
10
|
import {windowsInstallLayout} from './windows-install-layout.mjs';
|
|
11
|
+
import {inspectWindowsCredentialAcl} from './windows-credential-boundary.mjs';
|
|
11
12
|
import {runDevAgentWorker} from './dev-agent-runner.mjs';
|
|
12
13
|
const FAIL=code=>{throw Error(code);};
|
|
13
14
|
export const DIRECT_DEV_URL='https://ailab-remoteshell.duckdns.org/dev/';
|
|
@@ -64,6 +65,10 @@ export function acquireDirectLock(p,{pid=process.pid,alive=id=>{
|
|
|
64
65
|
fd=openSync(lock,'wx',0o600);
|
|
65
66
|
writeFileSync(fd,JSON.stringify({pid,created:Date.now(),nonce}));
|
|
66
67
|
closeSync(fd);fd=undefined;
|
|
68
|
+
if(p.os==='win32'){
|
|
69
|
+
try{sealWindowsPrivateFile(lock,{home:p.home});}
|
|
70
|
+
catch(e){rmSync(lock,{force:true});throw e;}
|
|
71
|
+
}
|
|
67
72
|
}catch(e){if(fd!==undefined)closeSync(fd);throw e;}
|
|
68
73
|
return ()=>{
|
|
69
74
|
try{
|
|
@@ -75,16 +80,19 @@ export function acquireDirectLock(p,{pid=process.pid,alive=id=>{
|
|
|
75
80
|
try{return create();}catch(e){
|
|
76
81
|
if(e.code!=='EEXIST')FAIL('DEVICE_DIRECT_LOCK_DENIED');
|
|
77
82
|
}
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
if(p.os!=='linux')FAIL('DEVICE_DIRECT_STALE_LOCK');
|
|
83
|
+
// Windows logoff/reboot and Linux systemd can kill the npm wrapper before
|
|
84
|
+
// its child gets an exit event. Reclaim only verified dead process locks.
|
|
85
|
+
// Windows requires NTFS SID/owner/DACL proof, Linux requires uid/mode proof.
|
|
86
|
+
if(p.os!=='linux'&&p.os!=='win32')FAIL('DEVICE_DIRECT_STALE_LOCK');
|
|
82
87
|
let snapshot,prior,bytes;
|
|
83
88
|
try{
|
|
84
89
|
snapshot=lstatSync(lock);
|
|
85
|
-
if(!snapshot.isFile()||snapshot.isSymbolicLink()||snapshot.
|
|
86
|
-
(snapshot.mode&0o777)!==0o600||snapshot.size<1||snapshot.size>256)
|
|
90
|
+
if(!snapshot.isFile()||snapshot.isSymbolicLink()||snapshot.size<1||snapshot.size>256)
|
|
87
91
|
FAIL('DEVICE_DIRECT_STALE_LOCK');
|
|
92
|
+
if(p.os==='linux'){
|
|
93
|
+
if(snapshot.uid!==process.getuid?.()||(snapshot.mode&0o777)!==0o600)
|
|
94
|
+
FAIL('DEVICE_DIRECT_STALE_LOCK');
|
|
95
|
+
}else inspectWindowsCredentialAcl({file:lock,home:p.home});
|
|
88
96
|
bytes=readFileSync(lock,'utf8');prior=JSON.parse(bytes);
|
|
89
97
|
if(!Number.isSafeInteger(prior?.pid)||prior.pid<=1)
|
|
90
98
|
FAIL('DEVICE_DIRECT_STALE_LOCK');
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// #327 S2: single-user fixed-version Windows logon runner.
|
|
2
|
+
// Small persistent launcher; npm package remains in the normal npx cache.
|
|
3
|
+
import {readFileSync,writeFileSync} from 'node:fs';
|
|
4
|
+
import {dirname,join} from 'node:path';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
import {spawn} from 'node:child_process';
|
|
7
|
+
const root=dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const FAIL=()=>{process.exitCode=1;};
|
|
9
|
+
function validPath(x){return typeof x==='string'&&/^[A-Za-z]:\\/.test(x)&&
|
|
10
|
+
!/[\r\n"'&|<>%]/.test(x)&&!x.split('\\').includes('..');}
|
|
11
|
+
let config=null;
|
|
12
|
+
try{
|
|
13
|
+
const data=JSON.parse(readFileSync(join(root,'direct-autostart.json'),'utf8'));
|
|
14
|
+
if(data.schema!==1||!/^0\.1\.0-beta\.\d+$/.test(data.version)||
|
|
15
|
+
!validPath(data.node)||!validPath(data.npmCli))throw Error('INVALID_CONFIG');
|
|
16
|
+
config=data;
|
|
17
|
+
}catch{console.error('DEVICE_DIRECT_AUTOSTART_CONFIG_DENIED');FAIL();}
|
|
18
|
+
if(config){
|
|
19
|
+
const env={...process.env,PUPPETEER_SKIP_DOWNLOAD:'true',
|
|
20
|
+
npm_config_ignore_scripts:'true',npm_config_omit:'optional',
|
|
21
|
+
npm_config_audit:'false',npm_config_fund:'false'};
|
|
22
|
+
const execute=offline=>new Promise(resolve=>{
|
|
23
|
+
const args=[config.npmCli,'exec','--yes',...(offline?['--offline']:[]),
|
|
24
|
+
'--package=@remoteshell/device@'+config.version,'--','remoteshell-device','run'];
|
|
25
|
+
const child=spawn(config.node,args,{shell:false,windowsHide:true,
|
|
26
|
+
stdio:['ignore','ignore','pipe'],env});
|
|
27
|
+
let errors='',settled=false;
|
|
28
|
+
child.stderr?.on('data',chunk=>{if(errors.length<2048)errors+=String(chunk).slice(0,2048-errors.length);});
|
|
29
|
+
const finish=code=>{if(!settled){settled=true;resolve({code,cacheMiss:/ENOTCACHED/i.test(errors)})}};
|
|
30
|
+
child.once('error',()=>finish(1));
|
|
31
|
+
child.once('exit',code=>finish(code??1));
|
|
32
|
+
});
|
|
33
|
+
try{
|
|
34
|
+
// No network for normal logons. Only an explicit cache miss may fetch
|
|
35
|
+
// the exact same immutable version; never substitute @beta or @latest.
|
|
36
|
+
const first=await execute(true);
|
|
37
|
+
if(first.code!==0){
|
|
38
|
+
if(first.cacheMiss){
|
|
39
|
+
const retry=await execute(false);
|
|
40
|
+
if(retry.code!==0)FAIL();
|
|
41
|
+
}else FAIL();
|
|
42
|
+
}
|
|
43
|
+
}catch{FAIL();}
|
|
44
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// #327 S2. Opt-in per-user Windows login autostart for exact public npx.
|
|
2
|
+
// No install/clone, no credential mutation and no other user's startup keys.
|
|
3
|
+
import {spawnSync} from 'node:child_process';
|
|
4
|
+
import {existsSync,readFileSync,rmSync} from 'node:fs';
|
|
5
|
+
import {homedir} from 'node:os';
|
|
6
|
+
import {win32} from 'node:path';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {devOfficialRegistration} from './dev-agent-client.mjs';
|
|
9
|
+
import {directPaths,requireNoLegacyInstall} from './direct-npx-runtime.mjs';
|
|
10
|
+
import {atomicWindowsPrivate,readWindowsPrivate,ensureWindowsPrivateStore} from './windows-private-store.mjs';
|
|
11
|
+
import {canonicalWindowsLocalFile,isWindowsChildPath} from './native-path-contract.mjs';
|
|
12
|
+
import {inspectWindowsCredentialAcl} from './windows-credential-boundary.mjs';
|
|
13
|
+
const VALUE='RemoteShell-Direct-npx';
|
|
14
|
+
const KEY='HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
|
|
15
|
+
const DENY=()=>{throw Error('DEVICE_DIRECT_AUTOSTART_DENIED');};
|
|
16
|
+
function execReg(args,{run=spawnSync}={}){
|
|
17
|
+
const root=process.env.SystemRoot||'C:\\Windows';
|
|
18
|
+
const result=run(win32.join(root,'System32','reg.exe'),args,{
|
|
19
|
+
shell:false,windowsHide:true,encoding:'utf8',timeout:10000,maxBuffer:8192,stdio:'pipe'});
|
|
20
|
+
if(result?.error||result?.signal||![0,1].includes(result?.status))DENY();
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
function paths({home=homedir(),localAppData=process.env.LOCALAPPDATA,os=process.platform}={}){
|
|
24
|
+
if(os!=='win32')DENY();
|
|
25
|
+
const p=directPaths({home,localAppData,os});
|
|
26
|
+
const runner=win32.join(p.storageDir,'direct-autostart-runner.mjs');
|
|
27
|
+
const config=win32.join(p.storageDir,'direct-autostart.json');
|
|
28
|
+
for(const x of [runner,config]){canonicalWindowsLocalFile(x);isWindowsChildPath(x,p.storageDir);}
|
|
29
|
+
return {p,runner,config};
|
|
30
|
+
}
|
|
31
|
+
export function exactAutostartVersion(value){
|
|
32
|
+
if(typeof value!=='string'||!/^0\.1\.0-beta\.\d+$/.test(value))DENY();
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function stableExec({node=process.execPath,npmCli=process.env.npm_execpath,home=homedir()}={}){
|
|
36
|
+
for(const x of [node,npmCli]){canonicalWindowsLocalFile(x);if(!existsSync(x))DENY();}
|
|
37
|
+
// npm's executable must be from a persistent install, not an ephemeral _npx.
|
|
38
|
+
for(const x of [node,npmCli]){
|
|
39
|
+
if(/[/\\]_npx[/\\]/i.test(x)||/[/\\]Temp[/\\]/i.test(x))DENY();
|
|
40
|
+
}
|
|
41
|
+
if(!/node\.exe$/i.test(node)||!/npm-cli\.js$/i.test(npmCli))DENY();
|
|
42
|
+
return {node,npmCli};
|
|
43
|
+
}
|
|
44
|
+
function runValue(node,runner){return '"'+node+'" "'+runner+'"';}
|
|
45
|
+
function current({run}={}){
|
|
46
|
+
const result=execReg(['query',KEY,'/v',VALUE],{run});
|
|
47
|
+
if(result.status===1)return null;
|
|
48
|
+
const match=String(result.stdout||'').split(/\r?\n/)
|
|
49
|
+
.find(x=>new RegExp('^\\s*'+VALUE+'\\s+REG_SZ\\s+','i').test(x));
|
|
50
|
+
if(!match)DENY();
|
|
51
|
+
const v=match.replace(new RegExp('^\\s*'+VALUE+'\\s+REG_SZ\\s+','i'),'').trim();
|
|
52
|
+
if(!v)DENY();
|
|
53
|
+
return v;
|
|
54
|
+
}
|
|
55
|
+
export function directAutostartStatus({run}={}){
|
|
56
|
+
const value=current({run});
|
|
57
|
+
return {enabled:value!==null,registered:undefined,scope:'current-Windows-user'};
|
|
58
|
+
}
|
|
59
|
+
export function enableDirectAutostart({version,home=homedir(),localAppData=process.env.LOCALAPPDATA,
|
|
60
|
+
node=process.execPath,npmCli=process.env.npm_execpath,run=spawnSync}={}){
|
|
61
|
+
exactAutostartVersion(version);
|
|
62
|
+
const {p,runner,config}=paths({home,localAppData});
|
|
63
|
+
requireNoLegacyInstall(p);
|
|
64
|
+
const registration=devOfficialRegistration({storageDir:p.storageDir});
|
|
65
|
+
if(!registration)DENY();
|
|
66
|
+
ensureWindowsPrivateStore(p.storageDir,{home});
|
|
67
|
+
const exe=stableExec({node,npmCli,home});
|
|
68
|
+
const command=runValue(exe.node,runner);
|
|
69
|
+
const active=current({run});
|
|
70
|
+
if(active!==null){
|
|
71
|
+
if(active!==command)DENY();
|
|
72
|
+
const stored=JSON.parse(readWindowsPrivate(config,{home}));
|
|
73
|
+
if(stored.version!==version||stored.node!==exe.node||stored.npmCli!==exe.npmCli)DENY();
|
|
74
|
+
return {enabled:true,version,reused:true,credentialsPreserved:true};
|
|
75
|
+
}
|
|
76
|
+
if(existsSync(runner)||existsSync(config))DENY(); // incomplete install: investigate, never overwrite.
|
|
77
|
+
const source=readFileSync(fileURLToPath(new URL('./windows-direct-autostart-runner.mjs',import.meta.url)),'utf8');
|
|
78
|
+
let wroteRunner=false,wroteConfig=false;
|
|
79
|
+
try{
|
|
80
|
+
atomicWindowsPrivate(runner,source,{home});wroteRunner=true;
|
|
81
|
+
atomicWindowsPrivate(config,JSON.stringify({schema:1,version,...exe})+'\n',{home});
|
|
82
|
+
wroteConfig=true;
|
|
83
|
+
const result=execReg(['add',KEY,'/v',VALUE,'/t','REG_SZ','/d',command,'/f'],{run});
|
|
84
|
+
if(result.status!==0)DENY();
|
|
85
|
+
}catch(error){
|
|
86
|
+
// Only files created by this invocation are ever removed on failure.
|
|
87
|
+
if(wroteConfig)rmSync(config,{force:true});
|
|
88
|
+
if(wroteRunner)rmSync(runner,{force:true});
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
return {enabled:true,version,reused:false,credentialsPreserved:true,deviceId:registration.deviceId};
|
|
92
|
+
}
|
|
93
|
+
export function disableDirectAutostart({home=homedir(),localAppData=process.env.LOCALAPPDATA,
|
|
94
|
+
node=process.execPath,run=spawnSync}={}){
|
|
95
|
+
const {runner,config}=paths({home,localAppData});
|
|
96
|
+
const value=current({run});
|
|
97
|
+
if(value===null)return {enabled:false,changed:false,credentialsPreserved:true};
|
|
98
|
+
if(!value.endsWith(' "'+runner+'"'))DENY();
|
|
99
|
+
const result=execReg(['delete',KEY,'/v',VALUE,'/f'],{run});
|
|
100
|
+
if(result.status!==0)DENY();
|
|
101
|
+
// Explicit disable revokes only this user's launcher, never credentials.
|
|
102
|
+
// Existing running Agent is not killed here; stop is an independent action.
|
|
103
|
+
for(const file of [config,runner]){
|
|
104
|
+
if(existsSync(file)){
|
|
105
|
+
inspectWindowsCredentialAcl({file,home});
|
|
106
|
+
rmSync(file);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {enabled:false,changed:true,credentialsPreserved:true};
|
|
110
|
+
}
|
|
@@ -102,6 +102,19 @@ function verifyFile(file,{home=homedir()}={}){
|
|
|
102
102
|
// Avoid a duplicate PowerShell invocation in every credential operation.
|
|
103
103
|
inspectWindowsCredentialAcl({file,home});
|
|
104
104
|
}
|
|
105
|
+
// Seal a newly created exclusive lock using the same owner/SYSTEM ACL proof
|
|
106
|
+
// as credentials. Used by #327 S2 for Windows logoff/reboot recovery.
|
|
107
|
+
export function sealWindowsPrivateFile(file,{home=homedir()}={}){
|
|
108
|
+
try{
|
|
109
|
+
const store=win32.dirname(file);
|
|
110
|
+
checkStore(store,{home});
|
|
111
|
+
const stat=lstatSync(file);
|
|
112
|
+
if(!stat.isFile()||stat.isSymbolicLink()||stat.nlink!==1)deny();
|
|
113
|
+
sealAcl(file);
|
|
114
|
+
verifyFile(file,{home});
|
|
115
|
+
return true;
|
|
116
|
+
}catch{deny();}
|
|
117
|
+
}
|
|
105
118
|
export function readWindowsPrivate(file,{home=homedir()}={}){
|
|
106
119
|
try{
|
|
107
120
|
verifyFile(file,{home});
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteshell/device",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.9",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@remoteshell/device",
|
|
9
|
-
"version": "0.1.0-beta.
|
|
9
|
+
"version": "0.1.0-beta.9",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
12
12
|
"@wonderwhy-er/desktop-commander": "0.3.1"
|