Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate Native Apps' Jailer on Install #202

Merged
merged 4 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions services/better-jail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { asyncExecFile } from './adapter';

export async function buildBetterJail(id: string, appDir: string) {
// Populate the jail with `native` instead of `native_devmode`, to gain higher privileges
await asyncExecFile('jailer', ['-t', 'native', '-p', appDir, '-i', id, '/bin/true']);
}
18 changes: 15 additions & 3 deletions services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import { asyncStat, asyncExecFile, asyncPipeline, asyncUnlink, asyncWriteFile, asyncReadFile, asyncChmod, asyncMkdir } from './adapter';
import { fetchWrapper } from './fetch-wrapper';
import { buildBetterJail } from './better-jail';

import rootAppInfo from '../appinfo.json';
import serviceInfo from './services.json';
Expand Down Expand Up @@ -406,8 +407,14 @@
return serviceRemote as Service;
}

async function getAppInfo(appId: string): Promise<Record<string, any>> {
const appList = await asyncCall<{ apps: { id: string }[] }>(
interface AppInfo {
id: string;
title: string;
type: string;
folderPath: string;
}
async function getAppInfo(appId: string): Promise<AppInfo> {
const appList = await asyncCall<{ apps: AppInfo[] }>(

Check failure on line 417 in services/service.ts

View workflow job for this annotation

GitHub Actions / build / build

Replace `⏎······getInstallerService(),⏎······'luna://com.webos.applicationManager/dev/listApps',⏎······{},⏎····` with `getInstallerService(),·'luna://com.webos.applicationManager/dev/listApps',·{}`
getInstallerService(),
'luna://com.webos.applicationManager/dev/listApps',
{},
Expand Down Expand Up @@ -491,7 +498,12 @@

try {
const appInfo = await getAppInfo(installedPackageId);
await createToast(`Application installed: ${appInfo['title']}`, service);
if (appInfo.type === 'native' && runningAsRoot) {
await createToast(`Updating jailer config for ${appInfo.title}…`, service);
await buildBetterJail(appInfo.id, appInfo.folderPath)

Check failure on line 503 in services/service.ts

View workflow job for this annotation

GitHub Actions / build / build

Delete `⏎············`
.catch((err) => console.warn('jailer execution failed:', err));

Check failure on line 504 in services/service.ts

View workflow job for this annotation

GitHub Actions / build / build

Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function
}
await createToast(`Application installed: ${appInfo.title}`, service);
} catch (err: unknown) {
console.warn('appinfo fetch failed:', err);
await createToast(`Application installed: ${installedPackageId}`, service);
Expand Down
Loading