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:
parent
fa1e46f6ec
commit
bbbe88e07d
|
@ -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
27
main.c
|
@ -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);
|
||||
|
|
10
sync.c
10
sync.c
|
@ -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,20 +133,25 @@ 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);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
p = strrchr (path, '/');
|
||||
|
||||
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");
|
||||
}
|
||||
else
|
||||
unlink(path);
|
||||
}
|
||||
}
|
||||
puts ("");
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user