Add an option to install the package right away

Bug #880616 reported by Serhiy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
command-not-found
Fix Committed
Undecided
Serhiy

Bug Description

I'm just surprised it was not implemented already. (Is it because some security considerations?)
So I've added this option and it can be added to the release after testing, adding option for root and l10n.

Related branches

Revision history for this message
Serhiy (xintx-ua) wrote :

+ it can launch the desired application with one more line of code, of course :)

Serhiy (xintx-ua)
Changed in command-not-found:
status: New → Confirmed
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Would you mind proposing the patch as a merge request. It can be reviewed easier there.

I have some comments on the patch itself, don't use os.system, it's a hole for exploits. Use subprocess.call() with shell=False (the default). Other than that we need to ensure that just pressing enter will _NOT_ install the package.

I was thinking about adding a apt-cache summary of the package that you'd install. We'd need to see how this looks like in practice.

Revision history for this message
Serhiy (xintx-ua) wrote :

Ok, thanks a lot, I will try it.

Revision history for this message
Serhiy (xintx-ua) wrote :

But it's impossible to execute apt-get install with shell=False since it requires sudo and sudo requires user to type password interactively. Not to say about warning the user about installing dependencies or even worse - removing conflicting packages. So I don't think '-y' key is the option even if command-not-found has privileges to install packages.

Revision history for this message
Serhiy (xintx-ua) wrote :

About pressing enter: it should not install, I strongly agree and made it so in the first patch, didn't I?
And I also agree about adding summary.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

You are confusing things. shell=False means that we'll not use bash to parse the command. You can easily invoke everything correctly with: subprocess.call(['sudo', 'apt-get', 'install', package_name])

The user will have console control over this process. Anyway let's continue this in a merge request. If you need setting one up just ask me (#ubuntu-devel as zyga)

Serhiy (xintx-ua)
Changed in command-not-found:
assignee: nobody → Загорія Сергій (xintx-ua)
Serhiy (xintx-ua)
Changed in command-not-found:
status: Confirmed → In Progress
Serhiy (xintx-ua)
summary: - Add an option to install the package right away ( + draft patch )
+ Add an option to install the package right away
Serhiy (xintx-ua)
Changed in command-not-found:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.