Эх сурвалжийг харах

fixed errors introduced by ME when hand-applying Oswald Nuddenhagen's
patch.

Michael Elkins 23 жил өмнө
parent
commit
d6fd1939ba
2 өөрчлөгдсөн 17 нэмэгдсэн , 6 устгасан
  1. 2 2
      dotlock.c
  2. 15 4
      imap.c

+ 2 - 2
dotlock.c

@@ -53,7 +53,7 @@ int dotlock_unlock (int *fd)
   if (*fd != -1)
   {
     lck.l_type = F_UNLCK;
-    if (fcntl (*fd, F_SETLKW, &lck))
+    if (fcntl (*fd, F_SETLK, &lck))
       r = -1;
     close (*fd);
     *fd = -1;
@@ -71,7 +71,7 @@ int main (void)
     perror ("dotlock_lock");
     goto done;
   }
-  puts("sleeping for 5 seconds");
+  puts ("sleeping for 5 seconds");
   sleep(5);
   if (dotlock_unlock (&fd))
   {

+ 15 - 4
imap.c

@@ -633,12 +633,13 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap, int flags)
 
       if (fork () == 0)
       {
-	if (dup2 (a[0],0) || dup2 (a[0], 1))
+	if (dup2 (a[0], 0) == -1 || dup2 (a[0], 1) == -1)
 	{
-	  _exit(127);
+	  _exit (127);
 	}
+	close (a[0]);
 	close (a[1]);
-	execl ("/bin/sh", "sh", "-c", box->tunnel);
+	execl ("/bin/sh", "sh", "-c", box->tunnel, 0);
 	_exit (127);
       }
 
@@ -796,14 +797,24 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap, int flags)
 	   * if we don't have a global password set, prompt the user for
 	   * it now.
 	   */
-	  if (!global.pass)
+	  if (!global.pass || !*global.pass)
 	  {
 	    global.pass = getpass ("Password:");
 	    if (!global.pass)
+	    {
+	      perror ("getpass");
+	      exit (1);
+	    }
+	    if (!*global.pass)
 	    {
 	      fprintf (stderr, "Skipping %s, no password", box->path);
 	      break;
 	    }
+	    /*
+	     * getpass() returns a pointer to a static buffer.  make a copy
+	     * for long term storage.
+	     */
+	    global.pass = strdup (global.pass);
 	  }
 	  box->pass = strdup (global.pass);
 	}