]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Authention plain working with crypted passwd
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 8 Jul 2025 21:29:00 +0000 (17:29 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 8 Jul 2025 21:29:00 +0000 (17:29 -0400)
lib/lvleml.c
sql/mailleur.sql

index 28a661ac46262e341e585f068f374b1c2110134b..0702fdc94e06dea1a185238be9fe4978b238cd90 100644 (file)
@@ -377,7 +377,7 @@ while (proceed==true) {
       break;
     case 1      :       //do we have valide data?
       if ((strlen(data[1])==0)||(strlen(data[2])==0)) {
-        (void) rou_alert(0,"%s data[1]=<%s> or data[2]=<%s> missing (Bug?)",
+        (void) rou_alert(0,"%s data[1]=<%s> or data[2]=<%s> missing (Remote Bug?)",
                             OPEP,data[1],data[2]);
         phase=999;      //No need to go further
         }
@@ -392,12 +392,22 @@ while (proceed==true) {
         char *givenpass;
   
         givenpass=data[2];
-        if (givenpass!=(char *)0) {
+        if (usr->passwd==(char *)0) {
+          (void) rou_alert(0,"%s usr=<%s> password empty, assigning one",
+                              OPEP,data[1]);
+          usr->passwd=cnv_getrndstr(10);
+          }
+        if (givenpass!=(char *)0) 
           *rmtpass=strdup(givenpass);
-          if (strncmp(usr->passwd,"$1",2)==0) 
-            givenpass=crypt("$1",givenpass); 
-          isok=(strcmp(givenpass,usr->passwd)==0);
+        if (usr->passwd[0]=='$') {
+          if ((givenpass=crypt(givenpass,usr->passwd))==(char *)0) {
+            (void) rou_alert(0,"%s Trouble to crypt (Bug?) pass=<%s> "
+                               "user=<%s> (error=<%s>)",
+                                OPEP,givenpass,usr->passwd,strerror(errno));
+            givenpass=data[2];      //trying to overcome
+            }
           }
+        isok=(strcmp(givenpass,usr->passwd)==0);
         usr=sql_freeusr(usr);
         }
       }
index 41e0c294dbdf203b6d316844cf833b76701ed5be..95201ddfdcda33883842bce0a46e6aba71c14f34 100644 (file)
@@ -74,7 +74,7 @@ CREATE FUNCTION updpass()
   RETURNS trigger AS $$
        BEGIN
        NEW.hash = md5(concat (NEW.email,':',NEW.realm,':',new.password));
-//     NEW.password = crypt(new.password, gen_salt('md5'));
+       NEW.password = crypt(new.password, gen_salt('md5'));
        RETURN NEW;
        END
   $$ LANGUAGE 'plpgsql';