generic: drop most of the KIOSK functionality

This commit is contained in:
Ivailo Monev 2015-05-19 05:23:35 +00:00
parent 4a7ee7d515
commit bbea8b2acc
17 changed files with 49 additions and 184 deletions

View file

@ -157,12 +157,6 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString& path)
return true;
}
// Forbid desktop files outside of standard locations if kiosk is set so
if (!KAuthorized::authorize(QLatin1String("run_desktop_files"))) {
kWarning() << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl;
return false;
}
// Not otherwise permitted, so only allow if the file is executable, or if
// owned by root (uid == 0)
QFileInfo entryInfo( path );

View file

@ -145,28 +145,21 @@ void KHelpMenuPrivate::createActions(KHelpMenu* q)
return;
mActionsCreated = true;
if (mShowWhatsThis && KAuthorized::authorizeKAction("help_whats_this")) {
if (mShowWhatsThis) {
mWhatsThisAction = KStandardAction::whatsThis(q, SLOT(contextHelpActivated()), q);
}
const KAboutData *aboutData = mAboutData ? mAboutData : KGlobal::mainComponent().aboutData();
if (KAuthorized::authorizeKAction("help_report_bug") && aboutData && !aboutData->bugAddress().isEmpty()) {
if (aboutData && !aboutData->bugAddress().isEmpty()) {
mReportBugAction = KStandardAction::reportBug(q, SLOT(reportBug()), q);
}
if (KAuthorized::authorizeKAction("switch_application_language")) {
if((KGlobal::dirs()->findAllResources("locale", QString::fromLatin1("*/entry.desktop"))).count() > 0) {
mSwitchApplicationLanguageAction = KStandardAction::create(KStandardAction::SwitchApplicationLanguage, q, SLOT(switchApplicationLanguage()), q);
}
if((KGlobal::dirs()->findAllResources("locale", QString::fromLatin1("*/entry.desktop"))).count() > 0) {
mSwitchApplicationLanguageAction = KStandardAction::create(KStandardAction::SwitchApplicationLanguage, q, SLOT(switchApplicationLanguage()), q);
}
if (KAuthorized::authorizeKAction("help_about_app")) {
mAboutAppAction = KStandardAction::aboutApp(q, SLOT(aboutApplication()), q);
}
if (KAuthorized::authorizeKAction("help_about_kde")) {
mAboutKDEAction = KStandardAction::aboutKDE(q, SLOT(aboutKDE()), q);
}
mAboutAppAction = KStandardAction::aboutApp(q, SLOT(aboutApplication()), q);
mAboutKDEAction = KStandardAction::aboutKDE(q, SLOT(aboutKDE()), q);
}
// Used in the non-xml-gui case, like kfind or ksnapshot's help button.

View file

@ -405,9 +405,6 @@ void KLineEdit::setCompletionMode( KGlobalSettings::Completion mode )
if ( echoMode() != QLineEdit::Normal )
mode = KGlobalSettings::CompletionNone; // Override the request.
if ( kapp && !KAuthorized::authorize("lineedit_text_completion") )
mode = KGlobalSettings::CompletionNone;
if ( mode == KGlobalSettings::CompletionPopupAuto ||
mode == KGlobalSettings::CompletionAuto ||
mode == KGlobalSettings::CompletionMan )
@ -1200,7 +1197,7 @@ QMenu* KLineEdit::createStandardContextMenu()
// If a completion object is present and the input
// widget is not read-only, show the Text Completion
// menu item.
if ( compObj() && !isReadOnly() && KAuthorized::authorize("lineedit_text_completion") )
if ( compObj() && !isReadOnly() )
{
QMenu *subMenu = popup->addMenu( KIcon("text-completion"), i18nc("@title:menu", "Text Completion") );
connect( subMenu, SIGNAL(triggered(QAction*)),

View file

@ -246,10 +246,7 @@ void KToolBar::Private::init(bool readConfig, bool _isMainToolBar)
q->mainWindow(), SLOT(setSettingsDirty()));
}
if (!KAuthorized::authorize("movable_toolbars"))
q->setMovable(false);
else
q->setMovable(!KToolBar::toolBarsLocked());
q->setMovable(!KToolBar::toolBarsLocked());
connect(q, SIGNAL(movableChanged(bool)),
q, SLOT(slotMovableChanged(bool)));
@ -1045,8 +1042,6 @@ int KToolBar::iconSizeDefault() const
void KToolBar::slotMovableChanged(bool movable)
{
if (movable && !KAuthorized::authorize("movable_toolbars"))
setMovable(false);
}
void KToolBar::dragEnterEvent(QDragEnterEvent *event)

View file

@ -251,8 +251,7 @@ void ToolBarHandler::setupActions()
// We have no XML file associated with our action collection, so load settings from KConfig
actionCollection()->readSettings(); // #233712
if ( KAuthorized::authorizeKAction( "options_show_toolbar" ) )
plugActionList( actionListName, d->actions );
plugActionList( actionListName, d->actions );
d->connectToActionContainers();
}

View file

@ -677,40 +677,6 @@ void WebPage::slotGeometryChangeRequested(const QRect & rect)
bool WebPage::checkLinkSecurity(const QNetworkRequest &req, NavigationType type) const
{
// Check whether the request is authorized or not...
if (!KAuthorized::authorizeUrlAction("redirect", mainFrame()->url(), req.url())) {
//kDebug() << "*** Failed security check: base-url=" << mainFrame()->url() << ", dest-url=" << req.url();
QString buttonText, title, message;
int response = KMessageBox::Cancel;
KUrl linkUrl (req.url());
if (type == QWebPage::NavigationTypeLinkClicked) {
message = i18n("<qt>This untrusted page links to<br/><b>%1</b>."
"<br/>Do you want to follow the link?</qt>", linkUrl.url());
title = i18n("Security Warning");
buttonText = i18nc("follow link despite of security warning", "Follow");
} else {
title = i18n("Security Alert");
message = i18n("<qt>Access by untrusted page to<br/><b>%1</b><br/> denied.</qt>",
Qt::escape(linkUrl.prettyUrl()));
}
if (buttonText.isEmpty()) {
KMessageBox::error( 0, message, title);
} else {
// Dangerous flag makes the Cancel button the default
response = KMessageBox::warningContinueCancel(0, message, title,
KGuiItem(buttonText),
KStandardGuiItem::cancel(),
QString(), // no don't ask again info
KMessageBox::Notify | KMessageBox::Dangerous);
}
return (response == KMessageBox::Continue);
}
return true;
}

View file

@ -935,12 +935,6 @@ void KFileWidget::slotOk()
KIO::StatJob *statJob = KIO::stat(url, KIO::HideProgressInfo);
bool res = KIO::NetAccess::synchronousRun(statJob, this);
if (!KAuthorized::authorizeUrlAction("open", KUrl(), url)) {
QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, d->url.prettyUrl());
KMessageBox::error(this, msg);
return;
}
// if we are on local mode, make sure we haven't got a remote base url
if ((mode & KFile::LocalOnly) && !d->mostLocalUrl(d->url).isLocalFile()) {
KMessageBox::sorry(this,

View file

@ -448,7 +448,7 @@ void KBookmarkMenu::refill()
void KBookmarkMenu::addOpenInTabs()
{
if( !m_pOwner || !m_pOwner->supportsTabs() || !KAuthorized::authorizeKAction("bookmarks") )
if( !m_pOwner || !m_pOwner->supportsTabs() )
return;
QString title = i18n( "Open Folder in Tabs" );
@ -464,7 +464,7 @@ void KBookmarkMenu::addOpenInTabs()
void KBookmarkMenu::addAddBookmarksList()
{
if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !m_pOwner->supportsTabs() || !KAuthorized::authorizeKAction("bookmarks") )
if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !m_pOwner->supportsTabs() )
return;
if (d->bookmarksToFolder == 0) {
@ -481,7 +481,7 @@ void KBookmarkMenu::addAddBookmarksList()
void KBookmarkMenu::addAddBookmark()
{
if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !KAuthorized::authorizeKAction("bookmarks") )
if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) )
return;
if (d->addAddBookmark == 0) {
@ -499,7 +499,7 @@ void KBookmarkMenu::addAddBookmark()
void KBookmarkMenu::addEditBookmarks()
{
if( ( m_pOwner && !m_pOwner->enableOption(KBookmarkOwner::ShowEditBookmark) ) || !KAuthorized::authorizeKAction("bookmarks") )
if( ( m_pOwner && !m_pOwner->enableOption(KBookmarkOwner::ShowEditBookmark) ) )
return;
KAction * m_paEditBookmarks = m_actionCollection->addAction(KStandardAction::EditBookmarks, "edit_bookmarks",
@ -510,7 +510,7 @@ void KBookmarkMenu::addEditBookmarks()
void KBookmarkMenu::addNewFolder()
{
if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !KAuthorized::authorizeKAction("bookmarks"))
if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) )
return;
if (d->newBookmarkFolder == 0) {

View file

@ -556,7 +556,6 @@ void KOpenWithDialogPrivate::setMimeType(const KUrl::List &_urls)
void KOpenWithDialogPrivate::init(const QString &_text, const QString &_value)
{
bool bReadOnly = !KAuthorized::authorize("shell_access");
m_terminaldirty = false;
view = 0;
m_pService = 0;
@ -572,30 +571,21 @@ void KOpenWithDialogPrivate::init(const QString &_text, const QString &_value)
label->setWordWrap(true);
topLayout->addWidget(label);
if (!bReadOnly)
{
// init the history combo and insert it into the URL-Requester
KHistoryComboBox *combo = new KHistoryComboBox();
KLineEdit *lineEdit = new KLineEdit(q);
lineEdit->setClearButtonShown(true);
combo->setLineEdit(lineEdit);
combo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
combo->setDuplicatesEnabled( false );
KConfigGroup cg( KGlobal::config(), QString::fromLatin1("Open-with settings") );
int max = cg.readEntry( "Maximum history", 15 );
combo->setMaxCount( max );
int mode = cg.readEntry( "CompletionMode", int(KGlobalSettings::completionMode()));
combo->setCompletionMode((KGlobalSettings::Completion)mode);
const QStringList list = cg.readEntry( "History", QStringList() );
combo->setHistoryItems( list, true );
edit = new KUrlRequester( combo, mainWidget );
}
else
{
edit = new KUrlRequester( mainWidget );
edit->lineEdit()->setReadOnly(true);
edit->button()->hide();
}
// init the history combo and insert it into the URL-Requester
KHistoryComboBox *combo = new KHistoryComboBox();
KLineEdit *lineEdit = new KLineEdit(q);
lineEdit->setClearButtonShown(true);
combo->setLineEdit(lineEdit);
combo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
combo->setDuplicatesEnabled( false );
KConfigGroup cg( KGlobal::config(), QString::fromLatin1("Open-with settings") );
int max = cg.readEntry( "Maximum history", 15 );
combo->setMaxCount( max );
int mode = cg.readEntry( "CompletionMode", int(KGlobalSettings::completionMode()));
combo->setCompletionMode((KGlobalSettings::Completion)mode);
const QStringList list = cg.readEntry( "History", QStringList() );
combo->setHistoryItems( list, true );
edit = new KUrlRequester( combo, mainWidget );
edit->setText( _value );
edit->setWhatsThis(i18n(
@ -635,9 +625,7 @@ void KOpenWithDialogPrivate::init(const QString &_text, const QString &_value)
q, SLOT(_k_slotDbClick()));
terminal = new QCheckBox( i18n("Run in &terminal"), mainWidget );
if (bReadOnly)
terminal->hide();
QObject::connect(terminal, SIGNAL(toggled(bool)), q, SLOT(slotTerminalToggled(bool)));
QObject::connect(terminal, SIGNAL(toggled(bool)), q, SLOT(slotTerminalToggled(bool)));
topLayout->addWidget(terminal);
@ -660,7 +648,7 @@ void KOpenWithDialogPrivate::init(const QString &_text, const QString &_value)
KConfigGroup confGroup( KGlobal::config(), QString::fromLatin1("General") );
QString preferredTerminal = confGroup.readPathEntry("TerminalApplication", QString::fromLatin1("konsole"));
if (bReadOnly || preferredTerminal != "konsole")
if (preferredTerminal != "konsole")
nocloseonexit->hide();
nocloseonexitLayout->addWidget( nocloseonexit );

View file

@ -927,9 +927,6 @@ KFilePropsPlugin::KFilePropsPlugin( KPropertiesDialog *_props )
button->setText(i18n("File Type Options"));
connect( button, SIGNAL(clicked()), SLOT(slotEditFileType()));
if (!KAuthorized::authorizeKAction("editfiletype"))
button->hide();
}
if ( !magicMimeComment.isEmpty() && magicMimeComment != mimeComment )
@ -3388,9 +3385,7 @@ bool KDesktopPropsPlugin::supports( const KFileItemList& _items )
}
KDesktopFile config(url.toLocalFile());
return config.hasApplicationType() &&
KAuthorized::authorize("run_desktop_files") &&
KAuthorized::authorize("shell_access");
return config.hasApplicationType();
}
#include "moc_kpropertiesdialog.cpp"

View file

@ -430,7 +430,7 @@ int KFileItemActions::addServiceActionsTo(QMenu* mainMenu)
// static
KService::List KFileItemActions::associatedApplications(const QStringList& mimeTypeList, const QString& traderConstraint)
{
if (!KAuthorized::authorizeKAction("openwith") || mimeTypeList.isEmpty()) {
if (mimeTypeList.isEmpty()) {
return KService::List();
}
@ -496,10 +496,6 @@ static KService::Ptr preferredService(const QString& mimeType, const QString& co
void KFileItemActions::addOpenWithActionsTo(QMenu* topMenu, const QString& traderConstraint)
{
if (!KAuthorized::authorizeKAction("openwith")) {
return;
}
d->m_traderConstraint = traderConstraint;
KService::List offers = associatedApplications(d->m_mimeTypeList, traderConstraint);

View file

@ -117,7 +117,6 @@ bool KRun::isExecutableFile(const KUrl& url, const QString &mimetype)
bool KRun::runUrl(const KUrl& u, const QString& _mimetype, QWidget* window, bool tempFile, bool runExecutables, const QString& suggestedFileName, const QByteArray& asn)
{
bool noRun = false;
bool noAuth = false;
if (_mimetype == QLatin1String("inode/directory-locked")) {
KMessageBoxWrapper::error(window,
i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>", Qt::escape(u.prettyUrl())));
@ -130,13 +129,8 @@ bool KRun::runUrl(const KUrl& u, const QString& _mimetype, QWidget* window, bool
}
else if (isExecutableFile(u, _mimetype)) {
if (u.isLocalFile() && runExecutables) {
if (KAuthorized::authorize("shell_access")) {
return (KRun::runCommand(KShell::quoteArg(u.toLocalFile()), QString(), QString(), window, asn, u.directory())); // just execute the url as a command
// ## TODO implement deleting the file if tempFile==true
}
else {
noAuth = true;
}
return (KRun::runCommand(KShell::quoteArg(u.toLocalFile()), QString(), QString(), window, asn, u.directory())); // just execute the url as a command
// ## TODO implement deleting the file if tempFile==true
}
else if (_mimetype == QLatin1String("application/x-executable")) {
noRun = true;
@ -146,10 +140,6 @@ bool KRun::runUrl(const KUrl& u, const QString& _mimetype, QWidget* window, bool
if (!runExecutables) {
noRun = true;
}
if (!KAuthorized::authorize("shell_access")) {
noAuth = true;
}
}
if (noRun) {
@ -158,11 +148,6 @@ bool KRun::runUrl(const KUrl& u, const QString& _mimetype, QWidget* window, bool
"For safety it will not be started.</qt>", Qt::escape(u.prettyUrl())));
return false;
}
if (noAuth) {
KMessageBoxWrapper::error(window,
i18n("<qt>You do not have permission to run <b>%1</b>.</qt>", Qt::escape(u.prettyUrl())));
return false;
}
KUrl::List lst;
lst.append(u);
@ -182,12 +167,6 @@ bool KRun::runUrl(const KUrl& u, const QString& _mimetype, QWidget* window, bool
bool KRun::displayOpenWithDialog(const KUrl::List& lst, QWidget* window, bool tempFiles,
const QString& suggestedFileName, const QByteArray& asn)
{
if (!KAuthorized::authorizeKAction("openwith")) {
KMessageBox::sorry(window,
i18n("You are not authorized to select an application to open this file."));
return false;
}
KOpenWithDialog l(lst, i18n("Open with:"), QString(), window);
l.setWindowModality(Qt::WindowModal);
if (l.exec()) {
@ -868,12 +847,6 @@ static bool makeFileExecutable(const QString &fileName)
// to make the file executable or we failed to make it executable.
static bool makeServiceExecutable(const KService& service, QWidget* window)
{
if (!KAuthorized::authorize("run_desktop_files")) {
kWarning() << "No authorization to execute " << service.entryPath();
KMessageBox::sorry(window, i18n("You are not authorized to execute this service."));
return false; // Don't circumvent the Kiosk
}
KGuiItem continueItem = KStandardGuiItem::cont();
SecureMessageDialog *baseDialog = new SecureMessageDialog(window);
@ -1120,16 +1093,6 @@ void KRun::init()
d->startTimer();
return;
}
if (!KAuthorized::authorizeUrlAction("open", KUrl(), d->m_strURL)) {
QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, d->m_strURL.prettyUrl());
d->m_showingDialog = true;
KMessageBoxWrapper::error(d->m_window, msg);
d->m_showingDialog = false;
d->m_bFault = true;
d->m_bFinished = true;
d->startTimer();
return;
}
if (!d->m_bIsLocalFile && d->m_strURL.isLocalFile()) {
d->m_bIsLocalFile = true;

View file

@ -68,13 +68,6 @@ int main(int argc, char **argv)
return 2;
}
if (!KAuthorized::authorize("shell_access"))
{
KMessageBox::sorry(0,
i18n("You do not have permission to access the %1 protocol.", url.protocol()));
return 3;
}
if (!url.user().isEmpty())
{
cmd << "-l";

View file

@ -204,8 +204,11 @@ endif(PHONON_FOUND)
kde4_add_library(plasma ${LIBRARY_TYPE} ${plasma_LIB_SRCS})
target_link_libraries(plasma ${QT_QTUITOOLS_LIBRARY} ${QT_QTWEBKIT_LIBRARY}
${QT_QTSCRIPT_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY}
${KDE4_KDEUI_LIBS} ${KDE4_KDNSSD_LIBS} ${KDE4_THREADWEAVER_LIBS} ${PLASMA_EXTRA_LIBS})
${QT_QTSCRIPT_LIBRARY} ${QT_QTNETWORK_LIBRARY}
${QT_QTXML_LIBRARY} ${QT_QTSQL_LIBRARY}
${QT_QTDECLARATIVE_LIBRARY} ${KDE4_KDEUI_LIBS}
${KDE4_KDNSSD_LIBS} ${KDE4_THREADWEAVER_LIBS}
${PLASMA_EXTRA_LIBS})
if(X11_FOUND)
target_link_libraries(plasma ${X11_LIBRARIES})

View file

@ -1225,9 +1225,8 @@ void Applet::flushPendingConstraintsEvents()
}
if (d->hasConfigurationInterface) {
bool canConfig = unlocked || KAuthorized::authorize("plasma/allow_configure_when_locked");
configAction->setVisible(canConfig);
configAction->setEnabled(canConfig);
configAction->setVisible(unlocked);
configAction->setEnabled(unlocked);
}
}
@ -1253,9 +1252,8 @@ void Applet::flushPendingConstraintsEvents()
action = d->actions->action("configure");
if (action && d->hasConfigurationInterface) {
bool canConfig = unlocked || KAuthorized::authorize("plasma/allow_configure_when_locked");
action->setVisible(canConfig);
action->setEnabled(canConfig);
action->setVisible(unlocked);
action->setEnabled(unlocked);
}
if (d->extender) {
@ -1671,8 +1669,7 @@ void Applet::setHasConfigurationInterface(bool hasInterface)
if (configAction) {
bool enable = hasInterface;
if (enable) {
const bool unlocked = immutability() == Mutable;
enable = unlocked || KAuthorized::authorize("plasma/allow_configure_when_locked");
enable = immutability() == Mutable;
}
configAction->setEnabled(enable);
}
@ -1841,7 +1838,7 @@ void Applet::showConfigurationInterface()
return;
}
if (immutability() != Mutable && !KAuthorized::authorize("plasma/allow_configure_when_locked")) {
if (immutability() != Mutable) {
return;
}

View file

@ -590,7 +590,7 @@ void Containment::showContextMenu(const QPointF &containmentPos, const QPoint &s
void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
if (!isContainment() || !KAuthorized::authorizeKAction("plasma/containment_context_menu")) {
if (!isContainment()) {
Applet::contextMenuEvent(event);
return;
}
@ -642,12 +642,6 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void ContainmentPrivate::addContainmentActions(KMenu &desktopMenu, QEvent *event)
{
if (static_cast<Corona*>(q->scene())->immutability() != Mutable &&
!KAuthorized::authorizeKAction("plasma/containment_actions")) {
//kDebug() << "immutability";
return;
}
const QString trigger = ContainmentActions::eventToString(event);
prepareContainmentActions(trigger, QPoint(), &desktopMenu);
}
@ -1998,7 +1992,7 @@ void Containment::destroy(bool confirm)
void ContainmentPrivate::createToolBox()
{
if (!toolBox && KAuthorized::authorizeKAction("plasma/containment_context_menu")) {
if (!toolBox) {
toolBox = Plasma::AbstractToolBox::load(q->corona()->preferredToolBoxPlugin(type), QVariantList(), q);
if (toolBox) {

View file

@ -188,9 +188,7 @@ void Corona::initializeLayout(const QString &configName)
}
}
if (config()->isImmutable() ||
!KAuthorized::authorize("plasma/" + KGlobal::mainComponent().aboutData()->appName() +
"/unlockedDesktop")) {
if (config()->isImmutable()) {
setImmutability(SystemImmutable);
} else {
KConfigGroup coronaConfig(config(), "General");