2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
11 #if defined(AFS_AIX41_ENV)
12 #include <sys/types.h>
13 #include <sys/param.h>
19 #include <sys/socket.h>
24 #include <afs/kauth.h>
25 #include <afs/kautils.h>
28 int afs_authenticate (char *userName, char *response, int *reenter, char **message) {
29 char *reason, *pword, prompt[256];
31 int code, unixauthneeded, password_expires = -1;
38 sprintf(prompt,"Enter AFS password for %s: ",userName);
39 pword=getpass(prompt);
40 if(strlen(pword)==0) {
41 printf("Unable to read password because zero length passord is illegal\n");
42 *message = (char *)malloc(256);
43 sprintf(*message, "Unable to read password because zero length passord is illegal\n");
47 if ((pwd = getpwnam(userName)) == NULL){
48 *message = (char *)malloc(256);
49 sprintf(*message, "getpwnam for user failed\n");
52 if (code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG, userName,
53 (char *)0, (char *)0, pword, 0, &password_expires, 0, &reason)) {
56 *message = (char *)malloc(1024);
57 sprintf(*message, "Unable to authenticate to AFS because %s.\n", reason);
60 #if defined(AFS_KERBEROS_ENV)
61 setup_ticket_file(userName);
66 int afs_chpass (char *userName, char *oldPasswd, char *newPasswd, char **message) {
70 int afs_passwdexpired (char *userName, char **message) {
74 int afs_passwdrestrictions (char *userName, char *newPasswd, char *oldPasswd, char **message) {
78 int afs_getgrset (char *userName) {
82 int afs_getgrgid (int id) {
86 int afs_getgrnam (char *name) {
90 int afs_getpwnam(int id)
95 int afs_getpwuid(char *name)
100 int afs_initialize(struct secmethod_table *meths) {
102 * Initialize kauth package here so we don't have to call it
103 * each time we call the authenticate routine.
106 bzero(meths, sizeof(struct secmethod_table));
108 * Initialize the exported interface routines. Except the authenticate one
109 * the others are currently mainly noops.
111 meths->method_chpass = afs_chpass;
112 meths->method_authenticate = afs_authenticate;
113 meths->method_passwdexpired = afs_passwdexpired;
114 meths->method_passwdrestrictions = afs_passwdrestrictions;
116 * These we need to bring in because, for afs users, /etc/security/user's
117 * "registry" must non-local (i.e. DCE) since otherwise it assumes it's a
118 * local domain and uses valid_crypt(passwd) to validate the afs passwd
119 * which, of course, will fail. NULL return from these routine simply
120 * means use the local version ones after all.
122 meths->method_getgrgid = afs_getgrgid;
123 meths->method_getgrset = afs_getgrset;
124 meths->method_getgrnam = afs_getgrnam;
125 meths->method_getpwnam = afs_getpwnam;
126 meths->method_getpwuid = afs_getpwuid;
130 #if defined(AFS_KERBEROS_ENV)
132 setup_ticket_file(userName)
135 extern char* ktc_tkt_string();
138 setpwent(); /* open the pwd database */
139 pwd = getpwnam(userName);
142 if ( chown(ktc_tkt_string(), pwd->pw_uid, pwd->pw_gid) < 0 )
145 else perror("getpwnam : ");
146 endpwent(); /* close the pwd database */
148 #endif /* AFS_KERBEROS_ENV */