Skip to content

Commit

Permalink
Do not run destreamer as privileged user
Browse files Browse the repository at this point in the history
chromium does not run as root/admin unless its sandbox is disabled.

To prevent security breaches, we will not support running as privileged user.

Everyone is free to make the necessary changes to remove this restriction, in which case destreamer will not be responsible for any issue or data loss.

+ Update README
  • Loading branch information
kylon committed Apr 6, 2020
1 parent f01ef06 commit c519795
Show file tree
Hide file tree
Showing 4 changed files with 443 additions and 243 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ Options:
--verbose, -v Print additional information to the console
(use this before opening an issue on GitHub)
[boolean] [default: false]
```

Make sure you use the right escape char for your shell if using line breaks (as this example shows).

# Make sure you use the right escape char for your shell if using line breaks (as this example shows).
# For PowerShell your escape char is the backtick (`) instead of backslash (\), for cmd.exe use caret (^).
For PowerShell your escape char is the backtick (`) instead of backslash (\\), for cmd.exe use caret (^).

```
$ node destreamer.js --username [email protected] --outputDirectory "videos" \
--videoUrls "https://web.microsoftstream.com/video/VIDEO-1" \
"https://web.microsoftstream.com/video/VIDEO-2" \
Expand All @@ -79,8 +81,6 @@ $ node destreamer.js --username [email protected] --outputDirectory "videos"
--videoUrls list.txt
```

**DO NOT RUN IN AN ELEVATED SHELL ON WINDOWS**, not going to work, Chromium will keep crashing.

Passing `--username` is optional. It's there to make logging in faster (the username field will be populated automatically on the login form).

You can use an absolute path for `--outputDirectory`, for example `/mnt/videos`.
Expand Down
19 changes: 17 additions & 2 deletions destreamer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { sleep, getVideoUrls } from './utils';
import { execSync } from 'child_process';
import isElevated from 'is-elevated';
import puppeteer from 'puppeteer';
import { terminal as term } from 'terminal-kit';
import fs from 'fs';
import os from 'os';
import path from 'path';
import yargs from 'yargs';
import sanitize from 'sanitize-filename';
Expand Down Expand Up @@ -267,6 +269,19 @@ process.on('unhandledRejection', (reason, promise) => {
throw new Error("Killing process..\n");
});

async function main() {
const isValidUser = !(await isElevated());

if (!isValidUser) {
const usrName = os.platform() === 'win32' ? 'Admin':'root';

term.red('\nERROR: Destream does not run as '+usrName+'!\nPlease run destreamer with a non-privileged user.\n');
process.exit(-1);
}

sanityChecks();
rentVideoForLater(getVideoUrls(argv.videoUrls), argv.outputDirectory, argv.username);
}

// run
sanityChecks();
rentVideoForLater(getVideoUrls(argv.videoUrls), argv.outputDirectory, argv.username);
main();
Loading

0 comments on commit c519795

Please sign in to comment.