add inetd flag. default means try to figure out if stdin is a socket
or not. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6799 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
22
kdc/hpropd.c
22
kdc/hpropd.c
@@ -149,6 +149,7 @@ dump_krb4(krb5_context context, hdb_entry *ent, int fd)
|
|||||||
}
|
}
|
||||||
#endif /* KRB4 */
|
#endif /* KRB4 */
|
||||||
|
|
||||||
|
static int inetd_flag = -1;
|
||||||
static int help_flag;
|
static int help_flag;
|
||||||
static int version_flag;
|
static int version_flag;
|
||||||
static int print_dump;
|
static int print_dump;
|
||||||
@@ -162,6 +163,8 @@ struct getargs args[] = {
|
|||||||
{ "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" },
|
{ "print", 0, arg_flag, &print_dump, "print dump to stdout" },
|
||||||
|
{ "inetd", 'i', arg_negative_flag, &inetd_flag,
|
||||||
|
"Not started from inetd" },
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
{ "v4dump", '4', arg_flag, &v4dump, "create v4 type DB" },
|
{ "v4dump", '4', arg_flag, &v4dump, "create v4 type DB" },
|
||||||
#endif
|
#endif
|
||||||
@@ -235,18 +238,26 @@ main(int argc, char **argv)
|
|||||||
if(from_stdin)
|
if(from_stdin)
|
||||||
fd = STDIN_FILENO;
|
fd = STDIN_FILENO;
|
||||||
else {
|
else {
|
||||||
mini_inetd (krb5_getportbyname (context, "hprop", "tcp",
|
|
||||||
HPROP_PORT));
|
|
||||||
fd = STDIN_FILENO;
|
|
||||||
{
|
|
||||||
int sin_len;
|
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
struct sockaddr *sa = (struct sockaddr *)&ss;
|
struct sockaddr *sa = (struct sockaddr *)&ss;
|
||||||
|
int sin_len = sizeof(ss);
|
||||||
char addr_name[256];
|
char addr_name[256];
|
||||||
|
|
||||||
|
fd = STDIN_FILENO;
|
||||||
|
if (inetd_flag == -1) {
|
||||||
|
if (getpeername (fd, sa, &sin_len) < 0)
|
||||||
|
inetd_flag = 0;
|
||||||
|
else
|
||||||
|
inetd_flag = 1;
|
||||||
|
}
|
||||||
|
if (!inetd_flag) {
|
||||||
|
mini_inetd (krb5_getportbyname (context, "hprop", "tcp",
|
||||||
|
HPROP_PORT));
|
||||||
|
}
|
||||||
sin_len = sizeof(ss);
|
sin_len = sizeof(ss);
|
||||||
if(getpeername(fd, sa, &sin_len) < 0)
|
if(getpeername(fd, sa, &sin_len) < 0)
|
||||||
krb5_err(context, 1, errno, "getpeername");
|
krb5_err(context, 1, errno, "getpeername");
|
||||||
|
|
||||||
if (inet_ntop(sa->sa_family,
|
if (inet_ntop(sa->sa_family,
|
||||||
socket_get_address (sa),
|
socket_get_address (sa),
|
||||||
addr_name,
|
addr_name,
|
||||||
@@ -255,7 +266,6 @@ main(int argc, char **argv)
|
|||||||
sizeof(addr_name));
|
sizeof(addr_name));
|
||||||
|
|
||||||
krb5_log(context, fac, 0, "Connection from %s", addr_name);
|
krb5_log(context, fac, 0, "Connection from %s", addr_name);
|
||||||
}
|
|
||||||
|
|
||||||
gethostname(hostname, sizeof(hostname));
|
gethostname(hostname, sizeof(hostname));
|
||||||
ret = krb5_sname_to_principal(context, hostname, HPROP_NAME,
|
ret = krb5_sname_to_principal(context, hostname, HPROP_NAME,
|
||||||
|
Reference in New Issue
Block a user