Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
32
cde/lib/pam/pam_modules/dial_auth/Imakefile
Normal file
32
cde/lib/pam/pam_modules/dial_auth/Imakefile
Normal file
@@ -0,0 +1,32 @@
|
||||
/* $XConsortium: Imakefile /main/4 1996/04/21 19:13:07 drk $
|
||||
*
|
||||
* (c) Copyright 1996 Digital Equipment Corporation.
|
||||
* (c) Copyright 1996 Hewlett-Packard Company.
|
||||
* (c) Copyright 1996 International Business Machines Corp.
|
||||
* (c) Copyright 1995,1996 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1996 Novell, Inc.
|
||||
* (c) Copyright 1996 FUJITSU LIMITED.
|
||||
* (c) Copyright 1996 Hitachi.
|
||||
*/
|
||||
|
||||
#define DoNormalLib NormalLibPam
|
||||
#define DoSharedLib SharedLibPam
|
||||
#define DoDebugLib DebugLibPam
|
||||
#define DoProfileLib ProfileLibPam
|
||||
#define LibName pam_dial_auth
|
||||
#define SoRev SOPAMREV
|
||||
#define LibHeaders NO
|
||||
|
||||
#include <Threads.tmpl>
|
||||
|
||||
SRCS = dial_auth.c
|
||||
|
||||
OBJS = dial_auth.o
|
||||
|
||||
#ifdef SharedPamDialAuthReqs
|
||||
REQUIREDLIBS = SharedPamDialAuthReqs
|
||||
#endif
|
||||
|
||||
#include <Library.tmpl>
|
||||
|
||||
DependTarget()
|
||||
139
cde/lib/pam/pam_modules/dial_auth/dial_auth.c
Normal file
139
cde/lib/pam/pam_modules/dial_auth/dial_auth.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/* $XConsortium: dial_auth.c /main/5 1996/05/09 04:28:31 drk $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992-1995, by Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ident "@(#)dial_auth.c 1.20 96/02/09 SMI"
|
||||
|
||||
#include "unix_headers.h"
|
||||
|
||||
/*
|
||||
* pam_sm_auth_port - This is the top level function in the
|
||||
* module called by pam_auth_port in the framework
|
||||
* Returns: PAM_SERVICE_ERR on failure, 0 on success
|
||||
*/
|
||||
|
||||
int
|
||||
pam_sm_authenticate(
|
||||
pam_handle_t *pamh,
|
||||
int flags,
|
||||
int argc,
|
||||
const char **argv)
|
||||
{
|
||||
char *ttyn, *user;
|
||||
struct pam_conv *pam_convp;
|
||||
FILE *fp;
|
||||
char defpass[30];
|
||||
char line[80];
|
||||
char *p1, *p2;
|
||||
struct passwd pwd;
|
||||
char pwd_buffer[1024];
|
||||
char *password;
|
||||
static struct pam_response *ret_resp;
|
||||
int retcode;
|
||||
char messages[PAM_MAX_NUM_MSG][PAM_MAX_MSG_SIZE];
|
||||
int num_msg;
|
||||
int i;
|
||||
int debug = 0;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (strcasecmp(argv[i], "debug") == 0)
|
||||
debug = 1;
|
||||
else
|
||||
syslog(LOG_DEBUG, "illegal option %s", argv[i]);
|
||||
}
|
||||
|
||||
if ((retcode = pam_get_user(pamh, &user, NULL))
|
||||
!= PAM_SUCCESS ||
|
||||
(retcode = pam_get_item(pamh, PAM_TTY, (void **)&ttyn))
|
||||
!= PAM_SUCCESS ||
|
||||
(retcode = pam_get_item(pamh, PAM_CONV, (void **)&pam_convp))
|
||||
!= PAM_SUCCESS)
|
||||
return (retcode);
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_DEBUG,
|
||||
"Dialpass authenticate user = %s, ttyn = %s",
|
||||
user, ttyn);
|
||||
}
|
||||
|
||||
if (getpwnam_r(user, &pwd, pwd_buffer, sizeof (pwd_buffer)) == NULL)
|
||||
return (PAM_USER_UNKNOWN);
|
||||
|
||||
if ((fp = fopen(DIAL_FILE, "r")) == NULL) {
|
||||
return (PAM_SUCCESS);
|
||||
}
|
||||
|
||||
while ((p1 = fgets(line, sizeof (line), fp)) != NULL) {
|
||||
while (*p1 != '\n' && *p1 != ' ' && *p1 != '\t')
|
||||
p1++;
|
||||
*p1 = '\0';
|
||||
if (strcmp(line, ttyn) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
(void) fclose(fp);
|
||||
|
||||
if (p1 == NULL || (fp = fopen(DPASS_FILE, "r")) == NULL)
|
||||
return (PAM_SUCCESS);
|
||||
|
||||
defpass[0] = '\0';
|
||||
p2 = 0;
|
||||
|
||||
while ((p1 = fgets(line, sizeof (line)-1, fp)) != NULL) {
|
||||
while (*p1 && *p1 != ':')
|
||||
p1++;
|
||||
*p1++ = '\0';
|
||||
p2 = p1;
|
||||
while (*p1 && *p1 != ':')
|
||||
p1++;
|
||||
*p1 = '\0';
|
||||
if (pwd.pw_shell != NULL && strcmp(pwd.pw_shell, line) == 0)
|
||||
break;
|
||||
|
||||
if (strcmp(SHELL, line) == 0)
|
||||
SCPYN(defpass, p2);
|
||||
p2 = 0;
|
||||
}
|
||||
|
||||
(void) fclose(fp);
|
||||
|
||||
if (!p2)
|
||||
p2 = defpass;
|
||||
|
||||
if (*p2 != '\0') {
|
||||
strcpy(messages[0], PAM_MSG(pamh, 1, "Dialup Password: "));
|
||||
num_msg = 1;
|
||||
retcode = __pam_get_input(PAM_PROMPT_ECHO_OFF, pam_convp->conv,
|
||||
num_msg, messages, NULL, &ret_resp);
|
||||
if (retcode != PAM_SUCCESS)
|
||||
return (retcode);
|
||||
password = ret_resp->resp;
|
||||
|
||||
/* UNIX passwords can only be 8 characters long */
|
||||
password[8] = '\0';
|
||||
|
||||
if (strcmp(crypt(password, p2), p2)) {
|
||||
__pam_free_resp(num_msg, ret_resp);
|
||||
return (PAM_SERVICE_ERR);
|
||||
}
|
||||
__pam_free_resp(num_msg, ret_resp);
|
||||
}
|
||||
|
||||
return (PAM_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* dummy pam_sm_setcred - does nothing
|
||||
*/
|
||||
pam_sm_setcred(
|
||||
pam_handle_t *pamh,
|
||||
int flags,
|
||||
int argc,
|
||||
const char **argv)
|
||||
{
|
||||
return (PAM_SUCCESS);
|
||||
}
|
||||
18
cde/lib/pam/pam_modules/dial_auth/libpam_dial_auth.elist
Normal file
18
cde/lib/pam/pam_modules/dial_auth/libpam_dial_auth.elist
Normal file
@@ -0,0 +1,18 @@
|
||||
/****************************************************************************
|
||||
* Export list for libpam_dial_auth.
|
||||
* This list *must* be updated whenever a change is made to the libpam_dial_auth
|
||||
* API.
|
||||
*
|
||||
* The syntax for the symbol declarations in this list is as follows:
|
||||
* public sym => Public C symbol, i.e., publicised API
|
||||
* private sym => Private C symbol, i.e., unpublicised API
|
||||
* internal sym => Internal C symbol, i.e., not part of API
|
||||
* publicC++ sym => Public C++ symbol, i.e., publicised API
|
||||
* privateC++ sym => Private C++ symbol, i.e., unpublicised API
|
||||
* internalC++ sym => Internal C++ symbol, i.e., not part of API
|
||||
*
|
||||
* $TOG: libpam_dial_auth.elist /main/1 1999/09/08 15:58:41 mgreess $
|
||||
*****************************************************************************/
|
||||
|
||||
public pam_sm_authenticate
|
||||
public pam_sm_setcred
|
||||
92
cde/lib/pam/pam_modules/dial_auth/unix_headers.h
Normal file
92
cde/lib/pam/pam_modules/dial_auth/unix_headers.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* $XConsortium: unix_headers.h /main/4 1996/05/09 04:28:47 drk $ */
|
||||
/*
|
||||
* Copyright (c) 1992-1995, by Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _UNIX_HEADERS_H
|
||||
#define _UNIX_HEADERS_H
|
||||
|
||||
#pragma ident "@(#)unix_headers.h 1.6 96/02/02 SMI" /* PAM 2.6 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
******************************************************************
|
||||
|
||||
PROPRIETARY NOTICE(Combined)
|
||||
|
||||
This source code is unpublished proprietary information
|
||||
constituting, or derived under license from AT&T's UNIX(r) System V.
|
||||
In addition, portions of such source code were derived from Berkeley
|
||||
4.3 BSD under license from the Regents of the University of
|
||||
California.
|
||||
|
||||
|
||||
|
||||
Copyright Notice
|
||||
|
||||
Notice of copyright on this source code product does not indicate
|
||||
publication.
|
||||
|
||||
(c) 1986, 1987, 1988, 1989, 1990, 1991, 1992 Sun Microsystems, Inc
|
||||
(c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T.
|
||||
All rights reserved.
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
******************************************************************** *
|
||||
* *
|
||||
* Unix Scheme Header Files *
|
||||
* *
|
||||
* ******************************************************************** */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_modules.h>
|
||||
#include <pwd.h>
|
||||
#include <shadow.h>
|
||||
#include <string.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/auth.h>
|
||||
#include <locale.h>
|
||||
#include <crypt.h>
|
||||
#include <syslog.h>
|
||||
|
||||
/*
|
||||
* Various useful files and string constants
|
||||
*/
|
||||
#define DIAL_FILE "/etc/dialups"
|
||||
#define DPASS_FILE "/etc/d_passwd"
|
||||
#define SHELL "/usr/bin/sh"
|
||||
|
||||
/*
|
||||
* PAM_MSG macro for return of internationalized text
|
||||
*/
|
||||
|
||||
#define PAM_MSG(pamh, number, string)\
|
||||
(char *) __pam_get_i18n_msg(pamh, "pam_unix", 2, number, string)
|
||||
|
||||
/*
|
||||
* Miscellaneous constants
|
||||
*/
|
||||
#define SLEEPTIME 4
|
||||
#define ERROR 1
|
||||
#define OK 0
|
||||
#define MAXTRYS 5
|
||||
#define ROOTUID 0
|
||||
|
||||
/*
|
||||
* String manipulation macros: SCPYN, EQN and ENVSTRNCAT
|
||||
*/
|
||||
#define SCPYN(a, b) (void) strncpy(a, b, sizeof (a))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UNIX_HEADERS_H */
|
||||
Reference in New Issue
Block a user