当前位置: 首页>>代码示例>>C++>>正文


C++ KUser::isSuperUser方法代码示例

本文整理汇总了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." ) );
  }
}
开发者ID:crevetor,项目名称:kcalcore,代码行数:9,代码来源:selftestdialog.cpp

示例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;
}
开发者ID:blue-shell,项目名称:folderview,代码行数:56,代码来源:kdepasswd.cpp


注:本文中的KUser::isSuperUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。