summaryrefslogtreecommitdiffstats
path: root/kcheckpass/checkpass_aix.c
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcheckpass/checkpass_aix.c
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
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
Diffstat (limited to 'kcheckpass/checkpass_aix.c')
-rw-r--r--kcheckpass/checkpass_aix.c95
1 files changed, 95 insertions, 0 deletions
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 <[email protected]>
+ * Copyright (c) 2003 Oswald Buddenhagen <[email protected]>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * 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