simplify by using krb5_err instead of errx
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6749 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -54,20 +54,17 @@ proto (int sock, const char *hostname, const char *service)
|
|||||||
|
|
||||||
status = krb5_init_context(&context);
|
status = krb5_init_context(&context);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_init_context: %s",
|
krb5_err (context, 1, status, "krb5_init_context");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_auth_con_init (context, &auth_context);
|
status = krb5_auth_con_init (context, &auth_context);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_auth_con_init: %s",
|
krb5_err (context, 1, status, "krb5_auth_con_init");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_auth_con_setaddrs_from_fd (context,
|
status = krb5_auth_con_setaddrs_from_fd (context,
|
||||||
auth_context,
|
auth_context,
|
||||||
&sock);
|
&sock);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_auth_con_setaddrs_from_fd: %s",
|
krb5_err (context, 1, status, "krb5_auth_con_setaddrs_from_fd");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_sname_to_principal (context,
|
status = krb5_sname_to_principal (context,
|
||||||
hostname,
|
hostname,
|
||||||
@@ -75,8 +72,7 @@ proto (int sock, const char *hostname, const char *service)
|
|||||||
KRB5_NT_SRV_HST,
|
KRB5_NT_SRV_HST,
|
||||||
&server);
|
&server);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_sname_to_principal: %s",
|
krb5_err (context, 1, status, "krb5_sname_to_principal");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_sendauth (context,
|
status = krb5_sendauth (context,
|
||||||
&auth_context,
|
&auth_context,
|
||||||
@@ -92,8 +88,7 @@ proto (int sock, const char *hostname, const char *service)
|
|||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_sendauth: %s",
|
krb5_err (context, 1, status, "krb5_sendauth");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
data.data = "hej";
|
data.data = "hej";
|
||||||
data.length = 3;
|
data.length = 3;
|
||||||
@@ -106,8 +101,7 @@ proto (int sock, const char *hostname, const char *service)
|
|||||||
&packet,
|
&packet,
|
||||||
NULL);
|
NULL);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_mk_safe: %s",
|
krb5_err (context, 1, status, "krb5_mk_safe");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
len = packet.length;
|
len = packet.length;
|
||||||
net_len = htonl(len);
|
net_len = htonl(len);
|
||||||
@@ -128,8 +122,7 @@ proto (int sock, const char *hostname, const char *service)
|
|||||||
&packet,
|
&packet,
|
||||||
NULL);
|
NULL);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_mk_priv: %s",
|
krb5_err (context, 1, status, "krb5_mk_priv");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
len = packet.length;
|
len = packet.length;
|
||||||
net_len = htonl(len);
|
net_len = htonl(len);
|
||||||
|
@@ -56,19 +56,17 @@ proto (int sock, const char *service)
|
|||||||
|
|
||||||
status = krb5_auth_con_init (context, &auth_context);
|
status = krb5_auth_con_init (context, &auth_context);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_auth_con_init: %s",
|
krb5_err (context, 1, status, "krb5_auth_con_init");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_auth_con_setaddrs_from_fd (context,
|
status = krb5_auth_con_setaddrs_from_fd (context,
|
||||||
auth_context,
|
auth_context,
|
||||||
&sock);
|
&sock);
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_auth_con_setaddrs_from_fd: %s",
|
krb5_err (context, 1, status, "krb5_auth_con_setaddrs_from_fd");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
if(gethostname (hostname, sizeof(hostname)) < 0)
|
if(gethostname (hostname, sizeof(hostname)) < 0)
|
||||||
err (1, "gethostname");
|
krb5_err (context, 1, errno, "gethostname");
|
||||||
|
|
||||||
status = krb5_sname_to_principal (context,
|
status = krb5_sname_to_principal (context,
|
||||||
hostname,
|
hostname,
|
||||||
@@ -76,8 +74,7 @@ proto (int sock, const char *service)
|
|||||||
KRB5_NT_SRV_HST,
|
KRB5_NT_SRV_HST,
|
||||||
&server);
|
&server);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_sname_to_principal: %s",
|
krb5_err (context, 1, status, "krb5_sname_to_principal");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_recvauth (context,
|
status = krb5_recvauth (context,
|
||||||
&auth_context,
|
&auth_context,
|
||||||
@@ -88,15 +85,13 @@ proto (int sock, const char *service)
|
|||||||
NULL,
|
NULL,
|
||||||
&ticket);
|
&ticket);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_recvauth: %s",
|
krb5_err (context, 1, status, "krb5_recvauth");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
status = krb5_unparse_name (context,
|
status = krb5_unparse_name (context,
|
||||||
ticket->client,
|
ticket->client,
|
||||||
&name);
|
&name);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_unparse_name: %s",
|
krb5_err (context, 1, status, "krb5_unparse_name");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
printf ("User is `%s'\n", name);
|
printf ("User is `%s'\n", name);
|
||||||
free (name);
|
free (name);
|
||||||
@@ -120,8 +115,7 @@ proto (int sock, const char *service)
|
|||||||
&data,
|
&data,
|
||||||
NULL);
|
NULL);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_rd_safe: %s",
|
krb5_err (context, 1, status, "krb5_rd_safe");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
printf ("safe packet: %.*s\n", (int)data.length,
|
printf ("safe packet: %.*s\n", (int)data.length,
|
||||||
(char *)data.data);
|
(char *)data.data);
|
||||||
@@ -142,8 +136,7 @@ proto (int sock, const char *service)
|
|||||||
&data,
|
&data,
|
||||||
NULL);
|
NULL);
|
||||||
if (status)
|
if (status)
|
||||||
errx (1, "krb5_rd_priv: %s",
|
krb5_err (context, 1, status, "krb5_rd_priv");
|
||||||
krb5_get_err_text(context, status));
|
|
||||||
|
|
||||||
printf ("priv packet: %.*s\n", (int)data.length,
|
printf ("priv packet: %.*s\n", (int)data.length,
|
||||||
(char *)data.data);
|
(char *)data.data);
|
||||||
|
Reference in New Issue
Block a user