1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
|
#!/usr/local/bin/perl
#
# $NetBSD: pidentd2netbsd,v 1.2 2002/11/30 03:18:46 lukem Exp $
#
# Perl script to convert a standard distribution directory for pidentd into
# a NetBSD source tree.
#
# This is done as a script so that as each distribution is released,
# only changes from the previous one need to be dealt with as
# modifications to this script and related files. This should
# reduce the cost of updating from a new release of pidentd by an
# order of magnitude (or more?)
#
# This script requires two environment variables set:
# SRCDIR - pidentd source directory
# TARGETDIR - name of the high level directory to make
#
# Written by SAITOH Masanobu July 1st, 1998 for pidentd-2.8.3
#
$version = "2.8.3";
# definitions ...
@subdirs = ("libexec/identd");
@identdf = ("identd.c", "parse.c", "config.c", "proxy.c", "version.c",
"netbsd.c");
@identdhf = ("identd.h", "error.h", "paths.h");
@identdmf = ("identd.8");
@identddf = ("CREDITS", "README");
# sed edit list: file, sed-program
%sedlist = ();
#
# Utility Subroutines
#
sub makedir {
system("mkdir -p @_");
}
# &fixrcs (fromfile, tofile);
sub fixrcs
{
my ($f, $t) = @_;
my @keywords = ("Author", "Date", "Header", "Id", "Locker", "Log",
"Name", "RCSfile", "Revision", "Source", "State");
my $state = 0;
my $hdr = 0;
open(IFILE, "<$f") || die "Cannot open $f";
open(OFILE, ">$t") || die "Cannot create $t";
if ($t =~ /.*\.[0-9]/) {
print OFILE '.\\" $', 'NetBSD', '$', "\n.\\", "\n";
}
elsif ($t =~ /.*\.[ch]/) {
print OFILE "/*\t", '$', 'NetBSD', '$', "\t*/\n\n";
}
elsif ($t =~ /.*\.[yl]/) {
$hdr = 1;
}
else {
print OFILE '$', 'NetBSD', '$', "\n";
}
while (<IFILE>) {
if ($hdr == 1) {
if (/%{/) {
print OFILE "%{\n/*\t", '$', 'NetBSD', '$', "\t*/\n\n";
$hdr = 0;
next;
}
}
if ($state == 2) {
if (/#endif/) {
print OFILE "#else\n__RCSID(", '"$', 'NetBSD', '$"',
");\n#endif\n";
$state = 0;
}
}
if ($state == 1) {
print OFILE "#if 0\n";
$state = 2;
}
if (/#ifndef lint/) {
print OFILE "#include <sys/cdefs.h>\n";
$state = 1;
}
foreach $key (@keywords) {
s/\$$key\$/$key/g;
s/\$$key:(.*)\$/$key:$1/g;
}
print OFILE $_;
}
close(IFILE) || die "closing input file";
close(OFILE) || die "closing output file";
}
# ©files (fromdir, todir, list of files);
sub copyfiles {
local ($fdir, $tdir, @list) = @_;
local ($f);
foreach $f (@list) {
print " $fdir/$f --> $tdir/$f\n";
&fixrcs("$fdir/$f", "$tdir/$f");
}
}
# ©file (fromfile, tofile);
sub copyfile {
local ($f, $t) = @_;
print " $f --> $t\n";
system ("cp $f $t");
}
sub uniq {
local (@inlist) = @_;
local (@outlist);
@outlist = ($inlist[0]);
for ( $i=1; $i < @inlist; $i++ ) {
if ($inlist[$i] ne $inlist[$i-1]) {
push (@outlist, $inlist[$i]);
}
}
@outlist;
}
sub dumpsrcs {
local (@names) = @_;
local ($count);
$count = 0;
while ($f = pop(@names)) {
print ODATA "$f ";
if ($count == 5 && @names > 0) {
print ODATA "\\\n";
$count = 0;
} else {
$count += 1;
}
}
if ($count != 0) {
print ODATA "\n";
}
}
#
# Main progarm.
#
$srcdir = $ENV{'SRCDIR'};
$targetdir = $ENV{'TARGETDIR'};
$incdirs = "-I.";
if (!$srcdir | !targetdir) {
die "You must define the environment variables SRCDIR and TARGETDIR.\n"
}
print "Making the NetBSD directory tree.\n";
foreach $f (@subdirs) {
print " -->$f\n";
makedir ("$targetdir/$f");
}
print "Populating the libexec/identd directory.\n";
system("cp $srcdir/identd.man $targetdir/libexec/identd/identd.8");
©files ("$srcdir/src", "$targetdir/libexec/identd", @identdf, @identdhf);
©files ("$srcdir", "$targetdir/libexec/identd", @identddf);
#
# Build makefiles
#
$first = "True";
while ($line = <DATA>) {
chop ($line);
if (substr($line,0,2) eq "%%") {
@cmd = split (/ /,$line);
if ($cmd[1] eq "file") {
print "Building $targetdir/$cmd[2]\n";
if ($first eq "") {
close (ODATA);
} else {
$first = "";
}
open (ODATA, ">$targetdir/$cmd[2]") ||
die "Could not create $targetdir/$cmd[2]";
} elsif ($cmd[1] eq "awks") {
print " Defining AWKS\n";
if ($first) {
die "Data file must start with a %% file!";
}
print ODATA "AWKS=\t";
&dumpsrcs (@identddaf);
} elsif ($cmd[1] eq "srcs") {
print " Defining SRCS\n";
if ($first) {
die "Data file must start with a %% file!";
}
print ODATA "SRCS=\t";
&dumpsrcs (@identdf);
} elsif ($cmd[1] eq "man") {
print " Defining MAN\n";
if ($first) {
die "Data file must start with a %% file!";
}
print ODATA "MAN=\t";
&dumpsrcs (@identdmf);
} elsif ($cmd[1] eq "version") {
print " Defining VERSION\n";
print ODATA "char version[] = \"$version\";";
} elsif ($cmd[1] eq "NetBSD") {
if ($first) {
die "Data section must start with a %% file!";
}
print ODATA "$cmd[2] \$"."NetBSD".": \$ $cmd[3]\n";
} elsif ($cmd[1] eq "patch") {
print "Patching in directory $cmd[2]\n";
$cwd = `pwd`;
chop($cwd);
chdir ("$targetdir/$cmd[2]")
|| die "Can't connect to $targetdir/$cmd[2] in patch.\n";
if (!$first) {
close (ODATA);
$first = "True";
}
open (ODATA, ">PATCH") ||
die "Could not create PATCH file";
$more = "True";
while ($more) {
$line = <DATA>;
if (substr($line,0,2) eq "%%") {
$more = "";
close (ODATA);
} else {
print ODATA $line;
}
}
system ("patch < PATCH");
system ("rm -f *.orig PATCH");
chdir($cwd);
}
} else {
if ($first) {
die "Data file must start with a %% file!";
}
print ODATA "$line\n";
}
}
close (ODATA);
#
# Sed transformations of files
#
foreach $n (keys(%sedlist)) {
print "Modifying $n\n";
system ("cd $targetdir; sed $sedlist{$n} $n > tmp; mv -f tmp $n");
}
#
# end of the script
#
# what follows is the data for makefiles and other special files
# that need to be created.
__END__
%% file libexec/identd/Makefile
%% NetBSD #
PROG= identd
%% srcs
%% man
CPPFLAGS+= -DINCLUDE_EXTENSIONS -DSTRONG_LOG -DALLOW_FORMAT
LDADD+= -lkvm
DPADD+= ${LIBKVM}
.include <bsd.prog.mk>
%% patch libexec/identd
--- pidentd-2.8.3/src/config.c Tue Jul 29 06:01:26 1997
+++ identd/config.c Wed Jul 1 21:54:11 1998
@@ -10,6 +10,10 @@
*/
#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -44,7 +48,7 @@
}
netcnt = 0;
- while (start = fgets(buf, sizeof buf, fp)) {
+ while ((start = fgets(buf, sizeof buf, fp)) != NULL) {
char *net, *mask;
char *cmd = strtok(buf, " \t");
if (cmd) {
%% end patch
%% patch libexec/identd
--- pidentd-2.8.3/src/identd.c Mon Jun 1 08:19:51 1998
+++ identd/identd.c Wed Jul 1 21:54:11 1998
@@ -13,7 +13,7 @@
#define void int
#endif
-#if defined(IRIX) || defined(SVR4) || defined(NeXT) || (defined(sco) && sco >= 42) || defined(_AIX4) || defined(__FreeBSD__) || defined(ultrix)
+#if defined(IRIX) || defined(SVR4) || defined(NeXT) || (defined(sco) && sco >= 42) || defined(_AIX4) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(ultrix)
# define SIGRETURN_TYPE void
# define SIGRETURN_TYPE_IS_VOID
#else
@@ -66,7 +66,7 @@
extern int errno;
#endif
-#if defined(SOLARIS) || defined(__FreeBSD__) || defined(__linux__) || defined(_AIX)
+#if defined(SOLARIS) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(_AIX)
# include <unistd.h>
# include <stdlib.h>
# include <string.h>
@@ -75,7 +75,7 @@
#include "identd.h"
#include "error.h"
#include "paths.h"
-#include "crypto.h"
+
/* Antique unixes do not have these things defined... */
#ifndef FD_SETSIZE
@@ -94,10 +94,6 @@
#endif
-extern void *calloc();
-extern void *malloc();
-
-
char *path_unix = (char *) NULL;
char *path_kmem = (char *) NULL;
@@ -128,6 +124,11 @@
static int syslog_facility = LOG_DAEMON;
#endif
+static int comparemem __P((void *, void *, int));
+char *clearmem __P((void *, int));
+static SIGRETURN_TYPE child_handler __P((int));
+int main __P((int, char *[]));
+
/*
** The structure passing convention for GCC is incompatible with
** Suns own C compiler, so we define our own inet_ntoa() function.
@@ -236,7 +237,8 @@
** if the -w or -b options are used.
*/
static SIGRETURN_TYPE
-child_handler()
+child_handler(dummy)
+ int dummy;
{
#if defined(NeXT) || (defined(__sgi) && defined(__SVR3))
union wait status;
@@ -650,10 +652,11 @@
** handshake.
*/
#if (defined(SVR4) || defined(hpux) || defined(__hpux) || defined(IRIX) || \
- defined(_CRAY) || defined(_AUX_SOURCE)) || defined(sco) || defined(LINUX)
+ defined(_CRAY) || defined(_AUX_SOURCE) || defined(sco) || \
+ defined(LINUX))
signal(SIGCHLD, SIG_IGN);
#else
- signal(SIGCHLD, (SIGRETURN_TYPE (*)()) child_handler);
+ signal(SIGCHLD, child_handler);
#endif
/*
%% end patch
%% patch libexec/identd
diff -u pidentd-2.8.3/src/identd.h identd/identd.h
--- pidentd-2.8.3/src/identd.h Tue Jul 29 06:01:26 1997
+++ identd/identd.h Wed Jul 1 23:32:04 1998
@@ -38,11 +40,17 @@
extern int lport;
extern int fport;
-extern char *gethost();
+extern char *gethost __P((struct in_addr *));
-extern int k_open();
-extern int k_getuid();
-extern int parse();
-extern int parse_config();
+extern int k_open __P((void));
+extern int k_getuid __P((struct in_addr *, int, struct in_addr *, int, int *));
+extern int parse __P((FILE *, struct in_addr *, struct in_addr *));
+extern int parse_config __P((char *, int));
+
+#ifdef INCLUDE_PROXY
+int proxy __P((struct in_addr *, struct in_addr *, int, int, struct timeval *));
+#else
+int proxy __P((void *, void *, int, int, void *));
+#endif
#endif
%% end patch
%% patch libexec/identd
--- pidentd-2.8.3/src/netbsd.c Tue Jul 29 06:01:27 1997
+++ identd/netbsd.c Thu Jul 2 00:11:01 1998
@@ -12,6 +12,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <limits.h>
@@ -63,10 +64,6 @@
#include "error.h"
-extern void *calloc();
-extern void *malloc();
-
-
struct nlist nl[] =
{
#define N_FILE 0
@@ -86,6 +83,9 @@
static struct inpcbtable tcbtable;
+static int getbuf __P((long, char *, int, char *));
+static struct socket *getlist __P((struct inpcbtable *, struct inpcbtable *,
+ struct in_addr *, int, struct in_addr *, int));
int k_open()
{
@@ -121,7 +121,7 @@
if (kvm_read(kd, addr, buf, len) != len)
{
if (syslog_flag)
- syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
+ syslog(LOG_ERR, "getbuf: kvm_read(%#lx, %d) - %s : %m",
addr, len, what);
return 0;
@@ -152,7 +152,7 @@
for (kpcbp = tcbtablep->inpt_queue.cqh_first;
kpcbp != (struct inpcb *)ktcbtablep;
kpcbp = pcb.inp_queue.cqe_next) {
- if (!getbuf((long) kpcbp, &pcb, sizeof(struct inpcb), "tcb"))
+ if (!getbuf((long) kpcbp, (char *)&pcb, sizeof(struct inpcb), "tcb"))
break;
if (pcb.inp_faddr.s_addr == faddr->s_addr &&
pcb.inp_laddr.s_addr == laddr->s_addr &&
@@ -181,10 +181,10 @@
struct ucred ucb;
/* -------------------- FILE DESCRIPTOR TABLE -------------------- */
- if (!getbuf(nl[N_NFILE].n_value, &nfile, sizeof(nfile), "nfile"))
+ if (!getbuf(nl[N_NFILE].n_value, (char *)&nfile, sizeof(nfile), "nfile"))
return -1;
- if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
+ if (!getbuf(nl[N_FILE].n_value, (char *)&addr, sizeof(addr), "&file"))
return -1;
{
@@ -200,7 +200,7 @@
}
xfile = malloc(siz);
if (!xfile)
- ERROR1("k_getuid: malloc(%d)", siz);
+ ERROR1("k_getuid: malloc(%ld)", (u_long)siz);
if ((rv = sysctl(mib, 2, xfile, &siz, NULL, 0)) == -1)
{
ERROR1("k_getuid: sysctl 2 (%d)", rv);
@@ -210,11 +210,12 @@
}
/* -------------------- TCP PCB LIST -------------------- */
- if (!getbuf(nl[N_TCBTABLE].n_value, &tcbtable, sizeof(tcbtable), "tcbtable"))
+ if (!getbuf(nl[N_TCBTABLE].n_value, (char *)&tcbtable, sizeof(tcbtable),
+ "tcbtable"))
return -1;
- sockp = getlist(&tcbtable, nl[N_TCBTABLE].n_value, faddr, fport, laddr,
- lport);
+ sockp = getlist(&tcbtable, (struct inpcbtable *)nl[N_TCBTABLE].n_value,
+ faddr, fport, laddr, lport);
if (!sockp)
return -1;
@@ -231,7 +232,7 @@
if (xfile[i].f_type == DTYPE_SOCKET &&
(struct socket *) xfile[i].f_data == sockp)
{
- if (!getbuf(xfile[i].f_cred, &ucb, sizeof(ucb), "ucb"))
+ if (!getbuf((long)xfile[i].f_cred, (char *)&ucb, sizeof(ucb), "ucb"))
return -1;
*uid = ucb.cr_uid;
%% end patch
%% patch libexec/identd
diff -u pidentd-2.8.3/src/parse.c identd/parse.c
--- pidentd-2.8.3/src/parse.c Fri Mar 20 08:49:10 1998
+++ identd/parse.c Wed Jul 1 23:32:04 1998
@@ -14,6 +16,8 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <pwd.h>
@@ -28,11 +32,7 @@
# include <arpa/inet.h>
#endif
-#ifdef HAVE_KVM
-# include <kvm.h>
-#else
-# include "kvm.h"
-#endif
+#include <kvm.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -48,9 +48,10 @@
#include "identd.h"
#include "error.h"
-#include "crypto.h"
-extern void *malloc();
+static int eat_whitespace __P((void));
+static int check_noident __P((char *));
+static int valid_fhost(struct in_addr *, char *);
/*
** This function will eat whitespace characters until
@@ -193,7 +194,6 @@
char arg[33];
#endif
#ifdef INCLUDE_EXTENSIONS
- extern int proxy();
int c;
#endif
struct in_addr laddr2;
@@ -631,7 +631,7 @@
{
char* cp;
char** gmp;
- long bp;
+ int bp;
char buff[512];
for (cp = format, bp = 0; *cp != 0; cp++)
{
@@ -649,7 +649,7 @@
sprintf (&buff[bp], "%.*s", 490-bp, grname);
bp += strlen(&buff[bp]); if (bp >= 490) break;
setgrent();
- while (grp = getgrent()) {
+ while ((grp = getgrent()) != NULL) {
if (grp->gr_gid == pwp->pw_gid) continue;
for (gmp = grp->gr_mem; *gmp && **gmp; gmp++) {
if (! strcmp(*gmp, pwp->pw_name)) {
@@ -666,7 +666,7 @@
sprintf (&buff[bp], "%d", pwp->pw_gid);
bp += strlen(&buff[bp]); if (bp >= 490) break;
setgrent();
- while (grp = getgrent()) {
+ while ((grp = getgrent()) != NULL) {
if (grp->gr_gid == pwp->pw_gid) continue;
for (gmp = grp->gr_mem; *gmp && **gmp; gmp++) {
if (! strcmp(*gmp, pwp->pw_name)) {
%% end patch
%% patch libexec/identd
--- pidentd-2.8.3/src/proxy.c Tue Jul 29 06:01:28 1997
+++ identd/proxy.c Wed Jul 1 21:54:10 1998
@@ -12,19 +12,16 @@
#include <stdio.h>
#include <errno.h>
-#include "identd.h"
-
-
-#ifdef INCLUDE_PROXY
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
-#include <ident.h>
-#endif
+#include "identd.h"
-#ifndef __STDC__
-#define void int
+#ifdef INCLUDE_PROXY
+int proxy __P((struct in_addr *, struct in_addr *, int, int, struct timeval *));
+#else
+int proxy __P((void *, void *, int, int, void *));
#endif
/*
%% end patch
%% patch libexec/identd
--- pidentd-2.8.3/identd.man Tue Jul 29 06:01:22 1997
+++ identd/identd.8 Wed Jul 1 23:32:04 1998
@@ -4,9 +4,9 @@
.\"
.TH IDENTD 8 "27 May 1992"
.SH NAME
-identd, in.identd \- TCP/IP IDENT protocol server
+identd \- TCP/IP IDENT protocol server
.SH SYNOPSIS
-.B xDESTDIRx/[in.]identd
+.B identd
.RB [ \-i | \-w | \-b ]
.RB [ \-t<seconds> ]
.RB [ \-u<uid> ]
@@ -322,14 +322,14 @@
mode of operation.
.SH EXAMPLES
Assuming the server is located in
-.B /usr/etc/in.identd
+.B /usr/libexec/identd
one can put either:
.PP
-ident stream tcp wait sys /usr/etc/in.identd in.identd -w -t120
+ident stream tcp wait sys /usr/libexec/identd identd -w -t120
.PP
or:
.PP
-ident stream tcp nowait sys /usr/etc/in.identd in.identd -i
+ident stream tcp nowait sys /usr/libexec/identd identd -i
.PP
into the
.B /etc/inetd.conf
@@ -342,7 +342,7 @@
.B /etc/rc.local
file:
.PP
-/usr/etc/in.identd -b -u2 -g2
+/usr/libexec/identd -b -u2 -g2
.PP
This will make it run in the background as user 2, group 2 (user "sys",
group "kmem" on SunOS 4.1.1).
@@ -376,12 +376,12 @@
one or the other or both.
.SH FILES
.TP
-.B xCONFDIRx/identd.conf
+.B /etc/identd.conf
This file is as yet un-used, but will eventually contain configuration
options for
.B identd
.TP
-.B xCONFDIRx/identd.key
+.B /etc/identd.key
If compiled with
.I \-ldes
this file can be used to specify a secret key for encrypting replies.
%% end patch
|