Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 67991
Collapse All | Expand All

(-)ppp-2.4.2.orig/etc.ppp/callback-client (+6 lines)
Line 0 Link Here
1
#!/bin/sh
2
# Script callback-client
3
# Script parameters: delay time in seconds
4
5
sleep $1
6
/usr/sbin/chat -v "" ATZ OK "" RING ATA CONNECT
(-)ppp-2.4.2.orig/etc.ppp/callback-server (+6 lines)
Line 0 Link Here
1
#!/bin/sh
2
# Script callback-server
3
# Script parameters: delay time in seconds, callback number
4
5
sleep $1
6
/usr/sbin/chat -v "" ATZ OK ATDT$2 CONNECT
(-)ppp-2.4.2.orig/etc.ppp/callback-users (+10 lines)
Line 0 Link Here
1
# User list for callback
2
# Username option
3
# option - no callback
4
# option * or empty user definied
5
# option other admin definied: this number
6
# in username * and ? wildcars valid, callback uses the best fit
7
# Examples:
8
# zotyo        67435   # user zotyo admin definied, number 67453
9
# gates        -       # gates not called back
10
*
(-)ppp-2.4.2.orig/linux/Makefile.top (-2 / +9 lines)
Lines 3-9 Link Here
3
3
4
BINDIR = $(DESTDIR)/usr/sbin
4
BINDIR = $(DESTDIR)/usr/sbin
5
INCDIR = $(DESTDIR)/usr/include
5
INCDIR = $(DESTDIR)/usr/include
6
MANDIR = $(DESTDIR)/usr/man
6
MANDIR = $(DESTDIR)/usr/share/man
7
ETCDIR = $(DESTDIR)/etc/ppp
7
ETCDIR = $(DESTDIR)/etc/ppp
8
8
9
# uid 0 = root
9
# uid 0 = root
Lines 26-32 Link Here
26
	cd pppdump; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install
26
	cd pppdump; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install
27
27
28
install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
28
install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
29
	$(ETCDIR)/chap-secrets
29
	$(ETCDIR)/chap-secrets $(ETCDIR)/callback-users \
30
	$(ETCDIR)/callback-client $(ETCDIR)/callback-server
30
31
31
install-devel:
32
install-devel:
32
	cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) INCDIR=$(INCDIR) $(MFLAGS) install-devel
33
	cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) INCDIR=$(INCDIR) $(MFLAGS) install-devel
Lines 37-42 Link Here
37
	$(INSTALL) -c -m 600 etc.ppp/pap-secrets $@
38
	$(INSTALL) -c -m 600 etc.ppp/pap-secrets $@
38
$(ETCDIR)/chap-secrets:
39
$(ETCDIR)/chap-secrets:
39
	$(INSTALL) -c -m 600 etc.ppp/chap-secrets $@
40
	$(INSTALL) -c -m 600 etc.ppp/chap-secrets $@
41
$(ETCDIR)/callback-users:
42
	$(INSTALL) -c -m 664 etc.ppp/callback-users $@
43
$(ETCDIR)/callback-client:
44
	$(INSTALL) -c -m 700 etc.ppp/callback-client $@
45
$(ETCDIR)/callback-server:
46
	$(INSTALL) -c -m 700 etc.ppp/callback-server $@
40
47
41
$(BINDIR):
48
$(BINDIR):
42
	$(INSTALL) -d -m 755 $@
49
	$(INSTALL) -d -m 755 $@
(-)ppp-2.4.2.orig/pppd/auth.c (-3 / +3 lines)
Lines 248-254 Link Here
248
248
249
/* Prototypes for procedures local to this file. */
249
/* Prototypes for procedures local to this file. */
250
250
251
static void network_phase __P((int));
252
static void check_idle __P((void *));
251
static void check_idle __P((void *));
253
static void connect_time_expired __P((void *));
252
static void connect_time_expired __P((void *));
254
static int  plogin __P((char *, char *, char **));
253
static int  plogin __P((char *, char *, char **));
Lines 671-677 Link Here
671
/*
670
/*
672
 * Proceed to the network phase.
671
 * Proceed to the network phase.
673
 */
672
 */
674
static void
673
void
675
network_phase(unit)
674
network_phase(unit)
676
    int unit;
675
    int unit;
677
{
676
{
Lines 697-703 Link Here
697
    /*
696
    /*
698
     * If we negotiated callback, do it now.
697
     * If we negotiated callback, do it now.
699
     */
698
     */
700
    if (go->neg_cbcp) {
699
    if (((go->neg_cbcp) || (lcp_hisoptions[unit].neg_cbcp))
700
	&& (phase != PHASE_CALLBACK)) {
701
	new_phase(PHASE_CALLBACK);
701
	new_phase(PHASE_CALLBACK);
702
	(*cbcp_protent.open)(unit);
702
	(*cbcp_protent.open)(unit);
703
	return;
703
	return;
(-)ppp-2.4.2.orig/pppd/cbcp.c (-78 / +483 lines)
Lines 1-8 Link Here
1
/*
1
/*
2
 * cbcp - Call Back Configuration Protocol.
2
 * cbcp - Call Back Configuration Protocol.
3
 *
3
 *
4
 * Copyright (c) 1995 Pedro Roque Marques.  All rights reserved.
4
 * Copyright (c) 1995 Pedro Roque Marques.
5
 * Copyright (c) 2001 Bolke de Bruin
6
 * Copyright (c) 2004 Valery Kartel
5
 *
7
 *
8
 * All rights reserved.
9
 * 
6
 * Redistribution and use in source and binary forms, with or without
10
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
11
 * modification, are permitted provided that the following conditions
8
 * are met:
12
 * are met:
Lines 39-66 Link Here
39
#include <string.h>
43
#include <string.h>
40
#include <sys/types.h>
44
#include <sys/types.h>
41
#include <sys/time.h>
45
#include <sys/time.h>
46
#include <syslog.h>
47
#include <sys/stat.h>
42
48
43
#include "pppd.h"
49
#include "pppd.h"
44
#include "cbcp.h"
50
#include "cbcp.h"
45
#include "fsm.h"
51
#include "fsm.h"
46
#include "lcp.h"
52
#include "lcp.h"
53
#include "ipcp.h"
54
#include "pathnames.h"
47
55
48
static const char rcsid[] = RCSID;
56
static const char rcsid[] = RCSID;
49
57
50
/*
58
/*
51
 * Options.
52
 */
53
static int setcbcp __P((char **));
54
55
static option_t cbcp_option_list[] = {
56
    { "callback", o_special, (void *)setcbcp,
57
      "Ask for callback", OPT_PRIO | OPT_A2STRVAL, &cbcp[0].us_number },
58
    { NULL }
59
};
60
61
/*
62
 * Protocol entry points.
59
 * Protocol entry points.
63
 */
60
 */
61
 
64
static void cbcp_init      __P((int unit));
62
static void cbcp_init      __P((int unit));
65
static void cbcp_open      __P((int unit));
63
static void cbcp_open      __P((int unit));
66
static void cbcp_lowerup   __P((int unit));
64
static void cbcp_lowerup   __P((int unit));
Lines 84-91 Link Here
84
    0,
82
    0,
85
    "CBCP",
83
    "CBCP",
86
    NULL,
84
    NULL,
87
    cbcp_option_list,
88
    NULL,
89
    NULL,
85
    NULL,
90
    NULL
86
    NULL
91
};
87
};
Lines 93-119 Link Here
93
cbcp_state cbcp[NUM_PPP];	
89
cbcp_state cbcp[NUM_PPP];	
94
90
95
/* internal prototypes */
91
/* internal prototypes */
96
92
static void cbcp_sendreq __P((void *arg));
97
static void cbcp_recvreq __P((cbcp_state *us, u_char *pckt, int len));
93
static void cbcp_recvreq __P((cbcp_state *us, u_char *pckt, int len));
98
static void cbcp_resp __P((cbcp_state *us));
94
static void cbcp_sendresp __P((cbcp_state *us));
99
static void cbcp_up __P((cbcp_state *us));
95
static void cbcp_recvresp __P((cbcp_state *us, char *pckt, int len));
96
static void cbcp_sendack __P((void *));
100
static void cbcp_recvack __P((cbcp_state *us, u_char *pckt, int len));
97
static void cbcp_recvack __P((cbcp_state *us, u_char *pckt, int len));
98
101
static void cbcp_send __P((cbcp_state *us, int code, u_char *buf, int len));
99
static void cbcp_send __P((cbcp_state *us, int code, u_char *buf, int len));
100
static void cbcp_make_options __P((int unit));
101
static int  cbcp_check_user __P((char *user, char *mask));
102
static void cbcp_start_callback __P((cbcp_state *us));
103
static void cbcp_up __P((cbcp_state *us));
102
104
103
/* option processing */
105
104
static int
106
cbcp_state *stop_iface = NULL;
105
setcbcp(argv)
107
106
    char **argv;
108
void (*cbcp_init_hook) __P((cbcp_state *)) = NULL;
107
{
108
    lcp_wantoptions[0].neg_cbcp = 1;
109
    cbcp_protent.enabled_flag = 1;
110
    cbcp[0].us_number = strdup(*argv);
111
    if (cbcp[0].us_number == 0)
112
	novm("callback number");
113
    cbcp[0].us_type |= (1 << CB_CONF_USER);
114
    cbcp[0].us_type |= (1 << CB_CONF_ADMIN);
115
    return (1);
116
}
117
109
118
/* init state */
110
/* init state */
119
static void
111
static void
Lines 125-131 Link Here
125
    us = &cbcp[iface];
117
    us = &cbcp[iface];
126
    memset(us, 0, sizeof(cbcp_state));
118
    memset(us, 0, sizeof(cbcp_state));
127
    us->us_unit = iface;
119
    us->us_unit = iface;
128
    us->us_type |= (1 << CB_CONF_NO);
129
}
120
}
130
121
131
/* lower layer is up */
122
/* lower layer is up */
Lines 135-152 Link Here
135
{
126
{
136
    cbcp_state *us = &cbcp[iface];
127
    cbcp_state *us = &cbcp[iface];
137
128
138
    dbglog("cbcp_lowerup");
129
    CBCPDEBUG((LOG_DEBUG, "cbcp_lowerup"));
139
    dbglog("want: %d", us->us_type);
130
    CBCPDEBUG((LOG_DEBUG, "want: %d", us->us_type));
140
141
    if (us->us_type == CB_CONF_USER)
142
        dbglog("phone no: %s", us->us_number);
143
}
131
}
144
132
145
static void
133
static void
146
cbcp_open(unit)
134
cbcp_open(unit)
147
    int unit;
135
    int unit;
148
{
136
{
149
    dbglog("cbcp_open");
137
    CBCPDEBUG((LOG_DEBUG, "cbcp_open"));
138
    if (lcp_hisoptions[unit].neg_cbcp)
139
       cbcp_make_options(unit);
150
}
140
}
151
141
152
/* process an incomming packet */
142
/* process an incomming packet */
Lines 161-171 Link Here
161
    u_short len;
151
    u_short len;
162
152
163
    cbcp_state *us = &cbcp[unit];
153
    cbcp_state *us = &cbcp[unit];
154
    lcp_options *go  = &lcp_gotoptions[unit];
155
    lcp_options *his = &lcp_hisoptions[unit];
164
156
165
    inp = inpacket;
157
    inp = inpacket;
166
158
167
    if (pktlen < CBCP_MINLEN) {
159
    if (pktlen < CBCP_MINLEN) {
168
        error("CBCP packet is too small");
160
	syslog(LOG_ERR, "CBCP packet is too small");
169
	return;
161
	return;
170
    }
162
    }
171
163
Lines 175-181 Link Here
175
167
176
#if 0
168
#if 0
177
    if (len > pktlen) {
169
    if (len > pktlen) {
178
        error("CBCP packet: invalid length");
170
	syslog(LOG_ERR, "CBCP packet: invalid length");
179
        return;
171
        return;
180
    }
172
    }
181
#endif
173
#endif
Lines 184-200 Link Here
184
 
176
 
185
    switch(code) {
177
    switch(code) {
186
    case CBCP_REQ:
178
    case CBCP_REQ:
179
	if ( !go->neg_cbcp )
180
	{
181
	    syslog(LOG_ERR, "CBCP received CBCP_REQ, but CBCP running in server mode!");
182
	    return;
183
	}
187
        us->us_id = id;
184
        us->us_id = id;
188
	cbcp_recvreq(us, inp, len);
185
	cbcp_recvreq(us, inp, len);
189
	break;
186
	break;
190
187
191
    case CBCP_RESP:
188
    case CBCP_RESP:
192
	dbglog("CBCP_RESP received");
189
	if ( !his->neg_cbcp )
190
	{
191
	    syslog(LOG_ERR, "CBCP received CBCP_RESP, but CBCP running in client mode!");
192
	    return;
193
	}
194
	if (id != us->us_id)
195
	    syslog(LOG_DEBUG, "id doesn't match: expected %d recv %d",
196
		   us->us_id, id);
197
198
	cbcp_recvresp(us, inp, len);
193
	break;
199
	break;
194
200
195
    case CBCP_ACK:
201
    case CBCP_ACK:
202
	if ( !go->neg_cbcp )
203
	{
204
	    syslog(LOG_ERR, "CBCP received CBCP_ACK, but CBCP running in server mode!");
205
	    return;
206
	}
196
	if (id != us->us_id)
207
	if (id != us->us_id)
197
	    dbglog("id doesn't match: expected %d recv %d",
208
	    syslog(LOG_DEBUG, "id doesn't match: expected %d recv %d",
198
		   us->us_id, id);
209
		   us->us_id, id);
199
210
200
	cbcp_recvack(us, inp, len);
211
	cbcp_recvack(us, inp, len);
Lines 274-286 Link Here
274
		printer(arg, " delay = %d", delay);
285
		printer(arg, " delay = %d", delay);
275
	    }
286
	    }
276
287
277
	    if (olen > 3) {
288
	    if (olen > 4) {
278
	        int addrt;
289
	        int addrt;
279
		char str[256];
290
		char str[256];
280
291
281
		GETCHAR(addrt, p);
292
		GETCHAR(addrt, p);
282
		memcpy(str, p, olen - 4);
293
		memcpy(str, p, olen - 4);
283
		str[olen - 4] = 0;
294
		str[olen - 4] = 0;
295
		p += olen - 4;
284
		printer(arg, " number = %s", str);
296
		printer(arg, " number = %s", str);
285
	    }
297
	    }
286
	    printer(arg, ">");
298
	    printer(arg, ">");
Lines 306-346 Link Here
306
    u_char *pckt;
318
    u_char *pckt;
307
    int pcktlen;
319
    int pcktlen;
308
{
320
{
309
    u_char type, opt_len, delay, addr_type;
321
    u_char type, opt_len, addr_type;
310
    char address[256];
322
    char address[256];
311
    int len = pcktlen;
323
    int len = pcktlen;
312
324
313
    address[0] = 0;
325
    address[0] = 0;
314
326
315
    while (len) {
327
    while (len) {
316
        dbglog("length: %d", len);
317
318
	GETCHAR(type, pckt);
328
	GETCHAR(type, pckt);
319
	GETCHAR(opt_len, pckt);
329
	GETCHAR(opt_len, pckt);
320
330
331
	us->us_delay = 0;
321
	if (opt_len > 2)
332
	if (opt_len > 2)
322
	    GETCHAR(delay, pckt);
333
	    GETCHAR(us->us_delay, pckt);
323
334
324
	us->us_allowed |= (1 << type);
335
	us->us_allowed |= (1 << type);
325
336
326
	switch(type) {
337
	switch(type) {
327
	case CB_CONF_NO:
338
	case CB_CONF_NO:
328
	    dbglog("no callback allowed");
339
	    CBCPDEBUG((LOG_DEBUG, "no callback allowed"));
329
	    break;
340
	    break;
330
341
331
	case CB_CONF_USER:
342
	case CB_CONF_USER:
332
	    dbglog("user callback allowed");
343
	    CBCPDEBUG((LOG_DEBUG, "user callback allowed"));
333
	    if (opt_len > 4) {
344
	    if (opt_len > 4) {
334
	        GETCHAR(addr_type, pckt);
345
	        GETCHAR(addr_type, pckt);
335
		memcpy(address, pckt, opt_len - 4);
346
		memcpy(address, pckt, opt_len - 4);
336
		address[opt_len - 4] = 0;
347
		address[opt_len - 4] = 0;
337
		if (address[0])
348
		if (address[0])
338
		    dbglog("address: %s", address);
349
		    CBCPDEBUG((LOG_DEBUG, "address: %s", address));
339
	    }
350
	    }
340
	    break;
351
	    break;
341
352
342
	case CB_CONF_ADMIN:
353
	case CB_CONF_ADMIN:
343
	    dbglog("user admin defined allowed");
354
	    CBCPDEBUG((LOG_DEBUG, "user admin defined allowed"));
344
	    break;
355
	    break;
345
356
346
	case CB_CONF_LIST:
357
	case CB_CONF_LIST:
Lines 349-407 Link Here
349
	len -= opt_len;
360
	len -= opt_len;
350
    }
361
    }
351
362
352
    cbcp_resp(us);
363
    cbcp_sendresp(us);
353
}
364
}
354
365
355
static void
366
static void
356
cbcp_resp(us)
367
cbcp_sendresp(us)
357
    cbcp_state *us;
368
    cbcp_state *us;
358
{
369
{
359
    u_char cb_type;
370
    u_char cb_allowed;
360
    u_char buf[256];
371
    u_char buf[256];
361
    u_char *bufp = buf;
372
    u_char *bufp = buf;
362
    int len = 0;
373
    int len = 0;
363
374
364
    cb_type = us->us_allowed & us->us_type;
375
    cb_allowed = us->us_allowed;
365
    dbglog("cbcp_resp cb_type=%d", cb_type);
376
    CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp: available options: %d", cb_allowed));
366
377
367
#if 0
378
#if 0
368
    if (!cb_type)
379
    if (!cb_allowed)
369
        lcp_down(us->us_unit);
380
        lcp_down(us->us_unit);
370
#endif
381
#endif
371
382
372
    if (cb_type & ( 1 << CB_CONF_USER ) ) {
383
    if (cb_allowed & ( 1 << CB_CONF_USER ) ) {
373
	dbglog("cbcp_resp CONF_USER");
384
	us->us_type= ( 1 << CB_CONF_USER );
385
	CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp CONF_USER"));
374
	PUTCHAR(CB_CONF_USER, bufp);
386
	PUTCHAR(CB_CONF_USER, bufp);
375
	len = 3 + 1 + strlen(us->us_number) + 1;
387
	len = 3 + 1 + strlen(us->us_number) + 1;
376
	PUTCHAR(len , bufp);
388
	PUTCHAR(len , bufp);
377
	PUTCHAR(5, bufp); /* delay */
389
	PUTCHAR(us->us_delay, bufp);
378
	PUTCHAR(1, bufp);
390
	PUTCHAR(1, bufp);
379
	BCOPY(us->us_number, bufp, strlen(us->us_number) + 1);
391
	BCOPY(us->us_number, bufp, strlen(us->us_number) + 1);
380
	cbcp_send(us, CBCP_RESP, buf, len);
392
	cbcp_send(us, CBCP_RESP, buf, len);
381
	return;
393
	return;
382
    }
394
    }
383
395
384
    if (cb_type & ( 1 << CB_CONF_ADMIN ) ) {
396
    if (cb_allowed & ( 1 << CB_CONF_ADMIN ) ) {
385
	dbglog("cbcp_resp CONF_ADMIN");
397
	us->us_type= ( 1 << CB_CONF_ADMIN );
398
	CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp CONF_ADMIN"));
386
        PUTCHAR(CB_CONF_ADMIN, bufp);
399
        PUTCHAR(CB_CONF_ADMIN, bufp);
387
	len = 3;
400
	len = 3;
388
	PUTCHAR(len, bufp);
401
	PUTCHAR(len , bufp);
389
	PUTCHAR(5, bufp); /* delay */
402
	PUTCHAR(us->us_delay, bufp);
390
	cbcp_send(us, CBCP_RESP, buf, len);
403
	cbcp_send(us, CBCP_RESP, buf, len);
391
	return;
404
	return;
392
    }
405
    }
393
406
394
    if (cb_type & ( 1 << CB_CONF_NO ) ) {
407
    if (cb_allowed & ( 1 << CB_CONF_NO ) ) {
395
        dbglog("cbcp_resp CONF_NO");
408
	us->us_type= ( 1 << CB_CONF_NO );
409
	CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp CONF_NO"));
396
	PUTCHAR(CB_CONF_NO, bufp);
410
	PUTCHAR(CB_CONF_NO, bufp);
397
	len = 2;
411
	len = 3;
398
	PUTCHAR(len , bufp);
412
	PUTCHAR(len , bufp);
413
	PUTCHAR(0, bufp);
399
	cbcp_send(us, CBCP_RESP, buf, len);
414
	cbcp_send(us, CBCP_RESP, buf, len);
400
	start_networks(us->us_unit);
401
	return;
415
	return;
402
    }
416
    }
417
    syslog(LOG_WARNING, "cbcp_sendresp: no usable options available!");
403
}
418
}
404
419
420
/* Send the packet */
405
static void
421
static void
406
cbcp_send(us, code, buf, len)
422
cbcp_send(us, code, buf, len)
407
    cbcp_state *us;
423
    cbcp_state *us;
Lines 428-470 Link Here
428
    output(us->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
444
    output(us->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
429
}
445
}
430
446
447
/* Received Ack */
431
static void
448
static void
432
cbcp_recvack(us, pckt, len)
449
cbcp_recvack(us, pckt, len)
433
    cbcp_state *us;
450
    cbcp_state *us;
434
    u_char *pckt;
451
    u_char *pckt;
435
    int len;
452
    int len;
436
{
453
{
437
    u_char type, delay, addr_type;
454
    u_char type, addr_type;
438
    int opt_len;
455
    int opt_len;
439
    char address[256];
456
    char address[256];
440
457
458
    stop_iface = us;
459
    
441
    if (len) {
460
    if (len) {
442
        GETCHAR(type, pckt);
461
        GETCHAR(type, pckt);
443
	GETCHAR(opt_len, pckt);
462
	GETCHAR(opt_len, pckt);
444
     
463
     
445
	if (opt_len > 2)
464
	if (opt_len > 2)
446
	    GETCHAR(delay, pckt);
465
	    GETCHAR(us->us_delay, pckt);
447
466
448
	if (opt_len > 4) {
467
	if (opt_len > 4) {
449
	    GETCHAR(addr_type, pckt);
468
	    GETCHAR(addr_type, pckt);
450
	    memcpy(address, pckt, opt_len - 4);
469
	    memcpy(address, pckt, opt_len - 4);
451
	    address[opt_len - 4] = 0;
470
	    address[opt_len - 4] = 0;
452
	    if (address[0])
471
	    if (address[0])
453
	        dbglog("peer will call: %s", address);
472
		CBCPDEBUG((LOG_DEBUG, "peer will call: %s", address));
454
	}
473
	}
455
	if (type == CB_CONF_NO)
474
	if (type != CB_CONF_NO)
456
	    return;
475
	{
476
	    callback_in_progress = us->us_unit + 1;
477
	    callback_in_progress |=  CBCP_CLIENT;
478
	    cbcp_up(us);
479
	}
480
	else
481
	    network_phase(us->us_unit);
457
    }
482
    }
483
    else
484
	syslog(LOG_DEBUG, "cbcp: received bad ack - packet too small");
485
}
486
487
/* Make options
488
+   if auth req, options from callback-users file, else use CBCP_CONF_USER */
489
static void
490
cbcp_make_options (unit)
491
    int unit;
492
{
493
    cbcp_state *us = &cbcp[unit];
494
    FILE *userfile;
495
    struct stat sbuf;
496
    int best_fit, got_fit, newline;
497
    char  uname[ 256 ], option[ 256 ];    
498
499
    us->us_id = 1;
500
    us->us_count = 0;
501
    us->us_delay = 5; /* Default delay 5 seconds */
502
    if ( *peer_authname ) { /* Username available */
503
	userfile = fopen( _PATH_CBCP_USERS, "r" );
504
        if ( userfile == NULL ) {
505
	    syslog( LOG_ERR, "Can't open callback user file: %s %m",
506
                    _PATH_CBCP_USERS );
507
            syslog( LOG_WARNING, "Allow user definied callback." );
508
            us->us_allowed = ( 1 << CB_CONF_USER );
509
        }
510
	else
511
	{
512
            if ( fstat(fileno(userfile), &sbuf) < 0) {
513
                syslog( LOG_WARNING, "Cannot stat userfile file %s: %m",
514
                	_PATH_CBCP_USERS );
515
            }
516
	    else
517
		if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) {
518
            	    syslog( LOG_WARNING, "Warning - user file %s has world and/or group access",
519
                	    _PATH_CBCP_USERS );
520
        	}
521
522
            us->us_allowed = ( 1 << CB_CONF_NO ); /* Assume, no callback allowed */
523
524
            if ( getword(userfile, uname, &newline, _PATH_CBCP_USERS) ) {  /* file not empty */
525
                newline = 1;
526
                best_fit = 0;
527
                *option = 0;
528
                for (;;) {
529
                    /*
530
                     * Skip until we find a word at the start of a line.
531
                     */
532
                    while ( !newline && getword(userfile, uname, 
533
                            &newline, _PATH_CBCP_USERS))
534
                        ;
535
                    if ( !newline )
536
                        break;          /* got to end of file */
537
538
                    /*
539
                     * Got a user - check if it's a match or a wildcard.
540
                     */
541
                    got_fit = cbcp_check_user( peer_authname, uname );
542
                    if ( got_fit <= best_fit ) {
543
                        newline = 0;
544
                        continue;
545
                    }
546
                
547
                    /* Read the options */
548
                    best_fit = got_fit;
549
                    if ( getword(userfile, option, &newline, _PATH_CBCP_USERS) )
550
                        break;
551
                        
552
                    if ( newline )
553
                        *option = 0;
554
555
                    if ( best_fit == 100 )
556
                        break;
557
                }
558
            }
559
560
            switch ( *option ) {
561
        	case '-':
562
		    us->us_allowed = ( 1 << CB_CONF_NO );
563
		    break;
564
        	case '*':
565
        	case  0:
566
		    us->us_allowed = ( 1 << CB_CONF_USER );
567
		    break;
568
        	default:
569
		    us->us_allowed = ( 1 << CB_CONF_ADMIN );
570
                    us->us_number = strdup( option );
571
		    break;
572
            }
573
            fclose( userfile );
574
        }    
575
     }
576
     else
577
        us->us_allowed = ( 1 << CB_CONF_USER );
578
	
579
    if (cbcp_init_hook)
580
        cbcp_init_hook( us );
581
     
582
     cbcp_sendreq( us );
583
}    
458
584
459
    cbcp_up(us);
585
/* make cbcp request packet & send it */
586
static void
587
cbcp_sendreq (arg)
588
    void *arg;
589
{
590
    cbcp_state *us=(cbcp_state *)arg;
591
    u_char cb_allow = us->us_allowed;
592
    u_char buf[256];
593
    u_char *bufp = buf;
594
    int len = 0;
595
596
    us->us_count++;
597
    if ( us->us_count<=CBCP_MAXRETRY )
598
	TIMEOUT( cbcp_sendreq, arg, CBCP_DEFTIMEOUT );
599
    else
600
    {
601
        lcp_close(0, "Sorry, CBCP not responding.");
602
        return;
603
    }
604
    CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq cb_allowed=%d", cb_allow));
605
606
    if ( cb_allow & ( 1 << CB_CONF_USER ) ) {
607
        CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq CONF_USER"));
608
        PUTCHAR(CB_CONF_USER, bufp);
609
        len+=3;
610
        PUTCHAR(3 , bufp);
611
        PUTCHAR(us->us_delay, bufp);
612
    }
613
614
    if ( cb_allow & ( 1 << CB_CONF_ADMIN ) ) {
615
	CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq CONF_ADMIN"));
616
	PUTCHAR(CB_CONF_ADMIN, bufp);
617
        len += 3;
618
        PUTCHAR(3 , bufp);
619
        PUTCHAR(us->us_delay, bufp);
620
    }
621
622
    if ( cb_allow & ( 1 << CB_CONF_NO ) ) {
623
        CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq CONF_NO"));
624
        PUTCHAR(CB_CONF_NO, bufp);
625
        len += 3;
626
        PUTCHAR(3 , bufp);
627
        PUTCHAR(us->us_delay, bufp);
628
    }
629
630
    if ( len )
631
        cbcp_send(us, CBCP_REQ, buf, len);
632
    else
633
    {
634
        syslog(LOG_WARNING, "cbcp: no available options to client!");    
635
    }  
636
}  
637
638
/* Received CBCP response, make ACK */
639
static void
640
cbcp_recvresp (us, pckt, len)
641
    cbcp_state *us;
642
    char *pckt;
643
    int len;
644
{
645
    u_char type, addr_type;
646
    int opt_len;
647
    char address[256];
648
649
    if ( len ) {
650
        GETCHAR(type, pckt);
651
        GETCHAR(opt_len, pckt);
652
653
        if ( !((1 << type) & us->us_allowed) ) {
654
            CBCPDEBUG((LOG_DEBUG, "CBCP received options not allowed on server!"));
655
            return;         
656
        }
657
658
        if ( (type!= CB_CONF_NO ) &&
659
             (type!= CB_CONF_USER ) &&
660
             (type!= CB_CONF_ADMIN ) ) {
661
            syslog(LOG_DEBUG, "CBCP received BAD Response: too more or unknown options %d",type);
662
            return;         
663
        }
664
665
        UNTIMEOUT( cbcp_sendreq, us );
666
        us->us_count = 0;
667
668
        if ( opt_len > 2 )
669
            GETCHAR(us->us_delay, pckt)
670
        if ( us->us_delay < 5 ) 
671
            us->us_delay = 5;
672
673
        if ( opt_len > 4 ) {
674
            GETCHAR(addr_type, pckt); /*  Address Type mezo elvesztve  !!! */
675
            memcpy(address, pckt, opt_len - 4);
676
            address[opt_len - 4] = 0;
677
            if ( address[0] )
678
                syslog(LOG_DEBUG, "peer will callback the client on: %s", address);
679
            us->us_number=strdup( address );
680
        }
681
682
        us->us_type = ( 1 << type );    
683
        cbcp_sendack( us );
684
    }
685
    else
686
    {
687
        syslog(LOG_DEBUG, "CBCP received BAD Response: size to small");
688
    }
689
}
690
691
/* Send the CBCP_ACK packet */
692
static void
693
cbcp_sendack (arg)
694
    void *arg;
695
{
696
    cbcp_state *us= (cbcp_state *)arg;
697
    u_char cb_type;
698
    u_char buf[256];
699
    u_char *bufp = buf;
700
    int len = 0;
701
702
    stop_iface = (cbcp_state *)arg;
703
    cb_type = us->us_type;
704
705
    CBCPDEBUG((LOG_DEBUG, "cbcp_sendack cb_type=%d", cb_type));
706
707
    us->us_count++;
708
    if ( us->us_count<=CBCP_MAXRETRY )
709
        TIMEOUT( cbcp_sendack, arg, CBCP_DEFTIMEOUT );
710
    else
711
    {
712
        lcp_close(0, "Sorry, CBCP not responding.");
713
        return;
714
    }
715
716
#if 0
717
    if ( !cb_type )
718
        lcp_down(us->us_unit);
719
#endif
720
721
    if ( cb_type == (1 << CB_CONF_USER ) ) {
722
        CBCPDEBUG((LOG_DEBUG, "cbcp_sendack CONF_USER"));
723
        PUTCHAR(CB_CONF_USER, bufp);
724
        len = 3 + 1 + strlen(us->us_number) + 1;
725
        PUTCHAR(len , bufp);
726
        PUTCHAR(us->us_delay, bufp); /* delay */
727
        PUTCHAR(1, bufp); /* Elvesztett byte... */
728
        BCOPY(us->us_number, bufp, strlen(us->us_number) + 1);
729
        cbcp_send(us, CBCP_ACK, buf, len);
730
/*      lcp_close( 2, "Illegal, but required to server..." ); */
731
        callback_in_progress = us->us_unit + 1;
732
        return;
733
    }
734
735
    if ( cb_type == (1 << CB_CONF_ADMIN ) ) {
736
        CBCPDEBUG((LOG_DEBUG, "cbcp_sendack CONF_ADMIN"));
737
        PUTCHAR(CB_CONF_ADMIN, bufp);
738
        len = 3;
739
        PUTCHAR(len , bufp);
740
        PUTCHAR(us->us_delay, bufp); /* delay */
741
        PUTCHAR(0, bufp);
742
        cbcp_send(us, CBCP_ACK, buf, len);
743
/*      lcp_close( 2, "Illegal, but required to server..." ); */
744
        callback_in_progress = us->us_unit + 1;
745
        return;
746
    }
747
748
    if ( cb_type == (1 << CB_CONF_NO ) ) {
749
        CBCPDEBUG((LOG_DEBUG, "cbcp_sendack CONF_NO"));
750
        PUTCHAR(CB_CONF_NO, bufp);
751
        len = 3;
752
        PUTCHAR(len , bufp);
753
        PUTCHAR(0, bufp);
754
        cbcp_send(us, CBCP_ACK, buf, len);
755
        if (us->us_count<=1)
756
            network_phase(us->us_unit);
757
        return;
758
    }
759
760
    syslog(LOG_DEBUG, "CBCP - Bad options in Ack routine.");
761
762
}
763
764
/* CBCP coming succesful up */
765
void cbcp_stop()
766
{
767
    if ( stop_iface && lcp_allowoptions[stop_iface->us_unit].neg_cbcp )
768
    {
769
        UNTIMEOUT( cbcp_sendack, stop_iface );
770
        cbcp_start_callback( stop_iface );
771
    }
460
}
772
}
461
773
462
/* ok peer will do callback */
774
/* The server side coming up & client 'ack-ed' */
775
void cbcp_start_callback (us)
776
    cbcp_state *us;
777
{
778
    lcp_allowoptions[us->us_unit].neg_cbcp=0;
779
780
    CBCPDEBUG((LOG_DEBUG, "cbcp_start_callback running"));
781
}
782
783
/* The client side coming up: server allowed the callback */
463
static void
784
static void
464
cbcp_up(us)
785
cbcp_up(us)
465
    cbcp_state *us;
786
    cbcp_state *us;
466
{
787
{
467
    persist = 0;
788
    lcp_wantoptions[us->us_unit].neg_cbcp=0;
468
    lcp_close(0, "Call me back, please");
789
    CBCPDEBUG((LOG_DEBUG, "cbcp_up called"));
469
    status = EXIT_CALLBACK;
790
    lcp_close(us->us_unit, "Call me back, please");
791
}
792
793
/* The main module gets the script with parameters to run */
794
char *cbcp_get_script()
795
{
796
    cbcp_state *us = &cbcp[(callback_in_progress & CBCP_NCLIENT)-1];
797
    char script[ 256 ];
798
799
    if ( callback_in_progress & CBCP_CLIENT )
800
        sprintf( script, "%s %d", _PATH_CBCP_CLIENT, us->us_delay );
801
    else
802
        sprintf( script, "%s %d %s", _PATH_CBCP_SERVER, 
803
        us->us_delay, us->us_number );
804
805
    return strdup( script );        
806
}
807
808
/* give me the hit rate. wild cars '*?' valids */
809
int cbcp_check_user ( user, mask )
810
    char *user;
811
    char *mask;
812
{
813
    char *curr_user = user;
814
    char *curr_mask = mask;
815
    char *find, backp = 0;
816
    int  count, len = 0;
817
818
    if ( !strcasecmp( user, mask ) )
819
        return 100;
820
821
    if ( !strcmp( mask, "*" ) )
822
        return 1;
823
    if ( !*user )
824
        return 0;
825
826
    count = 0;
827
828
    while(( find = strpbrk( curr_mask, "*?" )) != 0 ) {
829
        if ( find != curr_mask ) {
830
            len = find - curr_mask;
831
            if ( strncmp( curr_user, curr_mask, len ) )
832
                break;
833
        }
834
835
        curr_mask += len + 1;
836
        curr_user += len;
837
        count += len;
838
        if ( *curr_user == 0 )
839
            break;
840
841
        if ( *find == '?' ) {
842
            curr_user++;
843
            if ( *curr_user == 0 )
844
                break;
845
        } else {
846
            if ( *curr_mask == 0 )
847
                break;
848
849
            if ( ( find = strpbrk( curr_mask, "*?" )) != 0 ) {
850
                backp = *find;
851
                *find = 0;
852
            }
853
            curr_user = strstr( curr_user, curr_mask );
854
            if ( find )
855
                *find = backp;
856
            if ( !curr_user )
857
                break;
858
859
            find = strpbrk( curr_mask, "*?" );
860
            if ( find )
861
                len = find - curr_mask;
862
            else
863
                len = strlen( curr_mask );
864
865
            curr_mask += len;
866
            curr_user += len;
867
            count += len;
868
        }
869
    }
870
871
    if ( *curr_user && *curr_mask && !strcmp( curr_user, curr_mask ) )
872
        count += strlen( curr_user );
873
874
    return ( count * 100 / strlen( user ) );
470
}
875
}
(-)ppp-2.4.2.orig/pppd/cbcp.h (+12 lines)
Lines 6-11 Link Here
6
    u_char us_id;		/* Current id */
6
    u_char us_id;		/* Current id */
7
    u_char us_allowed;
7
    u_char us_allowed;
8
    int    us_type;
8
    int    us_type;
9
    u_char us_delay;
10
    u_char us_count;
9
    char   *us_number;    /* Telefone Number */
11
    char   *us_number;    /* Telefone Number */
10
} cbcp_state;
12
} cbcp_state;
11
13
Lines 18-26 Link Here
18
#define CBCP_REQ    1
20
#define CBCP_REQ    1
19
#define CBCP_RESP   2
21
#define CBCP_RESP   2
20
#define CBCP_ACK    3
22
#define CBCP_ACK    3
23
#define CBCP_DEFTIMEOUT        5
24
#define CBCP_MAXRETRY  50
25
#define CBCP_CLIENT    0x8000
26
#define CBCP_NCLIENT   0x7fff
27
28
#define CBCPDEBUG(x)   /*if (debug)*/ syslog x
21
29
22
#define CB_CONF_NO     1
30
#define CB_CONF_NO     1
23
#define CB_CONF_USER   2
31
#define CB_CONF_USER   2
24
#define CB_CONF_ADMIN  3
32
#define CB_CONF_ADMIN  3
25
#define CB_CONF_LIST   4
33
#define CB_CONF_LIST   4
34
35
char *cbcp_get_script __P(());
36
void  cbcp_stop __P(());
37
26
#endif
38
#endif
(-)ppp-2.4.2.orig/pppd/ipcp.c (+8 lines)
Lines 61-66 Link Here
61
#include "ipcp.h"
61
#include "ipcp.h"
62
#include "pathnames.h"
62
#include "pathnames.h"
63
63
64
#ifdef CBCP_SUPPORT
65
#include "cbcp.h"
66
#endif
67
64
static const char rcsid[] = RCSID;
68
static const char rcsid[] = RCSID;
65
69
66
/* global vars */
70
/* global vars */
Lines 1316-1321 Link Here
1316
    u_char maxslotindex, cflag;
1320
    u_char maxslotindex, cflag;
1317
    int d;
1321
    int d;
1318
1322
1323
#ifdef CBCP_SUPPORT
1324
    cbcp_stop();
1325
#endif
1326
1319
    /*
1327
    /*
1320
     * Reset all his options.
1328
     * Reset all his options.
1321
     */
1329
     */
(-)ppp-2.4.2.orig/pppd/ipv6cp.c (+8 lines)
Lines 167-172 Link Here
167
#include "magic.h"
167
#include "magic.h"
168
#include "pathnames.h"
168
#include "pathnames.h"
169
169
170
#ifdef CBCP_SUPPORT
171
#include "cbcp.h"
172
#endif
173
170
static const char rcsid[] = RCSID;
174
static const char rcsid[] = RCSID;
171
175
172
/* global vars */
176
/* global vars */
Lines 900-905 Link Here
900
    u_char *ucp = inp;		/* Pointer to current output char */
904
    u_char *ucp = inp;		/* Pointer to current output char */
901
    int l = *len;		/* Length left */
905
    int l = *len;		/* Length left */
902
906
907
#ifdef CBCP_SUPPORT
908
    cbcp_stop();
909
#endif
910
903
    /*
911
    /*
904
     * Reset all his options.
912
     * Reset all his options.
905
     */
913
     */
(-)ppp-2.4.2.orig/pppd/ipxcp.c (+8 lines)
Lines 62-67 Link Here
62
#include "pathnames.h"
62
#include "pathnames.h"
63
#include "magic.h"
63
#include "magic.h"
64
64
65
#ifdef CBCP_SUPPORT
66
#include "cbcp.h"
67
#endif
68
65
static const char rcsid[] = RCSID;
69
static const char rcsid[] = RCSID;
66
70
67
/* global vars */
71
/* global vars */
Lines 998-1003 Link Here
998
    u_char *ucp = inp;		/* Pointer to current output char */
1002
    u_char *ucp = inp;		/* Pointer to current output char */
999
    int l = *len;		/* Length left */
1003
    int l = *len;		/* Length left */
1000
1004
1005
#ifdef CBCP_SUPPORT
1006
    cbcp_stop();
1007
#endif
1008
1001
    /*
1009
    /*
1002
     * Reset all his options.
1010
     * Reset all his options.
1003
     */
1011
     */
(-)ppp-2.4.2.orig/pppd/lcp.c (-3 / +11 lines)
Lines 365-373 Link Here
365
    ao->neg_magicnumber = 1;
365
    ao->neg_magicnumber = 1;
366
    ao->neg_pcompression = 1;
366
    ao->neg_pcompression = 1;
367
    ao->neg_accompression = 1;
367
    ao->neg_accompression = 1;
368
#ifdef CBCP_SUPPORT
368
    ao->neg_cbcp = 0;
369
    ao->neg_cbcp = 1;
370
#endif
371
    ao->neg_endpoint = 1;
369
    ao->neg_endpoint = 1;
372
}
370
}
373
371
Lines 1767-1772 Link Here
1767
		break;
1765
		break;
1768
	    }
1766
	    }
1769
	    ho->neg_accompression = 1;
1767
	    ho->neg_accompression = 1;
1768
            break;
1769
1770
        case CI_CALLBACK:
1771
            LCPDEBUG((LOG_INFO, "lcp_reqci: rcvd CALLBACK"));
1772
            if (!ao->neg_cbcp ||
1773
                cilen != CILEN_CHAR ) {
1774
                orc = CONFREJ;
1775
                break;
1776
            }
1777
            ho->neg_cbcp = 1;
1770
	    break;
1778
	    break;
1771
1779
1772
	case CI_MRRU:
1780
	case CI_MRRU:
(-)ppp-2.4.2.orig/pppd/main.c (+77 lines)
Lines 159-164 Link Here
159
char **script_env;		/* Env. variable values for scripts */
159
char **script_env;		/* Env. variable values for scripts */
160
int s_env_nalloc;		/* # words avail at script_env */
160
int s_env_nalloc;		/* # words avail at script_env */
161
161
162
#ifdef CBCP_SUPPORT
163
int callback_in_progress;      /* Callback running */
164
#endif
165
162
u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */
166
u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */
163
u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
167
u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
164
168
Lines 283-288 Link Here
283
    struct protent *protp;
287
    struct protent *protp;
284
    char numbuf[16];
288
    char numbuf[16];
285
289
290
#ifdef CBCP_SUPPORT
291
    char *connector;
292
#endif
293
286
    link_stats_valid = 0;
294
    link_stats_valid = 0;
287
    new_phase(PHASE_INITIALIZE);
295
    new_phase(PHASE_INITIALIZE);
288
296
Lines 544-549 Link Here
544
552
545
	add_fd(fd_ppp);
553
	add_fd(fd_ppp);
546
	lcp_open(0);		/* Start protocol */
554
	lcp_open(0);		/* Start protocol */
555
#ifdef CBCP_SUPPORT
556
        for(callback_in_progress=1;callback_in_progress;) {
557
            callback_in_progress=0;
558
#endif
547
	status = EXIT_NEGOTIATION_FAILED;
559
	status = EXIT_NEGOTIATION_FAILED;
548
	new_phase(PHASE_ESTABLISH);
560
	new_phase(PHASE_ESTABLISH);
549
	while (phase != PHASE_DEAD) {
561
	while (phase != PHASE_DEAD) {
Lines 572-577 Link Here
572
		warn("unable to delete pid file %s: %m", pidfilename);
584
		warn("unable to delete pid file %s: %m", pidfilename);
573
	    pidfilename[0] = 0;
585
	    pidfilename[0] = 0;
574
	}
586
	}
587
#ifdef CBCP_SUPPORT
588
            if (callback_in_progress){
589
            connector = NULL;
590
                    cbcp_stop();
591
                    remove_fd(fd_ppp);
592
                    clean_check();
593
                    the_channel->disestablish_ppp(devfd);
594
                    fd_ppp = -1;
595
596
                if (!hungup){
597
                    lcp_lowerdown(0);
598
                } else {
599
                    tty_close_fds();
600
                    setup_serial(connector);                
601
                }
602
                
603
         devfd = callback();                
604
                
605
        /* set up the serial device as a ppp interface */
606
        tdb_writelock(pppdb);
607
        fd_ppp = the_channel->establish_ppp(devfd);
608
        if (fd_ppp < 0) {
609
            tdb_writeunlock(pppdb);
610
            status = EXIT_FATAL_ERROR;
611
            goto disconnect;
612
        }
613
614
        if (!demand && ifunit >= 0)
615
            set_ifunit(1);
616
        tdb_writeunlock(pppdb);
617
        /*
618
        * Start opening the connection and wait for
619
	* incoming events (reply, timeout, etc.).
620
        */
621
        notice("Connect: %s <--> %s", ifname, ppp_devnam);
622
        gettimeofday(&start_time, NULL);
623
        link_stats_valid = 0;
624
        script_unsetenv("CONNECT_TIME");
625
        script_unsetenv("BYTES_SENT");
626
        script_unsetenv("BYTES_RCVD");
627
        lcp_lowerup(0);
628
        /*
629
        * If we are initiating this connection, wait for a short
630
        * time for something from the peer.  This can avoid bouncing
631
        * our packets off his tty before he has it set up.
632
        */
633
    	add_fd(fd_ppp);
634
        if (listen_time != 0) {
635
            struct timeval t;
636
            t.tv_sec = listen_time / 1000;
637
            t.tv_usec = listen_time % 1000;
638
            wait_input(&t);
639
        }
640
            
641
        /*if (connector != NULL || ptycommand != NULL) {
642
            struct timeval t;
643
            t.tv_sec = 1;
644
            t.tv_usec = 0;
645
            wait_input(&t);
646
        }*/
647
 
648
        lcp_open(0);            /* Start protocol */
649
	}
650
    }       
651
#endif
575
652
576
	/*
653
	/*
577
	 * If we may want to bring the link up again, transfer
654
	 * If we may want to bring the link up again, transfer
(-)ppp-2.4.2.orig/pppd/Makefile.linux (-1 / +1 lines)
Lines 5-11 Link Here
5
5
6
# Default installation locations
6
# Default installation locations
7
BINDIR = $(DESTDIR)/usr/sbin
7
BINDIR = $(DESTDIR)/usr/sbin
8
MANDIR = $(DESTDIR)/usr/man
8
MANDIR = $(DESTDIR)/usr/share/man
9
INCDIR = $(DESTDIR)/usr/include
9
INCDIR = $(DESTDIR)/usr/include
10
10
11
TARGETS = pppd
11
TARGETS = pppd
(-)ppp-2.4.2.orig/pppd/options.c (+35 lines)
Lines 66-71 Link Here
66
char *strdup __P((char *));
66
char *strdup __P((char *));
67
#endif
67
#endif
68
68
69
#ifdef CBCP_SUPPORT
70
#include "fsm.h"
71
#include "lcp.h"
72
#include "cbcp.h"
73
#endif
74
69
static const char rcsid[] = RCSID;
75
static const char rcsid[] = RCSID;
70
76
71
struct option_value {
77
struct option_value {
Lines 165-170 Link Here
165
static int n_arguments __P((option_t *));
171
static int n_arguments __P((option_t *));
166
static int number_option __P((char *, u_int32_t *, int));
172
static int number_option __P((char *, u_int32_t *, int));
167
173
174
#ifdef CBCP_SUPPORT
175
static int setcbcp __P((char **));
176
#endif
177
168
/*
178
/*
169
 * Structure to store extra lists of options.
179
 * Structure to store extra lists of options.
170
 */
180
 */
Lines 304-309 Link Here
304
      "set filter for active pkts", OPT_PRIO },
314
      "set filter for active pkts", OPT_PRIO },
305
#endif
315
#endif
306
316
317
#ifdef CBCP_SUPPORT
318
    { "callback", o_special, setcbcp,
319
      "Callback request to server - OR - calling back the client" },
320
#endif
321
307
#ifdef MAXOCTETS
322
#ifdef MAXOCTETS
308
    { "maxoctets", o_int, &maxoctets,
323
    { "maxoctets", o_int, &maxoctets,
309
      "Set connection traffic limit",
324
      "Set connection traffic limit",
Lines 1594-1596 Link Here
1594
    return 0;
1609
    return 0;
1595
}
1610
}
1596
#endif /* PLUGIN */
1611
#endif /* PLUGIN */
1612
1613
#ifdef CBCP_SUPPORT
1614
static int
1615
setcbcp(argv)
1616
    char **argv;
1617
{
1618
    cbcp[0].us_number = strdup(*argv);
1619
    if (cbcp_protent.enabled_flag)
1620
        novm("Only one callback parameter supported!");
1621
    if (cbcp[0].us_number == 0)        
1622
        novm("callback number");
1623
    if (!strcmp(cbcp[0].us_number,"server")){
1624
        lcp_allowoptions[0].neg_cbcp = 1;
1625
    } else {
1626
        lcp_wantoptions[0].neg_cbcp = 1;
1627
    }
1628
    cbcp_protent.enabled_flag = 1;
1629
    return 1;
1630
}
1631
#endif
(-)ppp-2.4.2.orig/pppd/pathnames.h (+7 lines)
Lines 44-49 Link Here
44
#define _PATH_IPXDOWN	 _ROOT_PATH "/etc/ppp/ipx-down"
44
#define _PATH_IPXDOWN	 _ROOT_PATH "/etc/ppp/ipx-down"
45
#endif /* IPX_CHANGE */
45
#endif /* IPX_CHANGE */
46
46
47
#ifdef CBCP_SUPPORT
48
#define _PATH_CBCP_SERVER _ROOT_PATH "/etc/ppp/callback-server"
49
#define _PATH_CBCP_CLIENT _ROOT_PATH "/etc/ppp/callback-client"
50
#define _PATH_CBCP_USERS  _ROOT_PATH "/etc/ppp/callback-users"
51
#define _PATH_CBCP       _ROOT_PATH "/etc/ppp/callback"
52
#endif /* CBCP_SUPPORT */
53
47
#ifdef __STDC__
54
#ifdef __STDC__
48
#define _PATH_PPPDB	_ROOT_PATH _PATH_VARRUN "pppd.tdb"
55
#define _PATH_PPPDB	_ROOT_PATH _PATH_VARRUN "pppd.tdb"
49
#else /* __STDC__ */
56
#else /* __STDC__ */
(-)ppp-2.4.2.orig/pppd/plugins/radius/Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
# Copyright 2002 Roaring Penguin Software Inc.
3
# Copyright 2002 Roaring Penguin Software Inc.
4
#
4
#
5
5
6
MANDIR=/usr/man
6
MANDIR=/usr/share/man
7
PLUGIN=radius.so radattr.so radrealms.so
7
PLUGIN=radius.so radattr.so radrealms.so
8
CFLAGS=$(COPTS) -I../.. -I../../../include -Iradiusclient/include
8
CFLAGS=$(COPTS) -I../.. -I../../../include -Iradiusclient/include
9
9
(-)ppp-2.4.2.orig/pppd/plugins/radius/Makefile.linux (-1 / +1 lines)
Lines 3-9 Link Here
3
# Copyright 2002 Roaring Penguin Software Inc.
3
# Copyright 2002 Roaring Penguin Software Inc.
4
#
4
#
5
5
6
MANDIR=/usr/man
6
MANDIR=/usr/share/man
7
PLUGIN=radius.so radattr.so radrealms.so
7
PLUGIN=radius.so radattr.so radrealms.so
8
CFLAGS=$(COPTS) -I../.. -I../../../include -Iradiusclient/include
8
CFLAGS=$(COPTS) -I../.. -I../../../include -Iradiusclient/include
9
9
(-)ppp-2.4.2.orig/pppd/plugins/radius/radiusclient/config.h.in (-1 / +1 lines)
Lines 1-6 Link Here
1
/* config.h.in.  Generated automatically from configure.in by autoheader.  */
1
/* config.h.in.  Generated automatically from configure.in by autoheader.  */
2
/*
2
/*
3
 * $Id: config.h.in,v 1.3 2002/07/25 16:29:16 dfs Exp $
3
 * $Id: acconfig.h,v 1.1 2002/01/22 16:03:00 dfs Exp $
4
 *
4
 *
5
 * Copyright (C) 1996,1997 Lars Fenneberg
5
 * Copyright (C) 1996,1997 Lars Fenneberg
6
 *
6
 *
(-)ppp-2.4.2.orig/pppd/pppd.8 (+8 lines)
Lines 87-92 Link Here
87
or include .. as a pathname component.  The format of the options file
87
or include .. as a pathname component.  The format of the options file
88
is described below.
88
is described below.
89
.TP
89
.TP
90
.B callback \fIserver/number
91
When compiled with the CBCP extensions (-DCBCP_SUPPORT) the ppp daemon
92
can act as a client to servers which provide CBCP-protocol callback
93
negotiation or act as a \fIserver\fR. It reads its options from 
94
/etc/ppp/callback-users and invokes /etc/ppp/callback-server
95
when dialing out. Otherwise it will invoke /etc/ppp/callback-client
96
to wait for a call.
97
.TP
90
.B connect \fIscript
98
.B connect \fIscript
91
Usually there is something which needs to be done to prepare the link
99
Usually there is something which needs to be done to prepare the link
92
before the PPP protocol can be started; for instance, with a dial-up
100
before the PPP protocol can be started; for instance, with a dial-up
(-)ppp-2.4.2.orig/pppd/pppd.h (+12 lines)
Lines 71-76 Link Here
71
#include "eui64.h"
71
#include "eui64.h"
72
#endif
72
#endif
73
73
74
/* for cbcp_init_hook */
75
#include "cbcp.h"
76
77
74
/*
78
/*
75
 * Limits.
79
 * Limits.
76
 */
80
 */
Lines 334-339 Link Here
334
extern struct	bpf_program active_filter; /* Filter for link-active pkts */
338
extern struct	bpf_program active_filter; /* Filter for link-active pkts */
335
#endif
339
#endif
336
340
341
#ifdef CBCP_SUPPORT
342
extern int     callback_in_progress;   /*Callback running*/
343
#endif
344
337
#ifdef MSLANMAN
345
#ifdef MSLANMAN
338
extern bool	ms_lanman;	/* Use LanMan password instead of NT */
346
extern bool	ms_lanman;	/* Use LanMan password instead of NT */
339
				/* Has meaning only with MS-CHAP challenges */
347
				/* Has meaning only with MS-CHAP challenges */
Lines 488-493 Link Here
488
496
489
/* Procedures exported from tty.c. */
497
/* Procedures exported from tty.c. */
490
void tty_init __P((void));
498
void tty_init __P((void));
499
void setup_serial __P((char *));
500
int callback __P ((void));
491
501
492
/* Procedures exported from utils.c. */
502
/* Procedures exported from utils.c. */
493
void log_packet __P((u_char *, int, char *, int));
503
void log_packet __P((u_char *, int, char *, int));
Lines 513-518 Link Here
513
				/* read a complete buffer */
523
				/* read a complete buffer */
514
524
515
/* Procedures exported from auth.c */
525
/* Procedures exported from auth.c */
526
void network_phase __P((int));	  /* the dataexchanger CP-s goung up */
516
void link_required __P((int));	  /* we are starting to use the link */
527
void link_required __P((int));	  /* we are starting to use the link */
517
void link_terminated __P((int));  /* we are finished with the link */
528
void link_terminated __P((int));  /* we are finished with the link */
518
void link_down __P((int));	  /* the LCP layer has left the Opened state */
529
void link_down __P((int));	  /* the LCP layer has left the Opened state */
Lines 688-693 Link Here
688
extern void (*ip_up_hook) __P((void));
699
extern void (*ip_up_hook) __P((void));
689
extern void (*ip_down_hook) __P((void));
700
extern void (*ip_down_hook) __P((void));
690
extern void (*ip_choose_hook) __P((u_int32_t *));
701
extern void (*ip_choose_hook) __P((u_int32_t *));
702
extern void (*cbcp_init_hook) __P((cbcp_state *));
691
703
692
extern int (*chap_check_hook) __P((void));
704
extern int (*chap_check_hook) __P((void));
693
extern int (*chap_passwd_hook) __P((char *user, char *passwd));
705
extern int (*chap_passwd_hook) __P((char *user, char *passwd));
(-)ppp-2.4.2.orig/pppd/tty.c (-68 / +114 lines)
Lines 101-106 Link Here
101
#include "pppd.h"
101
#include "pppd.h"
102
#include "fsm.h"
102
#include "fsm.h"
103
#include "lcp.h"
103
#include "lcp.h"
104
#ifdef CBCP_SUPPORT
105
#include "cbcp.h"
106
#endif /* CBCP_SUPPORT */
104
107
105
void tty_process_extra_options __P((void));
108
void tty_process_extra_options __P((void));
106
void tty_check_options __P((void));
109
void tty_check_options __P((void));
Lines 131-136 Link Here
131
static int ttyfd;		/* Serial port file descriptor */
134
static int ttyfd;		/* Serial port file descriptor */
132
static char speed_str[16];	/* Serial port speed as string */
135
static char speed_str[16];	/* Serial port speed as string */
133
136
137
/*static void setup_serial __P();*/
138
134
mode_t tty_mode = (mode_t)-1;	/* Original access permissions to tty */
139
mode_t tty_mode = (mode_t)-1;	/* Original access permissions to tty */
135
int baud_rate;			/* Actual bits/second for serial device */
140
int baud_rate;			/* Actual bits/second for serial device */
136
char *callback_script;		/* script for doing callback */
141
char *callback_script;		/* script for doing callback */
Lines 511-520 Link Here
511
int connect_tty()
516
int connect_tty()
512
{
517
{
513
	char *connector;
518
	char *connector;
514
	int fdflags;
515
	struct stat statbuf;
516
	char numbuf[16];
519
	char numbuf[16];
517
520
521
	connector = doing_callback ? callback_script : connect_script;
522
518
	/*
523
	/*
519
	 * Get a pty master/slave pair if the pty, notty, socket,
524
	 * Get a pty master/slave pair if the pty, notty, socket,
520
	 * or record options were specified.
525
	 * or record options were specified.
Lines 542-613 Link Here
542
		locked = 1;
547
		locked = 1;
543
	}
548
	}
544
549
545
	/*
550
	setup_serial(connector);
546
	 * Open the serial device and set it up to be the ppp interface.
547
	 * First we open it in non-blocking mode so we can set the
548
	 * various termios flags appropriately.  If we aren't dialling
549
	 * out and we want to use the modem lines, we reopen it later
550
	 * in order to wait for the carrier detect signal from the modem.
551
	 */
552
	hungup = 0;
553
	kill_link = 0;
554
	connector = doing_callback? callback_script: connect_script;
555
	if (devnam[0] != 0) {
556
		for (;;) {
557
			/* If the user specified the device name, become the
558
			   user before opening it. */
559
			int err, prio;
560
561
			prio = privopen? OPRIO_ROOT: tty_options[0].priority;
562
			if (prio < OPRIO_ROOT)
563
				seteuid(uid);
564
			ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
565
			err = errno;
566
			if (prio < OPRIO_ROOT)
567
				seteuid(0);
568
			if (ttyfd >= 0)
569
				break;
570
			errno = err;
571
			if (err != EINTR) {
572
				error("Failed to open %s: %m", devnam);
573
				status = EXIT_OPEN_FAILED;
574
			}
575
			if (!persist || err != EINTR)
576
				return -1;
577
		}
578
		real_ttyfd = ttyfd;
579
		if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
580
		    || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
581
			warn("Couldn't reset non-blocking mode on device: %m");
582
583
#ifndef __linux__
584
		/*
585
		 * Linux 2.4 and above blocks normal writes to the tty
586
		 * when it is in PPP line discipline, so this isn't needed.
587
		 */
588
		/*
589
		 * Do the equivalent of `mesg n' to stop broadcast messages.
590
		 */
591
		if (fstat(ttyfd, &statbuf) < 0
592
		    || fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) {
593
			warn("Couldn't restrict write permissions to %s: %m", devnam);
594
		} else
595
			tty_mode = statbuf.st_mode;
596
#endif /* __linux__ */
597
598
		/*
599
		 * Set line speed, flow control, etc.
600
		 * If we have a non-null connection or initializer script,
601
		 * on most systems we set CLOCAL for now so that we can talk
602
		 * to the modem before carrier comes up.  But this has the
603
		 * side effect that we might miss it if CD drops before we
604
		 * get to clear CLOCAL below.  On systems where we can talk
605
		 * successfully to the modem with CLOCAL clear and CD down,
606
		 * we could clear CLOCAL at this point.
607
		 */
608
		set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
609
				   || initializer != NULL));
610
	}
611
551
612
	/*
552
	/*
613
	 * If the pty, socket, notty and/or record option was specified,
553
	 * If the pty, socket, notty and/or record option was specified,
Lines 736-741 Link Here
736
	return ttyfd;
676
	return ttyfd;
737
}
677
}
738
678
679
void setup_serial(char *connector)
680
{
681
    int fdflags;
682
    struct stat statbuf;
683
684
    /*
685
    * Open the serial device and set it up to be the ppp interface.
686
    * First we open it in non-blocking mode so we can set the
687
    * various termios flags appropriately.  If we aren't dialling
688
    * out and we want to use the modem lines, we reopen it later
689
    * in order to wait for the carrier detect signal from the modem.
690
    */
691
    hungup = 0;
692
    kill_link = 0;
693
    connector = doing_callback? callback_script: connect_script;
694
    if (devnam[0] != 0) {
695
	for (;;) {
696
    	    /* If the user specified the device name, become the
697
            user before opening it. */
698
            int err, prio;
699
700
    	    prio = privopen? OPRIO_ROOT: tty_options[0].priority;
701
            if (prio < OPRIO_ROOT)
702
                seteuid(uid);
703
            ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
704
            err = errno;
705
            if (prio < OPRIO_ROOT)
706
                seteuid(0);
707
            if (ttyfd >= 0)
708
                break;
709
            errno = err;
710
            if (err != EINTR) {
711
                error("Failed to open %s: %m", devnam);
712
                status = EXIT_OPEN_FAILED;
713
    	    }
714
            if (!persist || err != EINTR)
715
                return -1;
716
	}
717
        real_ttyfd = ttyfd;
718
        if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
719
	    || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
720
    	    warn("Couldn't reset non-blocking mode on device: %m");
721
722
	/*
723
        * Do the equivalent of `mesg n' to stop broadcast messages.
724
        */
725
        if (fstat(ttyfd, &statbuf) < 0
726
            || fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) {
727
            warn("Couldn't restrict write permissions to %s: %m", devnam);
728
        } else
729
    	    tty_mode = statbuf.st_mode;
730
731
	/*
732
        * Set line speed, flow control, etc.
733
        * If we have a non-null connection or initializer script,
734
        * on most systems we set CLOCAL for now so that we can talk
735
        * to the modem before carrier comes up.  But this has the
736
        * side effect that we might miss it if CD drops before we
737
        * get to clear CLOCAL below.  On systems where we can talk
738
        * successfully to the modem with CLOCAL clear and CD down,
739
        * we could clear CLOCAL at this point.
740
        */
741
        set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
742
                	    || initializer != NULL));
743
    }
744
}
745
746
#ifdef CBCP_SUPPORT
747
int callback()
748
{
749
    char *s;
750
    char numbuf[16];
751
752
    cbcp_protent.enabled_flag = 0; /* Already not need */
753
    s = cbcp_get_script();
754
    syslog(LOG_INFO, "Callback with <%s>",s );
755
756
    set_up_tty( ttyfd, 1 );
757
758
    if (real_ttyfd != -1) {
759
        if (!default_device && modem) {
760
            setdtr(real_ttyfd, 0);  /* in case modem is off hook */
761
            sleep(1);
762
            setdtr(real_ttyfd, 1);
763
        }
764
    }
765
766
    /* syslog(LOG_INFO, "ttyfd is %d and hungup is %d",ttyfd,hungup ); */
767
    if (device_script(s, ttyfd, ttyfd, 0) < 0) {
768
	error("Callback script failed");
769
        status = EXIT_INIT_FAILED;
770
        setdtr(ttyfd, 0 );
771
        return -1;
772
    }
773
774
    info("Serial connection established." );
775
776
    if (real_ttyfd != -1)
777
        set_up_tty( real_ttyfd, 0 );
778
779
    slprintf(numbuf, sizeof(numbuf), "%d", baud_rate);
780
    script_setenv("SPEED", numbuf, 1);
781
782
    return ttyfd;
783
}
784
#endif /* CBCP Support */
739
785
740
void disconnect_tty()
786
void disconnect_tty()
741
{
787
{
(-)ppp-2.4.2.orig/pppdump/Makefile (+17 lines)
Line 0 Link Here
1
CFLAGS= $(COPTS) -I../include/net
2
OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
3
4
INSTALL= install
5
6
all:	pppdump
7
8
pppdump: $(OBJS)
9
	$(CC) $(LDFLAGS) -o pppdump $(OBJS)
10
11
clean:
12
	rm -f pppdump $(OBJS) *~
13
14
install:
15
	mkdir -p $(BINDIR) $(MANDIR)/man8
16
	$(INSTALL) -s -c pppdump $(BINDIR)
17
	$(INSTALL) -c -m 444 pppdump.8 $(MANDIR)/man8
(-)ppp-2.4.2.orig/pppstats/Makefile (+33 lines)
Line 0 Link Here
1
#
2
# pppstats makefile
3
# $Id: Makefile.linux,v 1.5 2002/10/27 12:56:26 fcusack Exp $
4
#
5
6
PPPSTATSRCS = pppstats.c
7
PPPSTATOBJS = pppstats.o
8
9
#CC = gcc
10
COPTS = -O
11
COMPILE_FLAGS = -I../include
12
LIBS =
13
14
INSTALL= install -o root -g daemon
15
16
CFLAGS = $(COPTS) $(COMPILE_FLAGS)
17
18
all: pppstats
19
20
install: pppstats
21
	-mkdir -p $(MANDIR)/man8
22
	$(INSTALL) -s -c pppstats $(BINDIR)/pppstats
23
	$(INSTALL) -c -m 444 pppstats.8 $(MANDIR)/man8/pppstats.8
24
25
pppstats: $(PPPSTATSRCS)
26
	$(CC) $(CFLAGS) $(LDFLAGS) -o pppstats pppstats.c $(LIBS)
27
28
clean:
29
	rm -f pppstats *~ #* core
30
31
depend:
32
	cpp -M $(CFLAGS) $(PPPSTATSRCS) >.depend
33
#	makedepend $(CFLAGS) $(PPPSTATSRCS)
(-)ppp-2.4.2.orig/README.cbcp (-32 / +17 lines)
Lines 1-6 Link Here
1
	     Microsoft Call Back Configuration Protocol.
1
	     Microsoft Call Back Configuration Protocol.
2
			by Pedro Roque Marques
2
			by Pedro Roque Marques
3
			(updated by Paul Mackerras)
3
	    (updated by Paul Mackerras)
4
	    (updated by Bolke de Bruin, bolke@xs4all.nl)
5
	    (updated by Valery Kartel, droid@terem.kiev.ua)
4
6
5
The CBCP is a method by which the Microsoft Windows NT Server may
7
The CBCP is a method by which the Microsoft Windows NT Server may
6
implement additional security. It is possible to configure the server
8
implement additional security. It is possible to configure the server
Lines 11-20 Link Here
11
It is a requirement of servers to be so configured that the protocol be
13
It is a requirement of servers to be so configured that the protocol be
12
exchanged.
14
exchanged.
13
15
14
So, this set of patches may be applied to the pppd process to enable
15
the cbcp client *only* portion of the specification. It is primarily
16
meant to permit connection with Windows NT Servers.
17
18
The ietf-working specification may be obtained from ftp.microsoft.com
16
The ietf-working specification may be obtained from ftp.microsoft.com
19
in the developr/rfc directory.
17
in the developr/rfc directory.
20
18
Lines 22-51 Link Here
22
extended to permit the callback operation. For this reason, these
20
extended to permit the callback operation. For this reason, these
23
patches are not 'part' of pppd but are an adjunct to the code.
21
patches are not 'part' of pppd but are an adjunct to the code.
24
22
25
To enable CBCP support, all that is required is to uncomment the line
23
The configuration files in this setup are already configured to use
26
in Makefile.linux that sets CBCP=y and recompile pppd.
24
CBCP both as a server (when specified with "callback server") and
27
25
client (callback <number>). I sure would like some info how it is 
28
I use such script to make a callback:
26
working especially client side as I did not test that.
29
27
30
pppd debug nodetach /dev/modem 115200 crtscts modem	\
28
Also you may have noticed that a few other patches exist for older
31
callback 222222 name NAME remotename SERVER	\
29
versions of ppp (2.3.5, 2.3.7, 2.3.10) I have made these comply
32
connect 'chat -v "" atz OK atdt111111 CONNECT ""'
30
with the new 2.4.0 and I *do* hope it gets finally in the main
33
sleep 1
31
branch, because I know a lot of people are stuck with NT-RAS, and
34
pppd debug /dev/modem 115200 crtscts modem	\
32
would gladly replace it with a *nix/*bsd solution.
35
name NAME remotename SERVER defaultroute	\
33
36
connect 'chat -v RING ATA CONNECT "\c"'
34
Some work still has to be done. Client input should be checked for
37
35
should be shell escaped (SECURITY FLAW!), code cleanups should be made
38
First we invoke pppd with 'nodetach' option in order to not detach from
36
etc etc.
39
the controlling terminal and 'callback NUMBER' option, then wait for
40
1 second and invoke pppd again which waits for a callback (RING) and
41
then answers (ATA). Number 222222 is a callback number, i.e. server will
42
call us back at this number, while number 111111 is the number we are
43
calling to.
44
45
You have to put in /etc/ppp/chap-secrets the following two lines:
46
47
NAME SERVER PASSWORD
48
SERVER NAME PASSWORD
49
50
You have to use your real login name, remote server name and password.
51

Return to bug 67991