From d6fd1939ba20854d4267952046783892cf1191f7 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Sat, 22 Jun 2002 17:06:24 +0000 Subject: [PATCH] fixed errors introduced by ME when hand-applying Oswald Nuddenhagen's patch. --- dotlock.c | 4 ++-- imap.c | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dotlock.c b/dotlock.c index 30ab156..641672a 100644 --- a/dotlock.c +++ b/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)) { diff --git a/imap.c b/imap.c index 5fe1548..34d4379 100644 --- a/imap.c +++ b/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); }