1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <yaz/snprintf.h>
25 /* use env srcdir as base directory - or current directory if unset */
26 const char *get_srcdir(void)
28 const char *srcdir = getenv("srcdir");
29 if (!srcdir || ! *srcdir)
40 db = passwd_db_open();
45 yaz_snprintf(path, sizeof(path), "%s/no_such_file.txt", get_srcdir());
46 YAZ_CHECK_EQ(passwd_db_file_plain(db, path), -1);
47 YAZ_CHECK_EQ(passwd_db_file_crypt(db, path), -1);
48 yaz_snprintf(path, sizeof(path), "%s/tstpass.txt", get_srcdir());
50 YAZ_CHECK_EQ(passwd_db_file_crypt(db, path), 0);
51 YAZ_CHECK_EQ(passwd_db_auth(db, "other", "x1234"), -1);
52 YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "abcd"), -2);
53 YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "fruitbat"), 0);
54 YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "fruitbatx"), -2);
55 YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "fruitba"), -2);
57 YAZ_CHECK_EQ(passwd_db_file_plain(db, "passtest.txt"), -1);
62 int main (int argc, char **argv)
64 YAZ_CHECK_INIT(argc, argv);
72 * c-file-style: "Stroustrup"
73 * indent-tabs-mode: nil
75 * vim: shiftwidth=4 tabstop=8 expandtab