Don't require username & pw in rs_packet_create_acc_request().
authorLinus Nordberg <linus@nordu.net>
Sun, 10 Oct 2010 08:10:11 +0000 (10:10 +0200)
committerLinus Nordberg <linus@nordu.net>
Sun, 10 Oct 2010 08:10:11 +0000 (10:10 +0200)
lib/include/radsec/radsec.h
lib/packet.c

index c8b43bf..1d12787 100644 (file)
@@ -110,8 +110,8 @@ void rs_server_set_tries(struct rs_peer *server, int tries);
 /* Packet.  */
 int rs_packet_create_acc_request(struct rs_connection *conn,
                                 struct rs_packet **pkt,
-                                const char *user_name,
-                                const char *user_pw);
+                                const char *user_name, /* FIXME: remove? */
+                                const char *user_pw);  /* FIXME: remove? */
 void rs_packet_destroy(struct rs_packet *pkt);
 void rs_packet_add_attr(struct rs_packet *pkt, struct rs_attr *attr);
 int rs_packet_send(struct rs_packet *pkt, void *data);
index 54bfc01..9ac392d 100644 (file)
@@ -319,14 +319,20 @@ rs_packet_create_acc_request (struct rs_connection *conn,
   pkt = *pkt_out;
   pkt->rpkt->code = PW_AUTHENTICATION_REQUEST;
 
-  if (rs_attr_create (conn, &attr, "User-Name", user_name))
-    return -1;
-  rs_packet_add_attr (pkt, attr);
+  if (user_name)
+    {
+      if (rs_attr_create (conn, &attr, "User-Name", user_name))
+       return -1;
+      rs_packet_add_attr (pkt, attr);
+    }
 
-  if (rs_attr_create (conn, &attr, "User-Password", user_pw))
-    return -1;
-  /* FIXME: need this too? rad_pwencode(user_pw, &pwlen, SECRET, reqauth) */
-  rs_packet_add_attr (pkt, attr);
+  if (user_pw)
+    {
+      if (rs_attr_create (conn, &attr, "User-Password", user_pw))
+       return -1;
+      /* FIXME: need this too? rad_pwencode(user_pw, &pwlen, SECRET, reqauth) */
+      rs_packet_add_attr (pkt, attr);
+    }
 
   return RSE_OK;
 }
@@ -421,6 +427,7 @@ rs_packet_destroy(struct rs_packet *pkt)
 {
   if (pkt)
     {
+      // TODO: free all attributes
       rad_free (&pkt->rpkt);
       rs_free (pkt->conn->ctx, pkt);
     }