本文整理汇总了C++中KUser::isSuperUser方法的典型用法代码示例。如果您正苦于以下问题:C++ KUser::isSuperUser方法的具体用法?C++ KUser::isSuperUser怎么用?C++ KUser::isSuperUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUser
的用法示例。
在下文中一共展示了KUser::isSuperUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRootUser
void SelfTestDialog::testRootUser()
{
KUser user;
if ( user.isSuperUser() ) {
report( Error, ki18n( "Akonadi was started as root" ), ki18n( "Running Internet-facing applications as root/administrator exposes you to many security risks. MySQL, used by this Akonadi installation, will not allow itself to run as root, to protect you from these risks." ) );
} else {
report( Success, ki18n( "Akonadi is not running as root" ), ki18n( "Akonadi is not running as a root/administrator user, which is the recommended setup for a secure system." ) );
}
}
示例2: main
int main(int argc, char **argv)
{
KAboutData aboutData("kdepasswd", 0, ki18n("KDE passwd"),
KDE_VERSION_STRING, ki18n("Changes a UNIX password."),
KAboutData::License_Artistic, ki18n("Copyright (c) 2000 Geert Jansen"));
aboutData.addAuthor(ki18n("Geert Jansen"), ki18n("Maintainer"),
"[email protected]");
aboutData.setProgramIconName( "preferences-desktop-user-password" );
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
options.add("+[user]", ki18n("Change password of this user"));
KCmdLineArgs::addCmdLineOptions(options);
KUniqueApplication::addCmdLineOptions();
if (!KUniqueApplication::start()) {
kDebug() << "kdepasswd is already running";
return 2;
}
KUniqueApplication app;
KUser ku;
QString user;
bool bRoot = ku.isSuperUser();
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count())
user = args->arg(0);
/* You must be able to run "kdepasswd loginName" */
if ( !user.isEmpty() && user!=KUser().loginName() && !bRoot)
{
KMessageBox::sorry(0, i18n("You need to be root to change the password of other users."));
return 1;
}
QByteArray oldpass;
if (!bRoot)
{
int result = KDEpasswd1Dialog::getPassword(oldpass);
if (result != KDEpasswd1Dialog::Accepted)
return 1;
}
KDEpasswd2Dialog *dlg = new KDEpasswd2Dialog(oldpass, user.toLocal8Bit());
dlg->exec();
if (dlg->result() == KDEpasswd2Dialog::Rejected)
return 1;
return 0;
}