27
25
from The Open Group.
30
/* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
29
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
32
31
* Permission is hereby granted, free of charge, to any person obtaining a
33
* copy of this software and associated documentation files (the
34
* "Software"), to deal in the Software without restriction, including
35
* without limitation the rights to use, copy, modify, merge, publish,
36
* distribute, and/or sell copies of the Software, and to permit persons
37
* to whom the Software is furnished to do so, provided that the above
38
* copyright notice(s) and this permission notice appear in all copies of
39
* the Software and that both the above copyright notice(s) and this
40
* permission notice appear in supporting documentation.
42
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
45
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
46
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
47
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
48
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
49
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
50
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52
* Except as contained in this notice, the name of a copyright holder
53
* shall not be used in advertising or otherwise to promote the sale, use
54
* or other dealings in this Software without prior written authorization
55
* of the copyright holder.
32
* copy of this software and associated documentation files (the "Software"),
33
* to deal in the Software without restriction, including without limitation
34
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
35
* and/or sell copies of the Software, and to permit persons to whom the
36
* Software is furnished to do so, subject to the following conditions:
38
* The above copyright notice and this permission notice (including the next
39
* paragraph) shall be included in all copies or substantial portions of the
42
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48
* DEALINGS IN THE SOFTWARE.
58
/* $XFree86: xc/programs/xdm/greeter/greet.c,v 3.16tsi Exp $ */
61
53
* xdm - display manager daemon
100
101
int (*__xdm_PingServer)(struct display *d, Display *alternateDpy) = NULL;
101
102
void (*__xdm_SessionPingFailed)(struct display *d) = NULL;
102
void (*__xdm_Debug)(char * fmt, ...) = NULL;
103
void (*__xdm_Debug)(const char * fmt, ...) = NULL;
103
104
void (*__xdm_RegisterCloseOnFork)(int fd) = NULL;
104
105
void (*__xdm_SecureDisplay)(struct display *d, Display *dpy) = NULL;
105
106
void (*__xdm_UnsecureDisplay)(struct display *d, Display *dpy) = NULL;
106
107
void (*__xdm_ClearCloseOnFork)(int fd) = NULL;
107
108
void (*__xdm_SetupDisplay)(struct display *d) = NULL;
108
void (*__xdm_LogError)(char * fmt, ...) = NULL;
109
void (*__xdm_LogError)(const char * fmt, ...) = NULL;
109
110
void (*__xdm_SessionExit)(struct display *d, int status, int removeAuth) = NULL;
110
111
void (*__xdm_DeleteXloginResources)(struct display *d, Display *dpy) = NULL;
111
112
int (*__xdm_source)(char **environ, char *file) = NULL;
115
116
char **(*__xdm_parseArgs)(char **argv, char *string) = NULL;
116
117
void (*__xdm_printEnv)(char **e) = NULL;
117
118
char **(*__xdm_systemEnv)(struct display *d, char *user, char *home) = NULL;
118
void (*__xdm_LogOutOfMem)(char * fmt, ...) = NULL;
119
void (*__xdm_LogOutOfMem)(const char * fmt, ...) = NULL;
119
120
void (*__xdm_setgrent)(void) = NULL;
120
121
struct group *(*__xdm_getgrent)(void) = NULL;
121
122
void (*__xdm_endgrent)(void) = NULL;
123
124
struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS) = NULL;
125
126
void (*__xdm_endspent)(void) = NULL;
126
# endif /* QNX4 doesn't use endspent */
127
# endif /* QNX4 doesn't use endspent */
128
129
struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS) = NULL;
129
#if defined(linux) || defined(__GLIBC__)
130
# if defined(linux) || defined(__GLIBC__)
130
131
void (*__xdm_endpwent)(void) = NULL;
132
133
char *(*__xdm_crypt)(CRYPT_ARGS) = NULL;
134
135
pam_handle_t **(*__xdm_thepamhp)(void) = NULL;
139
140
#ifdef SECURE_RPC
141
#include <rpc/key_prot.h>
141
# include <rpc/rpc.h>
142
# include <rpc/key_prot.h>
145
#include <krb5/krb5.h>
146
# include <krb5/krb5.h>
148
149
extern Display *dpy;
458
464
__xdm_setgrent = dlfuncs->_setgrent;
459
465
__xdm_getgrent = dlfuncs->_getgrent;
460
466
__xdm_endgrent = dlfuncs->_endgrent;
462
468
__xdm_getspnam = dlfuncs->_getspnam;
464
470
__xdm_endspent = dlfuncs->_endspent;
465
# endif /* QNX4 doesn't use endspent */
471
# endif /* QNX4 doesn't use endspent */
467
473
__xdm_getpwnam = dlfuncs->_getpwnam;
468
#if defined(linux) || defined(__GLIBC__)
474
# if defined(linux) || defined(__GLIBC__)
469
475
__xdm_endpwent = dlfuncs->_endpwent;
471
477
__xdm_crypt = dlfuncs->_crypt;
473
479
__xdm_thepamhp = dlfuncs->_thepamhp;
477
483
*dpy = InitGreet (d);
499
502
struct myconv_data pcd = { d, greet, NULL };
500
503
struct pam_conv pc = { pamconv, &pcd };
501
504
const char * pam_fname;
505
char * username = NULL;
503
506
const char * login_prompt;
506
SetPrompt(login, 0, NULL, LOGIN_PROMPT_NOT_SHOWN, False);
509
SetPrompt(login, LOGIN_PROMPT_USERNAME, NULL, LOGIN_PROMPT_NOT_SHOWN, False);
507
510
login_prompt = GetPrompt(login, LOGIN_PROMPT_USERNAME);
508
SetPrompt(login, 1, NULL, LOGIN_PROMPT_NOT_SHOWN, False);
510
#define RUN_AND_CHECK_PAM_ERROR(function, args) \
511
SetPrompt(login, LOGIN_PROMPT_PASSWORD, NULL, LOGIN_PROMPT_NOT_SHOWN, False);
513
# define RUN_AND_CHECK_PAM_ERROR(function, args) \
512
515
pam_error = function args; \
513
516
if (pam_error != PAM_SUCCESS) { \
514
517
PAM_ERROR_PRINT(#function, *pamhp); \
520
523
RUN_AND_CHECK_PAM_ERROR(pam_start,
521
524
("xdm", NULL, &pc, pamhp));
533
536
LogOutOfMem("GreetUser");
535
538
char *colon = strrchr(hostname, ':');
537
540
if (colon != NULL)
540
543
RUN_AND_CHECK_PAM_ERROR(pam_set_item,
541
544
(*pamhp, PAM_RHOST, hostname));
545
548
RUN_AND_CHECK_PAM_ERROR(pam_set_item, (*pamhp, PAM_TTY, d->name));
547
550
if (!greet->allow_null_passwd) {
548
551
pam_flags |= PAM_DISALLOW_NULL_AUTHTOK;
550
553
RUN_AND_CHECK_PAM_ERROR(pam_authenticate,
551
554
(*pamhp, pam_flags));
553
556
/* handle expired passwords */
554
557
pam_error = pam_acct_mgmt(*pamhp, pam_flags);
555
558
pam_fname = "pam_acct_mgmt";
682
694
= { "<invalid pam msg style>",
683
695
"PAM_PROMPT_ECHO_OFF", "PAM_PROMPT_ECHO_ON",
684
696
"PAM_ERROR_MSG", "PAM_TEXT_INFO" } ;
686
698
struct pam_message *m;
687
699
struct pam_response *r;
689
701
struct myconv_data *d = (struct myconv_data *) appdata_ptr;
691
703
pam_handle_t **pamhp = thepamhp();
693
705
*response = calloc(num_msg, sizeof (struct pam_response));
694
706
if (*response == NULL)
695
707
return (PAM_BUF_ERR);
709
m = (struct pam_message *)*msg;
713
status = PAM_CONV_ERR;
700
717
for (i = 0; i < num_msg; i++ , m++ , r++) {
702
719
int promptId = 0;