From a13cddc1331aa1f5e7dca7d1b44482951d2757bf Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 13 Nov 2011 17:16:14 +1100 Subject: port to new RADIUS client library --- lib/examples/client-blocking.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/examples/client-blocking.c') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 23cd674..419be8c 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "debug.h" /* For rs_dump_packet(). */ @@ -73,7 +74,7 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) if (resp) { rs_dump_packet (resp); - if (rs_packet_frpkt (resp)->code == PW_AUTHENTICATION_ACK) + if (rs_packet_frpkt (resp)->code == PW_ACCESS_ACCEPT) printf ("Good auth.\n"); else printf ("Bad auth: %d\n", rs_packet_frpkt (resp)->code); -- cgit v1.1 From 3fd136cdbc85ddff5ed0a5953ee1827b9a948748 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 14 Nov 2011 12:43:48 +1100 Subject: remove rs_context_init_freeradius_dict --- lib/examples/client-blocking.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/examples/client-blocking.c') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 419be8c..509e68a 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -31,8 +31,6 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) { struct rs_peer *server; - if (rs_context_init_freeradius_dict (h, "/usr/share/freeradius/dictionary")) - goto cleanup; if (rs_conn_create (h, &conn, NULL)) goto cleanup; rs_conn_set_type (conn, RS_CONN_TYPE_UDP); @@ -48,8 +46,6 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) #else /* defined (USE_CONFIG_FILE) */ if (rs_context_read_config (h, av1)) goto cleanup; - if (rs_context_init_freeradius_dict (h, NULL)) - goto cleanup; if (rs_conn_create (h, &conn, av2)) goto cleanup; #endif /* defined (USE_CONFIG_FILE) */ -- cgit v1.1 From 34747348ee53e02bb6faa6a6e26c1440e327ff60 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 14 Nov 2011 17:05:17 +1100 Subject: remove rs_packet_frpkt --- lib/examples/client-blocking.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/examples/client-blocking.c') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 509e68a..2cfd617 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -70,10 +69,10 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) if (resp) { rs_dump_packet (resp); - if (rs_packet_frpkt (resp)->code == PW_ACCESS_ACCEPT) + if (rs_packet_code (resp) == PW_ACCESS_ACCEPT) printf ("Good auth.\n"); else - printf ("Bad auth: %d\n", rs_packet_frpkt (resp)->code); + printf ("Bad auth: %d\n", rs_packet_code (resp)); } else fprintf (stderr, "%s: no response\n", __func__); -- cgit v1.1 From a21be6733bfe23998f3aaec00d87d35fe0f1aefa Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 17 Dec 2012 16:05:55 +0100 Subject: Example code: Don't create rs_error on failing context creation. We don't export err_create() and the error is ENOMEM nowadays. --- lib/examples/client-blocking.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/examples/client-blocking.c') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 7d3869a..7ba71a0 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -25,12 +25,13 @@ blocking_client (const char *config_fn, const char *configuration, struct rs_request *request = NULL; struct rs_packet *req = NULL, *resp = NULL; struct rs_error *err = NULL; + int r; - if (rs_context_create (&h)) + r = rs_context_create (&h); + if (r) { - err = err_create (RSE_INTERNAL, NULL, 0, "unable to create context"); - assert (err != NULL); - return err; + assert(r == RSE_NOMEM); + assert (!"out of RAM -- unable to create libradsec context"); } #if !defined (USE_CONFIG_FILE) -- cgit v1.1 From 5b117878698519e798f928cef18eafc9dad4c15a Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 17 Dec 2012 16:07:16 +0100 Subject: Example code: Print a little bit more helpful information on failure. --- lib/examples/client-blocking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/examples/client-blocking.c') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 7ba71a0..1b77de3 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -125,7 +125,7 @@ main (int argc, char *argv[]) err = blocking_client (argv[1], argv[2], use_request_object_flag); if (err) { - fprintf (stderr, "%s\n", rs_err_msg (err)); + fprintf (stderr, "error: %s: %d\n", rs_err_msg (err), rs_err_code (err, 0)); return rs_err_code (err, 1); } return 0; -- cgit v1.1 From 09d1cff2418a900b587b2113f508984f2417cc11 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 17 Dec 2012 16:11:14 +0100 Subject: Add formal argument 'secret' to two public functions. The functions are rs_packet_create_authn_request() and rs_request_create_authn(). Attributes of type PW_USER_PASSWORD are supposed to be MD5 obfuscated (see vp2data_any()). NOTE: This is a non-backward compatible API change. --- lib/examples/client-blocking.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/examples/client-blocking.c') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 1b77de3..773a26c 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -59,14 +59,14 @@ blocking_client (const char *config_fn, const char *configuration, if (use_request_object_flag) { - if (rs_request_create_authn (conn, &request, USER_NAME, USER_PW)) + if (rs_request_create_authn (conn, &request, USER_NAME, USER_PW, SECRET)) goto cleanup; if (rs_request_send (request, &resp)) goto cleanup; } else { - if (rs_packet_create_authn_request (conn, &req, USER_NAME, USER_PW)) + if (rs_packet_create_authn_request (conn, &req, USER_NAME, USER_PW, SECRET)) goto cleanup; if (rs_packet_send (req, NULL)) goto cleanup; -- cgit v1.1