From 03dae1e9f8daf9c43fae4c05bcc8890b588a3a75 Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 30 Oct 2011 14:15:15 +0000 Subject: fix captcha return value when running in daemon mode git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5452 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/mbbsd/captcha.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pttbbs/mbbsd/captcha.c b/pttbbs/mbbsd/captcha.c index 6fa446a6..2d0146ab 100644 --- a/pttbbs/mbbsd/captcha.c +++ b/pttbbs/mbbsd/captcha.c @@ -49,14 +49,15 @@ gen_captcha(char *buf, int szbuf, char *fpath) // create file snprintf(fpath, PATHLEN, FN_JOBSPOOL_DIR ".captcha.%s", buf); - snprintf(cmd, sizeof(cmd), FIGLET_PATH " %s %s > %s", - opts, buf, fpath); + snprintf(cmd, sizeof(cmd), FIGLET_PATH + " %s %s >%s 2>/dev/null || rm %s", + opts, buf, fpath, fpath); + // for mbbsd daemons, system() may return -1 with errno=ECHILD, + // so we can only trust the command itself. // vmsg(cmd); - if (system(cmd) != 0) - return 0; - - return 1; + system(cmd); + return dashf(fpath) && dashs(fpath) > 1; } @@ -98,8 +99,7 @@ int verify_captcha(const char *reason) if (tries % 2 == 0 || !captcha[0]) { // if generation failed, skip captcha. - if (!gen_captcha(captcha, sizeof(captcha), fpath) || - !dashf(fpath)) + if (!gen_captcha(captcha, sizeof(captcha), fpath)) return 1; // prompt user about captcha -- cgit v1.2.3