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

Remove SSH bus #162

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 9 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
"node-fetch": "^2.6.1 <2.6.8",
"progress-stream": "^2.0.0",
"regenerator-runtime": "^0.13.7",
"shell-escape": "^0.2.0",
"ssh2": "^0.8.9",
"stream.pipeline-shim": "^1.1.0",
"webos-service": "git+https://github.com/webosose/nodejs-module-webos-service.git#59172863e61abb53b2f3f174ab9a23c655819188"
},
Expand Down
4 changes: 2 additions & 2 deletions services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function tryRespond<T extends Record<string, any>>(runner: (message: Message) =>

function runService() {
const service = new Service(serviceInfo.id);
const serviceRemote = new ServiceRemote(service);
const serviceRemote = new ServiceRemote();

service.activityManager.idleTimeout = 30;

Expand Down Expand Up @@ -699,7 +699,7 @@ if (process.argv[2] === 'self-update') {
});

(async () => {
const service = new ServiceRemote(null) as Service;
const service = new ServiceRemote() as Service;
try {
await createToast('Performing self-update (inner)', service);
const installedPackageId = await installPackage(process.argv[3], service);
Expand Down
17 changes: 15 additions & 2 deletions services/webos-service-remote/execbus.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ class Request extends EventEmitter {
}

export default class Handle {
constructor(usePublic) {
if (typeof usePublic === 'boolean') {
this.usePublic = usePublic;
} else {
/* use luna-send-pub when not root */
this.usePublic = process.uid !== 0;
}
}

/**
* Send a message via luna-send and start interactive session
* @param {string} uri
Expand All @@ -24,10 +33,14 @@ export default class Handle {
*/
// eslint-disable-next-line class-methods-use-this
subscribe(uri, payload) {
const command = this.usePublic ? 'luna-send-pub' : 'luna-send';
/* using -a with luna-send-pub causes an error */
const args = [...(this.usePublic ? [] : ['-a', 'webosbrew']), '-i', uri, payload];

let process;
let request;
try {
process = spawn('luna-send', ['-a', 'webosbrew', '-i', uri, payload]);
process = spawn(command, args);
request = new Request(process);
const stream = process.stdout;
let stdout = '';
Expand Down Expand Up @@ -55,7 +68,7 @@ export default class Handle {
JSON.stringify({
returnValue: false,
errorCode: -1,
errorText: `Unable to exec luna-send: ${err}`,
errorText: `Unable to exec ${command}: ${err}`,
}),
false,
),
Expand Down
15 changes: 3 additions & 12 deletions services/webos-service-remote/service.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import Message from './message';
import SSHHandle from './sshbus';
import ExecHandle from './execbus';
import Subscription from './subscription';

/**
* Drop in replacement for webos-service, but using SSH shell to call luna-send-pub instead.
* Drop in replacement for webos-service, but luna-send(-pub) instead.
*/
export default class Service {
/**
*
* @param {Service|null} service from webos-service module. Used for retreving SSH pubkey passphrase. If null is provided, alternative backend using root execution is used
*/
constructor(service) {
if (service === null) {
this.sendingHandle = new ExecHandle();
} else {
this.sendingHandle = new SSHHandle(service);
}
constructor() {
this.sendingHandle = new ExecHandle();
}

/* Call a service on the bus
Expand Down
71 changes: 0 additions & 71 deletions services/webos-service-remote/ssh-promise.js

This file was deleted.

Loading