add --print option
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6105 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
22
kdc/hpropd.c
22
kdc/hpropd.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 1998, 1999 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1997-1999 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -14,12 +14,7 @@
|
|||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by Kungliga Tekniska
|
|
||||||
* H<>gskolan and its contributors.
|
|
||||||
*
|
|
||||||
* 4. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@@ -82,15 +77,14 @@ open_socket(krb5_context context)
|
|||||||
|
|
||||||
static int help_flag;
|
static int help_flag;
|
||||||
static int version_flag;
|
static int version_flag;
|
||||||
|
static int print_dump;
|
||||||
static char *database = HDB_DEFAULT_DB;
|
static char *database = HDB_DEFAULT_DB;
|
||||||
static int from_stdin;
|
static int from_stdin;
|
||||||
|
|
||||||
struct getargs args[] = {
|
struct getargs args[] = {
|
||||||
#if 0
|
|
||||||
{ "slave", 's', arg_strings, &slaves, "slave server", "host" },
|
|
||||||
#endif
|
|
||||||
{ "database", 'd', arg_string, &database, "database", "file" },
|
{ "database", 'd', arg_string, &database, "database", "file" },
|
||||||
{ "stdin", 'n', arg_flag, &from_stdin, "read from stdin" },
|
{ "stdin", 'n', arg_flag, &from_stdin, "read from stdin" },
|
||||||
|
{ "print", 0, arg_flag, &print_dump, "print dump to stdout" },
|
||||||
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
|
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
|
||||||
{ "help", 'h', arg_flag, &help_flag, NULL, NULL}
|
{ "help", 'h', arg_flag, &help_flag, NULL, NULL}
|
||||||
};
|
};
|
||||||
@@ -191,6 +185,7 @@ int main(int argc, char **argv)
|
|||||||
if(ret) krb5_err(context, 1, ret, "krb5_kt_close");
|
if(ret) krb5_err(context, 1, ret, "krb5_kt_close");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!print_dump) {
|
||||||
asprintf(&tmp_db, "%s~", database);
|
asprintf(&tmp_db, "%s~", database);
|
||||||
ret = hdb_create(context, &db, tmp_db);
|
ret = hdb_create(context, &db, tmp_db);
|
||||||
if(ret)
|
if(ret)
|
||||||
@@ -198,6 +193,7 @@ int main(int argc, char **argv)
|
|||||||
ret = db->open(context, db, O_RDWR | O_CREAT | O_TRUNC, 0600);
|
ret = db->open(context, db, O_RDWR | O_CREAT | O_TRUNC, 0600);
|
||||||
if(ret)
|
if(ret)
|
||||||
krb5_err(context, 1, ret, "hdb_open(%s)", tmp_db);
|
krb5_err(context, 1, ret, "hdb_open(%s)", tmp_db);
|
||||||
|
}
|
||||||
|
|
||||||
nprincs = 0;
|
nprincs = 0;
|
||||||
while(1){
|
while(1){
|
||||||
@@ -218,14 +214,19 @@ int main(int argc, char **argv)
|
|||||||
data.length = 0;
|
data.length = 0;
|
||||||
send_priv(context, ac, &data, fd);
|
send_priv(context, ac, &data, fd);
|
||||||
}
|
}
|
||||||
|
if(!print_dump) {
|
||||||
ret = db->rename(context, db, database);
|
ret = db->rename(context, db, database);
|
||||||
if(ret) krb5_err(context, 1, ret, "db_rename");
|
if(ret) krb5_err(context, 1, ret, "db_rename");
|
||||||
ret = db->close(context, db);
|
ret = db->close(context, db);
|
||||||
if(ret) krb5_err(context, 1, ret, "db_close");
|
if(ret) krb5_err(context, 1, ret, "db_close");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = hdb_value2entry(context, &data, &entry);
|
ret = hdb_value2entry(context, &data, &entry);
|
||||||
if(ret) krb5_err(context, 1, ret, "hdb_value2entry");
|
if(ret) krb5_err(context, 1, ret, "hdb_value2entry");
|
||||||
|
if(print_dump)
|
||||||
|
hdb_print_entry(context, db, &entry, stdout);
|
||||||
|
else {
|
||||||
ret = db->store(context, db, 0, &entry);
|
ret = db->store(context, db, 0, &entry);
|
||||||
if(ret == HDB_ERR_EXISTS){
|
if(ret == HDB_ERR_EXISTS){
|
||||||
char *s;
|
char *s;
|
||||||
@@ -236,6 +237,7 @@ int main(int argc, char **argv)
|
|||||||
krb5_err(context, 1, ret, "db_store");
|
krb5_err(context, 1, ret, "db_store");
|
||||||
else
|
else
|
||||||
nprincs++;
|
nprincs++;
|
||||||
|
}
|
||||||
hdb_free_entry(context, &entry);
|
hdb_free_entry(context, &entry);
|
||||||
}
|
}
|
||||||
krb5_log(context, fac, 0, "Received %d principals", nprincs);
|
krb5_log(context, fac, 0, "Received %d principals", nprincs);
|
||||||
|
Reference in New Issue
Block a user