use getpass() to get the user's password

unlink the temp file if we are unable to fetch a new message from the
server.

update version to 0.3
This commit is contained in:
Michael Elkins 2000-12-21 17:51:07 +00:00
parent fa1e46f6ec
commit bbbe88e07d
3 changed files with 18 additions and 31 deletions

View File

@ -1,5 +1,5 @@
AC_INIT(isync.h)
AM_INIT_AUTOMAKE(isync,0.2)
AM_INIT_AUTOMAKE(isync,0.3)
AM_PROG_CC_STDC
if test $CC = gcc; then
CFLAGS="$CFLAGS -pipe"

27
main.c
View File

@ -86,27 +86,6 @@ usage (void)
exit (0);
}
static char *
enter_password (void)
{
struct termios t;
char pass[32];
tcgetattr (0, &t);
t.c_lflag &= ~ECHO;
tcsetattr (0, TCSANOW, &t);
printf ("Password: ");
fflush (stdout);
pass[sizeof (pass) - 1] = 0;
fgets (pass, sizeof (pass) - 1, stdin);
if (pass[0])
pass[strlen (pass) - 1] = 0; /* kill newline */
t.c_lflag |= ECHO;
tcsetattr (0, TCSANOW, &t);
puts ("");
return strdup (pass);
}
/* set defaults from the global configuration section */
static void
config_defaults (config_t * conf)
@ -383,12 +362,14 @@ main (int argc, char **argv)
if (!box->pass)
{
box->pass = enter_password ();
if (!box->pass)
char *pass = getpass ("Password:");
if (pass)
{
puts ("Aborting, no password");
exit (1);
}
box->pass = strdup (pass);
}
printf ("Reading %s\n", box->path);

20
sync.c
View File

@ -47,6 +47,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags)
char newpath[_POSIX_PATH_MAX];
char *p;
int fd;
int ret;
for (cur = mbox->msgs; cur; cur = cur->next)
{
@ -132,19 +133,24 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags)
continue;
}
imap_fetch_message (imap, cur->uid, fd);
ret = imap_fetch_message (imap, cur->uid, fd);
close (fd);
p = strrchr (path, '/');
if (!ret)
{
p = strrchr (path, '/');
snprintf (newpath, sizeof (newpath), "%s/%s%s", mbox->path,
(cur->flags & D_SEEN) ? "cur" : "new", p);
snprintf (newpath, sizeof (newpath), "%s/%s%s", mbox->path,
(cur->flags & D_SEEN) ? "cur" : "new", p);
// printf ("moving %s to %s\n", path, newpath);
// printf ("moving %s to %s\n", path, newpath);
if (rename (path, newpath))
perror ("rename");
if (rename (path, newpath))
perror ("rename");
}
else
unlink(path);
}
}
puts ("");