Please reduce use of sudo in REAMDE #9786

Closed
opened 2026-02-21 04:01:21 -05:00 by deekerman · 8 comments
Owner

Originally created by @madduck on GitHub (Jan 29, 2017).

The README.md file uses a lot of sudo, e.g. to invoke curl or wget, but also to actually invoke youtube-dl. But I am sure you'll agree that use of sudo should be kept to an absolute minimum.

So I suggest to use curl/wget as user and then copy the file to /usr/local/bin using install (which also takes care of chmod), if that's even necessary. Often, the use will be single-user, and then it'd be better to use something like ~/bin.

Originally created by @madduck on GitHub (Jan 29, 2017). The README.md file uses a lot of `sudo`, e.g. to invoke `curl` or `wget`, but also to actually invoke `youtube-dl`. But I am sure you'll agree that use of `sudo` should be kept to an absolute minimum. So I suggest to use `curl`/`wget` as user and then copy the file to `/usr/local/bin` using `install` (which also takes care of `chmod`), if that's even necessary. Often, the use will be single-user, and then it'd be better to use something like `~/bin`.
Author
Owner

@dstftw commented on GitHub (Jan 29, 2017):

but also to actually invoke youtube-dl

No it does not. No sudo is used to actually run youtube-dl in README.md (apart from built-in updating).

So I suggest to use curl/wget as user and then copy the file to /usr/local/bin using install (which also takes care of chmod), if that's even necessary.

Don't see much difference. You are still using sudo but also will need to deal with downloading as user somewhere in user directory and ensure not to overwrite if such file already exists. Just unnecessary clutter for nothing.

Often, the use will be single-user, and then it'd be better to use something like ~/bin.

You can't know the intention beforehand. Those who aware can handle this themselves. We provide generic instructions for average user that will just work.

@dstftw commented on GitHub (Jan 29, 2017): >but also to actually invoke `youtube-dl` No it does not. No `sudo` is used to actually run youtube-dl in `README.md` (apart from built-in updating). >So I suggest to use `curl`/`wget` as user and then copy the file to `/usr/local/bin` using `install` (which also takes care of `chmod`), if that's even necessary. Don't see much difference. You are still using `sudo` but also will need to deal with downloading as user somewhere in user directory and ensure not to overwrite if such file already exists. Just unnecessary clutter for nothing. >Often, the use will be single-user, and then it'd be better to use something like `~/bin`. You can't know the intention beforehand. Those who aware can handle this themselves. We provide generic instructions for average user that will just work.
Author
Owner

@madduck commented on GitHub (Jan 29, 2017):

Yeah, I just noticed it's used only for the updating. But still…

The difference is simple: at the moment, you are running complex toosl like curl and wget as root. You are also implicitly trusting the entire set of available CA certificates, which makes it a whole lot easier to launch a MITM-attack. Given the binary nature of youtube-dl, that'll go unnoticed, for sure, and the next thing is that you'll run my code as root…

Sure, it works for the average user, but you are also suggesting highly insecure practices and fueling average user naïvite about it.

And of course, you can't know the intentions beforehand, but I'd be surprised if the majority of the people doing manual installations do so for multiple users. If they just do it for themselves, then no root privilege is ever needed and it'd be a whole lot safer to not advocate for the use of sudo. Contrary to what you write, those who want to install it for multiple users will know what to do…

@madduck commented on GitHub (Jan 29, 2017): Yeah, I just noticed it's used only for the updating. But still… The difference is simple: at the moment, you are running complex toosl like `curl` and `wget` as root. You are also implicitly trusting the entire set of available CA certificates, which makes it a whole lot easier to launch a MITM-attack. Given the binary nature of `youtube-dl`, that'll go unnoticed, for sure, and the next thing is that you'll run my code as root… Sure, it works for the average user, but you are also suggesting highly insecure practices and fueling average user naïvite about it. And of course, you can't know the intentions beforehand, but I'd be surprised if the majority of the people doing manual installations do so for multiple users. If they just do it for themselves, then no `root` privilege is ever needed and it'd be a whole lot safer to not advocate for the use of `sudo`. Contrary to what you write, those who want to install it for multiple users will know what to do…
Author
Owner

@yan12125 commented on GitHub (Feb 1, 2017):

Users are expected to verify downloaded files with GPG keys, so MITM attacks won't work. Indeed README.md should mention GPG keys...

@yan12125 commented on GitHub (Feb 1, 2017): Users are expected to verify downloaded files with GPG keys, so MITM attacks won't work. Indeed README.md should mention GPG keys...
Author
Owner

@madduck commented on GitHub (Feb 2, 2017):

Yes, they should do so in addition. However, I suspect that the kind of user for which this documentation is written (i.e. the one that's best told to use sudo to get the job done because they clearly don't know better themselves) will likely not even know what GPG is…

Whatever.

@madduck commented on GitHub (Feb 2, 2017): Yes, they should do so in addition. However, I suspect that the kind of user for which this documentation is written (i.e. the one that's best told to use `sudo` to get the job done because they clearly don't know better themselves) will likely not even know what GPG is… Whatever.
Author
Owner

@yan12125 commented on GitHub (Feb 3, 2017):

IMO downloading files using sudo is safer - it prevents unauthorized modifications to downloaded files. youtube-dl checks GPG signatures during updates, too. (see youtube_dl/update.py), so it's not a big problem.

@yan12125 commented on GitHub (Feb 3, 2017): IMO downloading files using sudo is safer - it prevents unauthorized modifications to downloaded files. youtube-dl checks GPG signatures during updates, too. (see youtube_dl/update.py), so it's not a big problem.
Author
Owner

@madduck commented on GitHub (Feb 3, 2017):

IMO downloading files using sudo is safer - it prevents unauthorized modifications to downloaded files.

How so?

@madduck commented on GitHub (Feb 3, 2017): > IMO downloading files using sudo is safer - it prevents unauthorized modifications to downloaded files. How so?
Author
Owner

@yan12125 commented on GitHub (Feb 3, 2017):

If youtube-dl is owned by the current user, all user processes can modify it at any time. You may argue that downloading with local user and chown to root solves the problem, but there's inotify, which allows user processes monitor file system changes and take actions.

If you have a Mac, you may want to compare Homebrew and common Linux package managers like apt-get/yum/pacman. The former is more fragile as installed files may change without a notice.

@yan12125 commented on GitHub (Feb 3, 2017): If youtube-dl is owned by the current user, all user processes can modify it at any time. You may argue that downloading with local user and chown to root solves the problem, but there's ```inotify```, which allows user processes monitor file system changes and take actions. If you have a Mac, you may want to compare Homebrew and common Linux package managers like apt-get/yum/pacman. The former is more fragile as installed files may change without a notice.
Author
Owner

@madduck commented on GitHub (Feb 5, 2017):

Your view of security is, uh, just too different for me to be able to participate in this any longer. Good luck.

@madduck commented on GitHub (Feb 5, 2017): Your view of security is, uh, just too different for me to be able to participate in this any longer. Good luck.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl#9786
No description provided.