From 3465aec7e1529ed865ff8c30bcacb677fe7ba47c Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Sat, 16 Feb 2008 17:59:33 +0000 Subject: new feature: bcpasswd authentication type "unix". user has now also the choice to use the standard unix passwd/shadow authentication --- ax25/access.c | 28 ++++++++++++++++++++++++---- ax25/access.h | 1 + ax25/axspawn.c | 10 +++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ax25/access.c b/ax25/access.c index 46e010d..c431289 100644 --- a/ax25/access.c +++ b/ax25/access.c @@ -121,9 +121,16 @@ void ask_pw_sys(char *prompt, char *pass_want, char *pw) conv_randomize(); for (i = 0; i < 5; i++) { + int k; +again: j = conv_random(pwlen, 0); /* store generated request-numbers */ five_digits[i] = j+1; /* pos0 refers as 1 */ + /* same number again? */ + for (k = 0; k < i; k++) { + if (five_digits[k] == five_digits[i]) + goto again; + } /* store expected string in cp->passwd */ pass_want[i] = pw[j]; } @@ -218,6 +225,9 @@ void write_example_passwd(char *pwfile, char pwlocation, struct passwd *pw) { fprintf(f, "# %smd5:%s\n", (pwlocation == SYSTEMPW ? "username:" : ""), generate_rand_pw(MINPWLEN_MD5)); fprintf(f, "# sys/baycom standard (not very secure) - length: >= %d and <= %d characters\n", MINPWLEN_SYS, PASSSIZE); fprintf(f, "# %ssys:%s\n", (pwlocation == SYSTEMPW ? "username:" : ""), generate_rand_pw(MINPWLEN_SYS)); + fprintf(f, "# unix standard (plaintext): no password is read here. Your password is looked\n"); + fprintf(f, "# up during login in the system password table /etc/passwd or /etc/shadow\n"); + fprintf(f, "# unix\n"); fclose(f); } @@ -333,9 +343,14 @@ char *read_pwd (struct passwd *pw, int *pwtype) } else { p_buf = buf; } - if (!(pass = strchr(p_buf, ':'))) - continue; - *pass++ = 0; + + if (!Strcasecmp(p_buf, "unix")) { + pass = p_buf; + } else { + if (!(pass = strchr(p_buf, ':'))) + continue; + *pass++ = 0; + } while (*pass && isspace(*pass & 0xff)) pass++; @@ -347,8 +362,13 @@ char *read_pwd (struct passwd *pw, int *pwtype) *pwtype = PW_MD5; goto found; } else if ( (*pwtype & PW_SYS) && (!Strcasecmp(p_buf, "sys") || !strcmp(p_buf, "baycom")) ) { + fclose(f); *pwtype = PW_SYS; goto found; + } else if ( (*pwtype & PW_UNIX) && (!Strcasecmp(p_buf, "unix") ) ) { + fclose(f); + *pwtype = PW_UNIX; + return 0; } } } @@ -360,7 +380,7 @@ found: len = strlen(pass); if ((*pwtype == PW_SYS && len < MINPWLEN_SYS) || (*pwtype == PW_MD5 && len < MINPWLEN_MD5)) { - sprintf(buf, "Password in in password file too short\r"); + sprintf(buf, "Password in password file too short\r"); write_ax25(buf, strlen(buf), 1); goto end; } diff --git a/ax25/access.h b/ax25/access.h index 12e4666..4901418 100644 --- a/ax25/access.h +++ b/ax25/access.h @@ -11,6 +11,7 @@ #define PW_CLEARTEXT 1 #define PW_SYS 2 #define PW_MD5 4 +#define PW_UNIX 8 void ask_pw_sys(char *prompt, char *pass_want, char *pw); void ask_pw_md5(char *prompt, char *pass_want, char *pw); diff --git a/ax25/axspawn.c b/ax25/axspawn.c index bdf14a9..14f897f 100644 --- a/ax25/axspawn.c +++ b/ax25/axspawn.c @@ -1,6 +1,6 @@ /* * - * $Id: axspawn.c,v 1.13 2007/03/11 13:58:34 dl9sau Exp $ + * $Id: axspawn.c,v 1.14 2008/02/16 17:59:33 dl9sau Exp $ * * axspawn.c - run a program from ax25d. * @@ -1379,7 +1379,7 @@ int main(int argc, char **argv) read_config(); if (!pwtype) - pwtype = (PW_CLEARTEXT | PW_SYS | PW_MD5); + pwtype = (PW_CLEARTEXT | PW_SYS | PW_MD5 | PW_UNIX); pwtype_orig = pwtype; if (!*prompt) { if (gethostname(buf, sizeof(buf)) < 0) { @@ -1560,11 +1560,15 @@ int main(int argc, char **argv) again: if (!(pwd = read_pwd(pw, &pwtype))) { - if (!pwtype || pwtype != PW_CLEARTEXT) { + if ((!pwtype || pwtype != PW_CLEARTEXT) && (pwtype != PW_UNIX)) { sleep (EXITDELAY); return 1; } } + if (pwtype == PW_UNIX) { + pwtype = PW_CLEARTEXT; + pwcheck = 1; + } if (pwtype != PW_CLEARTEXT) { char pass_want[PASSSIZE+1]; -- cgit v1.2.3