# translation of abrt.ja.po to Japanese # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # # Kiyoto Hashida , 2009. # Hyu_gabaru Ryu_ichi , 2009. msgid "" msgstr "" "Project-Id-Version: abrt.ja\n" "Report-Msgid-Bugs-To: jmoskovc@redhat.com\n" "POT-Creation-Date: 2010-02-02 15:17+0100\n" "PO-Revision-Date: 2009-12-16 10:39+0900\n" "Last-Translator: Kiyoto Hashida \n" "Language-Team: Japanese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.4\n" "Plural-Forms: Plural-Forms: nplurals=1; plural=0;\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" #: src/Gui/ABRTExceptions.py:6 msgid "Another client is already running, trying to wake it." msgstr "別のクライアントが稼働していますので、それを呼び出しています。" #: src/Gui/ABRTExceptions.py:13 msgid "Got unexpected data from daemon (is the database properly updated?)." msgstr "" "デーモンから予想外のデータを受け取りました(データベースは正常に更新されてい" "ますか?)。" #: src/Gui/ABRTPlugin.py:62 #, fuzzy msgid "Not loaded plugins" msgstr "plugin の UI がありません %s" #: src/Gui/ABRTPlugin.py:63 msgid "Analyzer plugins" msgstr "アナライザー plugin" #: src/Gui/ABRTPlugin.py:64 msgid "Action plugins" msgstr "アクション plugin" #: src/Gui/ABRTPlugin.py:65 msgid "Reporter plugins" msgstr "レポーター plugin" #: src/Gui/ABRTPlugin.py:66 msgid "Database plugins" msgstr "データベース plugin" #: src/Gui/CCDBusBackend.py:74 src/Gui/CCDBusBackend.py:97 msgid "Can't connect to system dbus" msgstr "システム dbus に接続できません。" #: src/Gui/CCDBusBackend.py:120 src/Gui/CCDBusBackend.py:123 msgid "Please check if abrt daemon is running" msgstr "abrt デーモンが稼働しているかどうかチェックして下さい" #: src/Gui/CCDBusBackend.py:175 msgid "" "Daemon didn't return valid report info\n" "Debuginfo is missing?" msgstr "" "デーモンは有効な報告情報を返しませんでした。\n" "Debuginfo が無いですか?" #: src/Gui/ccgui.glade:8 msgid "Please wait.." msgstr "お待ち下さい..." #: src/Gui/ccgui.glade:60 msgid "Details" msgstr "詳細" #: src/Gui/ccgui.glade:76 msgid "About ABRT" msgstr "ABRT について" #: src/Gui/ccgui.glade:82 msgid "(C) 2009 Red Hat, Inc." msgstr "(C) 2009 Red Hat, Inc." #: src/Gui/ccgui.glade:83 msgid "" "This program is free software; you can redistribute it and/or modify it " "under the terms of the GNU General Public License as published by the Free " "Software Foundation; either version 2 of the License, or (at your option) " "any later version.\n" "\n" "This program is distributed in the hope that it will be useful, but WITHOUT " "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or " "FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for " "more details.\n" "\n" "You should have received a copy of the GNU General Public License along with " "this program. If not, see ." msgstr "" "This program is free software; you can redistribute it and/or modify it " "under the terms of the GNU General Public License as published by the Free " "Software Foundation; either version 2 of the License, or (at your option) " "any later version.\n" "\n" "This program is distributed in the hope that it will be useful, but WITHOUT " "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or " "FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for " "more details.\n" "\n" "You should have received a copy of the GNU General Public License along with " "this program. If not, see ." #: src/Gui/ccgui.glade:121 src/Gui/CCMainWindow.py:8 src/Gui/report.glade:7 msgid "Automatic Bug Reporting Tool" msgstr "自動バグ報告ツール(ABRT)" #: src/Gui/ccgui.glade:134 msgid "_File" msgstr "ファイル(_F)" #: src/Gui/ccgui.glade:155 msgid "_Edit" msgstr "編集(_E)" #: src/Gui/ccgui.glade:163 msgid "Plugins" msgstr "プラグイン" #: src/Gui/ccgui.glade:182 msgid "_Help" msgstr "ヘルプ(_H)" #: src/Gui/ccgui.glade:214 src/Gui/ccgui.glade:215 msgid "Delete" msgstr "削除" #: src/Gui/ccgui.glade:227 src/Gui/ccgui.glade:228 src/Gui/ccgui.glade:342 msgid "Report" msgstr "報告" #: src/Gui/ccgui.glade:298 msgid "Not Reported" msgstr "報告されていません" #: src/Gui/CCMainWindow.py:74 msgid "Icon" msgstr "アイコン" #: src/Gui/CCMainWindow.py:82 msgid "Package" msgstr "パッケージ" #: src/Gui/CCMainWindow.py:83 msgid "Application" msgstr "アプリケーション" #: src/Gui/CCMainWindow.py:84 msgid "Date" msgstr "期日" #: src/Gui/CCMainWindow.py:85 msgid "Crash count" msgstr "クラッシュカウント" #: src/Gui/CCMainWindow.py:86 msgid "User" msgstr "ユーザー" #: src/Gui/CCMainWindow.py:154 #, python-format msgid "" "Can't show the settings dialog\n" "%s" msgstr "" "セッティングのダイアログを表示できません\n" "%s" #: src/Gui/CCMainWindow.py:165 #, python-format msgid "" "Unable to finish current task!\n" "%s" msgstr "" "現在のタスクを終了できません! \n" "%s" #: src/Gui/CCMainWindow.py:192 #, python-format msgid "" "Error while loading the dumplist.\n" "%s" msgstr "" "dumplist のロード中にエラーが発生。\n" " %s" #: src/Gui/CCMainWindow.py:230 #, fuzzy msgid "This crash has been reported:\n" msgstr "このクラッシュは報告済みです:\n" #: src/Gui/CCMainWindow.py:231 msgid "This crash has been reported:\n" msgstr "このクラッシュは報告済みです:\n" #: src/Gui/CCMainWindow.py:250 msgid "Not reported!" msgstr "報告がありません!" #: src/Gui/CCMainWindow.py:298 msgid "" "Unable to get report!\n" "Debuginfo is missing?" msgstr "" "報告を取得できません\n" "Debuginfo が無いですか ?" #: src/Gui/CCMainWindow.py:318 #, python-format msgid "" "Reporting failed!\n" "%s" msgstr "" "報告が失敗しました!\n" "%s" #: src/Gui/CCMainWindow.py:337 src/Gui/CCMainWindow.py:364 #, python-format msgid "Error getting the report: %s" msgstr "報告の取得中にエラーです: %s" #: src/Gui/CCReporterDialog.py:24 msgid "Brief description how to reproduce this or what you did..." msgstr "この問題の再現手順、または実行したことの簡単な説明..." #: src/Gui/CCReporterDialog.py:99 msgid "You must check backtrace for sensitive data" msgstr "" #: src/Gui/CCReporterDialog.py:110 #, python-format msgid "" "Reporting disabled because the backtrace is unusable.\n" "Please try to install debuginfo manually using command: debuginfo-install " "%s \n" "then use Refresh button to regenerate the backtrace." msgstr "" "バックトレースが使用不可のために報告が無効になっています。\n" "コマンド : debuginfo-install %s を使用して手動で debuginfo を インス" "トールしてから \n" "リフレッシュボタンを使用してバックトレースを再生成して下さい。" #: src/Gui/CCReporterDialog.py:112 msgid "The backtrace is unusable, you can't report this!" msgstr "バックトレースが使用不可です。これを報告できません!" #: src/Gui/CCReporterDialog.py:116 msgid "" "The backtrace is incomplete, please make sure you provide good steps to " "reproduce." msgstr "" "バックトレースが不完全です。再生するために確実に正しい手順に従って 下さい。 " #: src/Gui/CCReporterDialog.py:158 #, python-format msgid "" "Can't save plugin settings:\n" " %s" msgstr "" "plugin のセッティングを保存できません:\n" " %s" #: src/Gui/dialogs.glade:7 msgid "Report done" msgstr "報告完了" #: src/Gui/dialogs.glade:78 msgid "Log" msgstr "ログ" #: src/Gui/PluginSettingsUI.py:18 msgid "Can't find PluginDialog widget in UI description!" msgstr "UI 説明の中で PluginDialog ウィジェットを見つけることが出来ません!" #: src/Gui/PluginSettingsUI.py:24 #, python-format msgid "No UI for plugin %s" msgstr "plugin の UI がありません %s" #: src/Gui/PluginSettingsUI.py:55 src/Gui/PluginSettingsUI.py:81 msgid "combo box is not implemented" msgstr "combo box が実装されていません" #: src/Gui/PluginSettingsUI.py:64 msgid "Nothing to hydrate!" msgstr "表示するデータはありません!" #: src/Gui/report.glade:41 msgid "Package:" msgstr "" #: src/Gui/report.glade:52 msgid "Component:" msgstr "" #: src/Gui/report.glade:63 msgid "Executable:" msgstr "" #: src/Gui/report.glade:74 msgid "Cmdline:" msgstr "" #: src/Gui/report.glade:98 src/Gui/report.glade:111 src/Gui/report.glade:124 #: src/Gui/report.glade:137 src/Gui/report.glade:215 src/Gui/report.glade:228 #: src/Gui/report.glade:241 src/Gui/report.glade:254 msgid "N/A" msgstr "" #: src/Gui/report.glade:159 msgid "Architecture:" msgstr "" #: src/Gui/report.glade:170 msgid "Kernel:" msgstr "" #: src/Gui/report.glade:181 msgid "Release:" msgstr "" #: src/Gui/report.glade:192 msgid "Reason:" msgstr "" #: src/Gui/report.glade:315 msgid "I checked backtrace and removed sensitive data (passwords, etc)" msgstr "" #: src/Gui/report.glade:334 msgid "Backtrace" msgstr "" #: src/Gui/report.glade:396 msgid "How to reproduce (in a few simple steps)" msgstr "(2、3の簡単なステップで)再生の方法" #: src/Gui/report.glade:439 msgid "Comment" msgstr "コメント" #: src/Gui/report.glade:487 #, fuzzy msgid "Attachments" msgstr "コメント" #: src/Gui/report.glade:536 msgid "Please fix the following problems" msgstr "" #: src/Gui/report.glade:546 msgid " " msgstr " " #: src/Gui/report.glade:593 msgid "Show log" msgstr "" #: src/Gui/report.glade:635 msgid "Send report" msgstr "" #: src/Gui/SettingsDialog.py:33 src/Gui/SettingsDialog.py:50 msgid "Select plugin" msgstr "plugin を選択" #: src/Gui/SettingsDialog.py:36 msgid "Select database backend" msgstr "データベースバックエンドを選択" #: src/Gui/SettingsDialog.py:169 msgid "Remove this job" msgstr "このジョブを取り除く" #: src/Gui/SettingsDialog.py:213 msgid "Remove this action" msgstr "このアクションを取り除く" #: src/Gui/settings.glade:6 msgid "Settings" msgstr "設定" #: src/Gui/settings.glade:63 msgid "Web Site:" msgstr "ウェブサイト:" #: src/Gui/settings.glade:75 msgid "Author:" msgstr "著者:" #: src/Gui/settings.glade:87 msgid "Version:" msgstr "バージョン:" #: src/Gui/settings.glade:141 msgid "Description:" msgstr "説明:" #: src/Gui/settings.glade:153 msgid "Name:" msgstr "名前:" #: src/Gui/settings.glade:197 msgid "Plugin details" msgstr "Plugin の詳細" #: src/Gui/settings.glade:220 msgid "C_onfigure plugin" msgstr "plugin を設定(_C)" #: src/Gui/settings.glade:257 msgid "Global Settings" msgstr "グローバル設定" #: src/Gui/settings.glade:283 msgid "Check package GPG signature" msgstr "パッケージの GPG 署名をチェック" #: src/Gui/settings.glade:299 msgid "Database backend: " msgstr "データベースバックエンド:" #: src/Gui/settings.glade:325 msgid "Blacklisted packages: " msgstr "ブラックリスト内のパッケージ:" #: src/Gui/settings.glade:339 msgid "Max coredump storage size(MB):" msgstr "コアダンプ格納の最大サイズ (MB):" #: src/Gui/settings.glade:353 msgid "GPG keys: " msgstr "GPG キー: " #: src/Gui/settings.glade:456 msgid "Common" msgstr "共通" #: src/Gui/settings.glade:489 msgid "Plugin" msgstr "Plugin" #: src/Gui/settings.glade:499 msgid "Time (or period)" msgstr "時間 (又は、期間)" #: src/Gui/settings.glade:567 msgid "Cron" msgstr "Cron" #: src/Gui/settings.glade:601 msgid "Analyzer plugin" msgstr "アナライザー plugin" #: src/Gui/settings.glade:611 msgid "Associated action" msgstr "関連したアクション" #: src/Gui/settings.glade:690 msgid "Analyzers, Actions, Reporters" msgstr "アナライザ、アクション、レポーター" #: src/Gui/settings.glade:709 msgid "gtk-cancel" msgstr "gtk-cancel" #: src/Gui/settings.glade:723 msgid "gtk-ok" msgstr "gtk-ok" #: src/Gui/settings.glade:751 msgid "GPG Keys" msgstr "GPG キー" #: src/Applet/Applet.cpp:78 #, c-format msgid "A crash in package %s has been detected" msgstr "パッケージ %s のクラッシュが検出されました" #: src/Applet/Applet.cpp:253 msgid "ABRT service is not running" msgstr "ABRT サービスは稼働していません。" #: src/Applet/CCApplet.cpp:200 msgid "Warning" msgstr "警告" #: src/Daemon/Daemon.cpp:473 msgid "" "Report size exceeded the quota. Please check system's MaxCrashReportsSize " "value in abrt.conf." msgstr "" "報告のサイズが割り当て超過です。abrt.conf の中で MaxCrashReportsSize の値を " "チェックして下さい。" #: lib/Plugins/Bugzilla.cpp:124 msgid "Missing member 'reporter'" msgstr "" #: lib/Plugins/Bugzilla.cpp:176 msgid "Missing member 'cc'" msgstr "" #: lib/Plugins/Bugzilla.cpp:262 #, c-format msgid "Bug is already reported: %i" msgstr "バグは既に報告済みです: %i" #: lib/Plugins/Bugzilla.cpp:274 msgid "Missing member 'bug_id'" msgstr "" #: lib/Plugins/Bugzilla.cpp:283 msgid "Missing member 'bugs'" msgstr "" #: lib/Plugins/Bugzilla.cpp:346 #, c-format msgid "New bug id: %i" msgstr "新しいバグ id: %i" #: lib/Plugins/Bugzilla.cpp:440 msgid "Checking for duplicates..." msgstr "重複をチェックしています..." #: lib/Plugins/Bugzilla.cpp:446 msgid "Empty login and password. Please check Bugzilla.conf" msgstr "ログインとパスワードが空です。Bugzilla.conf を確認して下さい" #: lib/Plugins/Bugzilla.cpp:449 msgid "Logging into bugzilla..." msgstr "bugzilla にログインしています..." #: lib/Plugins/Bugzilla.cpp:454 msgid "Checking CC..." msgstr "CC をチェックしています..." #: lib/Plugins/Bugzilla.cpp:465 msgid "Creating new bug..." msgstr "新しいバグを作成中..." #: lib/Plugins/Bugzilla.cpp:469 msgid "Logging out..." msgstr "ログアウトしています..." #: lib/Plugins/Kerneloops.cpp:35 msgid "Getting local universal unique identification" msgstr "ローカルで普遍的な独特の識別を取得しています" #: lib/Plugins/CCpp.cpp:253 msgid "Generating backtrace" msgstr "バックトレース生成中" #: lib/Plugins/CCpp.cpp:388 msgid "Starting debuginfo installation" msgstr "debuginfo のインストールをスタート中" #: lib/Plugins/CCpp.cpp:537 msgid "Getting local universal unique identification..." msgstr "ローカルで普遍的な独特の識別を取得しています..." #: lib/Plugins/CCpp.cpp:556 msgid "Getting global universal unique identification..." msgstr "グローバルで普遍的な独特の識別を取得しています..." #: lib/Plugins/CCpp.cpp:734 msgid "Skipping debuginfo installation" msgstr "debuginfo のインストールをスキップします" #: lib/Plugins/KerneloopsReporter.cpp:100 msgid "Creating and submitting a report..." msgstr "報告の作成と提出をしています..." #: lib/Plugins/Logger.cpp:76 #, c-format msgid "Writing report to '%s'" msgstr " %s へのレポートを書き込み中" #: lib/Plugins/FileTransfer.cpp:54 msgid "FileTransfer: URL not specified" msgstr "ファイル転送: URL が示されていません" #: lib/Plugins/FileTransfer.cpp:58 #, c-format msgid "Sending archive %s to %s" msgstr "アーカイブ %s を %s に送信中" #: lib/Plugins/FileTransfer.cpp:289 msgid "File Transfer: Creating a report..." msgstr "ファイル転送: 報告を作成中..." #: lib/Plugins/FileTransfer.cpp:323 #, c-format msgid "Can't create and send an archive: %s" msgstr "アーカイブを作成して送信できません: %s" #: lib/Plugins/FileTransfer.cpp:352 #, c-format msgid "Can't create and send an archive %s" msgstr "アーカイブを作成して送信できません: %s" #: lib/Plugins/KerneloopsScanner.cpp:79 msgid "Creating kernel oops crash reports..." msgstr "カーネル oops クラッシュ報告を作成中..." #: lib/Plugins/Mailx.cpp:137 msgid "Sending an email..." msgstr "電子メールを送信中..." #: lib/Plugins/SOSreport.cpp:103 #, fuzzy, c-format msgid "Running sosreport: %s" msgstr "sosreport を実行しています: %s" #: lib/Plugins/SOSreport.cpp:109 #, fuzzy msgid "Done running sosreport" msgstr "sosreport の実行完了" #~ msgid "Plugin name is not set, can't load its settings" #~ msgstr "プラグイン名が設定されていません、その設定はロードできません" #~ msgid "" #~ "WARNING, you're about to send data which might contain sensitive " #~ "information.\n" #~ "Do you really want to send %s?\n" #~ msgstr "" #~ "警告、機密情報を含む可能性のあるデータを送信 しようとしています。\n" #~ "本当に%sを送信したいですか ?\n" #~ msgid "Following items will be sent" #~ msgstr "次の項目が送信されます" #~ msgid "Send" #~ msgstr "送信" #~ msgid "View and report application crashes" #~ msgstr "アプリケーションクラッシュを表示して報告" #~ msgid "Executing SOSreport plugin..." #~ msgstr "SOSreport plugin の実行中..." 418'>418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
/*
    SSSD

    Unit tests - exercise the krb5 child

    Authors:
        Jakub Hrozek <jhrozek@redhat.com>

    Copyright (C) 2012 Red Hat

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <stdlib.h>
#include <talloc.h>
#include <popt.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>

#include "util/util.h"
#include "src/tools/tools_util.h"

/* Interfaces being tested */
#include "providers/krb5/krb5_auth.h"
#include "providers/krb5/krb5_common.h"
#include "providers/krb5/krb5_utils.h"

extern struct dp_option default_krb5_opts[];
extern struct sss_krb5_cc_be file_cc;
extern struct sss_krb5_cc_be dir_cc;

static krb5_context krb5_error_ctx;
#define KRB5_CHILD_TEST_DEBUG(level, error) KRB5_DEBUG(level, krb5_error_ctx, error)

#define CHECK_KRET(kret, err) do {              \
    if (kret) {                                 \
        KRB5_CHILD_TEST_DEBUG(SSSDBG_OP_FAILURE, kret);    \
        return err;                             \
    }                                           \
} while(0)                                      \

#define CHECK_KRET_L(kret, err, label) do {     \
    if (kret) {                                 \
        KRB5_CHILD_TEST_DEBUG(SSSDBG_OP_FAILURE, kret);    \
        goto label;                             \
    }                                           \
} while(0)                                      \

struct krb5_child_test_ctx {
    struct tevent_context *ev;
    struct krb5child_req *kr;

    bool done;
    errno_t child_ret;

    uint8_t *buf;
    ssize_t len;
    struct krb5_child_response *res;
};

static errno_t
setup_krb5_child_test(TALLOC_CTX *mem_ctx, struct krb5_child_test_ctx **_ctx)
{
    struct krb5_child_test_ctx *ctx;

    ctx = talloc_zero(mem_ctx, struct krb5_child_test_ctx);
    if (!ctx) return ENOMEM;

    ctx->ev = tevent_context_init(ctx);
    if (ctx->ev == NULL) {
        DEBUG(SSSDBG_CRIT_FAILURE, ("Could not init tevent context"));
        talloc_free(ctx);
        return EFAULT;
    }

    *_ctx = ctx;
    return EOK;
}

int re_destructor(void *memctx)
{
    struct krb5_ctx *ctx = (struct krb5_ctx *) memctx;

    if (ctx->illegal_path_re) {
        pcre_free(ctx->illegal_path_re);
        ctx->illegal_path_re = NULL;
    }
    return 0;
}

static struct krb5_ctx *
create_dummy_krb5_ctx(TALLOC_CTX *mem_ctx, const char *realm)
{
    struct krb5_ctx *krb5_ctx;
    const char *errstr;
    int errval;
    int errpos;
    int i;
    errno_t ret;

    krb5_ctx = talloc_zero(mem_ctx, struct krb5_ctx);
    if (!krb5_ctx) return NULL;

    krb5_ctx->illegal_path_re = pcre_compile2(ILLEGAL_PATH_PATTERN, 0,
                                        &errval, &errstr, &errpos, NULL);
    if (krb5_ctx->illegal_path_re == NULL) {
        DEBUG(SSSDBG_OP_FAILURE,
              ("Invalid Regular Expression pattern at position %d. "
               "(Error: %d [%s])\n", errpos, errval, errstr));
        goto fail;
    }
    talloc_set_destructor((TALLOC_CTX *) krb5_ctx, re_destructor);

    /* Kerberos options */
    krb5_ctx->opts = talloc_zero_array(krb5_ctx, struct dp_option, KRB5_OPTS);
    if (!krb5_ctx->opts) goto fail;
    for (i = 0; i < KRB5_OPTS; i++) {
        krb5_ctx->opts[i].opt_name = default_krb5_opts[i].opt_name;
        krb5_ctx->opts[i].type = default_krb5_opts[i].type;
        krb5_ctx->opts[i].def_val = default_krb5_opts[i].def_val;
        switch (krb5_ctx->opts[i].type) {
            case DP_OPT_STRING:
                ret = dp_opt_set_string(krb5_ctx->opts, i,
                                        default_krb5_opts[i].def_val.string);
                break;
            case DP_OPT_BLOB:
                ret = dp_opt_set_blob(krb5_ctx->opts, i,
                                      default_krb5_opts[i].def_val.blob);
                break;
            case DP_OPT_NUMBER:
                ret = dp_opt_set_int(krb5_ctx->opts, i,
                                     default_krb5_opts[i].def_val.number);
                break;
            case DP_OPT_BOOL:
                ret = dp_opt_set_bool(krb5_ctx->opts, i,
                                      default_krb5_opts[i].def_val.boolean);
                break;
        }
        if (ret) goto fail;
    }

    ret = dp_opt_set_string(krb5_ctx->opts, KRB5_REALM, realm);
    if (ret) goto fail;

    return krb5_ctx;

fail:
    talloc_free(krb5_ctx);
    return NULL;
}

static struct pam_data *
create_dummy_pam_data(TALLOC_CTX *mem_ctx, const char *user,
                      const char *password)
{
    struct pam_data *pd;

    pd = talloc_zero(mem_ctx, struct pam_data);
    if (!pd) goto fail;

    pd->cmd = SSS_PAM_AUTHENTICATE;
    pd->user = talloc_strdup(pd, user);
    if (!pd->user) goto fail;

    pd->authtok = discard_const(talloc_strdup(pd, password));
    if (!pd->authtok) goto fail;
    pd->authtok_size = strlen(password);
    pd->authtok_type = SSS_AUTHTOK_TYPE_PASSWORD;
    DEBUG(SSSDBG_FUNC_DATA, ("Authtok [%s] len [%d]\n",
          pd->authtok, pd->authtok_size));

    return pd;

fail:
    talloc_free(pd);
    return NULL;
}

static struct krb5child_req *
create_dummy_req(TALLOC_CTX *mem_ctx, const char *user,
                 const char *password, const char *realm,
                 const char *ccname, const char *ccname_template,
                 int timeout)
{
    enum sss_krb5_cc_type cc_be;
    struct krb5child_req *kr;
    struct passwd *pwd;
    bool private = false;
    errno_t ret;
    const char *tmpl;

    /* The top level child request */
    kr = talloc_zero(mem_ctx, struct krb5child_req);
    if (!kr) return NULL;

    pwd = getpwnam(user);
    if (!pwd) {
        DEBUG(SSSDBG_FATAL_FAILURE,
              ("Cannot get info on user [%s]\n", user));
        goto fail;
    }

    kr->uid = pwd->pw_uid;
    kr->gid = pwd->pw_gid;

    /* The Kerberos context */
    kr->krb5_ctx = create_dummy_krb5_ctx(kr, realm);
    /* PAM Data structure */
    kr->pd = create_dummy_pam_data(kr, user, password);

    ret = krb5_get_simple_upn(kr, kr->krb5_ctx, NULL, kr->pd->user, NULL,
                              &kr->upn);
    if (ret != EOK) {
        DEBUG(SSSDBG_OP_FAILURE, ("krb5_get_simple_upn failed.\n"));
        goto fail;
    }

    /* Override options with what was provided by the user */
    if (ccname_template) {
        ret = dp_opt_set_string(kr->krb5_ctx->opts, KRB5_CCNAME_TMPL,
                                ccname_template);
        if (ret != EOK) goto fail;
        tmpl = ccname_template;
    } else {
        tmpl = dp_opt_get_cstring(kr->krb5_ctx->opts, KRB5_CCNAME_TMPL);
    }

    if (timeout) {
        ret = dp_opt_set_int(kr->krb5_ctx->opts, KRB5_AUTH_TIMEOUT, timeout);
        if (ret != EOK) {
            DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to set value for krb5_auth_timeout\n"));
            goto fail;
        }
    }

    if (!ccname) {
        kr->ccname = expand_ccname_template(kr, kr,
                                        dp_opt_get_cstring(kr->krb5_ctx->opts,
                                                           KRB5_CCNAME_TMPL),
                                            true, true, &private);
        if (!kr->ccname) goto fail;

        DEBUG(SSSDBG_FUNC_DATA, ("ccname [%s] uid [%llu] gid [%llu]\n",
              kr->ccname, (unsigned long long) kr->uid,
              (unsigned long long) kr->gid));
    } else {
        kr->ccname = talloc_strdup(kr, ccname);
    }
    if (!kr->ccname) goto fail;

    cc_be = sss_krb5_get_type(kr->ccname);
    switch (cc_be) {
    case SSS_KRB5_TYPE_FILE:
        kr->krb5_ctx->cc_be = &file_cc;
        break;
#ifdef HAVE_KRB5_DIRCACHE
    case SSS_KRB5_TYPE_DIR:
        kr->krb5_ctx->cc_be = &dir_cc;
        break;
#endif /* HAVE_KRB5_DIRCACHE */
    default:
        if (tmpl[0] != '/') {
            DEBUG(SSSDBG_OP_FAILURE, ("Unkown ccname database\n"));
            ret = EINVAL;
            goto fail;
        }
        DEBUG(SSSDBG_CONF_SETTINGS, ("The ccname template was "
              "missing an explicit type, but looks like an absolute "
              "path specifier. Assuming FILE:\n"));
        kr->krb5_ctx->cc_be = &file_cc;
        break;
    }
    DEBUG(SSSDBG_FUNC_DATA, ("ccname [%s] uid [%llu] gid [%llu]\n",
            kr->ccname, kr->uid, kr->gid));

    ret = kr->krb5_ctx->cc_be->create(kr->ccname,
                                      kr->krb5_ctx->illegal_path_re,
                                      kr->uid, kr->gid, private);
    if (ret != EOK) {
        DEBUG(SSSDBG_OP_FAILURE, ("create_ccache_dir failed.\n"));
        goto fail;
    }

    return kr;

fail:
    talloc_free(kr);
    return NULL;
}

static void
child_done(struct tevent_req *req)
{
    struct krb5_child_test_ctx *ctx = tevent_req_callback_data(req,
                                    struct krb5_child_test_ctx);
    errno_t ret;

    ret = handle_child_recv(req, ctx, &ctx->buf, &ctx->len);
    talloc_free(req);
    ctx->done = true;
    ctx->child_ret = ret;
}

static void
printtime(krb5_timestamp ts)
{
    krb5_error_code kret;
    char timestring[BUFSIZ];
    char fill = '\0';

#ifdef HAVE_KRB5_TIMESTAMP_TO_SFSTRING
    kret = krb5_timestamp_to_sfstring(ts, timestring, BUFSIZ, &fill);
    if (kret) {
        KRB5_CHILD_TEST_DEBUG(SSSDBG_OP_FAILURE, kret);
    }
    printf("%s", timestring);
#else
    printf("%s", ctime(&ts));
#endif /* HAVE_KRB5_TIMESTAMP_TO_SFSTRING */
}

static void
print_creds(krb5_context kcontext, krb5_creds *cred, const char *defname)
{
    krb5_error_code kret;
    char *name = NULL;
    char *sname = NULL;

    kret = krb5_unparse_name(kcontext, cred->client, &name);
    CHECK_KRET_L(kret, EIO, done);

    kret = krb5_unparse_name(kcontext, cred->server, &sname);
    CHECK_KRET_L(kret, EIO, done);

    if (!cred->times.starttime) {
        cred->times.starttime = cred->times.authtime;
    }


    printf("\t\t%s\n", sname);
    printf("\t\tValid from\t");  printtime(cred->times.starttime);
    printf("\n\t\tValid until\t"); printtime(cred->times.endtime);
    printf("\n");

    if (strcmp(name, defname)) {
        printf("\t\tfor client %s", name);
    }

done:
    krb5_free_unparsed_name(kcontext, name);
    krb5_free_unparsed_name(kcontext, sname);
}

static errno_t
print_ccache(const char *cc)
{
    krb5_cc_cursor cur;
    krb5_ccache cache = NULL;
    krb5_error_code kret;
    krb5_context kcontext = NULL;
    krb5_principal_data *princ = NULL;
    krb5_creds creds;
    char *defname = NULL;
    int i = 1;
    errno_t ret = EIO;

    kret = krb5_init_context(&kcontext);
    CHECK_KRET_L(kret, EIO, done);

    kret = krb5_cc_resolve(kcontext, cc, &cache);
    CHECK_KRET_L(kret, EIO, done);

    kret = krb5_cc_get_principal(kcontext, cache, &princ);
    CHECK_KRET_L(kret, EIO, done);

    kret = krb5_unparse_name(kcontext, princ, &defname);
    CHECK_KRET_L(kret, EIO, done);

    printf("\nTicket cache: %s:%s\nDefault principal: %s\n\n",
           krb5_cc_get_type(kcontext, cache),
           krb5_cc_get_name(kcontext, cache), defname);

    kret = krb5_cc_start_seq_get(kcontext, cache, &cur);
    CHECK_KRET_L(kret, EIO, done);

    while (!(kret = krb5_cc_next_cred(kcontext, cache, &cur, &creds))) {
        printf("Ticket #%d:\n", i);
        print_creds(kcontext, &creds, defname);
        krb5_free_cred_contents(kcontext, &creds);
    }

    kret = krb5_cc_end_seq_get(kcontext, cache, &cur);
    CHECK_KRET_L(kret, EIO, done);

    ret = EOK;
done:
    krb5_cc_close(kcontext, cache);
    krb5_free_unparsed_name(kcontext, defname);
    krb5_free_principal(kcontext, princ);
    krb5_free_context(kcontext);
    return ret;
}

int
main(int argc, const char *argv[])
{
    int opt;
    errno_t ret;
    struct krb5_child_test_ctx *ctx = NULL;
    struct tevent_req *req;

    int pc_debug = 0;
    int pc_timeout = 0;
    const char *pc_user = NULL;;
    const char *pc_passwd = NULL;;
    const char *pc_realm = NULL;;
    const char *pc_ccname = NULL;;
    const char *pc_ccname_tp = NULL;;
    char *password = NULL;
    bool rm_ccache = true;

    poptContext pc;
    struct poptOption long_options[] = {
        POPT_AUTOHELP
        { "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, 0,
          "The debug level to run with", NULL },
        { "user", 'u', POPT_ARG_STRING, &pc_user, 0,
          "The user to log in as", NULL },
        { "password", 'w', POPT_ARG_STRING, &pc_passwd, 0,
          "The authtok to use", NULL },
        { "ask-password", 'W', POPT_ARG_NONE, NULL, 'W',
          "Ask interactively for authtok", NULL },
        { "ccname", 'c', POPT_ARG_STRING, &pc_ccname, 0,
           "Force usage of a certain credential cache", NULL },
        { "ccname-template", 't', POPT_ARG_STRING, &pc_ccname_tp, 0,
           "Specify the credential cache template", NULL },
        { "realm", 'r', POPT_ARG_STRING, &pc_realm, 0,
          "The Kerberos realm to use", NULL },
        { "keep-ccache", 'k', POPT_ARG_NONE, NULL, 'k',
          "Do not delete the ccache when the tool finishes", NULL },
        { "timeout", '\0', POPT_ARG_INT, &pc_timeout, 0,
          "The timeout for the child, in seconds", NULL },
        POPT_TABLEEND
    };

    debug_prg_name = argv[0];
    pc = poptGetContext(NULL, argc, argv, long_options, 0);

    while ((opt = poptGetNextOpt(pc)) > 0) {
        switch(opt) {
        case 'W':
            errno = 0;
            password = getpass("Enter password:");
            if (!password) {
                return 1;
            }
            break;
        case 'k':
            rm_ccache = false;
            break;
        default:
            DEBUG(SSSDBG_FATAL_FAILURE, ("Unexpected option\n"));
            return 1;
        }
    }

    debug_level = debug_convert_old_level(pc_debug);

    if (opt != -1) {
        poptPrintUsage(pc, stderr, 0);
        fprintf(stderr, "%s", poptStrerror(opt));
        return 1;
    }

    if (!pc_user) {
        DEBUG(SSSDBG_FATAL_FAILURE, ("Please specify the user\n"));
        poptPrintUsage(pc, stderr, 0);
        return 1;
    }

    if (!pc_realm) {
        DEBUG(SSSDBG_FATAL_FAILURE, ("Please specify the realm\n"));
        poptPrintUsage(pc, stderr, 0);
        return 1;
    }

    if (!password && !pc_passwd) {
        DEBUG(SSSDBG_FATAL_FAILURE,
              ("Password was not provided or asked for\n"));
        poptPrintUsage(pc, stderr, 0);
        return 1;
    }