]> zub.fei.tuke.sk Git - ldapvmail/commitdiff
admin password, new implementation 0.2.1
authorPeter Popovec <popovec@fei.tuke.sk>
Thu, 7 Apr 2005 12:09:00 +0000 (14:09 +0200)
committerPeter Popovec <popovec@fei.tuke.sk>
Mon, 14 Feb 2005 10:11:00 +0000 (11:11 +0100)
compilation warning clean
fix initialization for Balias and Bforward buttons

debian/changelog
debian/copyright
debian/ex.package.doc-base [deleted file]
ldapadd.c
ldaplogin.c
ldaplogin.h
ldappass.c
ldappass.h
vmail.c
vmailHelper.c

index bfc643f0d71bdfb97d96d665d88bd76ef360292a..3ff8677d91debc31eabc42ecdfd215fd06040aa0 100644 (file)
@@ -1,3 +1,11 @@
+ldapvmail (0.2.1) unstable; urgency=low
+
+  * admin password, new implementation
+  * compilation warning clean
+  * fix initialization for Balias and Bforward buttons  
+
+ -- Peter Popovec <popovec@zubok>  Thu,  7 Apr 2005 13:55:05 +0200
+
 ldapvmail (0.2) unstable; urgency=low
 
   * Default is Maildir not mailbox
index 57658b9ff2b07efcfa035afdd055d9377afe0af6..dea16ab233581e3125f921cb348cf5286ec6c10d 100644 (file)
@@ -1,9 +1,8 @@
-This package was debianized by Peter Popovec <popovec@fei.tuke.sk> on
+By Peter Popovec <popovec@fei.tuke.sk> on
 Sun, 30 Jan 2005 12:15:51 +0100.
 
 It was downloaded from http://zub.fei.tuke.sk/local.packages
 
-Upstream Author(s): Peter Popovec <popovec@fei.tuke.sk>
 
 Copyright:
 
diff --git a/debian/ex.package.doc-base b/debian/ex.package.doc-base
deleted file mode 100644 (file)
index a878f0b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-Document: ldapvmail
-Title: Debian ldapvmail Manual
-Author: <insert document author here>
-Abstract: This manual describes what ldapvmail is
- and how it can be used to
- manage online manuals on Debian systems.
-Section: unknown
-
-Format: debiandoc-sgml
-Files: /usr/share/doc/ldapvmail/ldapvmail.sgml.gz
-
-Format: postscript
-Files: /usr/share/doc/ldapvmail/ldapvmail.ps.gz
-
-Format: text
-Files: /usr/share/doc/ldapvmail/ldapvmail.text.gz
-
-Format: HTML
-Index: /usr/share/doc/ldapvmail/html/index.html
-Files: /usr/share/doc/ldapvmail/html/*.html
-
-  
index 7319a31bc0a353bab81e9511d3eaf808c64a6dac..2f69955d8758b94f367d09e4c6c38675c4d4c58b 100644 (file)
--- a/ldapadd.c
+++ b/ldapadd.c
@@ -17,7 +17,8 @@ newAccount ()
 {
   newtComponent form, label, Bok, Bcancel, PWentry, DNentry, answer;
   struct newtExitStruct es;
-  char *DN, *PW, *GN, *SN;
+  const char *DN, *PW, *GN, *SN;
+  char *newDN;
   LDAP *ld;
   char *addAttrxValue[8];
 
@@ -181,7 +182,7 @@ newAccount ()
   addAttr0[i]->mod_values[3] = strdup ("inetOrgPerson");
   addAttr0[i]->mod_values[4] = strdup ("qmailUser");
   addAttr0[i]->mod_values[5] = NULL;
-  asprintf (&DN, "uid=%s,%s", addAttrxValue[0], GetDefaultVmailSubtree ());
+  asprintf (&newDN, "uid=%s,%s", addAttrxValue[0], GetDefaultVmailSubtree ());
 
   switch (ldapLogin (&ld, WRITE_OP))
     {
@@ -201,7 +202,7 @@ newAccount ()
       return 1;
     }
   int ecode;
-  if (0 == (ecode = ldap_add_s (ld, DN, addAttr0)))
+  if (0 == (ecode = ldap_add_s (ld, newDN, addAttr0)))
     {
       infoWindow ("VMAIL account add", "User ok", 100);
       return (0);
index 209b091222bac6d45aaf92b78ff5962244b2983d..bd1a92ab93726b4554c4b324baef179ba74fac37 100644 (file)
@@ -35,6 +35,8 @@ READ_OP or WRITE_OP. For WRITE_OP credential must be rereaded. For READ_OP
 can be used old credential only if is not expired or old credential is not 
 escaped with anonymous  bind. 
 
+WRITE_OP_CACHED  no timeout is checcked, if non anonymous credencial is 
+available, no new password is readed
 
 return value:
 0 if success, -1 init error, -3 no homedir, -4 invalid credential or other
@@ -56,41 +58,42 @@ ldapLogin (LDAP ** ld, int nomod)
   version = LDAP_VERSION3;
   ldap_set_option (*ld, LDAP_OPT_PROTOCOL_VERSION, &version);
   gettimeofday (&current, NULL);
-  //if we have anonymous credential or timeout exited
-  //we need to get new credential (bnegative timeout  -> write passwd cache)
-
-  if (GetDefaultVmailPcache () < 0)
+  if (nomod != WRITE_OP_CACHED || logindata.type == 0)
     {
-      if (logindata.type == 0
-         || current.tv_sec >
-         logindata.expire.tv_sec + abs (GetDefaultVmailPcache ()))
+      //if we have anonymous credential or timeout exited
+      //we need to get new credential (bnegative timeout  -> write passwd cache)
+
+      if (GetDefaultVmailPcache () < 0)
        {
-         if (0 != get_ldap_login (&logindata))
+         if (current.tv_sec >
+             logindata.expire.tv_sec + abs (GetDefaultVmailPcache ()))
            {
-             ldap_unbind (*ld);        //free ldap structure
-             return (-3);
+             if (0 != get_ldap_login (&logindata))
+               {
+                 ldap_unbind (*ld);    //free ldap structure
+                 return (-3);
+               }
            }
        }
-    }
-  else
-    //if we have anonymous credential or operation is write or timeout exited
-    //we need to get new credential
-    {
-      if (nomod == WRITE_OP || logindata.type == 0
-         || current.tv_sec >
-         logindata.expire.tv_sec + abs (GetDefaultVmailPcache ()))
+      else
+       //if we have anonymous credential or operation is write or timeout exited
+       //we need to get new credential
        {
-         if (0 != get_ldap_login (&logindata))
+         if (nomod == WRITE_OP || current.tv_sec >
+             logindata.expire.tv_sec + abs (GetDefaultVmailPcache ()))
            {
-             ldap_unbind (*ld);        //free ldap structure
-             return (-3);
+             if (0 != get_ldap_login (&logindata))
+               {
+                 ldap_unbind (*ld);    //free ldap structure
+                 return (-3);
+               }
            }
        }
     }
   if (ldap_simple_bind_s (*ld, logindata.binddn, logindata.bindpw))
     {
       ldap_unbind (*ld);       //free ldap structure
-      logindata.type = 0;      //set as anonymous login
+      logindata.type = 0;      //set as anonymous login
       return (-4);
     }
 
@@ -105,8 +108,8 @@ int
 get_ldap_login (bindCredencial * ldata)
 {
 
-  char *defaultDN = NULL;
-  char *PW, *DN;
+  const char *defaultDN = NULL;
+  const char *PW, *DN;
   newtComponent form, Bok, Bcancel, Banon, label, answer, DNentry, PWentry;
 
   defaultDN = GetDefaultVmailAdmin ();
index 008f3e0ce3334b5e5acc22d3916fe2105d3aa502..4c20526a768524f992613d64e6a94b891e55598d 100644 (file)
@@ -1,3 +1,4 @@
 #define READ_OP 1
 #define WRITE_OP 0
+#define WRITE_OP_CACHED 2
 int ldapLogin (LDAP ** ld, int type);
index 630a26d7004edf370365590446c4c790253d44ab..fa6d192e8d906970cda7511cd4ea7e64acf68ecf 100644 (file)
 #include "vmailHelper.h"
 
 int
-passBox (char *dn)
+passBox (char *dn, LDAP * ld)
 {
   newtComponent form, Label, entry1, entry2, button, cancel, answer;
-  char *pass1, *pass2;
-
+  const char *pass1, *pass2;
+  char *pass;
   newtOpenWindow (4, 8, 74, 10, "Change password for DN:");
   form = newtForm (NULL, NULL, 0);
   entry1 = newtEntry (11, 3, NULL, 32, &pass1, NEWT_FLAG_PASSWORD);
@@ -49,7 +49,8 @@ passBox (char *dn)
                          "Sorry, passwords do not match", 1);
              continue;
            }
-         ldapPass (dn, pass1);
+         pass = strdup (pass1);
+         ldapPass (dn, pass, ld);
          break;
        }
     }
@@ -59,9 +60,9 @@ passBox (char *dn)
 }
 
 int
-ldapPass (char *dn, char *pass)
+ldapPass (char *dn, char *pass, LDAP * ld)
 {
-  LDAP *ld;
+//  LDAP *ld;
   LDAPMod *addAttr0[2];
   addAttr0[0] = malloc (sizeof (LDAPMod));
   addAttr0[1] = NULL;
@@ -71,23 +72,25 @@ ldapPass (char *dn, char *pass)
   asprintf (&addAttr0[0]->mod_values[0], "{crypt}%s",
            crypt (pass, "$!$pemasksk"));
   addAttr0[0]->mod_values[1] = NULL;
-
-  switch (ldapLogin (&ld, WRITE_OP))
+  if (ld == NULL)
     {
-    case (0):
-      break;
-    case (-1):
-      infoWindow ("Password change", "LDAP init error", 1);
-      return (1);
-    case (-3):
-      infoWindow ("Password change",
-                 "Couldn't bind to server, operation canceled", 1);
-      return 1;
-    default:
-      infoWindow ("Password change",
-                 "Couldn't bind to server, invalid credencial or other error",
-                 1);
-      return 1;
+      switch (ldapLogin (&ld, WRITE_OP))
+       {
+       case (0):
+         break;
+       case (-1):
+         infoWindow ("Password change", "LDAP init error", 1);
+         return (1);
+       case (-3):
+         infoWindow ("Password change",
+                     "Couldn't bind to server, operation canceled", 1);
+         return 1;
+       default:
+         infoWindow ("Password change",
+                     "Couldn't bind to server, invalid credencial or other error",
+                     1);
+         return 1;
+       }
     }
   int ecode;
   if (0 == (ecode = ldap_modify_s (ld, dn, addAttr0)))
index e186e8e23880118fc6e79ee0e5b375c2669a9b64..686a2c26fe3e272030cf10534663c24e00cb6c60 100644 (file)
@@ -1,2 +1,2 @@
-int ldapPass (char *dn, char *pass);
-int passBox (char *dn);
+int ldapPass (char *dn, char *pass,LDAP *ld);
+int passBox (char *dn,LDAP *ld);
diff --git a/vmail.c b/vmail.c
index 61128b78be0356227dda3a159711672a8d3bde8b..197a9ad899737fafe097ef15bc83d6c517cc4f77 100644 (file)
--- a/vmail.c
+++ b/vmail.c
@@ -11,7 +11,7 @@
 #include "ldaplogin.h"
 #include "vmailHelper.h"
 #include "vmailsetup.h"
-
+#include "ldappass.h"
 
 typedef struct vmailEntry0
 {
@@ -27,15 +27,13 @@ typedef struct vmailEntry0
 
 int ldapEdit (vmailEntry * vmail);
 int doEdit0 (vmailEntry * vmail);
-int ldapPass (char *dn, char *pass);
-int passBox (char *dn);
 int ChangeEntry0 (char *wname, char *olddata, char **data, int type);
 char *ChangeEntry (char *wname, char **data, int type);
 char *getSearchFilter (void);
 int doEdit (void);
 
 int
-main ()
+main (int argc, char *argv[])
 {
   int rc, textWidth;
 
@@ -220,6 +218,7 @@ renewEdit:
 
   if (vmail->forwardValues != NULL)
     {
+      Bforward = NULL;
       Label0 = newtLabel (1, 6, "Forwarded to:");
       newtFormAddComponent (form, Label0);
       List1 =
@@ -241,6 +240,7 @@ renewEdit:
     }
   if (vmail->aliasValues != NULL)
     {
+      Balias=NULL;
       Label0 = newtLabel (1, 9, "Aliases:");
       newtFormAddComponent (form, Label0);
       List2 =
@@ -268,7 +268,6 @@ renewEdit:
        {
          int co;
          char *data = NULL;
-         realedit = 1;
          co = (int) newtListboxGetCurrent (List0);
        cycle1:
          {
@@ -295,6 +294,7 @@ renewEdit:
            {
              if (strlen (data) == 0)
                goto cycle1;
+             realedit = 1;
              newtListboxSetEntry (List0, co, data);
            }
        }
@@ -375,7 +375,7 @@ renewEdit:
        }
 
       if (answer == Bpass)
-       passBox (vmail->dn);
+       passBox (vmail->dn, NULL);
       if (answer == Bforward)
        {
          char **newdata;
@@ -432,7 +432,7 @@ int
 ChangeEntry0 (char *wname, char *olddata, char **data, int type)
 {
   newtComponent form, entry, cancel, button, answer, add = NULL;
-  char *entryValue;
+  const char *entryValue;
   newtOpenWindow (4, 8, 74, 10, wname);
   form = newtForm (NULL, NULL, 0);
   entry = newtEntry (16, 1, olddata, 40, &entryValue,
@@ -485,7 +485,8 @@ char *
 getSearchFilter ()
 {
   newtComponent form, label, Bcancel, Bok, POPentry, MAILentry, answer;
-  char *DN, *PW, *filter;
+  const char *DN, *PW;
+  char *filter;
 
   newtCenteredWindow (65, 12, "Search account");
   form = newtForm (NULL, NULL, 0);
index ad5f5e64cb6fa2f4a1aa37019272b25fcffb4ee5..4a1ae76f0dd83a618b7bbcaa63c9b676a067eea1 100644 (file)
@@ -6,7 +6,8 @@
 #include "ldappass.h"
 #include <sys/stat.h>
 #include <sys/types.h>
-
+#include "vmailsetup.h"
+#include <string.h>
 int
 infoWindow (char *wname, char *wmesg, int type)
 {
@@ -37,7 +38,8 @@ infoWindow (char *wname, char *wmesg, int type)
 int
 selectDN ()
 {
-  char *entryValue;
+  const char *entryValue;
+  char *DN;
   newtComponent form, label, button, entry, cancel, answer;
   LDAP *ld;
   struct timeval timeout;
@@ -47,8 +49,8 @@ selectDN ()
   label = newtTextbox (1, 0, 50, 3, NEWT_FLAG_WRAP);
   newtTextboxSetText (label, "Enter DN or uid/cn to search for DN");
   newtFormAddComponent (form, label);
-
-  entry = newtEntry (6, 2, NULL, 53, &entryValue,
+  DN = GetDefaultVmailAdmin ();
+  entry = newtEntry (6, 2, DN, 53, &entryValue,
                     NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
   newtFormAddComponent (form, entry);
   button = newtButton (19, 6, "Ok");
@@ -62,6 +64,20 @@ selectDN ()
       newtPopWindow ();
       return (0);
     }
+  if (entryValue == NULL)
+    {
+      newtFormDestroy (form);
+      newtPopWindow ();
+      return (0);
+
+    }
+  if (strlen (entryValue) == 0)
+    {
+      newtFormDestroy (form);
+      newtPopWindow ();
+      return (0);
+
+    }
   switch (ldapLogin (&ld, READ_OP))
     {
     case (0):
@@ -108,9 +124,8 @@ selectDN ()
       newtPopWindow ();
       return 1;
     }
-//entryValue DN for operatrion
-//TODO ....
-  passBox (entryValue);
+  DN = strdup (entryValue);
+  passBox (DN, ld);
   newtFormDestroy (form);
   newtPopWindow ();
   return (0);