1 --- xtrlock-2.0/Makefile.noimake 1995-11-07 15:51:48.000000000 +0100
2 +++ xtrlock-2.0/Makefile.noimake 2006-08-02 10:14:46.901687000 +0200
4 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 # GNU General Public License for more details.
11 +PAM_CFLAGS = -DPAM_PWD
15 +SHADOW_CFLAGS = -DSHADOW_PWD
22 +override CFLAGS += -Wall $(PAM_CFLAGS) $(SHADOW_CFLAGS)
23 +override LDFLAGS += -L/usr/X11R6/lib
24 +override LDLIBS += -lX11 -lcrypt $(PAM_LDLIBS) $(SHADOW_LDLIBS)
31 -xtrlock.o: xtrlock.c lock.bitmap mask.bitmap patchlevel.h
39 $(INSTALL) -c -m 755 xtrlock /usr/bin/X11
42 $(INSTALL) -c -m 644 xtrlock.man /usr/man/man1/xtrlock.1x
45 +##########################################################
48 +xtrlock.o: xtrlock.c lock.bitmap mask.bitmap patchlevel.h
51 --- xtrlock-2.0/xtrlock.c 2005-01-17 11:43:05.000000000 +0100
52 +++ xtrlock-2.0/xtrlock.c 2006-08-02 10:18:15.264274000 +0200
57 - * X Transparent Lock
59 - * Copyright (C)1993,1994 Ian Jackson
61 - * This is free software; you can redistribute it and/or modify
62 - * it under the terms of the GNU General Public License as published by
63 - * the Free Software Foundation; either version 2, or (at your option)
64 - * any later version.
66 - * This is distributed in the hope that it will be useful,
67 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
68 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 - * GNU General Public License for more details.
71 +/*------------------------------------------------------------------*\
76 + Copyright (C)1993,1994 Ian Jackson
78 + This is free software; you can redistribute it and/or modify
79 + it under the terms of the GNU General Public License as published by
80 + the Free Software Foundation; either version 2, or (at your option)
83 + This is distributed in the hope that it will be useful,
84 + but WITHOUT ANY WARRANTY; without even the implied warranty of
85 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86 + GNU General Public License for more details.
88 +\*------------------------------------------------------------------*/
90 +/*------------------------------------------------------------------*\
91 +\*------------------------------------------------------------------*/
94 #include <X11/Xutil.h>
100 +#endif /* SHADOW_PWD */
103 +#include <security/pam_appl.h>
104 +/* #include <security/pam_misc.h> */
105 +#endif /* PAM_PWD */
107 +/*----------------------------------------------*\
108 +\*----------------------------------------------*/
110 #include "lock.bitmap"
111 #include "mask.bitmap"
112 #include "patchlevel.h"
115 -Window window, root;
116 +/*------------------------------------------------------------------*\
118 +\*------------------------------------------------------------------*/
120 #define TIMEOUTPERATTEMPT 30000
121 #define MAXGOODWILL (TIMEOUTPERATTEMPT*5)
122 #define INITIALGOODWILL MAXGOODWILL
123 #define GOODWILLPORTION 0.3
126 +Window window, root;
130 +/*------------------------------------------------------------------*\
133 + taken from pure-ftpd's authstuff, but you can see similar stuff
134 + in xlockmore, openssh and basicly all pam-related apps :)
135 +\*------------------------------------------------------------------*/
138 + if (PAM_error != 0 || pam_error != PAM_SUCCESS) { \
139 + fprintf(stderr, "pam error: %s\n", pam_strerror(pam_handle, pam_error)); \
140 + pam_end(pam_handle, pam_error); \
146 + size += sizeof(struct pam_response); \
147 + if ((reply = realloc(reply, size)) == NULL) { \
149 + return PAM_CONV_ERR; \
152 +static const char* PAM_username = NULL;
153 +static const char* PAM_password = NULL;
154 +static int PAM_error = 0;
155 +static int pam_error = PAM_SUCCESS;
157 +static int PAM_conv(int num_msg, const struct pam_message **msgs,
158 + struct pam_response **resp, void *appdata_ptr) {
161 + unsigned int replies = 0U;
162 + struct pam_response *reply = NULL;
163 + size_t size = (size_t) 0U;
165 + (void) appdata_ptr;
167 + for (count = 0; count < num_msg; count++) {
168 + switch (msgs[count]->msg_style) {
169 + case PAM_PROMPT_ECHO_ON:
171 + memset(&reply[replies], 0, sizeof reply[replies]);
172 + if ((reply[replies].resp = strdup(PAM_username)) == NULL) {
174 + reply[replies].resp_retcode = PAM_BUF_ERR;
177 + return PAM_CONV_ERR;
179 + reply[replies++].resp_retcode = PAM_SUCCESS;
180 + /* PAM frees resp */
182 + case PAM_PROMPT_ECHO_OFF:
184 + memset(&reply[replies], 0, sizeof reply[replies]);
185 + if ((reply[replies].resp = strdup(PAM_password)) == NULL) {
187 + reply[replies].resp_retcode = PAM_BUF_ERR;
190 + return PAM_CONV_ERR;
192 + reply[replies++].resp_retcode = PAM_SUCCESS;
193 + /* PAM frees resp */
195 + case PAM_TEXT_INFO:
198 + case PAM_ERROR_MSG:
200 + /* Must be an error of some sort... */
203 + return PAM_CONV_ERR;
207 + return PAM_SUCCESS;
210 +static struct pam_conv PAM_conversation = {
214 +/*------------------------------------------------------------------*\
215 +\*------------------------------------------------------------------*/
217 int passwordok(const char *s) {
222 /* simpler, and should work with crypt() algorithms using longer
223 salt strings (like the md5-based one on freebsd). --marekm */
225 + pam_handle_t* pam_handle = NULL;
226 + PAM_username = pw->pw_name;
228 + pam_error = pam_start("xlock", PAM_username, &PAM_conversation, &pam_handle);
230 + pam_error = pam_authenticate(pam_handle, 0);
232 + pam_error = pam_end(pam_handle, pam_error);
236 return !strcmp(crypt(s, pw->pw_passwd), pw->pw_passwd);
241 int main(int argc, char **argv){
243 Pixmap csr_source,csr_mask;
244 XColor csr_fg, csr_bg, dummy;
252 - fprintf(stderr,"xtrlock (version %s): no arguments allowed\n",program_version);
253 + fprintf(stderr, "xtrlock (version %s): no arguments allowed\n",
258 - errno=0; pw= getpwuid(getuid());
259 - if (!pw) { perror("password entry for uid not found"); exit(1); }
261 + pw = getpwuid(getuid());
263 + perror("password entry for uid not found");
267 sp = getspnam(pw->pw_name);
269 @@ -107,10 +229,11 @@
270 /* we can be installed setuid root to support shadow passwords,
271 and we don't need root privileges any longer. --marekm */
275 if (strlen(pw->pw_passwd) < 13) {
276 fputs("password entry has no pwd\n",stderr); exit(1);
280 display= XOpenDisplay(0);