From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kcheckpass/checkpass_aix.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 kcheckpass/checkpass_aix.c (limited to 'kcheckpass/checkpass_aix.c') diff --git a/kcheckpass/checkpass_aix.c b/kcheckpass/checkpass_aix.c new file mode 100644 index 000000000..8f06cfe67 --- /dev/null +++ b/kcheckpass/checkpass_aix.c @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2001 Reza Arbab + * Copyright (c) 2003 Oswald Buddenhagen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "kcheckpass.h" + +#ifdef HAVE_AIX_AUTH +#include +#include +#include +#include + +/* + * The AIX builtin authenticate() uses whichever method the system + * has been configured for. (/etc/passwd, DCE, etc.) + */ +int authenticate(const char *, const char *, int *, char **); + +AuthReturn Authenticate(const char *method, + const char *login, char *(*conv) (ConvRequest, const char *)) +{ + int result; + int reenter; /* Tells if authenticate is done processing or not. */ + char *passwd; + char *msg; /* Contains a prompt message or failure reason. */ + + if (!strcmp(method, "classic")) { + + if (!(passwd = conv(ConvGetHidden, 0))) + return AuthAbort; + + if ((result = authenticate(login, passwd, &reenter, &msg))) { + if (msg) { + conv(ConvPutError, msg); + free(msg); + } + dispose(passwd); + return AuthBad; + } + if (reenter) { + char buf[256]; + snprintf(buf, sizeof(buf), "More authentication data requested: %s\n", msg); + conv(ConvPutError, buf); + free(msg); + dispose(passwd); + return result == ENOENT || result == ESAD ? AuthBad : AuthError; + } + dispose(passwd); + return AuthOk; + + } else if (!strcmp(method, "generic")) { + + for (passwd = 0;;) { + if ((result = authenticate(login, passwd, &reenter, &msg))) { + if (msg) { + conv(ConvPutError, msg); + free(msg); + } + if (passwd) + dispose(passwd); + return result == ENOENT || result == ESAD ? AuthBad : AuthError; + } + if (passwd) + dispose(passwd); + if (!reenter) + break; + passwd = conv(ConvGetHidden, msg); + free(msg); + if (!passwd) + return AuthAbort; + } + return AuthOk; + + } else + return AuthError; + +} + +#endif -- cgit v1.2.3