]> git.sur5r.net Git - ngadmin/commitdiff
Merge remote-tracking branch 'upstream/master'
authorAlkorin <github@alkorin.fr>
Wed, 10 Sep 2014 06:37:38 +0000 (08:37 +0200)
committerAlkorin <github@alkorin.fr>
Wed, 10 Sep 2014 06:37:38 +0000 (08:37 +0200)
Conflicts:
lib/src/session.c

lib/src/session.c

index aa0703d3478b3039d2f0781c901e252b2ea012ba..d698dcdac937f1c0f92fced825551dcd27064245 100644 (file)
@@ -4,6 +4,7 @@
 #include <ngadmin.h>
 
 #include <nsdp/attr.h>
+#include <nsdp/str.h>
 #include <nsdp/protocol.h>
 
 #include "lib.h"
@@ -159,13 +160,23 @@ int ngadmin_login (struct ngadmin *nga, int id)
        }
        clearList(attr, (void(*)(void*))freeAttr);
        
-       /* strangely, passwords must never be encrypted inside a read request,
-        * or it will be rejected. Seems more to be a firmware bug
-        */
-       pushBackList(attr, newAttr(ATTR_PASSWORD, strlen(nga->password), strdup(nga->password)));
+       at = newAttr(ATTR_PASSWORD, strlen(nga->password), strdup(nga->password));
+       if (nga->encrypt_pass)
+               passwordEndecode(at->data, at->size);
+       pushBackList(attr, at);
        ret = readRequest(nga, attr);
        
-       if (ret == ERR_INVOP || ret == ERR_BADPASS) {
+       if (nga->encrypt_pass && ret == ERR_BADPASS) {
+               /* strangely, with some switches, passwords must not be
+                * encrypted inside read requests or it will be rejected
+                * seems more to be a firmware bug
+                */
+               clearList(attr, (void(*)(void*))freeAttr);
+               pushBackList(attr, newAttr(ATTR_PASSWORD, strlen(nga->password), strdup(nga->password)));
+               ret = readRequest(nga, attr);
+       }
+       
+       if (ret == ERR_INVOP) {
                /* it seems some switches do not support login with read request
                 * fallback to write request, even if it has the drawback of
                 * the password being broadcasted back by the switch