summaryrefslogtreecommitdiff
path: root/src/ui.cc
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2009-09-05 10:30:32 -0700
committerDaniel Burrows <dburrows@debian.org>2009-09-05 10:30:32 -0700
commit9d8b728f17b6b219d8a9a0b4275c263dc2a6d252 (patch)
tree4be6d031d964b01d36008ad6ed4d5e017832d814 /src/ui.cc
parent9cb15390d83668e80c28c80640c2a368414c9569 (diff)
downloadaptitude-9d8b728f17b6b219d8a9a0b4275c263dc2a6d252.tar.gz
Add support for auto-su-to-root to the "clean package cache" command. (Closes: #492832)
Diffstat (limited to 'src/ui.cc')
-rw-r--r--src/ui.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ui.cc b/src/ui.cc
index 0e038dcb..0a2b5b15 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -1701,7 +1701,7 @@ static void do_sweep()
add_main_widget(cmine::create(), _("Minesweeper"), _("Waste time trying to find mines"), _("Minesweeper"));
}
-static void do_clean()
+static void really_do_clean()
{
if(active_download)
// Erk! That's weird!
@@ -1726,6 +1726,22 @@ static void do_clean()
}
}
+void do_clean()
+{
+ if(getuid()==0 || !aptcfg->FindB(PACKAGE "::Warn-Not-Root", true))
+ really_do_clean();
+ else
+ {
+ popup_widget(cw::dialogs::yesno(wrapbox(cw::text_fragment(_("Cleaning the package cache requires administrative privileges, which you currently do not have. Would you like to change to the root account?"))),
+ cw::util::arg(sigc::bind(sigc::ptr_fun(&do_su_to_root),
+ "--clean-on-startup")),
+ W_("Become root"),
+ cw::util::arg(sigc::ptr_fun(&really_do_update_lists)),
+ W_("Don't become root"),
+ cw::get_style("Error")));
+ }
+}
+
// Ok, this is, uh, weird. Erase has to be overridden to at least
// call unlink()
//