diff options
225 files changed, 2902 insertions, 2902 deletions
diff --git a/sbin/ancontrol/ancontrol.c b/sbin/ancontrol/ancontrol.c index c52a3147f13..3eba6e3d472 100644 --- a/sbin/ancontrol/ancontrol.c +++ b/sbin/ancontrol/ancontrol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ancontrol.c,v 1.20 2002/06/06 17:25:16 mickey Exp $ */ +/* $OpenBSD: ancontrol.c,v 1.21 2002/06/09 08:13:04 todd Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -1103,7 +1103,7 @@ an_readcache() an_getval(&areq); - an_sigitems = (int *) &areq.an_val; + an_sigitems = (int *) &areq.an_val; pt = ((char *) &areq.an_val); pt += sizeof(int); sc = (struct an_sigcache *) pt; diff --git a/sbin/atactl/atactl.8 b/sbin/atactl/atactl.8 index d927cb29518..708174d6554 100644 --- a/sbin/atactl/atactl.8 +++ b/sbin/atactl/atactl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: atactl.8,v 1.14 2002/06/08 12:50:42 gluk Exp $ +.\" $OpenBSD: atactl.8,v 1.15 2002/06/09 08:13:05 todd Exp $ .\" $NetBSD: atactl.8,v 1.5 1999/02/24 18:49:14 jwise Exp $ .\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -163,7 +163,7 @@ Support for automatic acoustic management is indicated by the device with .Sq Automatic Acoustic Management feature set in the output of the .Cm identify -command. +command. .Pp .Cm acousticdisable .Pp diff --git a/sbin/atactl/atactl.c b/sbin/atactl/atactl.c index df1bdd00dbd..a1ba6f6ff97 100644 --- a/sbin/atactl/atactl.c +++ b/sbin/atactl/atactl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atactl.c,v 1.15 2002/06/08 12:50:42 gluk Exp $ */ +/* $OpenBSD: atactl.c,v 1.16 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: atactl.c,v 1.4 1999/02/24 18:49:14 jwise Exp $ */ /*- @@ -468,7 +468,7 @@ valtostr(val, vinfo) void device_dump(argc, argv) int argc; - char *argv[]; + char *argv[]; { unsigned char buf[131072]; int error; @@ -1170,7 +1170,7 @@ device_attr(argc, argv) } /* - * Set the automatic acoustic management on the disk. + * Set the automatic acoustic management on the disk. */ void device_acoustic(argc, argv) @@ -1268,7 +1268,7 @@ usage: /* * En/disable features (the automatic acoustic managmement, Advanced Power - * Management) on the disk. + * Management) on the disk. */ void device_feature(argc, argv) diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c index 337c361ff9d..74b3662b329 100644 --- a/sbin/badsect/badsect.c +++ b/sbin/badsect/badsect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: badsect.c,v 1.7 2002/02/16 21:27:33 millert Exp $ */ +/* $OpenBSD: badsect.c,v 1.8 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: badsect.c,v 1.10 1995/03/18 14:54:28 cgd Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: badsect.c,v 1.7 2002/02/16 21:27:33 millert Exp $"; +static char rcsid[] = "$OpenBSD: badsect.c,v 1.8 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -130,7 +130,7 @@ main(argc, argv) } /* - * We've found the block device, but since the filesystem + * We've found the block device, but since the filesystem * is mounted, we must write to the raw (character) device * instead. This is not guaranteed to work if someone has a * /dev that doesn't follow standard naming conventions, but diff --git a/sbin/brconfig/brconfig.8 b/sbin/brconfig/brconfig.8 index 36dc8cbe986..a94926d0391 100644 --- a/sbin/brconfig/brconfig.8 +++ b/sbin/brconfig/brconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: brconfig.8,v 1.34 2002/01/17 15:55:30 espie Exp $ +.\" $OpenBSD: brconfig.8,v 1.35 2002/06/09 08:13:05 todd Exp $ .\" .\" Copyright (c) 1999-2001 Jason L. Wright (jason@thought.net) .\" All rights reserved. @@ -317,23 +317,23 @@ Configure the gif0 interface: Create Security Associations (SAs) between the external IP address of each bridge: .Bd -literal -# ipsecadm new esp -spi 4242 -dst 4.3.2.1 -src 1.2.3.4 \e\ +# ipsecadm new esp -spi 4242 -dst 4.3.2.1 -src 1.2.3.4 \e\ -enc 3des -auth md5 -keyfile keyfile1 -authkeyfile authkeyfile1 .Ed .Pp .Bd -literal -# ipsecadm new esp -spi 4243 -dst 1.2.3.4 -src 4.3.2.1 \e\ +# ipsecadm new esp -spi 4243 -dst 1.2.3.4 -src 4.3.2.1 \e\ -enc 3des -auth md5 -keyfile keyfile2 -authkeyfile authkeyfile2 .Ed .Pp Setup ingress flows so that traffic is allowed between the two bridges for the above associations: .Bd -literal -(on bridge1) # ipsecadm flow -dst 4.3.2.1 -out \e\ - -transport etherip -require \e\ +(on bridge1) # ipsecadm flow -dst 4.3.2.1 -out \e\ + -transport etherip -require \e\ -addr 1.2.3.4 255.255.255.255 4.3.2.1 255.255.255.255 -(on bridge2) # ipsecadm flow -dst 1.2.3.4 -out \e\ - -transport etherip -require \e\ +(on bridge2) # ipsecadm flow -dst 1.2.3.4 -out \e\ + -transport etherip -require \e\ -addr 4.3.2.1 255.255.255.255 1.2.3.4 255.255.255.255 .Ed .Pp diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index be2f6c2bd52..189596b9de7 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.74 2002/05/22 08:21:01 deraadt Exp $ */ +/* $OpenBSD: disklabel.c,v 1.75 2002/06/09 08:13:05 todd Exp $ */ /* * Copyright (c) 1987, 1993 @@ -43,7 +43,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.74 2002/05/22 08:21:01 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.75 2002/06/09 08:13:05 todd Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -417,7 +417,7 @@ writelabel(f, boot, lp) struct partition *pp = &lp->d_partitions[2]; /* - * If OpenBSD DOS partition is missing, or if + * If OpenBSD DOS partition is missing, or if * the label to be written is not within partition, * prompt first. Need to allow this in case operator * wants to convert the drive for dedicated use. @@ -953,7 +953,7 @@ makedisktab(f, lp) (void)fprintf(f, "o%c#%u:", c, pp->p_offset); if (pp->p_fstype != FS_UNUSED) { if ((unsigned) pp->p_fstype < FSMAXTYPES) - (void)fprintf(f, "t%c=%s:", c, + (void)fprintf(f, "t%c=%s:", c, fstypenames[pp->p_fstype]); else (void)fprintf(f, "t%c=unknown%d:", @@ -1077,7 +1077,7 @@ display_partition(f, lp, mp, i, unit, width) else putc(' ', f); fprintf(f, "- %u", - (pp->p_offset + + (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl - 1); if ((pp->p_offset + pp->p_size) % lp->d_secpercyl) diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 3bcdb375d83..583747ee0ba 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.80 2002/05/22 08:21:01 deraadt Exp $ */ +/* $OpenBSD: editor.c,v 1.81 2002/06/09 08:13:05 todd Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -28,7 +28,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.80 2002/05/22 08:21:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.81 2002/06/09 08:13:05 todd Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -1772,7 +1772,7 @@ editor_countfree(lp, freep) for (i = 0; i < lp->d_npartitions; i++) { pp = &lp->d_partitions[i]; if (pp->p_fstype != FS_UNUSED && pp->p_fstype != FS_BOOT && - pp->p_size > 0 && + pp->p_size > 0 && pp->p_offset + pp->p_size <= ending_sector && pp->p_offset >= starting_sector) *freep -= pp->p_size; @@ -2031,7 +2031,7 @@ mpsave(lp, mp, cdev, fstabfile) } bdev[strlen(bdev) - 1] = '\0'; - /* Sort mountpoints so we don't try to mount /usr/local before /usr */ + /* Sort mountpoints so we don't try to mount /usr/local before /usr */ qsort((void *)mi, MAXPARTITIONS, sizeof(struct mountinfo), micmp); if ((fp = fopen(fstabfile, "w")) == NULL) @@ -2360,7 +2360,7 @@ get_geometry(f, dgpp, bgpp) struct disklabel **bgpp; { #ifdef CPU_BIOS - int mib[4]; + int mib[4]; size_t size; dev_t devno; bios_diskinfo_t di; diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c index 71e789c6462..0b457447add 100644 --- a/sbin/dumpfs/dumpfs.c +++ b/sbin/dumpfs/dumpfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumpfs.c,v 1.14 2002/02/16 21:27:33 millert Exp $ */ +/* $OpenBSD: dumpfs.c,v 1.15 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: dumpfs.c,v 1.12 1997/04/26 05:41:33 lukem Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)dumpfs.c 8.2 (Berkeley) 2/2/94"; #else -static char rcsid[] = "$OpenBSD: dumpfs.c,v 1.14 2002/02/16 21:27:33 millert Exp $"; +static char rcsid[] = "$OpenBSD: dumpfs.c,v 1.15 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -198,7 +198,7 @@ dumpfs(name) if (afs.fs_flags & FS_DOSOFTDEP) printf("soft-updates "); if ((afs.fs_flags & ~(FS_UNCLEAN | FS_DOSOFTDEP)) != 0) - printf("unknown flags (%#x)", + printf("unknown flags (%#x)", afs.fs_flags & ~(FS_UNCLEAN | FS_DOSOFTDEP)); printf("\n"); if (afs.fs_cpc != 0) diff --git a/sbin/dumplfs/dumplfs.c b/sbin/dumplfs/dumplfs.c index 4770963d186..4c5653a3a2a 100644 --- a/sbin/dumplfs/dumplfs.c +++ b/sbin/dumplfs/dumplfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumplfs.c,v 1.6 2002/02/16 21:27:33 millert Exp $ */ +/* $OpenBSD: dumplfs.c,v 1.7 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: dumplfs.c,v 1.7 1995/12/14 22:36:34 thorpej Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)dumplfs.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: dumplfs.c,v 1.6 2002/02/16 21:27:33 millert Exp $"; +static char rcsid[] = "$OpenBSD: dumplfs.c,v 1.7 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -229,10 +229,10 @@ dump_ifile(fd, lfsp, do_ientries) dump_cleaner_info(lfsp, ipage); print_suheader; continue; - } + } if (i < (lfsp->lfs_segtabsz + lfsp->lfs_cleansz)) { - inum = dump_ipage_segusage(lfsp, inum, ipage, + inum = dump_ipage_segusage(lfsp, inum, ipage, lfsp->lfs_sepb); if (!inum) if(!do_ientries) @@ -259,11 +259,11 @@ dump_ifile(fd, lfsp, do_ientries) if (i < lfsp->lfs_cleansz) { dump_cleaner_info(lfsp, ipage); continue; - } else + } else i -= lfsp->lfs_cleansz; if (i < lfsp->lfs_segtabsz) { - inum = dump_ipage_segusage(lfsp, inum, ipage, + inum = dump_ipage_segusage(lfsp, inum, ipage, lfsp->lfs_sepb); if (!inum) if(!do_ientries) @@ -293,7 +293,7 @@ dump_ifile(fd, lfsp, do_ientries) if (i < lfsp->lfs_cleansz) { dump_cleaner_info(lfsp, ipage); continue; - } else + } else i -= lfsp->lfs_cleansz; if (i < lfsp->lfs_segtabsz) { @@ -398,7 +398,7 @@ dump_sum(fd, lfsp, sp, segnum, addr) int numblocks; struct dinode *inop; - if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum, + if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum, LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)))) { (void)printf("dumplfs: %s %d address 0x%lx\n", "corrupt summary block; segment", segnum, addr); @@ -423,10 +423,10 @@ dump_sum(fd, lfsp, sp, segnum, addr) printf(" Inode addresses:"); for (dp--, i = 0; i < sp->ss_ninos; dp--) { printf("\t0x%X {", *dp); - get(fd, *dp << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb), inop, + get(fd, *dp << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb), inop, (1 << lfsp->lfs_bshift)); for (j = 0; i < sp->ss_ninos && j < INOPB(lfsp); j++, i++) { - if (j > 0) + if (j > 0) (void)printf(", "); (void)printf("%d", inop[j].di_inumber); } @@ -476,7 +476,7 @@ dump_segment(fd, segnum, addr, lfsp, dump_sb) do { get(fd, sum_offset, sumblock, LFS_SUMMARY_SIZE); sump = (SEGSUM *)sumblock; - if (sump->ss_sumsum != cksum (&sump->ss_datasum, + if (sump->ss_sumsum != cksum (&sump->ss_datasum, LFS_SUMMARY_SIZE - sizeof(sump->ss_sumsum))) { sbp = (struct lfs *)sump; if (sb = (sbp->lfs_magic == LFS_MAGIC)) { @@ -492,7 +492,7 @@ dump_segment(fd, segnum, addr, lfsp, dump_sb) nblocks = dump_sum(fd, lfsp, sump, segnum, sum_offset >> (lfsp->lfs_bshift - lfsp->lfs_fsbtodb)); if (nblocks) - sum_offset += LFS_SUMMARY_SIZE + + sum_offset += LFS_SUMMARY_SIZE + (nblocks << lfsp->lfs_bshift); else sum_offset = 0; diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile index e7bf62047b3..9ebe2c7d5bf 100644 --- a/sbin/fdisk/Makefile +++ b/sbin/fdisk/Makefile @@ -1,5 +1,5 @@ # -# $OpenBSD: Makefile,v 1.18 2002/03/31 20:47:16 deraadt Exp $ +# $OpenBSD: Makefile,v 1.19 2002/06/09 08:13:05 todd Exp $ # # Copyright (c) 1997 Tobias Weingartner # All rights reserved. @@ -31,7 +31,7 @@ # .if ${MACHINE} == "i386" || ${MACHINE} == "macppc" || ${MACHINE} == "alpha" -PROG= fdisk +PROG= fdisk SRCS= fdisk.c user.c misc.c disk.c mbr.c part.c cmd.c manual.c DPADD= ${LIBUTIL} LDADD= -lutil diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index 95213315939..bb432e320bc 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.15 2002/01/18 08:38:26 kjell Exp $ */ +/* $OpenBSD: mbr.c,v 1.16 2002/06/09 08:13:05 todd Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -110,7 +110,7 @@ MBR_parse(disk, mbr_buf, offset, reloff, mbr) mbr->signature = getshort(&mbr_buf[MBR_SIG_OFF]); for (i = 0; i < NDOSPART; i++) - PRT_parse(disk, &mbr_buf[MBR_PART_OFF + MBR_PART_SIZE * i], + PRT_parse(disk, &mbr_buf[MBR_PART_OFF + MBR_PART_SIZE * i], offset, reloff, &mbr->part[i], i); } @@ -125,7 +125,7 @@ MBR_make(mbr, mbr_buf) putshort(&mbr_buf[MBR_SIG_OFF], mbr->signature); for (i = 0; i < NDOSPART; i++) - PRT_make(&mbr->part[i], mbr->offset, mbr->reloffset, + PRT_make(&mbr->part[i], mbr->offset, mbr->reloffset, &mbr_buf[MBR_PART_OFF + MBR_PART_SIZE * i]); } @@ -185,14 +185,14 @@ MBR_write(fd, where, buf) return (0); } -void +void MBR_pcopy(disk, mbr) disk_t *disk; mbr_t *mbr; { - /* + /* * Copy partition table from the disk indicated - * to the supplied mbr structure + * to the supplied mbr structure */ int i, fd, offset = 0, reloff = 0; @@ -205,7 +205,7 @@ MBR_pcopy(disk, mbr) MBR_parse(disk, mbr_disk, offset, reloff, &mbrd); for (i = 0; i < NDOSPART; i++) { PRT_parse(disk, &mbr_disk[MBR_PART_OFF + - MBR_PART_SIZE * i], + MBR_PART_SIZE * i], offset, reloff, &mbr->part[i], i); PRT_print(i, &mbr->part[i], NULL); } diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 90e9a84684e..b70891c1e5e 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.29 2002/02/12 17:56:35 kjell Exp $ */ +/* $OpenBSD: part.c,v 1.30 2002/06/09 08:13:05 todd Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -221,11 +221,11 @@ int PRT_check_chs(partn) prt_t *partn; { - if ( (partn->shead > 255) || - (partn->ssect >63) || - (partn->scyl > 1023) || - (partn->ehead >255) || - (partn->esect >63) || + if ( (partn->shead > 255) || + (partn->ssect >63) || + (partn->scyl > 1023) || + (partn->ehead >255) || + (partn->esect >63) || (partn->ecyl > 1023) ) { return 0; @@ -247,8 +247,8 @@ PRT_make(partn, offset, reloff, prt) if ((partn->scyl > 1023) || (partn->ecyl > 1023)) { scsave = partn->scyl; ecsave = partn->ecyl; - partn->scyl = (partn->scyl > 1023)? 1023: partn->scyl; - partn->ecyl = (partn->ecyl > 1023)? 1023: partn->ecyl; + partn->scyl = (partn->scyl > 1023)? 1023: partn->scyl; + partn->ecyl = (partn->ecyl > 1023)? 1023: partn->ecyl; modified = 1; } if ((partn->id == DOSPTYP_EXTEND) || (partn->id == DOSPTYP_EXTENDL)) @@ -304,7 +304,7 @@ PRT_print(num, partn, units) printf(" #: id C H S - C H S [ start: size ]\n"); printf("------------------------------------------------------------------------\n"); } else { - size = (double)partn->ns * DEV_BSIZE / + size = (double)partn->ns * DEV_BSIZE / unit_types[i].conversion; printf("%c%1d: %.2X %4d %3d %2d - %4d %3d %2d [%12d:%12.f%s] %s\n", (partn->flag == 0x80)?'*':' ', diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 46412d47c5c..be53b0cfd17 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.c,v 1.9 2002/02/17 19:42:27 millert Exp $ */ +/* $OpenBSD: fsck.c,v 1.10 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: fsck.c,v 1.7 1996/10/03 20:06:30 christos Exp $ */ /* @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * From: @(#)mount.c 8.19 (Berkeley) 4/19/94 - * From: NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp + * From: NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp * */ @@ -257,7 +257,7 @@ checkfs(vfstype, spec, mntpt, auxarg, pidp) argv[argc] = NULL; if (flags & (CHECK_DEBUG|CHECK_VERBOSE)) { - (void)printf("start %s %swait %s", mntpt, + (void)printf("start %s %swait %s", mntpt, pidp ? "no" : "", fsname); for (i = 1; i < argc; i++) (void)printf(" %s", argv[i]); diff --git a/sbin/fsck/fsutil.h b/sbin/fsck/fsutil.h index 6c08f0fef6b..b39bbe2f547 100644 --- a/sbin/fsck/fsutil.h +++ b/sbin/fsck/fsutil.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsutil.h,v 1.3 2002/02/17 19:42:27 millert Exp $ */ +/* $OpenBSD: fsutil.h,v 1.4 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: fsutil.h,v 1.3 1996/10/03 20:06:31 christos Exp $ */ /* @@ -32,13 +32,13 @@ void perror(const char *); void errexit(const char *, ...) - __attribute__((__noreturn__,__format__(__printf__,1,2))); + __attribute__((__noreturn__,__format__(__printf__,1,2))); void pfatal(const char *, ...) - __attribute__((__format__(__printf__,1,2))); + __attribute__((__format__(__printf__,1,2))); void pwarn(const char *, ...) - __attribute__((__format__(__printf__,1,2))); + __attribute__((__format__(__printf__,1,2))); void panic(const char *, ...) - __attribute__((__noreturn__,__format__(__printf__,1,2))); + __attribute__((__noreturn__,__format__(__printf__,1,2))); char *rawname(char *); char *unrawname(char *); char *blockcheck(char *); @@ -54,5 +54,5 @@ char *estrdup(const char *); #define CHECK_DEBUG 4 struct fstab; -int checkfstab(int, int, void *(*)(struct fstab *), +int checkfstab(int, int, void *(*)(struct fstab *), int (*) (const char *, const char *, const char *, void *, pid_t *)); diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index f832e330c77..c8c8dcebcff 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: preen.c,v 1.10 2002/05/26 09:24:35 deraadt Exp $ */ +/* $OpenBSD: preen.c,v 1.11 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: preen.c,v 1.15 1996/09/28 19:21:42 christos Exp $ */ /* @@ -80,7 +80,7 @@ static int nrun = 0, ndisks = 0; static struct diskentry *finddisk(const char *); static void addpart(const char *, const char *, const char *, void *); -static int startdisk(struct diskentry *, +static int startdisk(struct diskentry *, int (*)(const char *, const char *, const char *, void *, pid_t *)); static void printpart(void); diff --git a/sbin/fsck_ext2fs/dir.c b/sbin/fsck_ext2fs/dir.c index 21159556a7e..b1c23d59e73 100644 --- a/sbin/fsck_ext2fs/dir.c +++ b/sbin/fsck_ext2fs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.7 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: dir.c,v 1.8 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: dir.c,v 1.5 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -54,7 +54,7 @@ char *lfname = "lost+found"; int lfmode = 01777; -struct ext2fs_dirtemplate emptydir = { 0, DIRBLKSIZ }; +struct ext2fs_dirtemplate emptydir = { 0, DIRBLKSIZ }; struct ext2fs_dirtemplate dirhead = { 0, 12, 1, EXT2_FT_DIR, ".", 0, DIRBLKSIZ - 12, 2, EXT2_FT_DIR, ".." diff --git a/sbin/fsck_ext2fs/fsck.h b/sbin/fsck_ext2fs/fsck.h index 5b2275adcb0..89794c93d41 100644 --- a/sbin/fsck_ext2fs/fsck.h +++ b/sbin/fsck_ext2fs/fsck.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.h,v 1.5 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: fsck.h,v 1.6 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: fsck.h,v 1.1 1997/06/11 11:21:47 bouyer Exp $ */ /* @@ -115,14 +115,14 @@ struct inodesc { /* * Linked list of duplicate blocks. - * + * * The list is composed of two parts. The first part of the * list (from duplist through the node pointed to by muldup) - * contains a single copy of each duplicate block that has been + * contains a single copy of each duplicate block that has been * found. The second part of the list (from muldup to the end) * contains duplicate blocks that have been found more than once. * To check if a block has been found as a duplicate it is only - * necessary to search from duplist through muldup. To find the + * necessary to search from duplist through muldup. To find the * total number of times that a block has been found as a duplicate * the entire list must be searched for occurences of the block * in question. The following diagram shows a sample list where diff --git a/sbin/fsck_ext2fs/inode.c b/sbin/fsck_ext2fs/inode.c index c6e97e2ca5c..d699bd6094b 100644 --- a/sbin/fsck_ext2fs/inode.c +++ b/sbin/fsck_ext2fs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.9 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: inode.c,v 1.10 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: inode.c,v 1.8 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -513,7 +513,7 @@ findino(idesc) if (ino == 0) return (KEEPON); if (strcmp(dirp->e2d_name, idesc->id_name) == 0 && - (ino == EXT2_ROOTINO || ino >= EXT2_FIRSTINO) + (ino == EXT2_ROOTINO || ino >= EXT2_FIRSTINO) && ino <= maxino) { idesc->id_parent = ino; return (STOP|FOUND); diff --git a/sbin/fsck_ext2fs/pass1.c b/sbin/fsck_ext2fs/pass1.c index bd99eabaf0b..1eb0c81ca45 100644 --- a/sbin/fsck_ext2fs/pass1.c +++ b/sbin/fsck_ext2fs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.7 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: pass1.c,v 1.8 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: pass1.c,v 1.9 2000/01/31 11:40:12 bouyer Exp $ */ /* @@ -133,7 +133,7 @@ checkinode(inumber, idesc) mode_t mode; dp = getnextinode(inumber); - if (inumber < EXT2_FIRSTINO && inumber != EXT2_ROOTINO) + if (inumber < EXT2_FIRSTINO && inumber != EXT2_ROOTINO) return; mode = fs2h16(dp->e2di_mode) & IFMT; diff --git a/sbin/fsck_ext2fs/pass2.c b/sbin/fsck_ext2fs/pass2.c index a2da0883e51..77bdfb54d97 100644 --- a/sbin/fsck_ext2fs/pass2.c +++ b/sbin/fsck_ext2fs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.6 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: pass2.c,v 1.7 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: pass2.c,v 1.6 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -203,7 +203,7 @@ pass2check(idesc) char namebuf[MAXPATHLEN + 1]; char pathbuf[MAXPATHLEN + 1]; - /* + /* * check for "." */ if (idesc->id_entryno != 0) @@ -284,7 +284,7 @@ chk1: dirp->e2d_reclen = proto.e2d_reclen; } if (fs2h32(dirp->e2d_ino) != 0 && - dirp->e2d_namlen == 2 && + dirp->e2d_namlen == 2 && strncmp(dirp->e2d_name, "..", 2) == 0) { inp->i_dotdot = fs2h32(dirp->e2d_ino); if (sblock.e2fs.e2fs_rev > E2FS_REV0 && diff --git a/sbin/fsck_ext2fs/pass5.c b/sbin/fsck_ext2fs/pass5.c index f1793dc7331..7849feab27b 100644 --- a/sbin/fsck_ext2fs/pass5.c +++ b/sbin/fsck_ext2fs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.9 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: pass5.c,v 1.10 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: pass5.c,v 1.7 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -104,7 +104,7 @@ pass5() memset(&idesc[0], 0, sizeof idesc); for (i = 0; i < 3; i++) { idesc[i].id_type = ADDR; - } + } j = fs->e2fs.e2fs_ipg * c + 1; @@ -143,7 +143,7 @@ pass5() /* fill in unused par of the inode map */ for (i = fs->e2fs.e2fs_ipg / NBBY; i < fs->e2fs_bsize; i++) - ibmap[i] = 0xff; + ibmap[i] = 0xff; dbase = c * sblock.e2fs.e2fs_bpg + sblock.e2fs.e2fs_first_dblock; @@ -233,7 +233,7 @@ pass5() } } -void +void print_bmap(map, size) u_char *map; u_int32_t size; diff --git a/sbin/fsck_ext2fs/setup.c b/sbin/fsck_ext2fs/setup.c index b42913f448a..4dd2a4c1a6e 100644 --- a/sbin/fsck_ext2fs/setup.c +++ b/sbin/fsck_ext2fs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.8 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: setup.c,v 1.9 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: setup.c,v 1.1 1997/06/11 11:22:01 bouyer Exp $ */ /* @@ -221,11 +221,11 @@ setup(dev) if (typemap == NULL) { printf("cannot alloc %u bytes for typemap\n", (unsigned)(maxino + 1)); - goto badsblabel; + goto badsblabel; } lncntp = (int16_t *)calloc((unsigned)(maxino + 1), sizeof(int16_t)); if (lncntp == NULL) { - printf("cannot alloc %u bytes for lncntp\n", + printf("cannot alloc %u bytes for lncntp\n", (unsigned)((maxino + 1) * sizeof(int16_t))); goto badsblabel; } @@ -239,7 +239,7 @@ setup(dev) inphead = (struct inoinfo **)calloc((unsigned)numdirs, sizeof(struct inoinfo *)); if (inpsort == NULL || inphead == NULL) { - printf("cannot alloc %u bytes for inphead\n", + printf("cannot alloc %u bytes for inphead\n", (unsigned)(numdirs * sizeof(struct inoinfo *))); goto badsblabel; } diff --git a/sbin/fsck_ffs/SMM.doc/1.t b/sbin/fsck_ffs/SMM.doc/1.t index 8853320cf65..6c72cafb93b 100644 --- a/sbin/fsck_ffs/SMM.doc/1.t +++ b/sbin/fsck_ffs/SMM.doc/1.t @@ -1,4 +1,4 @@ -.\" $OpenBSD: 1.t,v 1.3 1996/10/20 08:36:44 tholo Exp $ +.\" $OpenBSD: 1.t,v 1.4 2002/06/09 08:13:06 todd Exp $ .\" $NetBSD: 1.t,v 1.3 1996/04/05 01:45:44 cgd Exp $ .\" .\" Copyright (c) 1982, 1993 @@ -54,16 +54,16 @@ If an inconsistency is discovered, corrective action must be taken. .I Fsck_ffs runs in two modes. -Normally it is run non-interactively by the system after +Normally it is run non-interactively by the system after a normal boot. When running in this mode, it will only make changes to the file system that are known to always be correct. If an unexpected inconsistency is found .I fsck_ffs -will exit with a non-zero exit status, +will exit with a non-zero exit status, leaving the system running single-user. -Typically the operator then runs +Typically the operator then runs .I fsck_ffs interactively. When running in this mode, diff --git a/sbin/fsck_ffs/SMM.doc/2.t b/sbin/fsck_ffs/SMM.doc/2.t index 99abe88af54..f5e10314c8b 100644 --- a/sbin/fsck_ffs/SMM.doc/2.t +++ b/sbin/fsck_ffs/SMM.doc/2.t @@ -1,4 +1,4 @@ -.\" $OpenBSD: 2.t,v 1.2 1996/06/23 14:30:37 deraadt Exp $ +.\" $OpenBSD: 2.t,v 1.3 2002/06/09 08:13:06 todd Exp $ .\" $NetBSD: 2.t,v 1.2 1995/03/18 14:56:08 cgd Exp $ .\" .\" Copyright (c) 1982, 1993 @@ -213,7 +213,7 @@ the order that the update requests were being honored must first be understood. .PP When a user program does an operation to change the file system, -such as a +such as a .I write , the data to be written is copied into an internal .I "in-core" @@ -257,7 +257,7 @@ which inode should really claim the block. A similar problem can arise with a multiply claimed inode. .PP The problem with asynchronous inode updates -can be avoided by doing all inode deallocations synchronously. +can be avoided by doing all inode deallocations synchronously. Consequently, inodes and indirect blocks are written to the disk synchronously (\fIi.e.\fP the process blocks until the information is diff --git a/sbin/fsck_ffs/SMM.doc/3.t b/sbin/fsck_ffs/SMM.doc/3.t index 547c90067cc..4c88f25bd6c 100644 --- a/sbin/fsck_ffs/SMM.doc/3.t +++ b/sbin/fsck_ffs/SMM.doc/3.t @@ -1,4 +1,4 @@ -.\" $OpenBSD: 3.t,v 1.4 1996/10/20 08:36:45 tholo Exp $ +.\" $OpenBSD: 3.t,v 1.5 2002/06/09 08:13:06 todd Exp $ .\" $NetBSD: 3.t,v 1.4 1996/10/11 20:15:49 thorpej Exp $ .\" .\" Copyright (c) 1982, 1993 @@ -73,11 +73,11 @@ Normally is run non-interactively. In this mode it will only fix corruptions that are expected to occur from an unclean halt. -These actions are a proper subset of the actions that +These actions are a proper subset of the actions that .I fsck_ffs will take when it is running interactively. -Throughout this paper we assume that -.I fsck_ffs +Throughout this paper we assume that +.I fsck_ffs is being run interactively, and all possible errors can be encountered. When an inconsistency is discovered in this mode, @@ -137,7 +137,7 @@ since they are statically determined by can check that these sizes are within reasonable bounds. All other file system checks require that these sizes be correct. If -.I fsck_ffs +.I fsck_ffs detects corruption in the static parameters of the default super-block, .I fsck_ffs requests the operator to specify the location of an alternate super-block. @@ -355,7 +355,7 @@ When found, will prompt the user to adjust the length of the offending directory which is done by shortening the size of the directory to the end of the last allocated block preceeding the hole. -Unfortunately, this means that another Phase 1 run has to be done. +Unfortunately, this means that another Phase 1 run has to be done. .I Fsck will remind the user to rerun fsck after repairing a directory containing an unallocated block. @@ -403,7 +403,7 @@ This condition only occurs when there has been a hardware failure. .SH \s+2Acknowledgements\s0 .PP -I thank Bill Joy, Sam Leffler, Robert Elz and Dennis Ritchie +I thank Bill Joy, Sam Leffler, Robert Elz and Dennis Ritchie for their suggestions and help in implementing the new file system. Thanks also to Robert Henry for his editorial input to get this document together. diff --git a/sbin/fsck_ffs/SMM.doc/4.t b/sbin/fsck_ffs/SMM.doc/4.t index e24b77d516d..935c984968e 100644 --- a/sbin/fsck_ffs/SMM.doc/4.t +++ b/sbin/fsck_ffs/SMM.doc/4.t @@ -1,4 +1,4 @@ -.\" $OpenBSD: 4.t,v 1.3 1996/10/20 08:36:46 tholo Exp $ +.\" $OpenBSD: 4.t,v 1.4 2002/06/09 08:13:06 todd Exp $ .\" $NetBSD: 4.t,v 1.3 1996/04/05 01:45:48 cgd Exp $ .\" .\" Copyright (c) 1982, 1993 @@ -37,7 +37,7 @@ .ds RH Appendix A \- Fsck_ffs Error Conditions .NH Appendix A \- Fsck_ffs Error Conditions -.NH 2 +.NH 2 Conventions .PP .I Fsck_ffs @@ -65,7 +65,7 @@ the file systems after an unclean halt. While preen'ing a file system, it will only fix corruptions that are expected to occur from an unclean halt. -These actions are a proper subset of the actions that +These actions are a proper subset of the actions that .I fsck_ffs will take when it is running interactively. Throughout this appendix many errors have several options @@ -91,7 +91,7 @@ program in which they can occur. The error conditions that may occur in more than one Phase will be discussed in initialization. -.NH 2 +.NH 2 Initialization .PP Before a file system check can be performed, certain @@ -279,7 +279,7 @@ and will be followed by the message: .br .B "SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck_ffs(8)." .br -The super block has been corrupted. +The super block has been corrupted. An alternative super block must be selected from among those listed by .I newfs @@ -337,7 +337,7 @@ It will retry the read and print out the message: .B "THE FOLLOWING SECTORS COULD NOT BE READ: \fIN\fP" .br where \fIN\fP indicates the sectors that could not be read. -If +If .I fsck_ffs ever tries to write back one of the blocks on which the read failed it will print the message: @@ -392,11 +392,11 @@ terminate the program. .B "bad inode number DDD to ginode" .br An internal error has attempted to read non-existent inode \fIDDD\fP. -This error causes +This error causes .I fsck_ffs to exit. See a guru. -.NH 2 +.NH 2 Phase 1 \- Check Blocks and Sizes .PP This phase concerns itself with @@ -436,7 +436,7 @@ has found inode \fII\fP whose size is shorter than the number of blocks allocated to it. This condition should only occur if the system crashes while in the midst of truncating a file. -When preen'ing the file system, +When preen'ing the file system, .I fsck_ffs completes the truncation to the specified size. .LP @@ -504,11 +504,11 @@ terminate the program. .LP .B "BAD STATE DDD TO BLKERR" .br -An internal error has scrambled +An internal error has scrambled .I fsck_ffs 's state map to have the impossible value \fIDDD\fP. .I Fsck_ffs -exits immediately. +exits immediately. See a guru. .sp .LP @@ -584,7 +584,7 @@ Possible responses to the CORRECT prompt are: replace the block count of inode \fII\fP with \fIY\fP. .IP NO ignore this error condition. -.NH 2 +.NH 2 Phase 1B: Rescan for More Dups .PP When a duplicate block is found in the file system, the file system is @@ -601,7 +601,7 @@ This error condition will always invoke the error condition in Phase 2. You can determine which inodes have overlapping blocks by examining this error condition and the DUP error condition in Phase 1. -.NH 2 +.NH 2 Phase 2 \- Check Pathnames .PP This phase concerns itself with removing directory entries @@ -838,7 +838,7 @@ leave the directory unchanged. .br A directory \fII\fP has been found whose first entry is \fIF\fP. .I Fsck_ffs -cannot resolve this problem. +cannot resolve this problem. The file system should be mounted and the offending entry \fIF\fP moved elsewhere. The file system should then be unmounted and @@ -898,7 +898,7 @@ leave the directory unchanged. .br A directory \fII\fP has been found whose second entry is \fIF\fP. .I Fsck_ffs -cannot resolve this problem. +cannot resolve this problem. The file system should be mounted and the offending entry \fIF\fP moved elsewhere. The file system should then be unmounted and @@ -969,7 +969,7 @@ to the root inode. .I Fsck_ffs exits. See a guru. -.NH 2 +.NH 2 Phase 3 \- Check Connectivity .PP This phase concerns itself with the directory connectivity seen in @@ -1062,13 +1062,13 @@ There is no space to add another entry to the .I lost+found directory in the root directory of the file system. -When preen'ing the +When preen'ing the .I lost+found directory is expanded. .LP Possible responses to the EXPAND prompt are: .IP YES -the +the .I lost+found directory is expanded to make room for the new entry. If the attempted expansion fails @@ -1122,7 +1122,7 @@ routine that descends the file system directory structure. .I Fsck_ffs exits. See a guru. -.NH 2 +.NH 2 Phase 4 \- Check Reference Counts .PP This phase concerns itself with the link count information @@ -1234,13 +1234,13 @@ There is no space to add another entry to the .I lost+found directory in the root directory of the file system. -When preen'ing the +When preen'ing the .I lost+found directory is expanded. .LP Possible responses to the EXPAND prompt are: .IP YES -the +the .I lost+found directory is expanded to make room for the new entry. If the attempted expansion fails @@ -1315,7 +1315,7 @@ Possible responses to the CLEAR prompt are: de-allocate inode \fII\fP by zeroing its contents. .IP NO ignore this error condition. -.NH 2 +.NH 2 Phase 5 - Check Cyl groups .PP This phase concerns itself with the free-block and used-inode maps. @@ -1374,7 +1374,7 @@ Possible responses to the SALVAGE prompt are: reconstruct the superblock free block information. .IP NO ignore this error condition. -.NH 2 +.NH 2 Cleanup .PP Once a file system has been checked, a few cleanup functions are performed. @@ -1408,7 +1408,7 @@ UNIX keeps. When preen'ing, .I fsck_ffs will exit with a code of 4. -The standard auto-reboot script distributed with 4.3BSD +The standard auto-reboot script distributed with 4.3BSD interprets an exit code of 4 by issuing a reboot system call. .sp .LP diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index 30910fe2db6..bdb8ba7cabf 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.11 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: dir.c,v 1.12 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.5 (Berkeley) 12/8/94"; #else -static char rcsid[] = "$OpenBSD: dir.c,v 1.11 2002/02/16 21:27:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: dir.c,v 1.12 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -158,7 +158,7 @@ dirscan(idesc) dirty(bp); sbdirty(); } - if (n & STOP) + if (n & STOP) return (n); } return (idesc->id_filesize > 0 ? KEEPON : STOP); diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index b169c5ed7b9..9f709e8b86f 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.h,v 1.9 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: fsck.h,v 1.10 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: fsck.h,v 1.13 1996/10/11 20:15:46 thorpej Exp $ */ /* @@ -116,14 +116,14 @@ struct inodesc { /* * Linked list of duplicate blocks. - * + * * The list is composed of two parts. The first part of the * list (from duplist through the node pointed to by muldup) - * contains a single copy of each duplicate block that has been + * contains a single copy of each duplicate block that has been * found. The second part of the list (from muldup to the end) * contains duplicate blocks that have been found more than once. * To check if a block has been found as a duplicate it is only - * necessary to search from duplist through muldup. To find the + * necessary to search from duplist through muldup. To find the * total number of times that a block has been found as a duplicate * the entire list must be searched for occurences of the block * in question. The following diagram shows a sample list where diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 128027fa529..4d0f3f42727 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.21 2002/04/23 18:54:12 espie Exp $ */ +/* $OpenBSD: main.c,v 1.22 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.21 2002/04/23 18:54:12 espie Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.22 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -306,7 +306,7 @@ checkfilesys(filesys, mntpt, auxdata, child) sbdirty(); } if (cvtlevel && sblk.b_dirty) { - /* + /* * Write out the duplicate super blocks */ for (cylno = 0; cylno < sblock.fs_ncg; cylno++) diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index c501666ebdd..78130c0080e 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.12 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: pass2.c,v 1.13 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass2.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: pass2.c,v 1.12 2002/02/16 21:27:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: pass2.c,v 1.13 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -69,7 +69,7 @@ pass2_info1(buf, buflen) char *buf; int buflen; { - return snprintf(buf, buflen, "phase 2, directory %d/%d", + return snprintf(buf, buflen, "phase 2, directory %d/%d", info_pos, info_max); } @@ -78,7 +78,7 @@ pass2_info2(buf, buflen) char *buf; int buflen; { - return snprintf(buf, buflen, "phase 2, parent directory %d/%d", + return snprintf(buf, buflen, "phase 2, parent directory %d/%d", info_pos, info_max); } @@ -275,7 +275,7 @@ pass2check(idesc) dirp->d_type = typemap[dirp->d_ino]; ret |= ALTERED; } - /* + /* * check for "." */ if (idesc->id_entryno != 0) diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c index 8d32bb133de..e3dc277247b 100644 --- a/sbin/fsck_ffs/pass4.c +++ b/sbin/fsck_ffs/pass4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass4.c,v 1.5 2001/11/05 07:39:16 mpech Exp $ */ +/* $OpenBSD: pass4.c,v 1.6 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: pass4.c,v 1.11 1996/09/27 22:45:17 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass4.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: pass4.c,v 1.5 2001/11/05 07:39:16 mpech Exp $"; +static char rcsid[] = "$OpenBSD: pass4.c,v 1.6 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -61,7 +61,7 @@ pass4_info(buf, buflen) char * buf; int buflen; { - return snprintf(buf, buflen, "phase 4, inode %d/%d", + return snprintf(buf, buflen, "phase 4, inode %d/%d", info_inumber, lastino); } diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 2e73760b81c..a144f8a8f34 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.15 2002/02/16 21:27:34 millert Exp $ */ +/* $OpenBSD: setup.c,v 1.16 2002/06/09 08:13:05 todd Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.5 (Berkeley) 11/23/94"; #else -static char rcsid[] = "$OpenBSD: setup.c,v 1.15 2002/02/16 21:27:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: setup.c,v 1.16 2002/06/09 08:13:05 todd Exp $"; #endif #endif /* not lint */ @@ -185,7 +185,7 @@ setup(dev) sbdirty(); } } - if (sblock.fs_interleave < 1 || + if (sblock.fs_interleave < 1 || sblock.fs_interleave > sblock.fs_nsect) { pwarn("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK", sblock.fs_interleave); @@ -197,7 +197,7 @@ setup(dev) dirty(&asblk); } } - if (sblock.fs_npsect < sblock.fs_nsect || + if (sblock.fs_npsect < sblock.fs_nsect || sblock.fs_npsect > sblock.fs_nsect*2) { pwarn("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK", sblock.fs_npsect); @@ -372,7 +372,7 @@ setup(dev) } lncntp = (int16_t *)calloc((unsigned)(maxino + 1), sizeof(int16_t)); if (lncntp == NULL) { - printf("cannot alloc %lu bytes for lncntp\n", + printf("cannot alloc %lu bytes for lncntp\n", (unsigned long)(maxino + 1) * sizeof(int16_t)); goto badsblabel; } @@ -384,7 +384,7 @@ setup(dev) inphead = (struct inoinfo **)calloc((unsigned)numdirs, sizeof(struct inoinfo *)); if (inpsort == NULL || inphead == NULL) { - printf("cannot alloc %lu bytes for inphead\n", + printf("cannot alloc %lu bytes for inphead\n", (unsigned long)numdirs * sizeof(struct inoinfo *)); goto badsblabel; } diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index ec4c4e5ac55..6ca35dc492d 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsdb.c,v 1.10 2002/03/14 06:51:41 mpech Exp $ */ +/* $OpenBSD: fsdb.c,v 1.11 2002/06/09 08:13:06 todd Exp $ */ /* $NetBSD: fsdb.c,v 1.7 1997/01/11 06:50:53 lukem Exp $ */ /*- @@ -83,7 +83,7 @@ int returntosingle = 0; struct dinode *curinode; ino_t curinum; -static void +static void usage() { fprintf(stderr, "usage: %s [-d] -f <fsname>\n", __progname); @@ -207,7 +207,7 @@ helpfn(argc, argv) printf("Commands are:\n%-10s %5s %5s %s\n", "command", "min argc", "max argc", "what"); - + for (cmdtp = cmds; cmdtp->cmd; cmdtp++) printf("%-10s %5u %5u %s\n", cmdtp->cmd, cmdtp->minargc, cmdtp->maxargc, cmdtp->helptxt); @@ -386,7 +386,7 @@ static const char *typename[] = { "unregistered #13", "whiteout", }; - + static int slot; static int @@ -449,7 +449,7 @@ CMDFUNCSTART(focusname) return 1; ocurrent = curinum; - + if (argv[1][0] == '/') { curinum = ROOTINO; curinode = ginode(ROOTINO); @@ -526,7 +526,7 @@ CMDFUNCSTART(chinum) char *cp; ino_t inum; struct inodesc idesc; - + slotcount = 0; if (!checkactivedir()) return 1; @@ -577,7 +577,7 @@ CMDFUNCSTART(chname) int rval; char *cp; struct inodesc idesc; - + slotcount = 0; if (!checkactivedir()) return 1; @@ -655,11 +655,11 @@ CMDFUNCSTART(chmode) return 1; modebits = strtol(argv[1], &cp, 8); - if (cp == argv[1] || *cp != '\0' ) { + if (cp == argv[1] || *cp != '\0' ) { warnx("bad modebits `%s'", argv[1]); return 1; } - + curinode->di_mode &= ~07777; curinode->di_mode |= modebits; inodirty(); @@ -698,11 +698,11 @@ CMDFUNCSTART(chaflags) return 1; flags = strtoul(argv[1], &cp, 0); - if (cp == argv[1] || *cp != '\0' ) { + if (cp == argv[1] || *cp != '\0' ) { warnx("bad flags `%s'", argv[1]); return 1; } - + if (flags > UINT_MAX) { warnx("flags set beyond 32-bit range of field (%lx)", flags); return(1); @@ -723,11 +723,11 @@ CMDFUNCSTART(chgen) return 1; gen = strtol(argv[1], &cp, 0); - if (cp == argv[1] || *cp != '\0' ) { + if (cp == argv[1] || *cp != '\0' ) { warnx("bad gen `%s'", argv[1]); return 1; } - + if (gen > INT_MAX || gen < INT_MIN) { warnx("gen set beyond 32-bit range of field (%lx)", gen); return(1); @@ -748,7 +748,7 @@ CMDFUNCSTART(linkcount) return 1; lcnt = strtol(argv[1], &cp, 0); - if (cp == argv[1] || *cp != '\0' ) { + if (cp == argv[1] || *cp != '\0' ) { warnx("bad link count `%s'", argv[1]); return 1; } @@ -756,7 +756,7 @@ CMDFUNCSTART(linkcount) warnx("max link count is %d", USHRT_MAX); return 1; } - + curinode->di_nlink = lcnt; inodirty(); printactive(); @@ -774,7 +774,7 @@ CMDFUNCSTART(chowner) return 1; uid = strtoul(argv[1], &cp, 0); - if (cp == argv[1] || *cp != '\0' ) { + if (cp == argv[1] || *cp != '\0' ) { /* try looking up name */ if ((pwd = getpwnam(argv[1]))) { uid = pwd->pw_uid; @@ -783,7 +783,7 @@ CMDFUNCSTART(chowner) return 1; } } - + curinode->di_uid = uid; inodirty(); printactive(); @@ -801,7 +801,7 @@ CMDFUNCSTART(chgroup) return 1; gid = strtoul(argv[1], &cp, 0); - if (cp == argv[1] || *cp != '\0' ) { + if (cp == argv[1] || *cp != '\0' ) { if ((grp = getgrnam(argv[1]))) { gid = grp->gr_gid; } else { @@ -809,7 +809,7 @@ CMDFUNCSTART(chgroup) return 1; } } - + curinode->di_gid = gid; inodirty(); printactive(); @@ -844,7 +844,7 @@ badformat: for (p = name; *p; p++) if (*p < '0' || *p > '9') goto badformat; - + p = name; #define VAL() ((*p++) - '0') t.tm_year = VAL(); diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c index 713b128ad59..592b61a5977 100644 --- a/sbin/fsdb/fsdbutil.c +++ b/sbin/fsdb/fsdbutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsdbutil.c,v 1.7 2002/03/14 06:51:41 mpech Exp $ */ +/* $OpenBSD: fsdbutil.c,v 1.8 2002/06/09 08:13:06 todd Exp $ */ /* $NetBSD: fsdbutil.c,v 1.5 1996/09/28 19:30:37 christos Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fsdbutil.c,v 1.7 2002/03/14 06:51:41 mpech Exp $"; +static char rcsid[] = "$OpenBSD: fsdbutil.c,v 1.8 2002/06/09 08:13:06 todd Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -93,7 +93,7 @@ argcount(cmdp, argc, argv) else warnx("command `%s' takes from %u to %u arguments", cmdp->cmd, cmdp->minargc-1, cmdp->maxargc-1); - + warnx("usage: %s: %s", cmdp->cmd, cmdp->helptxt); return 1; } diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index a76defcc476..25d8139f746 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsirand.c,v 1.14 2002/02/16 21:27:35 millert Exp $ */ +/* $OpenBSD: fsirand.c,v 1.15 2002/06/09 08:13:06 todd Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -27,9 +27,9 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef lint -static char rcsid[] = "$OpenBSD: fsirand.c,v 1.14 2002/02/16 21:27:35 millert Exp $"; -#endif /* not lint */ +#ifndef lint +static char rcsid[] = "$OpenBSD: fsirand.c,v 1.15 2002/06/09 08:13:06 todd Exp $"; +#endif /* not lint */ #include <sys/types.h> #include <sys/disklabel.h> diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index c35cc3b7c21..3e4fd5323c1 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.56 2002/06/05 06:33:30 jsyn Exp $ +.\" $OpenBSD: ifconfig.8,v 1.57 2002/06/09 08:13:06 todd Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -404,7 +404,7 @@ can either be a string, a series of hexadecimal digits (preceded by or a set of keys of the form .Ar n:k1,k2,k3,k4 , -where +where .Ar n specifies which of the keys will be used for transmitted packets, and the four keys, diff --git a/sbin/init/Makefile b/sbin/init/Makefile index 77f59d9fefc..1536d009758 100644 --- a/sbin/init/Makefile +++ b/sbin/init/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.6 2000/08/20 18:42:39 millert Exp $ +# $OpenBSD: Makefile,v 1.7 2002/06/09 08:13:06 todd Exp $ STATIC= -static PROG= init MAN= init.8 -DPADD= ${LIBUTIL} -LDADD= -lutil +DPADD= ${LIBUTIL} +LDADD= -lutil BINMODE=500 INSTALLFLAGS=-fschg CFLAGS+=-DDEBUGSHELL -DSECURE -DLOGIN_CAP diff --git a/sbin/init/init.c b/sbin/init/init.c index 264e5e07571..0fc7cd144c2 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.26 2002/05/22 08:21:02 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.27 2002/06/09 08:13:06 todd Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: init.c,v 1.26 2002/05/22 08:21:02 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.27 2002/06/09 08:13:06 todd Exp $"; #endif #endif /* not lint */ @@ -652,9 +652,9 @@ single_user() return (state_func_t) requested_transition; if (!WIFEXITED(status)) { - if (WTERMSIG(status) == SIGKILL) { - /* - * reboot(8) killed shell? + if (WTERMSIG(status) == SIGKILL) { + /* + * reboot(8) killed shell? */ warning("single user shell terminated."); sleep(STALL_TIMEOUT); @@ -1023,7 +1023,7 @@ start_window_system(sp) * Start a login session running. * For first open, man-handle tty directly to determine if it * really exists. It is not efficient to spawn gettys on devices - * that do not exist. + * that do not exist. */ pid_t start_getty(sp) @@ -1190,7 +1190,7 @@ multi_user() /* * If the administrator has not set the security level to -1 * to indicate that the kernel should not run multiuser in secure - * mode, and the run script has not set a higher level of security + * mode, and the run script has not set a higher level of security * than level 1, then put the kernel into secure mode. */ if (getsecuritylevel() == 0) diff --git a/sbin/iopctl/iopctl.c b/sbin/iopctl/iopctl.c index a334cda4617..8ca66fe4750 100644 --- a/sbin/iopctl/iopctl.c +++ b/sbin/iopctl/iopctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iopctl.c,v 1.1 2001/07/05 02:07:46 mickey Exp $ */ +/* $OpenBSD: iopctl.c,v 1.2 2002/06/09 08:13:06 todd Exp $ */ /* $NetBSD: iopctl.c,v 1.8 2001/03/20 13:07:51 ad Exp $ */ /*- @@ -270,7 +270,7 @@ showlct(char **argv) show("local tid", "%d", letoh16(ent->localtid) & 4095); show("change indicator", "%d", letoh32(ent->changeindicator)); show("flags", "%x", letoh32(ent->deviceflags)); - show("class id", "%x (%s)", classid & 4095, + show("class id", "%x (%s)", classid & 4095, class2str(classid & 4095)); show("version", "%x", (classid >> 12) & 15); show("organisation id", "%x", classid >> 16); diff --git a/sbin/ipsecadm/ipsecadm.8 b/sbin/ipsecadm/ipsecadm.8 index 3bc5d0d1b7c..f2a0325fb50 100644 --- a/sbin/ipsecadm/ipsecadm.8 +++ b/sbin/ipsecadm/ipsecadm.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ipsecadm.8,v 1.49 2001/12/21 11:41:50 mpech Exp $ +.\" $OpenBSD: ipsecadm.8,v 1.50 2002/06/09 08:13:06 todd Exp $ .\" .\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> .\" All rights reserved. @@ -641,13 +641,13 @@ authentication: .Bd -literal # ipsecadm new esp -enc 3des -auth sha1 -spi 100a -dst 169.20.12.2 \e\ -src 169.20.12.3 \e\ - -key 638063806380638063806380638063806380638063806380 \e\ + -key 638063806380638063806380638063806380638063806380 \e\ -authkey 1234123412341234123412341234123412341234 .Ed .Pp Setup a SA for authentication with old ah only: .Bd -literal -# ipsecadm old ah -auth md5 -spi 10f2 -dst 169.20.12.2 -src 169.20.12.3 \e\ +# ipsecadm old ah -auth md5 -spi 10f2 -dst 169.20.12.2 -src 169.20.12.3 \e\ -key 12341234deadbeef .Ed .Pp diff --git a/sbin/isakmpd/BUGS b/sbin/isakmpd/BUGS index d286c3b3f8f..170282c62e0 100644 --- a/sbin/isakmpd/BUGS +++ b/sbin/isakmpd/BUGS @@ -1,4 +1,4 @@ -$OpenBSD: BUGS,v 1.13 2000/02/19 19:32:20 niklas Exp $ +$OpenBSD: BUGS,v 1.14 2002/06/09 08:13:06 todd Exp $ $EOM: BUGS,v 1.38 2000/02/18 08:47:35 niklas Exp $ Until we have a bug-tracking system setup, we might just add bugs to this @@ -92,7 +92,7 @@ file: * SIGSEGV after sa_enter: sa added to sa list, trigged by DELETE notify (Linux) * Passive connections, undefined local&remote IDs will cause IKE peer IDs - to be used. + to be used. * host route support in KLIPS does not work properly diff --git a/sbin/isakmpd/DESIGN-NOTES b/sbin/isakmpd/DESIGN-NOTES index 5b6ca770c23..88b566fbcff 100644 --- a/sbin/isakmpd/DESIGN-NOTES +++ b/sbin/isakmpd/DESIGN-NOTES @@ -1,4 +1,4 @@ -$OpenBSD: DESIGN-NOTES,v 1.18 2002/04/23 12:51:11 ho Exp $ +$OpenBSD: DESIGN-NOTES,v 1.19 2002/06/09 08:13:06 todd Exp $ $EOM: DESIGN-NOTES,v 1.48 1999/08/12 22:34:25 niklas Exp $ General coding conventions @@ -59,7 +59,7 @@ ike_main_mode.c IKE's main mode exchange logic. ike_phase_1.c Common parts IKE's main & aggressive modes' exchange logic. ike_quick_mode.c IKE's quick mode logic. -init.c Initialization of all modules (might be autogenned in the +init.c Initialization of all modules (might be autogenned in the future). ipsec.c The IPsec DOI. ipsec_fld.fld Description of IPsec DOI-specific packet layouts. @@ -103,7 +103,7 @@ struct hash A hashing class struct ipsec_exch IPsec-specific exchange fields. struct ipsec_proto IPsec-specific protocol attributes. struct ipsec_sa IPsec-specific SA stuff. -struct message A generic ISAKMP message. +struct message A generic ISAKMP message. struct payload A "fat" payload reference pointing into message buffers struct prf A pseudo random function class struct proto Per-protocol attributes. @@ -133,7 +133,7 @@ ISAKMP SA Cookie pair. I.e. there exists a one-to-one Phase 2 exchange Cookie pair + message ID. -Generic SA Cookie pair + message ID + SPI. +Generic SA Cookie pair + message ID + SPI. However it would be really nice to have a name of any SA that is natural to use for human beings, for things like deleting SAs manually. The simplest @@ -251,11 +251,11 @@ The FIFO UI is also described in the isakmpd(8) man page. In addition to giving commands over the FIFO, you may send signals to the daemon. Currently two such signals are implemented: - + SIGHUP Re-initialize isakmpd (not fully implemented yet) SIGUSR1 Generate a report, much as the "r" FIFO command. -For example, to generate a report, you do: +For example, to generate a report, you do: unix# kill -USR1 <PID of isakmpd process> diff --git a/sbin/isakmpd/GNUmakefile b/sbin/isakmpd/GNUmakefile index b61f38d044c..ffd524891ac 100644 --- a/sbin/isakmpd/GNUmakefile +++ b/sbin/isakmpd/GNUmakefile @@ -1,4 +1,4 @@ -# $OpenBSD: GNUmakefile,v 1.2 2001/01/28 22:38:47 niklas Exp $ +# $OpenBSD: GNUmakefile,v 1.3 2002/06/09 08:13:06 todd Exp $ # # Copyright (c) 1998, 1999, 2000 Niklas Hallqvist. All rights reserved. @@ -126,7 +126,7 @@ DEBUG= -g # Ignore any files with these names... .PHONY: mksubdirs all clean cleandir cleandepend beforedepend \ - afterdepend realclean realcleandepend + afterdepend realclean realcleandepend # Default target, it needs to be the first target in makefile... :( @@ -209,12 +209,12 @@ ${PROG} beforedepend: ${GENERATED} ${PROG}: ${OBJS} ${DPADD} ${CC} ${DEBUG} ${LDFLAGS} ${LDSTATIC} -o $@ ${OBJS} ${LDADD} -# Depend rules +# Depend rules depend: beforedepend .depend mksubdirs afterdepend @true # Since 'mkdep' et al maybe doesn't exist... -MKDEP:= ${CC} -MM +MKDEP:= ${CC} -MM .depend: ${SRCS} @rm -f .depend diff --git a/sbin/isakmpd/QUESTIONS b/sbin/isakmpd/QUESTIONS index 08c768bc21b..22bc045cce7 100644 --- a/sbin/isakmpd/QUESTIONS +++ b/sbin/isakmpd/QUESTIONS @@ -1,4 +1,4 @@ -$OpenBSD: QUESTIONS,v 1.3 1998/11/17 11:10:06 niklas Exp $ +$OpenBSD: QUESTIONS,v 1.4 2002/06/09 08:13:06 todd Exp $ $EOM: QUESTIONS,v 1.12 1998/10/11 17:11:06 niklas Exp $ Does the spec limit the count of SA payloads in a message? Where if so? @@ -29,6 +29,6 @@ IV generation is not described precisely in Appendix B of -oakley-08.txt: 'Subsequent messages MUST use the last CBC encryption block from the previous message as their IV'. This probably means that we take the new IV from the last encrypted block of the last message we sent. The SSH testing site uses -the last block from the last message they received. This is probably not +the last block from the last message they received. This is probably not what was meant and should be clarified on ipsec@tis.com. [ From what we have gathered this is what is meant. ] diff --git a/sbin/isakmpd/apps/certpatch/certpatch.c b/sbin/isakmpd/apps/certpatch/certpatch.c index f01da5418b7..98b4da69408 100644 --- a/sbin/isakmpd/apps/certpatch/certpatch.c +++ b/sbin/isakmpd/apps/certpatch/certpatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: certpatch.c,v 1.17 2001/07/11 00:40:29 angelos Exp $ */ +/* $OpenBSD: certpatch.c,v 1.18 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: certpatch.c,v 1.11 2000/12/21 14:50:09 ho Exp $ */ /* @@ -38,7 +38,7 @@ */ /* - * This program takes a certificate generated by ssleay and a + * This program takes a certificate generated by ssleay and a * private key. It encodes a new id as subject alt name * extension into the certifcate. The result gets written as * new certificate that can be used by isakmpd. @@ -155,10 +155,10 @@ main (int argc, char **argv) SSLeay_add_all_algorithms (); /* Use a certificate created by ssleay and add the appr. extension */ - printf ("Reading ssleay created certificate %s and modify it\n", + printf ("Reading ssleay created certificate %s and modify it\n", certin); file = BIO_new (BIO_s_file ()); - if (BIO_read_filename (file, certin) == -1) + if (BIO_read_filename (file, certin) == -1) { perror ("read"); return (1); diff --git a/sbin/isakmpd/apps/keyconv/base64.c b/sbin/isakmpd/apps/keyconv/base64.c index a610d0e5f00..85d957c0d9b 100644 --- a/sbin/isakmpd/apps/keyconv/base64.c +++ b/sbin/isakmpd/apps/keyconv/base64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: base64.c,v 1.2 2001/08/22 15:25:32 ho Exp $ */ +/* $OpenBSD: base64.c,v 1.3 2002/06/09 08:13:07 todd Exp $ */ /* * Copyright (c) 1996-1999 by Internet Software Consortium. @@ -109,9 +109,9 @@ static const char Pad64 = '='; end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the - ------------------------------------------------- + ------------------------------------------------- following cases can arise: - + (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters @@ -153,7 +153,7 @@ b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { target[datalength++] = Base64[output[2]]; target[datalength++] = Base64[output[3]]; } - + /* Now we worry about padding. */ if (0 != srclength) { /* Get what's left. */ diff --git a/sbin/isakmpd/apps/keyconv/keyconv.c b/sbin/isakmpd/apps/keyconv/keyconv.c index 5e9175b5a68..dd737e875fe 100644 --- a/sbin/isakmpd/apps/keyconv/keyconv.c +++ b/sbin/isakmpd/apps/keyconv/keyconv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyconv.c,v 1.3 2002/01/23 18:13:50 ho Exp $ */ +/* $OpenBSD: keyconv.c,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /* * Copyright (c) 2000, 2001 Hakan Olsson. All rights reserved. @@ -698,7 +698,7 @@ convert_openssl_to_dns (char *file_in, char *file_out) { /* * OpenSSL never stores private and public key values, so - * we have to regenerate them from p and g. + * we have to regenerate them from p and g. */ if (DH_generate_key (dh) == 0) { diff --git a/sbin/isakmpd/cert.c b/sbin/isakmpd/cert.c index e1c3434b128..76f088ab5c0 100644 --- a/sbin/isakmpd/cert.c +++ b/sbin/isakmpd/cert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cert.c,v 1.21 2002/06/06 02:15:27 ho Exp $ */ +/* $OpenBSD: cert.c,v 1.22 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: cert.c,v 1.18 2000/09/28 12:53:27 niklas Exp $ */ /* @@ -57,8 +57,8 @@ struct cert_handler cert_handler[] = { #ifdef USE_X509 { - ISAKMP_CERTENC_X509_SIG, - x509_cert_init, x509_cert_get, x509_cert_validate, + ISAKMP_CERTENC_X509_SIG, + x509_cert_init, x509_cert_get, x509_cert_validate, x509_cert_insert, x509_cert_free, x509_certreq_validate, x509_certreq_decode, x509_free_aca, x509_cert_obtain, x509_cert_get_key, x509_cert_get_subjects, diff --git a/sbin/isakmpd/cert.h b/sbin/isakmpd/cert.h index df4db49cb19..eca990c006a 100644 --- a/sbin/isakmpd/cert.h +++ b/sbin/isakmpd/cert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cert.h,v 1.9 2001/07/01 19:48:42 niklas Exp $ */ +/* $OpenBSD: cert.h,v 1.10 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: cert.h,v 1.8 2000/09/28 12:53:27 niklas Exp $ */ /* @@ -42,7 +42,7 @@ #include <sys/types.h> #include <sys/queue.h> -/* +/* * CERT handler for each kind of certificate: * * cert_init - Initialize CERT handler - called only once. @@ -61,7 +61,7 @@ struct cert_handler { u_int16_t id; /* ISAKMP Cert Encoding ID */ int (*cert_init) (void); - void *(*cert_get) (u_int8_t *, u_int32_t); + void *(*cert_get) (u_int8_t *, u_int32_t); int (*cert_validate) (void *); int (*cert_insert) (int, void *); void (*cert_free) (void *); diff --git a/sbin/isakmpd/conf.c b/sbin/isakmpd/conf.c index 5ac87436390..e3b65baa31d 100644 --- a/sbin/isakmpd/conf.c +++ b/sbin/isakmpd/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.41 2002/06/01 07:44:21 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.42 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: conf.c,v 1.48 2000/12/04 02:04:29 angelos Exp $ */ /* @@ -470,7 +470,7 @@ conf_load_defaults (int tr) conf_set (tr, sect, "AUTHENTICATION_METHOD", mm_auth[auth], 0, 1); /* XXX Always DH group 2 (MODP_1024) */ - conf_set (tr, sect, "GROUP_DESCRIPTION", + conf_set (tr, sect, "GROUP_DESCRIPTION", dh_group[group < group_max ? group : 1], 0, 1); conf_set (tr, sect, "Life", CONF_DFLT_TAG_LIFE_MAIN_MODE, 0, 1); @@ -505,7 +505,7 @@ conf_load_defaults (int tr) char tmp[CONF_MAX]; snprintf (tmp, CONF_MAX, "QM-%s%s%s%s%s%s", PROTO (proto), - MODE_p (mode), qm_enc_p[enc], qm_hash_p[hash], + MODE_p (mode), qm_enc_p[enc], qm_hash_p[hash], PFS (pfs), dh_group_p[group]); strlcpy (sect, tmp, CONF_MAX); @@ -545,7 +545,7 @@ conf_load_defaults (int tr) /* XXX Another shortcut -- to keep length down. */ if (pfs) - conf_set (tr, sect, "GROUP_DESCRIPTION", + conf_set (tr, sect, "GROUP_DESCRIPTION", dh_group[group < group_max ? group : 1], 0, 1); } diff --git a/sbin/isakmpd/crypto.c b/sbin/isakmpd/crypto.c index c46eba7ac44..25462e55f8c 100644 --- a/sbin/isakmpd/crypto.c +++ b/sbin/isakmpd/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.12 2002/06/01 07:44:21 deraadt Exp $ */ +/* $OpenBSD: crypto.c,v 1.13 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: crypto.c,v 1.32 2000/03/07 20:08:51 niklas Exp $ */ /* @@ -143,7 +143,7 @@ des3_encrypt (struct keystate *ks, u_int8_t *data, u_int16_t len) u_int8_t iv[MAXBLK]; memcpy (iv, ks->riv, ks->xf->blocksize); - des_ede3_cbc_encrypt (DC data, DC data, len, ks->ks_des[0], ks->ks_des[1], + des_ede3_cbc_encrypt (DC data, DC data, len, ks->ks_des[0], ks->ks_des[1], ks->ks_des[2], DC iv, DES_ENCRYPT); } @@ -153,12 +153,12 @@ des3_decrypt (struct keystate *ks, u_int8_t *data, u_int16_t len) u_int8_t iv[MAXBLK]; memcpy (iv, ks->riv, ks->xf->blocksize); - des_ede3_cbc_encrypt (DC data, DC data, len, ks->ks_des[0], ks->ks_des[1], + des_ede3_cbc_encrypt (DC data, DC data, len, ks->ks_des[0], ks->ks_des[1], ks->ks_des[2], DC iv, DES_DECRYPT); } #undef DC #endif /* USE_TRIPLEDES */ - + #ifdef USE_BLOWFISH enum cryptoerr blf_init (struct keystate *ks, u_int8_t *key, u_int16_t len) @@ -194,7 +194,7 @@ blf_decrypt (struct keystate *ks, u_int8_t *data, u_int16_t len) { u_int16_t i, blocksize = ks->xf->blocksize; u_int32_t xl, xr; - + data += len - blocksize; for (i = len - blocksize; i >= blocksize; data -= blocksize, i -= blocksize) { diff --git a/sbin/isakmpd/crypto.h b/sbin/isakmpd/crypto.h index 7984bb2afe1..c15fcdd05b6 100644 --- a/sbin/isakmpd/crypto.h +++ b/sbin/isakmpd/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.4 2000/10/16 23:28:04 niklas Exp $ */ +/* $OpenBSD: crypto.h,v 1.5 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: crypto.h,v 1.12 2000/10/15 21:56:41 niklas Exp $ */ /* @@ -54,7 +54,7 @@ #elif defined (USE_32BIT) #define XOR64(x,y) *(u_int32_t *)(x) ^= *(u_int32_t *)(y); \ - *(u_int32_t *)((u_int8_t *)(x) + 4) ^= *(u_int32_t *)((u_int8_t *)(y) + 4); + *(u_int32_t *)((u_int8_t *)(x) + 4) ^= *(u_int32_t *)((u_int8_t *)(y) + 4); #define SET64(x,y) *(u_int32_t *)(x) = *(u_int32_t *)(y); \ *(u_int32_t *)((u_int8_t *)(x) + 4) = *(u_int32_t *)((u_int8_t *)(y) + 4); @@ -70,14 +70,14 @@ #endif /* USE_64BIT */ #define SET_32BIT_BIG(x,y) (x)[3]= (y); (x)[2]= (y) >> 8; \ - (x)[1] = (y) >> 16; (x)[0]= (y) >> 24; + (x)[1] = (y) >> 16; (x)[0]= (y) >> 24; #define GET_32BIT_BIG(x) (u_int32_t)(x)[3] | ((u_int32_t)(x)[2] << 8) | \ ((u_int32_t)(x)[1] << 16)| ((u_int32_t)(x)[0] << 24); -/* +/* * This is standard for all block ciphers we use at the moment. * Theoretically this could increase in future, e.g. for TwoFish. - * Keep MAXBLK uptodate + * Keep MAXBLK uptodate */ #define BLOCKSIZE 8 diff --git a/sbin/isakmpd/dh.c b/sbin/isakmpd/dh.c index 16beb6a746d..80e31176477 100644 --- a/sbin/isakmpd/dh.c +++ b/sbin/isakmpd/dh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.c,v 1.6 2001/04/09 22:09:51 ho Exp $ */ +/* $OpenBSD: dh.c,v 1.7 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: dh.c,v 1.5 1999/04/17 23:20:22 niklas Exp $ */ /* @@ -58,7 +58,7 @@ dh_getlen (struct group *group) * Each time this function is called a new value is created, that * means the application has to save the exchange value itself, * dh_create_exchange should only be called once. - */ + */ int dh_create_exchange (struct group *group, u_int8_t *buf) { diff --git a/sbin/isakmpd/dnssec.c b/sbin/isakmpd/dnssec.c index c84c794df54..e0482300a3c 100644 --- a/sbin/isakmpd/dnssec.c +++ b/sbin/isakmpd/dnssec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dnssec.c,v 1.12 2002/01/03 16:27:41 ho Exp $ */ +/* $OpenBSD: dnssec.c,v 1.13 2002/06/09 08:13:06 todd Exp $ */ /* * Copyright (c) 2001 Håkan Olsson. All rights reserved. @@ -95,7 +95,7 @@ dns_get_key (int type, struct message *msg, int *keylen) /* algorithm = DNS_KEYALG_DSS; */ return 0; - case IKE_AUTH_PRE_SHARED: + case IKE_AUTH_PRE_SHARED: default: return 0; } @@ -121,7 +121,7 @@ dns_get_key (int type, struct message *msg, int *keylen) if (id_len < sizeof ip4) return 0; memcpy (&ip4, id + ISAKMP_ID_DATA_OFF, sizeof ip4); - snprintf (name, MAXHOSTNAMELEN, "%d.%d.%d.%d.in-addr.arpa.", ip4 >> 24, + snprintf (name, MAXHOSTNAMELEN, "%d.%d.%d.%d.in-addr.arpa.", ip4 >> 24, (ip4 >> 16) & 0xFF, (ip4 >> 8) & 0xFF, ip4 & 0xFF); break; @@ -173,16 +173,16 @@ dns_get_key (int type, struct message *msg, int *keylen) if (ret) { - LOG_DBG ((LOG_MISC, 30, "dns_get_key: no DNS responses (error %d)", + LOG_DBG ((LOG_MISC, 30, "dns_get_key: no DNS responses (error %d)", ret)); return 0; } - - LOG_DBG ((LOG_MISC, 80, + + LOG_DBG ((LOG_MISC, 80, "dns_get_key: rrset class %d type %d ttl %d nrdatas %d nrsigs %d", - rr->rri_rdclass, rr->rri_rdtype, rr->rri_ttl, rr->rri_nrdatas, + rr->rri_rdclass, rr->rri_rdtype, rr->rri_ttl, rr->rri_nrdatas, rr->rri_nsigs)); - + /* We don't accept unvalidated data. */ if (!(rr->rri_flags & RRSET_VALIDATED)) { @@ -190,18 +190,18 @@ dns_get_key (int type, struct message *msg, int *keylen) freerrset (rr); return 0; } - + /* Sanity. */ if (rr->rri_nrdatas == 0 || rr->rri_rdtype != T_KEY) { LOG_DBG ((LOG_MISC, 30, "dns_get_key: no KEY RRs received")); freerrset (rr); return 0; - } + } memset (&key_rr, 0, sizeof key_rr); - /* + /* * Find a key with the wanted algorithm, if any. * XXX If there are several keys present, we currently only find the first. */ diff --git a/sbin/isakmpd/exchange.h b/sbin/isakmpd/exchange.h index faae678c901..c29c54f2480 100644 --- a/sbin/isakmpd/exchange.h +++ b/sbin/isakmpd/exchange.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exchange.h,v 1.20 2001/06/05 05:59:43 niklas Exp $ */ +/* $OpenBSD: exchange.h,v 1.21 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: exchange.h,v 1.28 2000/09/28 12:54:28 niklas Exp $ */ /* @@ -156,9 +156,9 @@ struct exchange { /* Used only by KeyNote, to cache the key used to authenticate Phase 1 */ char *keynote_key; /* printable format */ - /* + /* * Received certificate - used to verify signatures on packet, - * stored here for later policy processing. + * stored here for later policy processing. * * The rules for the recv_* and sent_* fields are: * - recv_cert stores the credential (if any) received from the peer; diff --git a/sbin/isakmpd/genconstants.sh b/sbin/isakmpd/genconstants.sh index 0744d7f0e19..21e1eb78ab1 100644 --- a/sbin/isakmpd/genconstants.sh +++ b/sbin/isakmpd/genconstants.sh @@ -1,4 +1,4 @@ -# $OpenBSD: genconstants.sh,v 1.8 2001/01/27 12:03:32 niklas Exp $ +# $OpenBSD: genconstants.sh,v 1.9 2002/06/09 08:13:06 todd Exp $ # $EOM: genconstants.sh,v 1.6 1999/04/02 01:15:53 niklas Exp $ # @@ -46,7 +46,7 @@ locase_function='function locase (str) { return retval; }' -$awk " +$awk " $locase_function "' BEGIN { diff --git a/sbin/isakmpd/genfields.sh b/sbin/isakmpd/genfields.sh index 827bf2df1d7..9ed30c76d10 100644 --- a/sbin/isakmpd/genfields.sh +++ b/sbin/isakmpd/genfields.sh @@ -1,4 +1,4 @@ -# $OpenBSD: genfields.sh,v 1.6 2001/01/27 12:03:32 niklas Exp $ +# $OpenBSD: genfields.sh,v 1.7 2002/06/09 08:13:06 todd Exp $ # $EOM: genfields.sh,v 1.5 1999/04/02 01:15:55 niklas Exp $ # @@ -46,7 +46,7 @@ locase_function='function locase (str) { return retval; }' -$awk " +$awk " $locase_function "' BEGIN { diff --git a/sbin/isakmpd/hash.c b/sbin/isakmpd/hash.c index a5984e317ee..c0a2b12c508 100644 --- a/sbin/isakmpd/hash.c +++ b/sbin/isakmpd/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.8 2001/08/17 14:12:54 niklas Exp $ */ +/* $OpenBSD: hash.c,v 1.9 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: hash.c,v 1.10 1999/04/17 23:20:34 niklas Exp $ */ /* @@ -62,14 +62,14 @@ static unsigned char digest[HASH_MAX]; static struct hash hashes[] = { { HASH_MD5, 5, MD5_SIZE, (void *)&Ctx.md5ctx, digest, sizeof (MD5_CTX), (void *)&Ctx2.md5ctx, - (void (*) (void *))MD5Init, - (void (*) (void *, unsigned char *, unsigned int))MD5Update, + (void (*) (void *))MD5Init, + (void (*) (void *, unsigned char *, unsigned int))MD5Update, (void (*) (unsigned char *, void *))MD5Final, hmac_init, hmac_final }, { HASH_SHA1, 6, SHA1_SIZE, (void *)&Ctx.sha1ctx, digest, sizeof (SHA1_CTX), (void *)&Ctx2.sha1ctx, - (void (*) (void *))SHA1Init, - (void (*) (void *, unsigned char *, unsigned int))SHA1Update, + (void (*) (void *))SHA1Init, + (void (*) (void *, unsigned char *, unsigned int))SHA1Update, (void (*) (unsigned char *, void *))SHA1Final, hmac_init, hmac_final }, }; @@ -101,7 +101,7 @@ hmac_init (struct hash *hash, unsigned char *okey, int len) unsigned char key[HMAC_BLOCKLEN]; memset (key, 0, blocklen); - if (len > blocklen) + if (len > blocklen) { /* Truncate key down to blocklen */ hash->Init (hash->ctx); @@ -125,7 +125,7 @@ hmac_init (struct hash *hash, unsigned char *okey, int len) hash->Init (hash->ctx2); hash->Update (hash->ctx2, key, blocklen); - + memset (key, 0, blocklen); } diff --git a/sbin/isakmpd/if.c b/sbin/isakmpd/if.c index 354ba983356..e21ac1af727 100644 --- a/sbin/isakmpd/if.c +++ b/sbin/isakmpd/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.10 2001/10/26 13:29:26 ho Exp $ */ +/* $OpenBSD: if.c,v 1.11 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: if.c,v 1.12 1999/10/01 13:45:20 niklas Exp $ */ /* @@ -109,7 +109,7 @@ siocgifconf (struct ifconf *ifcp) } close (s); return 0; - + err: if (buf) free (buf); diff --git a/sbin/isakmpd/ike_auth.c b/sbin/isakmpd/ike_auth.c index ec6f7380a96..0bfc004c542 100644 --- a/sbin/isakmpd/ike_auth.c +++ b/sbin/isakmpd/ike_auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ike_auth.c,v 1.63 2002/06/01 07:44:21 deraadt Exp $ */ +/* $OpenBSD: ike_auth.c,v 1.64 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: ike_auth.c,v 1.59 2000/11/21 00:21:31 angelos Exp $ */ /* @@ -1251,7 +1251,7 @@ get_raw_key_from_file (int type, u_int8_t *id, size_t id_len, RSA **rsa) else LOG_DBG((LOG_NEGOTIATION, 50, "get_raw_key_from_file: file %s not found", filename)); - + return (*rsa ? 0 : -1); } #endif /* USE_RAWKEY */ diff --git a/sbin/isakmpd/ipsec.c b/sbin/isakmpd/ipsec.c index d539f1cff9f..338c68eb50f 100644 --- a/sbin/isakmpd/ipsec.c +++ b/sbin/isakmpd/ipsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec.c,v 1.66 2002/06/07 04:56:13 ho Exp $ */ +/* $OpenBSD: ipsec.c,v 1.67 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: ipsec.c,v 1.143 2000/12/11 23:57:42 niklas Exp $ */ /* @@ -211,13 +211,13 @@ ipsec_sa_check (struct sa *sa, void *v_arg) return 0; sa->transport->vtbl->get_dst (sa->transport, &dst); - if (memcmp (sockaddr_addrdata (dst), sockaddr_addrdata (arg->dst), + if (memcmp (sockaddr_addrdata (dst), sockaddr_addrdata (arg->dst), sockaddr_addrlen (dst)) == 0) incoming = 0; else { sa->transport->vtbl->get_src (sa->transport, &src); - if (memcmp (sockaddr_addrdata (src), sockaddr_addrdata (arg->dst), + if (memcmp (sockaddr_addrdata (src), sockaddr_addrdata (arg->dst), sockaddr_addrlen (src)) == 0) incoming = 1; else @@ -256,7 +256,7 @@ ipsec_sa_check_flow (struct sa *sa, void *v_arg) || (sa->flags & (SA_FLAG_READY | SA_FLAG_REPLACED)) != SA_FLAG_READY) return 0; - if (isa->tproto != isa2->tproto || isa->sport != isa2->sport + if (isa->tproto != isa2->tproto || isa->sport != isa2->sport || isa->dport != isa2->dport) return 0; @@ -270,7 +270,7 @@ ipsec_sa_check_flow (struct sa *sa, void *v_arg) && memcmp (sockaddr_addrdata (isa->dst_net), sockaddr_addrdata (isa2->dst_net), sockaddr_addrlen (isa->dst_net)) == 0 - && memcmp (sockaddr_addrdata (isa->dst_mask), + && memcmp (sockaddr_addrdata (isa->dst_mask), sockaddr_addrdata (isa2->dst_mask), sockaddr_addrlen (isa->dst_mask)) == 0; } @@ -373,7 +373,7 @@ ipsec_finalize_exchange (struct message *msg) addr2 = 0; if (sockaddr2text (isa->dst_mask, &mask2, 0)) mask2 = 0; - + LOG_DBG ((LOG_EXCHANGE, 50, "ipsec_finalize_exchange: " "src %s %s dst %s %s tproto %u sport %u dport %u", @@ -422,7 +422,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) { case IPSEC_ID_IPV4_ADDR: case IPSEC_ID_IPV4_ADDR_SUBNET: - isa->src_net = + isa->src_net = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in)); if (!isa->src_net) return -1; @@ -431,7 +431,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) isa->src_net->sa_len = sizeof (struct sockaddr_in); #endif - isa->src_mask = + isa->src_mask = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in)); if (!isa->src_mask) return -1; @@ -443,7 +443,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) case IPSEC_ID_IPV6_ADDR: case IPSEC_ID_IPV6_ADDR_SUBNET: - isa->src_net = + isa->src_net = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in6)); if (!isa->src_net) return -1; @@ -452,7 +452,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) isa->src_net->sa_len = sizeof (struct sockaddr_in6); #endif - isa->src_mask = + isa->src_mask = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in6)); if (!isa->src_mask) return -1; @@ -472,7 +472,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) { case IPSEC_ID_IPV4_ADDR: case IPSEC_ID_IPV6_ADDR: - memset (sockaddr_addrdata (isa->src_mask), 0xff, + memset (sockaddr_addrdata (isa->src_mask), 0xff, sockaddr_addrlen (isa->src_mask)); break; case IPSEC_ID_IPV4_ADDR_SUBNET: @@ -492,7 +492,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) { case IPSEC_ID_IPV4_ADDR: case IPSEC_ID_IPV4_ADDR_SUBNET: - isa->dst_net = + isa->dst_net = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in)); if (!isa->dst_net) return -1; @@ -501,7 +501,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) isa->dst_net->sa_len = sizeof (struct sockaddr_in); #endif - isa->dst_mask = + isa->dst_mask = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in)); if (!isa->dst_mask) return -1; @@ -513,7 +513,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) case IPSEC_ID_IPV6_ADDR: case IPSEC_ID_IPV6_ADDR_SUBNET: - isa->dst_net = + isa->dst_net = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in6)); if (!isa->dst_net) return -1; @@ -522,7 +522,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) isa->dst_net->sa_len = sizeof (struct sockaddr_in6); #endif - isa->dst_mask = + isa->dst_mask = (struct sockaddr *)calloc (1, sizeof (struct sockaddr_in6)); if (!isa->dst_mask) return -1; @@ -542,7 +542,7 @@ ipsec_set_network (u_int8_t *src_id, u_int8_t *dst_id, struct ipsec_sa *isa) { case IPSEC_ID_IPV4_ADDR: case IPSEC_ID_IPV6_ADDR: - memset (sockaddr_addrdata (isa->dst_mask), 0xff, + memset (sockaddr_addrdata (isa->dst_mask), 0xff, sockaddr_addrlen (isa->dst_mask)); break; case IPSEC_ID_IPV4_ADDR_SUBNET: @@ -954,25 +954,25 @@ ipsec_initiator (struct message *msg) * or 4-octet otherwise. */ static void -ipsec_delete_spi_list (struct sockaddr *addr, u_int8_t proto, +ipsec_delete_spi_list (struct sockaddr *addr, u_int8_t proto, u_int8_t *spis, int nspis, char *type) { struct sa *sa; int i; - for (i = 0; i < nspis; i++) + for (i = 0; i < nspis; i++) { if (proto == ISAKMP_PROTO_ISAKMP) { u_int8_t *spi = spis + i * ISAKMP_HDR_COOKIES_LEN; - /* + /* * This really shouldn't happen in IPSEC DOI * code, but Cisco VPN 3000 sends ISAKMP DELETE's * this way. */ sa = sa_lookup_isakmp_sa (addr, spi); - } + } else { u_int32_t spi = ((u_int32_t *)spis)[i]; @@ -1009,7 +1009,7 @@ ipsec_invalid_spi (struct message *msg, struct payload *p) u_int16_t totsiz; u_int8_t spisz; - /* + /* * get the invalid spi out of the variable sized notification data * field, which is after the variable sized SPI field [which specifies * the receiving entity's phase-1 SPI, not the invalid spi] @@ -1914,7 +1914,7 @@ ipsec_decode_id (u_int8_t *buf, int size, u_int8_t *id, size_t id_len, case IPSEC_ID_IPV6_ADDR_SUBNET: util_ntoa (&addr, AF_INET6, id + ISAKMP_ID_DATA_OFF); - util_ntoa (&addr, AF_INET6, id + ISAKMP_ID_DATA_OFF + + util_ntoa (&addr, AF_INET6, id + ISAKMP_ID_DATA_OFF + sizeof (struct in6_addr)); snprintf (buf, size, "%08x%08x%08x%08x/%08x%08x%08x%08x: %s/%s", *idp, *(idp + 1), *(idp + 2), *(idp + 3), *(idp + 4), @@ -2007,7 +2007,7 @@ ipsec_build_id (char *section, size_t *sz) memcpy (p + ISAKMP_ID_DATA_OFF, sockaddr_addrdata (addr), sockaddr_addrlen (addr)); if (subnet) - memcpy (p + ISAKMP_ID_DATA_OFF + sockaddr_addrlen (addr), + memcpy (p + ISAKMP_ID_DATA_OFF + sockaddr_addrlen (addr), sockaddr_addrdata (mask), sockaddr_addrlen (mask)); SET_IPSEC_ID_PROTO (p + ISAKMP_ID_DOI_DATA_OFF, tproto); diff --git a/sbin/isakmpd/ipsec.h b/sbin/isakmpd/ipsec.h index 71f4b1fe868..c4501eb6ef1 100644 --- a/sbin/isakmpd/ipsec.h +++ b/sbin/isakmpd/ipsec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec.h,v 1.20 2002/06/08 23:09:46 ho Exp $ */ +/* $OpenBSD: ipsec.h,v 1.21 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: ipsec.h,v 1.42 2000/12/03 07:58:20 angelos Exp $ */ /* @@ -159,7 +159,7 @@ extern int ipsec_esp_authkeylength (struct proto *); extern int ipsec_esp_enckeylength (struct proto *); extern int ipsec_fill_in_hash (struct message *msg); extern int ipsec_gen_g_x (struct message *); -extern int ipsec_get_id (char *, int *, struct sockaddr **, +extern int ipsec_get_id (char *, int *, struct sockaddr **, struct sockaddr **, u_int8_t *, u_int16_t *); extern ssize_t ipsec_id_size (char *, u_int8_t *); extern char *ipsec_id_string (u_int8_t *, size_t); diff --git a/sbin/isakmpd/isakmp_cfg.c b/sbin/isakmpd/isakmp_cfg.c index f2d9608e414..91ebc15aea3 100644 --- a/sbin/isakmpd/isakmp_cfg.c +++ b/sbin/isakmpd/isakmp_cfg.c @@ -244,7 +244,7 @@ cfg_initiator_send_ATTR (struct message *msg) conf_free_list (alist); } } - + if (attrlen == 0) { /* No data found. */ @@ -362,11 +362,11 @@ cfg_initiator_send_ATTR (struct message *msg) off += ISAKMP_ATTR_SZ + length; } - + if (msg->exchange->phase == 2) if (cfg_finalize_hash (msg, hashp, attrp, attrlen)) goto fail; - + return 0; fail: @@ -433,7 +433,7 @@ cfg_initiator_recv_ATTR (struct message *msg) attribute_map (attrp->p + ISAKMP_ATTRIBUTE_ATTRS_OFF, GET_ISAKMP_GEN_LENGTH (attrp->p) - ISAKMP_TRANSFORM_SA_ATTRS_OFF, cfg_decode_attribute, ie); - + switch (ie->cfg_type) { case ISAKMP_CFG_ACK: @@ -442,7 +442,7 @@ cfg_initiator_recv_ATTR (struct message *msg) msg->transport->vtbl->get_src (isakmp_sa->transport, &sa); if (sockaddr2text (sa, &addr, 0) < 0) addr = (char *)uk_addr; - + for (attr = LIST_FIRST (&ie->attrs); attr; attr = LIST_NEXT (attr, link)) LOG_DBG ((LOG_NEGOTIATION, 50, "cfg_initiator_recv_ATTR: " @@ -460,7 +460,7 @@ cfg_initiator_recv_ATTR (struct message *msg) msg->transport->vtbl->get_src (isakmp_sa->transport, &sa); if (sockaddr2text (sa, &addr, 0) < 0) addr = (char *)uk_addr; - + for (attr = LIST_FIRST (&ie->attrs); attr; attr = LIST_NEXT (attr, link)) LOG_DBG ((LOG_NEGOTIATION, 50, "cfg_initiator_recv_ATTR: " @@ -533,7 +533,7 @@ cfg_responder_recv_ATTR (struct message *msg) msg->transport->vtbl->get_dst (isakmp_sa->transport, &sa); if (sockaddr2text (sa, &addr, 0) < 0) addr = (char *)uk_addr; - + for (attr = LIST_FIRST (&ie->attrs); attr; attr = LIST_NEXT (attr, link)) LOG_DBG ((LOG_NEGOTIATION, 50, "cfg_responder_recv_ATTR: " @@ -600,7 +600,7 @@ cfg_responder_send_ATTR (struct message *msg) return -1; } free (id_string); - + if (message_add_payload (msg, ISAKMP_PAYLOAD_ATTRIBUTE, attrp, attrlen, 1)) { free (attrp); @@ -783,7 +783,7 @@ cfg_encode_attributes (struct isakmp_cfg_attr_head *attrs, u_int32_t type, /* With ACK we only include the attrs we've actually used. */ if (type == ISAKMP_CFG_ACK && attr->attr_used == 0) continue; - + switch (attr->type) { case ISAKMP_CFG_ATTR_INTERNAL_IP4_ADDRESS: @@ -882,22 +882,22 @@ cfg_encode_attributes (struct isakmp_cfg_attr_head *attrs, u_int32_t type, case ISAKMP_CFG_ATTR_INTERNAL_IP6_SUBNET: field = "Network"; /* XXX or just "Address" */ break; - + case ISAKMP_CFG_ATTR_INTERNAL_IP4_NETMASK: case ISAKMP_CFG_ATTR_INTERNAL_IP6_NETMASK: field = "Netmask"; break; - + case ISAKMP_CFG_ATTR_INTERNAL_IP4_DHCP: case ISAKMP_CFG_ATTR_INTERNAL_IP6_DHCP: field = "DHCP-server"; break; - + case ISAKMP_CFG_ATTR_INTERNAL_IP4_DNS: case ISAKMP_CFG_ATTR_INTERNAL_IP6_DNS: field = "Nameserver"; break; - + case ISAKMP_CFG_ATTR_INTERNAL_IP4_NBNS: case ISAKMP_CFG_ATTR_INTERNAL_IP6_NBNS: field = "WINS-server"; diff --git a/sbin/isakmpd/isakmpd.8 b/sbin/isakmpd/isakmpd.8 index 26f7369da6a..ef59e91d4a8 100644 --- a/sbin/isakmpd/isakmpd.8 +++ b/sbin/isakmpd/isakmpd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: isakmpd.8,v 1.39 2002/04/10 20:56:28 ho Exp $ +.\" $OpenBSD: isakmpd.8,v 1.40 2002/06/09 08:13:06 todd Exp $ .\" $EOM: isakmpd.8,v 1.23 2000/05/02 00:30:23 niklas Exp $ .\" .\" Copyright (c) 1998, 1999, 2000, 2001 Niklas Hallqvist. @@ -375,7 +375,7 @@ Phase 1 SA. .It Ic "D T" Set debug class <class> to level <level>. If <class> is specified as "A", the level applies to all debug classes. -"D T" toggles all debug classes to level zero. +"D T" toggles all debug classes to level zero. Another "D T" command will toggle them back to the earlier levels. .Pp .It Ic "p on[=<path>]" @@ -393,7 +393,7 @@ Report .Nm internal state to a file. See .Fl R -option. Same as when sent a SIGUSR1 signal. +option. Same as when sent a SIGUSR1 signal. .Pp .It Ic "R" Reinitialize diff --git a/sbin/isakmpd/isakmpd.c b/sbin/isakmpd/isakmpd.c index 02c1a3a9ef5..aa76265dd36 100644 --- a/sbin/isakmpd/isakmpd.c +++ b/sbin/isakmpd/isakmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isakmpd.c,v 1.42 2002/06/07 01:07:18 ho Exp $ */ +/* $OpenBSD: isakmpd.c,v 1.43 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: isakmpd.c,v 1.54 2000/10/05 09:28:22 niklas Exp $ */ /* @@ -301,10 +301,10 @@ daemon_shutdown (void) if (transport_prio_sendqs_empty ()) { /* - * When the prioritized transport sendq:s are empty, i.e all + * When the prioritized transport sendq:s are empty, i.e all * the DELETE notifications have been sent, we can shutdown. */ - + #ifdef USE_DEBUG log_packet_stop (); #endif @@ -418,7 +418,7 @@ main (int argc, char *argv[]) * indicated we should start a shutdown of the daemon. * * Note: Since _one_ message is sent per iteration of this enclosing - * while-loop, and we want to send a number of DELETE notifications, + * while-loop, and we want to send a number of DELETE notifications, * we must loop atleast this number of times. The daemon_shutdown() * function starts by queueing the DELETEs, all other calls just * increments the 'sigtermed' variable until it reaches a "safe" diff --git a/sbin/isakmpd/isakmpd.conf.5 b/sbin/isakmpd/isakmpd.conf.5 index af377d2a811..976a9b386c4 100644 --- a/sbin/isakmpd/isakmpd.conf.5 +++ b/sbin/isakmpd/isakmpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: isakmpd.conf.5,v 1.64 2002/04/10 20:56:57 ho Exp $ +.\" $OpenBSD: isakmpd.conf.5,v 1.65 2002/06/09 08:13:06 todd Exp $ .\" $EOM: isakmpd.conf.5,v 1.57 2000/12/21 14:43:17 ho Exp $ .\" .\" Copyright (c) 1998, 1999, 2000 Niklas Hallqvist. All rights reserved. @@ -110,14 +110,14 @@ SHA hash, and use Perfect Forward Security. .Pp .Pp Unless explicitly stated with -GRP1, 2 or 5, transforms and PFS suites -use DH group 2. There are currently no predefined ESP+AH Quick Mode suites. +use DH group 2. There are currently no predefined ESP+AH Quick Mode suites. .Pp The predefinitions include some default values for the special sections "General", and "X509-certificates". These default values are presented in the example below. .Pp All autogenerated values can be overridden by manual entries by using the -same section and tag names in the configuration file. +same section and tag names in the configuration file. In particular, the default phase 1 (Main or Aggressive Mode) and phase 2 (Quick Mode) lifetimes can be overridden by these tags under the "General" section; @@ -130,7 +130,7 @@ Default-phase-2-lifetime= 1200,60:86400 .Pp The Main Mode lifetime currently defaults to one hour (minimum 60 seconds, maximum 1 day). The Quick Mode lifetime defaults to 20 -minutes (minimum 60 seconds, maximum 1 day). +minutes (minimum 60 seconds, maximum 1 day). .\"XXX Following empty .Ss works around a nroff bug, we want the new line." .Ss .Pp @@ -621,7 +621,7 @@ The Protocol tag must be specified in conjunction with this tag. .It Em <IKECFG-ID> Parameters to use with IKE mode-config. One ID per peer. .Pp -An IKECFG-ID is written as [<ID-type>/<name>]. +An IKECFG-ID is written as [<ID-type>/<name>]. The following ID types are supported: .Bl -tag -width 12n .It IPv4 diff --git a/sbin/isakmpd/libcrypto.h b/sbin/isakmpd/libcrypto.h index 853432b5973..43ffb378402 100644 --- a/sbin/isakmpd/libcrypto.h +++ b/sbin/isakmpd/libcrypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libcrypto.h,v 1.12 2002/03/05 00:10:26 deraadt Exp $ */ +/* $OpenBSD: libcrypto.h,v 1.13 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: libcrypto.h,v 1.16 2000/09/28 12:53:27 niklas Exp $ */ /* @@ -66,7 +66,7 @@ extern void *libcrypto; #ifdef HAVE_DLOPEN -/* +/* * These prototypes matches SSLeay version 0.9.0b or OpenSSL 0.9.4, if you * try to load a different version than that, you are on your own. */ diff --git a/sbin/isakmpd/log.c b/sbin/isakmpd/log.c index f05d404a49e..f09a32c5383 100644 --- a/sbin/isakmpd/log.c +++ b/sbin/isakmpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.28 2002/05/10 15:13:12 ho Exp $ */ +/* $OpenBSD: log.c,v 1.29 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: log.c,v 1.30 2000/09/29 08:19:23 niklas Exp $ */ /* @@ -137,11 +137,11 @@ _log_get_class (int error_class) } static void -_log_print (int error, int syslog_level, const char *fmt, va_list ap, +_log_print (int error, int syslog_level, const char *fmt, va_list ap, int class, int level) { char buffer[LOG_SIZE], nbuf[LOG_SIZE + 32]; - static const char fallback_msg[] = + static const char fallback_msg[] = "write to log file failed (errno %d), redirecting output to syslog"; int len; struct tm *tm; @@ -161,7 +161,7 @@ _log_print (int error, int syslog_level, const char *fmt, va_list ap, tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec, _log_get_class (class), level); else /* LOG_PRINT (-1) or LOG_REPORT (-2) */ - snprintf (nbuf, LOG_SIZE + 32, "%02d%02d%02d.%06ld %s ", tm->tm_hour, + snprintf (nbuf, LOG_SIZE + 32, "%02d%02d%02d.%06ld %s ", tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec, class == LOG_PRINT ? "Default" : "Report>"); strlcat (nbuf, buffer, LOG_SIZE + 32); @@ -173,11 +173,11 @@ _log_print (int error, int syslog_level, const char *fmt, va_list ap, syslog (LOG_ALERT, fallback_msg, errno); fprintf (log_output, fallback_msg, errno); - /* + /* * Close log_output to prevent isakmpd from locking the file. * We may need to explicitly close stdout to do this properly. * XXX - Figure out how to match two FILE *'s and rewrite. - */ + */ if (fileno (log_output) != -1 && fileno (stdout) == fileno (log_output)) fclose (stdout); @@ -358,12 +358,12 @@ log_packet_init (char *newname) if (!packet_log) { - log_error ("log_packet_init: fopen (\"%s\", \"w\") failed", + log_error ("log_packet_init: fopen (\"%s\", \"w\") failed", pcaplog_file); return; } - log_print ("log_packet_init: starting IKE packet capture to file \"%s\"", + log_print ("log_packet_init: starting IKE packet capture to file \"%s\"", pcaplog_file); sf_hdr.magic = TCPDUMP_MAGIC; @@ -393,7 +393,7 @@ log_packet_restart (char *newname) if (newname) { if (stat (newname, &st) == 0) - log_print ("log_packet_restart: won't overwrite existing \"%s\"", + log_print ("log_packet_restart: won't overwrite existing \"%s\"", newname); else log_packet_init (newname); @@ -407,7 +407,7 @@ log_packet_restart (char *newname) /* Re-activate capture on current file. */ packet_log = fopen (pcaplog_file, "a"); if (!packet_log) - log_error ("log_packet_restart: fopen (\"%s\", \"a\") failed", + log_error ("log_packet_restart: fopen (\"%s\", \"a\") failed", pcaplog_file); else log_print ("log_packet_restart: capture restarted on file \"%s\"", @@ -439,12 +439,12 @@ log_packet_iov (struct sockaddr *src, struct sockaddr *dst, struct iovec *iov, for (i = 0, datalen = 0; i < iovcnt; i++) datalen += iov[i].iov_len; - + if (!packet_log || datalen > SNAPLEN) return; - + /* copy packet into buffer */ - for (i = 0, off = 0; i < iovcnt; i++) + for (i = 0, off = 0; i < iovcnt; i++) { memcpy (packet_buf + off, iov[i].iov_base, iov[i].iov_len); off += iov[i].iov_len; @@ -452,16 +452,16 @@ log_packet_iov (struct sockaddr *src, struct sockaddr *dst, struct iovec *iov, memset (&hdr, 0, sizeof hdr); memset (&udp, 0, sizeof udp); - + /* isakmp - turn off the encryption bit in the isakmp hdr */ isakmphdr = (struct isakmp_hdr *)packet_buf; isakmphdr->flags &= ~(ISAKMP_FLAGS_ENC); - + /* udp */ udp.uh_sport = udp.uh_dport = htons (500); datalen += sizeof udp; udp.uh_ulen = htons (datalen); - + /* ip */ hdr.sa_family = htonl (src->sa_family); switch (src->sa_family) @@ -470,7 +470,7 @@ log_packet_iov (struct sockaddr *src, struct sockaddr *dst, struct iovec *iov, /* Assume IPv4. XXX Can 'default' ever happen here? */ hdr.sa_family = htonl (AF_INET); hdr.ip.ip4.ip_src.s_addr = 0x02020202; - hdr.ip.ip4.ip_dst.s_addr = 0x01010101; + hdr.ip.ip4.ip_dst.s_addr = 0x01010101; /* The rest of the setup is common to AF_INET. */ goto setup_ip4; @@ -592,18 +592,18 @@ udp_cksum (struct packhdr *hdr, const struct udphdr *u, u_int16_t *d) sp = (u_int16_t *)u; for (i = 0; i < sizeof (struct udphdr); i += 2) sum += *sp++; - + sp = d; for (i = 0; i < (tlen&~1); i += 2) sum += *sp++; - + if (tlen & 1) sum += htons ((*(const char *)sp) << 8); - + while (sum > 0xffff) sum = (sum & 0xffff) + (sum >> 16); sum = ~sum & 0xffff; - + return sum; } @@ -613,14 +613,14 @@ in_cksum (const u_int16_t *w, int len) { int nleft = len, sum = 0; u_int16_t answer; - + while (nleft > 1) { sum += *w++; nleft -= 2; } if (nleft == 1) sum += htons (*(u_char *)w << 8); - + sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ sum += (sum >> 16); /* add carry */ answer = ~sum; /* truncate to 16 bits */ diff --git a/sbin/isakmpd/log.h b/sbin/isakmpd/log.h index fed703176d0..9843669cc47 100644 --- a/sbin/isakmpd/log.h +++ b/sbin/isakmpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.12 2002/05/28 11:17:57 ho Exp $ */ +/* $OpenBSD: log.h,v 1.13 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: log.h,v 1.19 2000/03/30 14:27:23 ho Exp $ */ /* @@ -76,7 +76,7 @@ extern void log_debug_toggle (void); #define PCAP_FILE_DEFAULT "/var/run/isakmpd.pcap" extern void log_packet_init (char *); -extern void log_packet_iov (struct sockaddr *, struct sockaddr *, +extern void log_packet_iov (struct sockaddr *, struct sockaddr *, struct iovec *, int); extern void log_packet_restart (char *); extern void log_packet_stop (void); diff --git a/sbin/isakmpd/math_2n.c b/sbin/isakmpd/math_2n.c index 853388517a7..3060df266bf 100644 --- a/sbin/isakmpd/math_2n.c +++ b/sbin/isakmpd/math_2n.c @@ -1,4 +1,4 @@ -/* $OpenBSD: math_2n.c,v 1.9 2002/01/23 17:43:24 ho Exp $ */ +/* $OpenBSD: math_2n.c,v 1.10 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: math_2n.c,v 1.15 1999/04/20 09:23:30 niklas Exp $ */ /* @@ -39,7 +39,7 @@ * B2N is a module for doing arithmetic on the Field GF(2**n) which is * isomorph to ring of polynomials GF(2)[x]/p(x) where p(x) is an * irreduciable polynomial over GF(2)[x] with grade n. - * + * * First we need functions which operate on GF(2)[x], operation * on GF(2)[x]/p(x) can be done as for Z_p then. */ @@ -128,7 +128,7 @@ b2n_resize (b2n_ptr n, unsigned int chunks) if (chunks == old) return 0; - + size = CHUNK_BYTES * chunks; new = realloc (n->limp, size); @@ -317,7 +317,7 @@ u_int32_t b2n_sigbit (b2n_ptr n) { int i, j; - + if (!n->dirty) return n->bits; @@ -331,7 +331,7 @@ b2n_sigbit (b2n_ptr n) for (j = CHUNK_MASK; j > 0; j--) if (n->limp[i] & b2n_mask[j]) break; - + n->bits = (i << CHUNK_SHIFTS) + j + 1; n->dirty = 0; return n->bits; @@ -352,22 +352,22 @@ b2n_add (b2n_ptr d, b2n_ptr a, b2n_ptr b) bmin = B2N_MIN (a,b); bmax = B2N_MAX (a,b); - + if (b2n_resize (d, bmax->chunks)) return -1; for (i = 0; i < bmin->chunks; i++) d->limp[i] = bmax->limp[i] ^ bmin->limp[i]; - /* + /* * If d is not bmax, we have to copy the rest of the bytes, and also * need to adjust to number of relevant bits. */ if (d != bmax) { - for ( ; i < bmax->chunks; i++) + for ( ; i < bmax->chunks; i++) d->limp[i] = bmax->limp[i]; - + d->bits = bmax->bits; } @@ -375,7 +375,7 @@ b2n_add (b2n_ptr d, b2n_ptr a, b2n_ptr b) * Help to converse memory. When the result of the addition is zero * truncate the used amount of memory. */ - if (d != bmax && !b2n_cmp_null (d)) + if (d != bmax && !b2n_cmp_null (d)) return b2n_set_null (d); else d->dirty = 1; @@ -402,7 +402,7 @@ b2n_cmp (b2n_ptr n, b2n_ptr m) return 1; else if (n->limp[i] < m->limp[i]) return -1; - + return 0; } @@ -444,7 +444,7 @@ b2n_lshift (b2n_ptr d, b2n_ptr n, unsigned int s) if (maj) memset (d->limp, 0, CHUNK_BYTES * maj); - if (add) + if (add) d->limp[d->chunks - 1] = 0; /* If !min there are no bit shifts, we are done */ @@ -517,7 +517,7 @@ b2n_mul (b2n_ptr d, b2n_ptr n, b2n_ptr m) if (b2n_sigbit (n) == 1) return b2n_set (d, m); - + b2n_init (tmp); b2n_init (tmp2); @@ -533,10 +533,10 @@ b2n_mul (b2n_ptr d, b2n_ptr n, b2n_ptr m) if (tmp2->limp[i]) for (j = 0; j < CHUNK_BITS; j++) { - if (tmp2->limp[i] & b2n_mask[j]) + if (tmp2->limp[i] & b2n_mask[j]) if (b2n_add (d, d, tmp)) goto fail; - + if (b2n_lshift (tmp, tmp, 1)) goto fail; } @@ -594,7 +594,7 @@ b2n_square (b2n_ptr d, b2n_ptr n) } else chunk += 2; - + t->dirty = 1; B2N_SWAP (d, t); b2n_clear (t); @@ -676,7 +676,7 @@ b2n_div (b2n_ptr q, b2n_ptr r, b2n_ptr n, b2n_ptr m) goto fail; if (b2n_lshift (mask, mask, sn - sm)) goto fail; - + /* Number of significant octets */ len = (sn - 1) >> CHUNK_SHIFTS; /* The first iteration is done over the relevant bits */ @@ -747,7 +747,7 @@ b2n_gcd (b2n_ptr e, b2n_ptr go, b2n_ptr ho) goto fail; if (b2n_set (h, ho)) goto fail; - + while (b2n_cmp_null (h)) { if (b2n_mod (g, g, h)) @@ -850,9 +850,9 @@ fail: } /* - * The trace tells us if there do exist any square roots + * The trace tells us if there do exist any square roots * for 'a' in GF(2)[x]/p(x). The number of square roots is - * 2 - 2*Trace. + * 2 - 2*Trace. * If z is a square root, z + 1 is the other. */ int @@ -864,7 +864,7 @@ b2n_trace (b2n_ptr ho, b2n_ptr a, b2n_ptr p) b2n_init (h); if (b2n_set (h, a)) goto fail; - + for (i = 0; i < m - 1; i++) { if (b2n_square (h, h)) @@ -898,7 +898,7 @@ b2n_halftrace (b2n_ptr ho, b2n_ptr a, b2n_ptr p) b2n_init (h); if (b2n_set (h, a)) goto fail; - + for (i = 0; i < (m - 1) / 2; i++) { if (b2n_square (h, h)) @@ -925,7 +925,7 @@ b2n_halftrace (b2n_ptr ho, b2n_ptr a, b2n_ptr p) } /* - * Solving the equation: y**2 + y = b in GF(2**m) where ip is the + * Solving the equation: y**2 + y = b in GF(2**m) where ip is the * irreduceable polynomial. If m is odd, use the half trace. */ int @@ -1007,7 +1007,7 @@ b2n_exp_mod (b2n_ptr d, b2n_ptr b0, u_int32_t e, b2n_ptr p) goto fail; if (b2n_mod (b, b0, p)) goto fail; - + while (e) { if (e & 1) @@ -1040,7 +1040,7 @@ b2n_exp_mod (b2n_ptr d, b2n_ptr b0, u_int32_t e, b2n_ptr p) * Low-level function to speed up scalar multiplication with * elliptic curves. * Multiplies a normal number by 3. - */ + */ /* Normal addition behaves as Z_{2**n} and not F_{2**n}. */ int @@ -1071,7 +1071,7 @@ b2n_nadd (b2n_ptr d0, b2n_ptr a0, b2n_ptr b0) d->limp[i] = a->limp[i] + b->limp[i] + carry; carry = (d->limp[i] < a->limp[i] ? 1 : 0); } - + for (; i < a->chunks && carry; i++) { d->limp[i] = a->limp[i] + carry; @@ -1097,7 +1097,7 @@ b2n_nsub (b2n_ptr d0, b2n_ptr a, b2n_ptr b) if (b2n_cmp (a, b) <= 0) return b2n_set_null (d0); - + b2n_init (d); if (b2n_resize (d, a->chunks)) { @@ -1110,7 +1110,7 @@ b2n_nsub (b2n_ptr d0, b2n_ptr a, b2n_ptr b) d->limp[i] = a->limp[i] - b->limp[i] - carry; carry = (d->limp[i] > a->limp[i] ? 1 : 0); } - + for (; i < a->chunks && carry; i++) { d->limp[i] = a->limp[i] - carry; diff --git a/sbin/isakmpd/math_ec2n.c b/sbin/isakmpd/math_ec2n.c index 047970f018a..fa39299d026 100644 --- a/sbin/isakmpd/math_ec2n.c +++ b/sbin/isakmpd/math_ec2n.c @@ -1,4 +1,4 @@ -/* $OpenBSD: math_ec2n.c,v 1.7 1999/04/20 11:32:57 niklas Exp $ */ +/* $OpenBSD: math_ec2n.c,v 1.8 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: math_ec2n.c,v 1.9 1999/04/20 09:23:31 niklas Exp $ */ /* @@ -142,7 +142,7 @@ ec2np_ison (ec2np_ptr p, ec2ng_ptr g) int res; b2n_t x, y, temp; - + if (p->inf) return 1; @@ -346,7 +346,7 @@ ec2np_mul (ec2np_ptr d, ec2np_ptr a, b2n_ptr e, ec2ng_ptr g) if (b2n_resize (k, h->chunks)) goto fail; - /* + /* * This is low level but can not be avoided, since we have to do single * bit checks on h and k. */ @@ -362,7 +362,7 @@ ec2np_mul (ec2np_ptr d, ec2np_ptr a, b2n_ptr e, ec2ng_ptr g) bits = ((bits - 1) & CHUNK_MASK); } - /* + /* * This is the addition, subtraction method which is faster because * we avoid one out of three additions (mean). */ diff --git a/sbin/isakmpd/message.c b/sbin/isakmpd/message.c index 9c62768bdc5..e2bdeeca760 100644 --- a/sbin/isakmpd/message.c +++ b/sbin/isakmpd/message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: message.c,v 1.53 2002/06/06 02:42:29 ho Exp $ */ +/* $OpenBSD: message.c,v 1.54 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: message.c,v 1.156 2000/10/10 12:36:39 provos Exp $ */ /* @@ -1229,13 +1229,13 @@ message_send (struct message *msg) #endif msg->flags |= MSG_IN_TRANSIT; exchange->in_transit = msg; - + /* * If we get a retransmission of a message before our response * has left the queue, don't queue it again, as it will result * in a circular list. */ - q = msg->flags & MSG_PRIORITIZED ? &msg->transport->prio_sendq : + q = msg->flags & MSG_PRIORITIZED ? &msg->transport->prio_sendq : &msg->transport->sendq; for (m = TAILQ_FIRST (q); m; m = TAILQ_NEXT (m, link)) @@ -1537,7 +1537,7 @@ message_dump_raw (char *header, struct message *msg, int class) for (i = 0; i < msg->iovlen; i++) for (j = 0; j < msg->iov[i].iov_len; j++) { - snprintf (p, 80 - (int)(p - buf), "%02x", + snprintf (p, 80 - (int)(p - buf), "%02x", ((u_int8_t *)msg->iov[i].iov_base)[j]); p += 2; if (++k % 32 == 0) diff --git a/sbin/isakmpd/pf_key_v2.c b/sbin/isakmpd/pf_key_v2.c index 66370543253..0b0b0016507 100644 --- a/sbin/isakmpd/pf_key_v2.c +++ b/sbin/isakmpd/pf_key_v2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_key_v2.c,v 1.106 2002/06/07 06:37:08 ho Exp $ */ +/* $OpenBSD: pf_key_v2.c,v 1.107 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: pf_key_v2.c,v 1.79 2000/12/12 00:33:19 niklas Exp $ */ /* @@ -303,7 +303,7 @@ pf_key_v2_read (u_int32_t seq) if (!fds) { log_error ("pf_key_v2_read: calloc (%lu, %lu) failed", - (unsigned long)howmany (pf_key_v2_socket + 1, + (unsigned long)howmany (pf_key_v2_socket + 1, NFDBITS), (unsigned long)sizeof (fd_mask)); goto cleanup; @@ -2199,7 +2199,7 @@ pf_key_v2_convert_id (u_int8_t *id, int idlen, size_t *reslen, int *idtype) return 0; snprintf (addrbuf + strlen (addrbuf), ADDRESS_MAX - strlen (addrbuf), "/%d", pf_key_v2_mask_to_bits ((u_int32_t) - *(addr + + *(addr + sizeof (struct in_addr)))); *reslen = strlen (addrbuf); res = strdup (addrbuf); @@ -2214,7 +2214,7 @@ pf_key_v2_convert_id (u_int8_t *id, int idlen, size_t *reslen, int *idtype) if (inet_ntop (AF_INET6, addr, addrbuf, ADDRESS_MAX) == NULL) return 0; snprintf (addrbuf + strlen (addrbuf), ADDRESS_MAX - strlen (addrbuf), - "/%d", pf_key_v2_mask6_to_bits (addr + + "/%d", pf_key_v2_mask6_to_bits (addr + sizeof (struct in6_addr))); *reslen = strlen (addrbuf); res = strdup (addrbuf); diff --git a/sbin/isakmpd/policy.c b/sbin/isakmpd/policy.c index 9126f77bc0e..ee6015fe927 100644 --- a/sbin/isakmpd/policy.c +++ b/sbin/isakmpd/policy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.c,v 1.52 2002/06/01 07:44:22 deraadt Exp $ */ +/* $OpenBSD: policy.c,v 1.53 2002/06/09 08:13:06 todd Exp $ */ /* $EOM: policy.c,v 1.49 2000/10/24 13:33:39 niklas Exp $ */ /* @@ -757,7 +757,7 @@ policy_callback (char *name) remote_id_type = "IPv6 address"; my_inet_ntop6 (id + ISAKMP_ID_DATA_OFF - ISAKMP_GEN_SZ, remote_id_addr_upper, sizeof remote_id_addr_upper); - strlcpy (remote_id_addr_lower, remote_id_addr_upper, + strlcpy (remote_id_addr_lower, remote_id_addr_upper, sizeof remote_id_addr_lower); remote_id = strdup (remote_id_addr_upper); if (!remote_id) @@ -2064,7 +2064,7 @@ keynote_cert_obtain (u_int8_t *id, size_t id_len, void *data, u_int8_t **cert, snprintf (file, len + id_len, "%s/", dirname); memcpy (file + strlen (dirname) + 1, id, id_len); - snprintf (file + strlen (dirname) + 1 + id_len, + snprintf (file + strlen (dirname) + 1 + id_len, len - strlen (dirname) - 1, "/%s", CREDENTIAL_FILE); break; } diff --git a/sbin/isakmpd/regress/b2n/b2ntest.c b/sbin/isakmpd/regress/b2n/b2ntest.c index f8e985c81a8..92ed91297c3 100644 --- a/sbin/isakmpd/regress/b2n/b2ntest.c +++ b/sbin/isakmpd/regress/b2n/b2ntest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b2ntest.c,v 1.6 2002/01/23 17:43:24 ho Exp $ */ +/* $OpenBSD: b2ntest.c,v 1.7 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: b2ntest.c,v 1.4 1998/07/16 19:31:55 provos Exp $ */ /* @@ -85,7 +85,7 @@ main (void) b2n_set_ui (m, 0); b2n_add (n, n, m); CMP_FAIL (n, "0x9090900000000000000000"); - + printf ("\nTesting: b2n_lshift: "); b2n_set_str (m, "0x808b8080c0"); b2n_lshift (n, m, 3); @@ -158,13 +158,13 @@ main (void) CMP_FAIL (n, "0x40005001040511"); b2n_set_str (m, "0x12329"); - printf ("\nTesting: sigbit: 0x12329: %d, %s", + printf ("\nTesting: sigbit: 0x12329: %d, %s", b2n_sigbit(m), b2n_sigbit(m) == 17 ? "OKAY" : "FAILED"); b2n_set_ui (m, 0); - printf ("\nTesting: sigbit: 0x0: %d, %s", + printf ("\nTesting: sigbit: 0x0: %d, %s", b2n_sigbit(m), b2n_sigbit(m) == 0 ? "OKAY" : "FAILED"); b2n_set_str (m, "0x7f3290000"); - printf ("\nTesting: sigbit: 0x7f3290000: %d, %s", + printf ("\nTesting: sigbit: 0x7f3290000: %d, %s", b2n_sigbit(m), b2n_sigbit(m) == 35 ? "OKAY" : "FAILED"); printf ("\nTesting: b2n_cmp: "); diff --git a/sbin/isakmpd/regress/crypto/cryptotest.c b/sbin/isakmpd/regress/crypto/cryptotest.c index 4b8045bed12..c5a26a89d91 100644 --- a/sbin/isakmpd/regress/crypto/cryptotest.c +++ b/sbin/isakmpd/regress/crypto/cryptotest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptotest.c,v 1.6 2001/06/12 21:46:47 niklas Exp $ */ +/* $OpenBSD: cryptotest.c,v 1.7 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: cryptotest.c,v 1.5 1998/10/07 16:40:49 niklas Exp $ */ /* @@ -90,7 +90,7 @@ special_test_blf (void) asc2bin (key, akey, strlen (akey)); asc2bin (iv, aiv, strlen (aiv)); asc2bin (cipher, acipher, 64); - + xf = crypto_get (BLOWFISH_CBC); printf ("Special Test-Case %s: ", xf->name); @@ -129,7 +129,7 @@ main (void) test_crypto (BLOWFISH_CBC); test_crypto (CAST_CBC); - + special_test_blf (); return 1; @@ -152,7 +152,7 @@ test_crypto (enum transform which) struct crypto_xf *xf; struct keystate *ks; enum cryptoerr err; - + xf = crypto_get (which); printf ("Testing %s: ", xf->name); diff --git a/sbin/isakmpd/regress/dh/dhtest.c b/sbin/isakmpd/regress/dh/dhtest.c index 3add8c4ce9e..7e6099a618c 100644 --- a/sbin/isakmpd/regress/dh/dhtest.c +++ b/sbin/isakmpd/regress/dh/dhtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhtest.c,v 1.3 1998/12/21 01:02:29 niklas Exp $ */ +/* $OpenBSD: dhtest.c,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: dhtest.c,v 1.1 1998/07/18 21:14:20 provos Exp $ */ /* @@ -100,7 +100,7 @@ main (void) printf ("FAILED "); else printf ("OKAY "); - + printf ("\n"); return 1; diff --git a/sbin/isakmpd/regress/hmac/hmactest.c b/sbin/isakmpd/regress/hmac/hmactest.c index 0d8ec23ab95..bc2fc0fa27d 100644 --- a/sbin/isakmpd/regress/hmac/hmactest.c +++ b/sbin/isakmpd/regress/hmac/hmactest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hmactest.c,v 1.3 1998/12/21 01:02:34 niklas Exp $ */ +/* $OpenBSD: hmactest.c,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: hmactest.c,v 1.3 1998/08/09 19:16:24 niklas Exp $ */ /* @@ -49,7 +49,7 @@ int main (void) { char key[100]; - + memset(key, 11, 20); test_hmac ("HMAC-MD5 Test Case 1", hash_get (HASH_MD5), key, 16, "Hi There", 8, "9294727a3638bb1c13f48ef8158bfc9d"); @@ -58,12 +58,12 @@ main (void) "what do ya want for nothing?", 28, "750c783e6ab0b503eaa86e310a5db738"); test_hmac ("HMAC-SHA1 Test Case 1", hash_get (HASH_SHA1), - key, 20, "Hi There", 8, + key, 20, "Hi There", 8, "b617318655057264e28bc0b6fb378c8ef146be00"); test_hmac ("HMAC-SHA1 Test Case 2", hash_get (HASH_SHA1), - "Jefe", 4, "what do ya want for nothing?", 28, + "Jefe", 4, "what do ya want for nothing?", 28, "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"); - + return 1; } @@ -87,7 +87,7 @@ test_hmac(char *test, struct hash *hash, char *key, int klen, } output[2*i] = 0; - if (!strcmp(output, cmp)) + if (!strcmp(output, cmp)) { printf("OKAY\n"); return 1; diff --git a/sbin/isakmpd/regress/prf/prftest.c b/sbin/isakmpd/regress/prf/prftest.c index 0935e720018..0d95b790f50 100644 --- a/sbin/isakmpd/regress/prf/prftest.c +++ b/sbin/isakmpd/regress/prf/prftest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prftest.c,v 1.5 2001/08/17 14:11:05 niklas Exp $ */ +/* $OpenBSD: prftest.c,v 1.6 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: prftest.c,v 1.2 1998/10/07 16:40:50 niklas Exp $ */ /* @@ -56,7 +56,7 @@ int main (void) { char key[100]; - + memset (key, 11, 20); test_prf ("PRF MD5 Test Case 1", HASH_MD5, key, 16, "Hi There", 8, "9294727a3638bb1c13f48ef8158bfc9d"); @@ -65,17 +65,17 @@ main (void) "what do ya want for nothing?", 28, "750c783e6ab0b503eaa86e310a5db738"); test_prf ("PRF SHA1 Test Case 1", HASH_SHA1, - key, 20, "Hi There", 8, + key, 20, "Hi There", 8, "b617318655057264e28bc0b6fb378c8ef146be00"); test_prf ("PRF SHA1 Test Case 2", HASH_SHA1, - "Jefe", 4, "what do ya want for nothing?", 28, + "Jefe", 4, "what do ya want for nothing?", 28, "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"); test_prf ("PRF SHA1 Test Case 3", HASH_SHA1, "Bloody long key, this one, eben longer than the blocksize " "of ordinary keyed HMAC functions", 90, - "what do ya want for nothing?", 28, + "what do ya want for nothing?", 28, "52ca5fbcd7d4821bc6bf8b6e95e131109dff901b"); - + return 0; } @@ -91,7 +91,7 @@ test_prf (char *test, enum hashes hash, char *key, int klen, printf ("Testing %s: ", test); prf = prf_alloc (PRF_HMAC, hash, key, klen); - if (!prf) + if (!prf) { printf("prf_alloc () failed\n"); return 0; @@ -110,7 +110,7 @@ test_prf (char *test, enum hashes hash, char *key, int klen, } output[2 * i] = 0; - if (strcmp (output, cmp) == 0) + if (strcmp (output, cmp) == 0) { printf ("OKAY\n"); return 1; diff --git a/sbin/isakmpd/regress/rsakeygen/Makefile b/sbin/isakmpd/regress/rsakeygen/Makefile index 552997f9db6..e05c6f2f62d 100644 --- a/sbin/isakmpd/regress/rsakeygen/Makefile +++ b/sbin/isakmpd/regress/rsakeygen/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2001/01/27 12:03:38 niklas Exp $ +# $OpenBSD: Makefile,v 1.13 2002/06/09 08:13:07 todd Exp $ # $EOM: Makefile,v 1.10 2000/03/28 21:23:24 ho Exp $ # @@ -76,8 +76,8 @@ DPADD+= ${LIBCRYPTO} PROG= .else -# USE_X509 is required for libcrypto.h to include the correct headers, -# but it is not set by ${OS}/Makefile.sysdep - setting it manually here +# USE_X509 is required for libcrypto.h to include the correct headers, +# but it is not set by ${OS}/Makefile.sysdep - setting it manually here # should be safe enough. CFLAGS+= -DUSE_X509 .endif diff --git a/sbin/isakmpd/regress/rsakeygen/rsakeygen.c b/sbin/isakmpd/regress/rsakeygen/rsakeygen.c index ac3d96bf1a3..f9631e7eeff 100644 --- a/sbin/isakmpd/regress/rsakeygen/rsakeygen.c +++ b/sbin/isakmpd/regress/rsakeygen/rsakeygen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsakeygen.c,v 1.14 2002/01/03 16:27:41 ho Exp $ */ +/* $OpenBSD: rsakeygen.c,v 1.15 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: rsakeygen.c,v 1.10 2000/12/21 15:18:53 ho Exp $ */ /* @@ -84,7 +84,7 @@ main (void) strlcpy (dec, TEST_STRING, 256); key = LC (RSA_generate_key, (1024, RSA_F4, NULL, NULL)); - if (key == NULL) + if (key == NULL) { printf("Failed to generate key\n"); return 0; diff --git a/sbin/isakmpd/regress/x509/x509test.c b/sbin/isakmpd/regress/x509/x509test.c index 7948547a341..8f7d25f0014 100644 --- a/sbin/isakmpd/regress/x509/x509test.c +++ b/sbin/isakmpd/regress/x509/x509test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509test.c,v 1.18 2002/01/03 16:27:41 ho Exp $ */ +/* $OpenBSD: x509test.c,v 1.19 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: x509test.c,v 1.9 2000/12/21 15:24:25 ho Exp $ */ /* @@ -115,7 +115,7 @@ x509_check_subjectaltname (u_char *id, u_int id_len, X509 *scert) return 0; } - /* + /* * Now that we have the X509 certicate in native form, get the * subjectAltName extension and verify that it matches our ID. */ @@ -129,15 +129,15 @@ x509_check_subjectaltname (u_char *id, u_int id_len, X509 *scert) switch (idtype) { case IPSEC_ID_IPV4_ADDR: - if (type == X509v3_IP_ADDR) + if (type == X509v3_IP_ADDR) ret = 1; break; case IPSEC_ID_FQDN: - if (type == X509v3_DNS_NAME) + if (type == X509v3_DNS_NAME) ret = 1; break; case IPSEC_ID_USER_FQDN: - if (type == X509v3_RFC_NAME) + if (type == X509v3_RFC_NAME) ret = 1; break; default: @@ -201,7 +201,7 @@ main (int argc, char *argv[]) printf ("Reading private key %s\n", argv[1]); keyfile = LC (BIO_new, (LC (BIO_s_file, ()))); - if (LC (BIO_read_filename, (keyfile, argv[1])) == -1) + if (LC (BIO_read_filename, (keyfile, argv[1])) == -1) { perror ("read"); exit (1); @@ -221,7 +221,7 @@ main (int argc, char *argv[]) /* Use a certificate created by ssleay. */ printf ("Reading ssleay created certificate %s\n", argv[2]); certfile = LC (BIO_new, (LC (BIO_s_file, ()))); - if (LC (BIO_read_filename, (certfile, argv[2])) == -1) + if (LC (BIO_read_filename, (certfile, argv[2])) == -1) { perror ("read"); exit (1); @@ -232,7 +232,7 @@ main (int argc, char *argv[]) cert = LC (PEM_read_bio_X509, (certfile, NULL, NULL)); #endif LC (BIO_free, (certfile)); - if (cert == NULL) + if (cert == NULL) { printf("PEM_read_bio_X509 () failed\n"); exit (1); @@ -252,7 +252,7 @@ main (int argc, char *argv[]) strlcpy (dec, "Eine kleine Testmeldung", 256); if ((len = LC (RSA_private_encrypt, (strlen (dec), dec, enc, priv_key, RSA_PKCS1_PADDING))) == -1) - + printf ("SIGN FAILED "); else err = LC (RSA_public_decrypt, (len, enc, dec, pub_key, RSA_PKCS1_PADDING)); @@ -262,7 +262,7 @@ main (int argc, char *argv[]) else printf ("OKAY"); printf ("\n"); - + printf ("Validate SIGNED: "); err = LC (X509_verify, (cert, pkey_pub)); diff --git a/sbin/isakmpd/sa.c b/sbin/isakmpd/sa.c index 62a6788d970..8cd9cdccae3 100644 --- a/sbin/isakmpd/sa.c +++ b/sbin/isakmpd/sa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sa.c,v 1.61 2002/06/07 15:59:37 ho Exp $ */ +/* $OpenBSD: sa.c,v 1.62 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: sa.c,v 1.112 2000/12/12 00:22:52 niklas Exp $ */ /* @@ -432,7 +432,7 @@ sa_dump (int cls, int level, char *header, struct sa *sa) { LOG_DBG ((cls, level, "%s: suite %d proto %d", header, proto->no, proto->proto)); - LOG_DBG ((cls, level, + LOG_DBG ((cls, level, "%s: spi_sz[0] %d spi[0] %p spi_sz[1] %d spi[1] %p", header, proto->spi_sz[0], proto->spi[0], proto->spi_sz[1], proto->spi[1])); @@ -555,7 +555,7 @@ report_proto (FILE *fd, struct proto *proto) case IPSEC_AUTH_DES_MAC: case IPSEC_AUTH_KPDK: /* XXX We should be supporting KPDK */ - fprintf (fd, "unknown (%d)", iproto->auth); + fprintf (fd, "unknown (%d)", iproto->auth); break; default: diff --git a/sbin/isakmpd/sa.h b/sbin/isakmpd/sa.h index 91961da1cd6..4b7fbb0b07c 100644 --- a/sbin/isakmpd/sa.h +++ b/sbin/isakmpd/sa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sa.h,v 1.28 2002/06/07 15:24:22 ho Exp $ */ +/* $OpenBSD: sa.h,v 1.29 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: sa.h,v 1.58 2000/10/10 12:39:01 provos Exp $ */ /* @@ -68,7 +68,7 @@ struct proto { /* The protocol number as found in the proposal payload. */ u_int8_t no; - + /* The protocol this SA is for. */ u_int8_t proto; @@ -155,7 +155,7 @@ struct sa { /* * Certificates or other information from Phase 1; these are copied from the * exchange, so look at exchange.h for an explanation of their use. - */ + */ int recv_certtype, recv_keytype; /* Certificate received from peer, native format. */ void *recv_cert; diff --git a/sbin/isakmpd/samples/VPN-3way-template.conf b/sbin/isakmpd/samples/VPN-3way-template.conf index fa64242f153..e5d645beadf 100644 --- a/sbin/isakmpd/samples/VPN-3way-template.conf +++ b/sbin/isakmpd/samples/VPN-3way-template.conf @@ -1,4 +1,4 @@ -# $OpenBSD: VPN-3way-template.conf,v 1.8 2001/06/27 03:31:43 angelos Exp $ +# $OpenBSD: VPN-3way-template.conf,v 1.9 2002/06/09 08:13:07 todd Exp $ # $EOM: VPN-3way-template.conf,v 1.8 2000/10/09 22:08:30 angelos Exp $ # # A configuration sample for the isakmpd ISAKMP/Oakley (aka IKE) daemon. @@ -6,7 +6,7 @@ # This is a template file of a VPN setup beteween three nodes in # a fully meshed 'three-way' configuration. Suggested use is to copy # this file to all three nodes and then edit them accordingly. -# +# # These nodes are initially called XXX, YYY and ZZZ. # # In pseudographics: XXX --- YYY diff --git a/sbin/isakmpd/samples/VPN-east.conf b/sbin/isakmpd/samples/VPN-east.conf index 475e9ae2e75..cc8163a5a75 100644 --- a/sbin/isakmpd/samples/VPN-east.conf +++ b/sbin/isakmpd/samples/VPN-east.conf @@ -1,11 +1,11 @@ -# $OpenBSD: VPN-east.conf,v 1.11 2000/10/09 23:27:29 niklas Exp $ +# $OpenBSD: VPN-east.conf,v 1.12 2002/06/09 08:13:07 todd Exp $ # $EOM: VPN-east.conf,v 1.12 2000/10/09 22:08:30 angelos Exp $ # A configuration sample for the isakmpd ISAKMP/Oakley (aka IKE) daemon. # # The network topology of the example net is like this: # -# 192.168.11.0/24 - west [.11] - 10.1.0.0/24 - [.12] east - 192.168.12.0/24 +# 192.168.11.0/24 - west [.11] - 10.1.0.0/24 - [.12] east - 192.168.12.0/24 # # "west" and "east" are the respective secrity gateways (aka VPN-nodes). diff --git a/sbin/isakmpd/samples/VPN-west.conf b/sbin/isakmpd/samples/VPN-west.conf index a5240e9fdcb..daff4344eaa 100644 --- a/sbin/isakmpd/samples/VPN-west.conf +++ b/sbin/isakmpd/samples/VPN-west.conf @@ -1,11 +1,11 @@ -# $OpenBSD: VPN-west.conf,v 1.11 2000/10/09 23:27:29 niklas Exp $ +# $OpenBSD: VPN-west.conf,v 1.12 2002/06/09 08:13:07 todd Exp $ # $EOM: VPN-west.conf,v 1.13 2000/10/09 22:08:30 angelos Exp $ # A configuration sample for the isakmpd ISAKMP/Oakley (aka IKE) daemon. # # The network topology of the example net is like this: # -# 192.168.11.0/24 - west [.11] - 10.1.0.0/24 - [.12] east - 192.168.12.0/24 +# 192.168.11.0/24 - west [.11] - 10.1.0.0/24 - [.12] east - 192.168.12.0/24 # # "west" and "east" are the respective secrity gateways (aka VPN-nodes). diff --git a/sbin/isakmpd/sysdep/freebsd/Makefile.sysdep b/sbin/isakmpd/sysdep/freebsd/Makefile.sysdep index 7a99372b989..23205d1861f 100644 --- a/sbin/isakmpd/sysdep/freebsd/Makefile.sysdep +++ b/sbin/isakmpd/sysdep/freebsd/Makefile.sysdep @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.sysdep,v 1.6 2001/10/26 16:03:07 ho Exp $ +# $OpenBSD: Makefile.sysdep,v 1.7 2002/06/09 08:13:07 todd Exp $ # # Copyright (c) 1999 Niklas Hallqvist. All rights reserved. @@ -42,7 +42,7 @@ LIBSYSDEPDIR= ${TOPDIR}/sysdep/common/libsysdep LIBSYSDEPDIR= ${.CURDIR}/sysdep/common/libsysdep .endif -LDADD+= -lgmp ${LIBSYSDEPDIR}/libsysdep.a -lipsec -L/usr/local/lib +LDADD+= -lgmp ${LIBSYSDEPDIR}/libsysdep.a -lipsec -L/usr/local/lib DPADD+= ${LIBGMP} ${LIBSYSDEPDIR}/libsysdep.a CFLAGS+= -DHAVE_GETNAMEINFO -DHAVE_GETIFADDRS \ diff --git a/sbin/isakmpd/sysdep/linux/klips.c b/sbin/isakmpd/sysdep/linux/klips.c index da614330e05..1393629ba2c 100644 --- a/sbin/isakmpd/sysdep/linux/klips.c +++ b/sbin/isakmpd/sysdep/linux/klips.c @@ -1,4 +1,4 @@ -/* $OpenBSD: klips.c,v 1.8 2001/06/29 19:08:12 ho Exp $ */ +/* $OpenBSD: klips.c,v 1.9 2002/06/09 08:13:07 todd Exp $ */ /* * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. @@ -254,7 +254,7 @@ klips_set_spi (struct sa *sa, struct proto *proto, int incoming, break; default: - LOG_DBG ((LOG_SYSDEP, 10, + LOG_DBG ((LOG_SYSDEP, 10, "klips_set_spi: Unsupported enc/auth alg negotiated")); return -1; } @@ -424,7 +424,7 @@ klips_set_spi (struct sa *sa, struct proto *proto, int incoming, free (emsg); return -1; } - + /* * Delete the IPsec SA represented by the INCOMING direction in protocol PROTO * of the IKE security association SA. @@ -481,7 +481,7 @@ klips_hex_decode (char *src, u_char *dst, int dstsize) { ch = tolower (p[0]); cl = tolower (p[1]); - + if ((ch >= '0') && (ch <= '9')) ch -= '0'; else if ((ch >= 'a') && (ch <= 'f')) @@ -498,7 +498,7 @@ klips_hex_decode (char *src, u_char *dst, int dstsize) *q++ = (ch << 4) | cl; } - + return (int)(q - dst); } @@ -527,7 +527,7 @@ klips_route_get (u_long dst) klips_hex_decode (netbuf, (u_char *)&net, sizeof net); klips_hex_decode (gatebuf, (u_char *)&gate, sizeof gate); klips_hex_decode (maskbuf, (u_char *)&mask, sizeof mask); - + net = htonl (net); gate = htonl (gate); mask = htonl (mask); diff --git a/sbin/isakmpd/sysdep/linux/sys/queue.h b/sbin/isakmpd/sysdep/linux/sys/queue.h index 6af6f7418bd..eb35990304c 100644 --- a/sbin/isakmpd/sysdep/linux/sys/queue.h +++ b/sbin/isakmpd/sysdep/linux/sys/queue.h @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.h,v 1.3 2001/01/26 11:34:05 niklas Exp $ */ +/* $OpenBSD: queue.h,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ /* @@ -85,7 +85,7 @@ #define LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ -} +} #define LIST_ENTRY(type) \ struct { \ diff --git a/sbin/isakmpd/sysdep/linux/sysdep.c b/sbin/isakmpd/sysdep/linux/sysdep.c index c9f8a17f6c8..b51ed820010 100644 --- a/sbin/isakmpd/sysdep/linux/sysdep.c +++ b/sbin/isakmpd/sysdep/linux/sysdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysdep.c,v 1.10 2001/10/26 12:23:45 ho Exp $ */ +/* $OpenBSD: sysdep.c,v 1.11 2002/06/09 08:13:07 todd Exp $ */ /* * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved. @@ -84,8 +84,8 @@ sysdep_random () u_int32_t *tmp = (u_int32_t *)&sig[i * 4]; rndval ^= *tmp; } - - return rndval; + + return rndval; } char * diff --git a/sbin/isakmpd/sysdep/openbsd/keynote_compat.c b/sbin/isakmpd/sysdep/openbsd/keynote_compat.c index 8a8c6aad64d..d76d524ff5f 100644 --- a/sbin/isakmpd/sysdep/openbsd/keynote_compat.c +++ b/sbin/isakmpd/sysdep/openbsd/keynote_compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keynote_compat.c,v 1.3 2000/12/12 01:49:48 niklas Exp $ */ +/* $OpenBSD: keynote_compat.c,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: keynote_compat.c,v 1.1 2000/10/15 19:18:26 niklas Exp $ */ /* @@ -51,7 +51,7 @@ * Permission to use, copy, and modify this software without fee * is hereby granted, provided that this entire notice is included in * all copies of any software which is or includes a copy or - * modification of this software. + * modification of this software. * * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR * IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO diff --git a/sbin/isakmpd/sysdep/openbsd/sysdep.c b/sbin/isakmpd/sysdep/openbsd/sysdep.c index 01a09dc0565..5fda1cf9456 100644 --- a/sbin/isakmpd/sysdep/openbsd/sysdep.c +++ b/sbin/isakmpd/sysdep/openbsd/sysdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysdep.c,v 1.21 2001/10/26 12:23:46 ho Exp $ */ +/* $OpenBSD: sysdep.c,v 1.22 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: sysdep.c,v 1.9 2000/12/04 04:46:35 angelos Exp $ */ /* @@ -139,14 +139,14 @@ int sysdep_cleartext (int fd, int af) { int level, sw; - struct { + struct { int ip_proto; /* IP protocol */ int auth_level; int esp_trans_level; int esp_network_level; int ipcomp_level; } optsw[] = - { + { { IPPROTO_IP, IP_AUTH_LEVEL, @@ -170,7 +170,7 @@ sysdep_cleartext (int fd, int af) #endif }, }; - + if (app_none) return 0; diff --git a/sbin/isakmpd/timer.c b/sbin/isakmpd/timer.c index 940ac2d4ad9..4300f4b65d1 100644 --- a/sbin/isakmpd/timer.c +++ b/sbin/isakmpd/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.9 2002/05/28 10:09:46 ho Exp $ */ +/* $OpenBSD: timer.c,v 1.10 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: timer.c,v 1.13 2000/02/20 19:58:42 niklas Exp $ */ /* @@ -116,7 +116,7 @@ timer_add_event (char *name, void (*func) (void *), void *arg, else { LOG_DBG ((LOG_TIMER, 10, "timer_add_event: event %s(%p) added last, " - "expiration in %lds", name, arg, + "expiration in %lds", name, arg, expiration->tv_sec - now.tv_sec)); TAILQ_INSERT_TAIL (&events, ev, link); } @@ -141,8 +141,8 @@ timer_report (void) gettimeofday (&now, 0); for (ev = TAILQ_FIRST (&events); ev; ev = TAILQ_NEXT (ev, link)) - LOG_DBG ((LOG_REPORT, 0, + LOG_DBG ((LOG_REPORT, 0, "timer_report: event %s(%p) scheduled in %d seconds", - (ev->name ? ev->name : "<unknown>"), ev, + (ev->name ? ev->name : "<unknown>"), ev, (int)(ev->expiration.tv_sec - now.tv_sec))); } diff --git a/sbin/isakmpd/transport.c b/sbin/isakmpd/transport.c index b2441dd5e3a..e0a7d7b3fc5 100644 --- a/sbin/isakmpd/transport.c +++ b/sbin/isakmpd/transport.c @@ -1,4 +1,4 @@ -/* $OpenBSD: transport.c,v 1.17 2002/06/07 21:59:22 ho Exp $ */ +/* $OpenBSD: transport.c,v 1.18 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: transport.c,v 1.43 2000/10/10 12:36:39 provos Exp $ */ /* @@ -120,13 +120,13 @@ transport_report (void) struct message *msg; for (t = LIST_FIRST (&transport_list); t; t = LIST_NEXT (t, link)) - { - LOG_DBG ((LOG_REPORT, 0, + { + LOG_DBG ((LOG_REPORT, 0, "transport_report: transport %p flags %x refcnt %d", t, t->flags, t->refcnt)); - + t->vtbl->report (t); - + /* This is the reason message_dump_raw lives outside message.c. */ for (msg = TAILQ_FIRST (&t->prio_sendq); msg; msg = TAILQ_NEXT (msg, link)) diff --git a/sbin/isakmpd/transport.h b/sbin/isakmpd/transport.h index 0c297683557..1339f0a5602 100644 --- a/sbin/isakmpd/transport.h +++ b/sbin/isakmpd/transport.h @@ -1,4 +1,4 @@ -/* $OpenBSD: transport.h,v 1.11 2001/10/26 11:37:16 ho Exp $ */ +/* $OpenBSD: transport.h,v 1.12 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: transport.h,v 1.16 2000/07/17 18:57:59 provos Exp $ */ /* @@ -116,7 +116,7 @@ struct transport { struct msg_head sendq; /* - * Prioritized send queue. Messages in this queue will be transmitted + * Prioritized send queue. Messages in this queue will be transmitted * before the normal sendq, they will also all be transmitted prior * to a daemon shutdown. Currently only used for DELETE notifications. */ diff --git a/sbin/isakmpd/ui.c b/sbin/isakmpd/ui.c index 1f3f370859e..13b9d5564be 100644 --- a/sbin/isakmpd/ui.c +++ b/sbin/isakmpd/ui.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui.c,v 1.29 2002/06/01 07:44:22 deraadt Exp $ */ +/* $OpenBSD: ui.c,v 1.30 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: ui.c,v 1.43 2000/10/05 09:25:12 niklas Exp $ */ /* @@ -206,7 +206,7 @@ ui_delete (char *cmd) log_print ("ui_delete: command \"%s\" malformed", cmd); return; } - + if (strcmp (message_id_str, "-") == 0) message_id = 0; diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 7ca1221c637..16f89d40d07 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.27 2002/05/28 11:23:20 ho Exp $ */ +/* $OpenBSD: util.c,v 1.28 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -380,7 +380,7 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) free (*address); return -1; } - snprintf (*address + strlen (*address), + snprintf (*address + strlen (*address), addrlen - strlen (*address), "%03ld", val); if (bstart) strlcat (*address, ".", addrlen); diff --git a/sbin/isakmpd/x509.h b/sbin/isakmpd/x509.h index a9ef7756096..f2f86f15d4c 100644 --- a/sbin/isakmpd/x509.h +++ b/sbin/isakmpd/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.14 2001/11/03 13:15:35 ho Exp $ */ +/* $OpenBSD: x509.h,v 1.15 2002/06/09 08:13:07 todd Exp $ */ /* $EOM: x509.h,v 1.11 2000/09/28 12:53:27 niklas Exp $ */ /* @@ -51,7 +51,7 @@ struct x509_attribval { }; /* - * The acceptable certification authority. + * The acceptable certification authority. * XXX We only support two names at the moment, as of ASN this can * be dynamic but we don't care for now. */ diff --git a/sbin/kbd/kbd_sparc.c b/sbin/kbd/kbd_sparc.c index b1ae3472aef..2ca19e12409 100644 --- a/sbin/kbd/kbd_sparc.c +++ b/sbin/kbd/kbd_sparc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd_sparc.c,v 1.5 1999/08/21 20:27:43 maja Exp $ */ +/* $OpenBSD: kbd_sparc.c,v 1.6 2002/06/09 08:13:07 todd Exp $ */ /* * Copyright (c) 1999 Mats O Jansson. All rights reserved. @@ -168,7 +168,7 @@ kbd_find_default() } snprintf(defaultmap,sizeof(defaultmap),"type_%d_layout_%02x\0",t,l); - /* Check if it exist, if not use "type_4_layout_00" */ + /* Check if it exist, if not use "type_4_layout_00" */ ret = keymaps[0].name[0]; @@ -176,8 +176,8 @@ kbd_find_default() ok = 0; for (j = 1; j < NUM_NAMES && keymaps[i].name[j]; j++) ok |= (strcmp(keymaps[i].name[j],defaultmap) == 0); - if (ok) ret = keymaps[i].name[0]; - } + if (ok) ret = keymaps[i].name[0]; + } return(ret); @@ -199,7 +199,7 @@ kbd_list() printf(" %s", keymaps[i].name[j]); if (keymaps[i].name[0] == defmap) printf(" default"); printf("\n"); - } + } } void diff --git a/sbin/lmccontrol/clockgen.c b/sbin/lmccontrol/clockgen.c index e5924e0bb22..ef2875b8e8e 100644 --- a/sbin/lmccontrol/clockgen.c +++ b/sbin/lmccontrol/clockgen.c @@ -1,12 +1,12 @@ -/* $OpenBSD: clockgen.c,v 1.1 2000/10/13 16:22:07 chris Exp $ */ -/* $Id: clockgen.c,v 1.1 2000/10/13 16:22:07 chris Exp $ */ +/* $OpenBSD: clockgen.c,v 1.2 2002/06/09 08:13:07 todd Exp $ */ +/* $Id: clockgen.c,v 1.2 2002/06/09 08:13:07 todd Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) * All rights reserved. www.lanmedia.com * * This code is written by Michael Graff (explorer@vix.com) for LMC. - * The code is derived from permitted modifications to software created + * The code is derived from permitted modifications to software created * by Matt Thomas (matt@3am-software.com). * * Redistribution and use in source and binary forms, with or without @@ -17,7 +17,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All marketing or advertising materials mentioning features or use of this + * 3. All marketing or advertising materials mentioning features or use of this * software must display the following acknowledgement: * This product includes software developed by LAN Media Corporation * and its contributors. diff --git a/sbin/lmccontrol/lmccontrol.c b/sbin/lmccontrol/lmccontrol.c index fe25efad3d2..a0ad78b5875 100644 --- a/sbin/lmccontrol/lmccontrol.c +++ b/sbin/lmccontrol/lmccontrol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lmccontrol.c,v 1.3 2001/06/04 14:59:48 mickey Exp $ */ +/* $OpenBSD: lmccontrol.c,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -6,7 +6,7 @@ * * This code is written by Michael Graff (explorer@vix.com) and * Rob Braun (bbraun@vix.com) for LMC. - * The code is derived from permitted modifications to software created + * The code is derived from permitted modifications to software created * by Matt Thomas (matt@3am-software.com). * * Redistribution and use in source and binary forms, with or without @@ -17,7 +17,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All marketing or advertising materials mentioning features or use of this + * 3. All marketing or advertising materials mentioning features or use of this * software must display the following acknowledgement: * This product includes software developed by LAN Media Corporation * and its contributors. @@ -155,7 +155,7 @@ main(int argc, char **argv) just_print = 0; wanted.keepalive_onoff = LMC_CTL_OFF; break; - case 'p': + case 'p': #if defined(linux) fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { @@ -175,7 +175,7 @@ main(int argc, char **argv) fprintf (stderr, "This option is not yet supported\n"); #endif break; - case 'P': + case 'P': fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { fprintf(stderr, "socket: %s\n", strerror(errno)); diff --git a/sbin/mknod/mknod.c b/sbin/mknod/mknod.c index d4da3e0e8fa..36048ab6d41 100644 --- a/sbin/mknod/mknod.c +++ b/sbin/mknod/mknod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mknod.c,v 1.10 2002/02/16 21:27:35 millert Exp $ */ +/* $OpenBSD: mknod.c,v 1.11 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: mknod.c,v 1.8 1995/08/11 00:08:18 jtc Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mknod.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: mknod.c,v 1.10 2002/02/16 21:27:35 millert Exp $"; +static char rcsid[] = "$OpenBSD: mknod.c,v 1.11 2002/06/09 08:13:07 todd Exp $"; #endif #endif /* not lint */ @@ -184,7 +184,7 @@ domkfifo(argc, argv, mode) int rv; for (rv = 0; *argv; ++argv) { - if (mkfifo(*argv, mode) < 0) { + if (mkfifo(*argv, mode) < 0) { warn("%s", *argv); rv = 1; } diff --git a/sbin/modload/a.out.c b/sbin/modload/a.out.c index 84c720786d7..eca0958d67b 100644 --- a/sbin/modload/a.out.c +++ b/sbin/modload/a.out.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a.out.c,v 1.2 2002/01/09 00:02:52 ericj Exp $ */ +/* $OpenBSD: a.out.c,v 1.3 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: a.out.c,v 1.1 1999/06/13 12:54:40 mrg Exp $ */ /* @@ -69,15 +69,15 @@ extern int symtab; void a_out_linkcmd(char *buf, size_t len, - const char *kernel, - const char *entry, - const char *outfile, - const void *address, + const char *kernel, + const char *entry, + const char *outfile, + const void *address, const char *object) { ssize_t n; - n = snprintf(buf, len, LINKCMD, kernel, entry, + n = snprintf(buf, len, LINKCMD, kernel, entry, outfile, address, object); if (n >= len) errx(1, "link command longer than %lu bytes", (u_long)len); @@ -93,7 +93,7 @@ a_out_read_header(int fd, struct exec *info_buf) err(1, "failed reading %lu bytes", (u_long)sizeof(*info_buf)); if (n != sizeof(*info_buf)) { if (debug) - fprintf(stderr, "failed to read %lu bytes", + fprintf(stderr, "failed to read %lu bytes", (u_long)sizeof(*info_buf)); return -1; } diff --git a/sbin/modload/elf.c b/sbin/modload/elf.c index 08a3d484071..17dc2e3ef5c 100644 --- a/sbin/modload/elf.c +++ b/sbin/modload/elf.c @@ -1,8 +1,8 @@ -/* $OpenBSD: elf.c,v 1.2 2002/01/08 21:58:36 ericj Exp $ */ +/* $OpenBSD: elf.c,v 1.3 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: elf.c,v 1.8 2002/01/03 21:45:58 jdolecek Exp $ */ /* - * Copyright (c) 1998 Johan Danielsson <joda@pdc.kth.se> + * Copyright (c) 1998 Johan Danielsson <joda@pdc.kth.se> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -236,7 +236,7 @@ read_elf_header(int fd, Elf_Ehdr *ehdr) ehdr->e_ident[EI_CLASS] != ELFCLASS) errx(4, "not in ELF%u format", ELFSIZE); if (ehdr->e_ehsize != ELF_HDR_SIZE) - errx(4, "file has ELF%u identity, but wrong header size", + errx(4, "file has ELF%u identity, but wrong header size", ELFSIZE); return 0; @@ -272,8 +272,8 @@ elf_mod_sizes(fd, modsize, strtablen, resrvp, sp) continue; } if (debug) - fprintf(stderr, - "%s: addr = %p size = %#lx align = %#lx\n", + fprintf(stderr, + "%s: addr = %p size = %#lx align = %#lx\n", s->name, s->addr, (u_long)s->size, (u_long)s->align); /* XXX try to get rid of the hole before the data section that GNU-ld likes to put there */ @@ -319,7 +319,7 @@ elf_mod_sizes(fd, modsize, strtablen, resrvp, sp) * -R executable to link against * -e entry point * -o output file - * -Ttext address to link text segment to in hex (assumes it's + * -Ttext address to link text segment to in hex (assumes it's * a page boundry) * -Tdata address to link data segment to in hex * <target> object file */ @@ -332,20 +332,20 @@ elf_mod_sizes(fd, modsize, strtablen, resrvp, sp) void elf_linkcmd(char *buf, size_t len, - const char *kernel, - const char *entry, - const char *outfile, - const void *address, + const char *kernel, + const char *entry, + const char *outfile, + const void *address, const char *object) { ssize_t n; if (data_offset == NULL) - n = snprintf(buf, len, LINKCMD, kernel, entry, + n = snprintf(buf, len, LINKCMD, kernel, entry, outfile, address, object); else - n = snprintf(buf, len, LINKCMD2, kernel, entry, - outfile, address, + n = snprintf(buf, len, LINKCMD2, kernel, entry, + outfile, address, (const char*)address + data_offset, object); if (n >= len) errx(1, "link command longer than %lu bytes", (u_long)len); @@ -375,7 +375,7 @@ elf_mod_load(int fd) && (s->type != SHT_DYNSYM)) { if (debug) fprintf(stderr, "loading `%s': addr = %p, " - "size = %#lx\n", + "size = %#lx\n", s->name, s->addr, (u_long)s->size); if (s->type == SHT_NOBITS) { /* skip some space */ @@ -435,7 +435,7 @@ elf_mod_symload(strtablen) err(12, "lseek"); if (read_elf_header(modfd, &ehdr) < 0) return; - + shstrtab = read_shstring_table(modfd, &ehdr); read_sections(modfd, &ehdr, shstrtab, &head); @@ -465,7 +465,7 @@ elf_mod_symload(strtablen) for (s = head; s; s = s->next) { struct elf_section *p = s; - + if ((p->type == SHT_STRTAB) && (strcmp(p->name, ".strtab") == 0 )) { if (debug) @@ -482,7 +482,7 @@ elf_mod_symload(strtablen) err(13, "malloc"); if (read(modfd, strbuf, p->size) != p->size) err(14, "read"); - + loadsym(strbuf, p->size); free(strbuf); } diff --git a/sbin/modload/modload.c b/sbin/modload/modload.c index 0fb8c972aa7..9f1759e912f 100644 --- a/sbin/modload/modload.c +++ b/sbin/modload/modload.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modload.c,v 1.33 2002/02/16 21:27:35 millert Exp $ */ +/* $OpenBSD: modload.c,v 1.34 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: modload.c,v 1.30 2001/11/08 15:33:15 christos Exp $ */ /* @@ -71,16 +71,16 @@ static void cleanup(void); /* prelink the module */ static int -prelink(const char *kernel, - const char *entry, - const char *outfile, - const void *address, +prelink(const char *kernel, + const char *entry, + const char *outfile, + const void *address, const char *object) { char cmdbuf[1024]; int error = 0; - linkcmd(cmdbuf, sizeof(cmdbuf), + linkcmd(cmdbuf, sizeof(cmdbuf), kernel, entry, outfile, address, object); if (debug) @@ -173,8 +173,8 @@ verify_entry(const char *entry, char *filename) return n; } -/* - * Transfer data to kernel memory in chunks +/* + * Transfer data to kernel memory in chunks * of MODIOBUF size at a time. */ void @@ -210,8 +210,8 @@ loadspace(size_t len) } } -/* - * Transfer symbol table to kernel memory in chunks +/* + * Transfer symbol table to kernel memory in chunks * of MODIOBUF size at a time. */ void @@ -339,7 +339,7 @@ main(int argc, char **argv) errx(1, "can't prelink `%s' creating `%s'", modobj, out); if (Sflag == 0) fileopen |= OUTFILE_CREAT; - + /* * Pre-open the 0-linked module to get the size information */ diff --git a/sbin/modload/modload.h b/sbin/modload/modload.h index e1940083881..e46de4261d6 100644 --- a/sbin/modload/modload.h +++ b/sbin/modload/modload.h @@ -1,4 +1,4 @@ -/* $OpenBSD: modload.h,v 1.3 2002/02/17 19:42:28 millert Exp $ */ +/* $OpenBSD: modload.h,v 1.4 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: modload.h,v 1.2 2001/11/08 15:33:15 christos Exp $ */ /* @@ -39,14 +39,14 @@ int elf_mod_sizes(int, size_t *, int *, struct lmc_resrv *, struct stat *); void *elf_mod_load(int); -void elf_linkcmd(char *, size_t, const char *, const char *, +void elf_linkcmd(char *, size_t, const char *, const char *, const char *, const void *, const char *); void elf_mod_symload(int); int a_out_mod_sizes(int, size_t *, int *, struct lmc_resrv *, struct stat *); void *a_out_mod_load(int); -void a_out_linkcmd(char *, size_t, const char *, const char *, +void a_out_linkcmd(char *, size_t, const char *, const char *, const char *, const void *, const char *); void a_out_mod_symload(int); diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 40176ae04eb..ae718799552 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.c,v 1.26 2002/02/17 19:42:28 millert Exp $ */ +/* $OpenBSD: mount.c,v 1.27 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94"; #else -static char rcsid[] = "$OpenBSD: mount.c,v 1.26 2002/02/17 19:42:28 millert Exp $"; +static char rcsid[] = "$OpenBSD: mount.c,v 1.27 2002/06/09 08:13:07 todd Exp $"; #endif #endif /* not lint */ @@ -458,7 +458,7 @@ prmount(sf) flags &= ~o->o_opt; } if (flags) - (void)printf("%sunknown flag%s %#x", !f++ ? " (" : ", ", + (void)printf("%sunknown flag%s %#x", !f++ ? " (" : ", ", flags & (flags - 1) ? "s" : "", flags); diff --git a/sbin/mount_lfs/mount_lfs.c b/sbin/mount_lfs/mount_lfs.c index 1b258c12f64..e41f6934793 100644 --- a/sbin/mount_lfs/mount_lfs.c +++ b/sbin/mount_lfs/mount_lfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_lfs.c,v 1.7 2002/04/23 18:54:12 espie Exp $ */ +/* $OpenBSD: mount_lfs.c,v 1.8 2002/06/09 08:13:07 todd Exp $ */ /* $NetBSD: mount_lfs.c,v 1.4 1996/04/13 05:35:44 cgd Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mount_lfs.c 8.3 (Berkeley) 3/27/94"; #else -static char rcsid[] = "$OpenBSD: mount_lfs.c,v 1.7 2002/04/23 18:54:12 espie Exp $"; +static char rcsid[] = "$OpenBSD: mount_lfs.c,v 1.8 2002/06/09 08:13:07 todd Exp $"; #endif #endif /* not lint */ @@ -128,7 +128,7 @@ main(argc, argv) if (mntflags & MNT_UPDATE) errcause = "specified device does not match mounted device"; - else + else errcause = "incorrect super block"; break; default: diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index bfdeb55edfd..a5dcc820739 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_nfs.c,v 1.28 2002/03/21 21:16:07 millert Exp $ */ +/* $OpenBSD: mount_nfs.c,v 1.29 2002/06/09 08:13:08 todd Exp $ */ /* $NetBSD: mount_nfs.c,v 1.12.4.1 1996/05/25 22:48:05 fvdl Exp $ */ /* @@ -301,7 +301,7 @@ main(argc, argv) if (altflags & ALTF_PORT) port_no = atoi(strstr(optarg, "port=") + 5); if (altflags & ALTF_NOAC) { - nfsargsp->flags + nfsargsp->flags |= (NFSMNT_ACREGMIN | NFSMNT_ACREGMAX | NFSMNT_ACDIRMIN | NFSMNT_ACDIRMAX); nfsargsp->acregmin = 0; diff --git a/sbin/mount_umap/mount_umap.c b/sbin/mount_umap/mount_umap.c index 6b68b63a801..53e27ed411f 100644 --- a/sbin/mount_umap/mount_umap.c +++ b/sbin/mount_umap/mount_umap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_umap.c,v 1.9 2002/02/16 21:27:36 millert Exp $ */ +/* $OpenBSD: mount_umap.c,v 1.10 2002/06/09 08:13:08 todd Exp $ */ /* $NetBSD: mount_umap.c,v 1.5 1996/04/13 01:32:05 jtc Exp $ */ /* @@ -47,7 +47,7 @@ char copyright[] = #if 0 static char sccsid[] = "@(#)mount_umap.c 8.3 (Berkeley) 3/27/94"; #else -static char rcsid[] = "$OpenBSD: mount_umap.c,v 1.9 2002/02/16 21:27:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: mount_umap.c,v 1.10 2002/06/09 08:13:08 todd Exp $"; #endif #endif /* not lint */ @@ -76,12 +76,12 @@ static char rcsid[] = "$OpenBSD: mount_umap.c,v 1.9 2002/02/16 21:27:36 millert /* * This routine provides the user interface to mounting a umap layer. - * It takes 4 mandatory parameters. The mandatory arguments are the place + * It takes 4 mandatory parameters. The mandatory arguments are the place * where the next lower level is mounted, the place where the umap layer is to * be mounted, the name of the user mapfile, and the name of the group * mapfile. The routine checks the ownerships and permissions on the * mapfiles, then opens and reads them. Then it calls mount(), which - * will, in turn, call the umap version of mount. + * will, in turn, call the umap version of mount. */ const struct mntopt mopts[] = { @@ -139,7 +139,7 @@ main(argc, argv) #ifdef MAPSECURITY /* * Check that group and other don't have write permissions on - * this umapfile, and that the umapfile belongs to root. + * this umapfile, and that the umapfile belongs to root. */ if (fstat(fileno(fp), &statbuf)) err(1, "%s%s", umapfile, not); @@ -187,7 +187,7 @@ main(argc, argv) #ifdef MAPSECURITY /* * Check that group and other don't have write permissions on - * this group mapfile, and that the file belongs to root. + * this group mapfile, and that the file belongs to root. */ if (fstat(fileno(gfp), &statbuf)) err(1, "%s%s", gmapfile, not); diff --git a/sbin/mount_umap/umap_manual b/sbin/mount_umap/umap_manual index 0ded71070b6..4fcae246af2 100644 --- a/sbin/mount_umap/umap_manual +++ b/sbin/mount_umap/umap_manual @@ -1,4 +1,4 @@ -% $OpenBSD: umap_manual,v 1.2 1996/06/23 14:31:41 deraadt Exp $ +% $OpenBSD: umap_manual,v 1.3 2002/06/09 08:13:08 todd Exp $ % $NetBSD: umap_manual,v 1.2 1995/03/18 14:58:19 cgd Exp $ \appendix @@ -9,10 +9,10 @@ Normally, the file system is expected to span a single administrative domain. An administrative domain, for these purposes, is a machine or set of machines that share common password file information, usually through -the yellow pages mechanism. File hierarchies that span more -than one domain leads to certain problems, since the same numerical -UID in one domain may correspond to a different user in another domain. -If the system administrator is very careful to ensure that both domains +the yellow pages mechanism. File hierarchies that span more +than one domain leads to certain problems, since the same numerical +UID in one domain may correspond to a different user in another domain. +If the system administrator is very careful to ensure that both domains contain identical user ID information, The umap layer can be used to run between those domains without changes @@ -32,12 +32,12 @@ identifier used by Unix systems to identify groups of users. ``Group name'' is the character string name attached to a particular GID in the local {\sf /etc/groups} file or the yellow pages groups file. -In order for the umap layer to work properly, all users -in either domain must have password file entries in both domains. -They do not, however, have to have the same numerical UID, nor even the -same character string login name (the latter is highly recommended, -if possible, however). Any user not having a UID in one domain will be -treated as the special user NOBODY by the other domain, probably with +In order for the umap layer to work properly, all users +in either domain must have password file entries in both domains. +They do not, however, have to have the same numerical UID, nor even the +same character string login name (the latter is highly recommended, +if possible, however). Any user not having a UID in one domain will be +treated as the special user NOBODY by the other domain, probably with undesirable consequences. Any user not owning any files in the shared sub-trees need not be given a UID in the other domain. @@ -49,30 +49,30 @@ known in the other domain, that group will be treated as being NULLGROUP. The umap layer has no provisions for enrolling UID's from other domains as group members, but, since each user from each domain must have some UID in every domain, the UID in the local domain can be used to enroll -the user in the local groups. +the user in the local groups. NOBODY and NULLGROUP are special reserved UID's and GID's, respectively. NOBODY is user 32767. NULLGROUP is group 65534. If the system administrator wants to have an appropriate text string appear when these UID's are encountered by programs like {\sf ls -l}, he should add these values to -the password and {\sf /etc/groups} file, or to the appropriate yellow pages. -If these IDs are already in use in that domain, different values can be -used for NOBODY and NULLGROUP, but that will require a recompilation of -the umap layer code and, as a result, the entire kernel. These -values are defined in the {\sf umap\_info.h} file, kept with the rest of the +the password and {\sf /etc/groups} file, or to the appropriate yellow pages. +If these IDs are already in use in that domain, different values can be +used for NOBODY and NULLGROUP, but that will require a recompilation of +the umap layer code and, as a result, the entire kernel. These +values are defined in the {\sf umap\_info.h} file, kept with the rest of the umap source code. -When the umap layer is in use, one of the participating domains is declared -to be the master. All UID and GID information stored for participating files -will be stored in vnodes using its mappings, no matter what site the copies of -the files are stored at. The master domain therefore need not run a copy -of the umap layer, as it already has all of the correct mappings. All +When the umap layer is in use, one of the participating domains is declared +to be the master. All UID and GID information stored for participating files +will be stored in vnodes using its mappings, no matter what site the copies of +the files are stored at. The master domain therefore need not run a copy +of the umap layer, as it already has all of the correct mappings. All other domains must run a umap layer on top of any other layers they use. \subsection{Setting Up a umap Layer} -The system administrator of a system needing to use the umap layer -must take several actions. +The system administrator of a system needing to use the umap layer +must take several actions. First, he must create files containing the necessary UID and GID mappings. There is a separate file for user and group IDs. The format of the files is the same. The first line contains the total number @@ -83,7 +83,7 @@ UID for the same user on the master machine. The maximum number of users that can be mapped for a single shared sub-tree is 64. The maximum number of groups that can be mapped for a single sub-tree is 16. These constants are set in the {\sf umap\_info.h} file, and can be changed, but changing them -requires recompilation. Separate mapping files can be used for each shared +requires recompilation. Separate mapping files can be used for each shared subtree, or the same mapping files can be shared by several sub-trees. Below is a sample UID mapping file. There are four entries. UID 5 is mapped @@ -92,7 +92,7 @@ machine, the UID's for users 5, 521, and 7000 are the same as on the master, but UID 2002 is for a user whose UID on the master machine is 604. All files in the sub-tree belonging to that user have UID 604 in their inodes, even on this machine, but the umap layer will ensure that anyone running -under UID 2002 will have all files in this sub-tree owned by 604 treated as if +under UID 2002 will have all files in this sub-tree owned by 604 treated as if they were owned by 2002. An {\sf ls -l} on a file owned by 604 in this sub-tree will show the login name associated with UID 2002 as the owner. @@ -126,9 +126,9 @@ problems, and what to do about them. \item{Problem: A file belongs to NOBODY, or group NULLGROUP. -Fixes: The mapping files don't know about this file's real user or group. -Either they are not in the mapping files, or the counts on the number of -entries in the mapping files are too low, so entries at the end (including +Fixes: The mapping files don't know about this file's real user or group. +Either they are not in the mapping files, or the counts on the number of +entries in the mapping files are too low, so entries at the end (including these) are being ignored. Add the entries or fix the counts, and either unmount and remount the sub-tree, or reboot.} @@ -138,13 +138,13 @@ Fixes: Possibly, some mapping has not been set properly. Check to see which files are used by the operation and who they appear to be owned by. If they are owned by NOBODY or some other suspicious user, there may be a problem in the mapping files. Be sure to check groups, -too. As above, if the counts of mappings in the mapping files are lower -than the actual numbers of pairs, pairs at the end of the file will be -ignored. If any changes are made in the mapping files, you will need to +too. As above, if the counts of mappings in the mapping files are lower +than the actual numbers of pairs, pairs at the end of the file will be +ignored. If any changes are made in the mapping files, you will need to either unmount and remount or reboot before they will take effect. Another possible problem can arise because not all Unix utilities -rely exclusively on numeric UID for identification. For instance, +rely exclusively on numeric UID for identification. For instance, SCCS saves the login name in files. If a user's login name on two machines isn't the same, SCCS may veto an operation even though Unix file permissions, as checked by the umap layer, may say it's OK. There's not much to be @@ -154,9 +154,9 @@ where similar problems arise, some of which may be even harder to handle.} \item{Problem: Someone has access permissions he should not have. -Fixes: This is probably caused by a mistake in the mapping files. Check -both user and group mapping files. If any changes are made in the mapping -files, you will need to unmount and remount the sub-tree or reboot before they +Fixes: This is probably caused by a mistake in the mapping files. Check +both user and group mapping files. If any changes are made in the mapping +files, you will need to unmount and remount the sub-tree or reboot before they will take effect.} \item{Problem: {\sf ls -l} (or a similar program) shows the wrong user for a file. @@ -168,8 +168,8 @@ not be what was intended. (Generally speaking, mapping two local UIDs to a single master UID is a bad idea, but the software will not prevent it. Similarly, mapping a single local UID to two master UIDs is a bad idea, but will not be prevented. In this case, only the first mapping of the -local UID will be done. The second, and all subsequent ones, will be -ignored.) If any changes are made in the mapping files, you will need to +local UID will be done. The second, and all subsequent ones, will be +ignored.) If any changes are made in the mapping files, you will need to unmount and remount the sub-tree or reboot before they will take effect.} \end{itemize} diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index 21e2a87f911..9b9336d2913 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.47 2002/06/04 00:09:08 deraadt Exp $ */ +/* $OpenBSD: mountd.c,v 1.48 2002/06/09 08:13:08 todd Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -395,10 +395,10 @@ mntsrv(rqstp, transp) case RPCMNT_MOUNT: if (debug) fprintf(stderr, - "Got mount request from %s\n", + "Got mount request from %s\n", inet_ntoa(transp->xp_raddr.sin_addr)); if (sport >= IPPORT_RESERVED && resvport_only) { - syslog(LOG_NOTICE, + syslog(LOG_NOTICE, "Refused mount RPC from host %s port %d", inet_ntoa(transp->xp_raddr.sin_addr), sport); svcerr_weakauth(transp); @@ -1379,7 +1379,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr) opt_flags |= OP_MAPALL; } else opt_flags |= OP_MAPROOT; - } else + } else if (cpoptarg && (!strcmp(cpopt, "mask") || !strcmp(cpopt, "m"))) { if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 1)) { diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index b46172d8bc6..920a160d126 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.21 2002/05/29 09:19:52 deraadt Exp $ */ +/* $OpenBSD: mkfs.c,v 1.22 2002/06/09 08:13:08 todd Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94"; #else -static char rcsid[] = "$OpenBSD: mkfs.c,v 1.21 2002/05/29 09:19:52 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mkfs.c,v 1.22 2002/06/09 08:13:08 todd Exp $"; #endif #endif /* not lint */ @@ -413,7 +413,7 @@ recalc: fsize, sblock.fs_fsize); exit(23); } - /* + /* * Calculate the number of cylinders per group */ sblock.fs_cpg = cpg; @@ -688,7 +688,7 @@ next: sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize, ((char *)fscs) + i); - /* + /* * Write out the duplicate super blocks */ for (cylno = 0; cylno < sblock.fs_ncg; cylno++) @@ -756,7 +756,7 @@ initcg(cylno, utime) acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag; acg.cg_btotoff = &acg.cg_space[0] - (u_char *)(&acg.cg_firstfield); acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(int32_t); - acg.cg_iusedoff = acg.cg_boff + + acg.cg_iusedoff = acg.cg_boff + sblock.fs_cpg * sblock.fs_nrpos * sizeof(int16_t); acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, NBBY); if (sblock.fs_contigsumsize <= 0) { @@ -1161,7 +1161,7 @@ calloc(size, numelm) void *base; size *= numelm; - if ((base = malloc(size)) != 0) + if ((base = malloc(size)) != 0) memset(base, 0, size); return (base); } diff --git a/sbin/newlfs/lfs.c b/sbin/newlfs/lfs.c index 42c7f9abd40..e917151cdf2 100644 --- a/sbin/newlfs/lfs.c +++ b/sbin/newlfs/lfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs.c,v 1.5 2002/02/16 21:27:37 millert Exp $ */ +/* $OpenBSD: lfs.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* $NetBSD: lfs.c,v 1.8 1995/06/19 21:30:36 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; #else -static char rcsid[] = "$OpenBSD: lfs.c,v 1.5 2002/02/16 21:27:37 millert Exp $"; +static char rcsid[] = "$OpenBSD: lfs.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; #endif #endif /* not lint */ @@ -167,7 +167,7 @@ struct direct lfs_lf_dir[] = { { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, }; -static daddr_t make_dinode +static daddr_t make_dinode (ino_t, struct dinode *, int, daddr_t, struct lfs *); static void make_dir( void *, struct direct *, int); static void put(int, off_t, void *, size_t); @@ -270,7 +270,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) lfsp->lfs_nseg = lfsp->lfs_dsize / lfsp->lfs_ssize; lfsp->lfs_maxfilesize = maxtable[lfsp->lfs_bshift] << lfsp->lfs_bshift; - /* + /* * The number of free blocks is set from the number of segments times * the segment size - 2 (that we never write because we need to make * sure the cleaner can run). Then we'll subtract off the room for the @@ -297,7 +297,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) /* Figure out where the superblocks are going to live */ lfsp->lfs_sboffs[0] = LFS_LABELPAD/lp->d_secsize; for (i = 1; i < LFS_MAXNUMSB; i++) { - sb_addr = ((i * sb_interval) << + sb_addr = ((i * sb_interval) << (lfsp->lfs_segshift - lfsp->lfs_bshift + lfsp->lfs_fsbtodb)) + lfsp->lfs_sboffs[0]; if (sb_addr > partp->p_size) @@ -306,15 +306,15 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) } last_sb_addr = lfsp->lfs_sboffs[i - 1]; lfsp->lfs_lastseg = lfsp->lfs_sboffs[0]; - lfsp->lfs_nextseg = + lfsp->lfs_nextseg = lfsp->lfs_sboffs[1] ? lfsp->lfs_sboffs[1] : lfsp->lfs_sboffs[0]; lfsp->lfs_curseg = lfsp->lfs_lastseg; /* * Initialize the segment usage table. The first segment will - * contain the superblock, the cleanerinfo (cleansz), the segusage - * table * (segtabsz), 1 block's worth of IFILE entries, the root - * directory, the lost+found directory and one block's worth of + * contain the superblock, the cleanerinfo (cleansz), the segusage + * table * (segtabsz), 1 block's worth of IFILE entries, the root + * directory, the lost+found directory and one block's worth of * inodes (containing the ifile, root, and l+f inodes). */ if (!(cleaninfo = malloc(lfsp->lfs_cleansz << lfsp->lfs_bshift))) @@ -336,7 +336,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) lfsp->lfs_bfree -= fsbtodb(lfsp, lfsp->lfs_cleansz + lfsp->lfs_segtabsz + 4); - /* + /* * Now figure out the address of the ifile inode. The inode block * appears immediately after the segment summary. */ @@ -355,27 +355,27 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) segp->su_nsums = 0; } - /* + /* * Initialize dynamic accounting. The blocks available for * writing are the bfree blocks minus 1 segment summary for * each segment since you can't write any new data without * creating a segment summary - 2 segments that the cleaner * needs. */ - lfsp->lfs_avail = lfsp->lfs_bfree - lfsp->lfs_nseg - + lfsp->lfs_avail = lfsp->lfs_bfree - lfsp->lfs_nseg - fsbtodb(lfsp, 2 * lfsp->lfs_ssize); lfsp->lfs_uinodes = 0; /* * Ready to start writing segments. The first segment is different * because it contains the segment usage table and the ifile inode - * as well as a superblock. For the rest of the segments, set the + * as well as a superblock. For the rest of the segments, set the * time stamp to be 0 so that the first segment is the most recent. * For each segment that is supposed to contain a copy of the super - * block, initialize its first few blocks and its segment summary + * block, initialize its first few blocks and its segment summary * to indicate this. */ lfsp->lfs_nfiles = LFS_FIRST_INUM - 1; - lfsp->lfs_cksum = + lfsp->lfs_cksum = cksum(lfsp, sizeof(struct lfs) - sizeof(lfsp->lfs_cksum)); /* Now create a block of disk inodes */ @@ -389,13 +389,13 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) fatal("%s", strerror(errno)); ifile = (IFILE *)ipagep; - /* + /* * Initialize IFILE. It is the next block following the * block of inodes (whose address has been calculated in * lfsp->lfs_idaddr; */ sb_addr = lfsp->lfs_idaddr + lfsp->lfs_bsize / lp->d_secsize; - sb_addr = make_dinode(LFS_IFILE_INUM, dip, + sb_addr = make_dinode(LFS_IFILE_INUM, dip, lfsp->lfs_cleansz + lfsp->lfs_segtabsz+1, sb_addr, lfsp); dip->di_mode = IFREG|IREAD|IWRITE; ip = &ifile[LFS_IFILE_INUM]; @@ -426,7 +426,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) /* Link remaining IFILE entries in free list */ - for (ip = &ifile[LFS_FIRST_INUM], i = LFS_FIRST_INUM; + for (ip = &ifile[LFS_FIRST_INUM], i = LFS_FIRST_INUM; i < lfsp->lfs_ifpb; ++ip) { ip->if_version = 1; ip->if_daddr = LFS_UNUSED_DADDR; @@ -440,10 +440,10 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) dp = datasump = malloc (blocks_used * sizeof(u_long)); *dp++ = ((u_long *)dpagep)[0]; /* inode block */ for (i = 0; i < lfsp->lfs_cleansz; i++) - *dp++ = ((u_long *)cleaninfo)[(i << lfsp->lfs_bshift) / + *dp++ = ((u_long *)cleaninfo)[(i << lfsp->lfs_bshift) / sizeof(u_long)]; /* Cleaner info */ for (i = 0; i < lfsp->lfs_segtabsz; i++) - *dp++ = ((u_long *)segtable)[(i << lfsp->lfs_bshift) / + *dp++ = ((u_long *)segtable)[(i << lfsp->lfs_bshift) / sizeof(u_long)]; /* Segusage table */ *dp++ = ((u_long *)ifile)[0]; /* Ifile */ @@ -469,20 +469,20 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) off += lfsp->lfs_bsize; /* - * use ipagep for space for writing out other stuff. It used to + * use ipagep for space for writing out other stuff. It used to * contain the ifile, but we're done with it. */ /* Write out the root and lost and found directories */ memset(ipagep, 0, lfsp->lfs_bsize); - make_dir(ipagep, lfs_root_dir, + make_dir(ipagep, lfs_root_dir, sizeof(lfs_root_dir) / sizeof(struct direct)); *dp++ = ((u_long *)ipagep)[0]; put(fd, off, ipagep, lfsp->lfs_bsize); off += lfsp->lfs_bsize; memset(ipagep, 0, lfsp->lfs_bsize); - make_dir(ipagep, lfs_lf_dir, + make_dir(ipagep, lfs_lf_dir, sizeof(lfs_lf_dir) / sizeof(struct direct)); *dp++ = ((u_long *)ipagep)[0]; put(fd, off, ipagep, lfsp->lfs_bsize); @@ -491,7 +491,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) lfsp->lfs_offset = (off + lfsp->lfs_bsize) / lp->d_secsize; put(fd, LFS_LABELPAD, lfsp, sizeof(struct lfs)); - /* + /* * Finally, calculate all the fields for the summary structure * and write it. */ @@ -558,9 +558,9 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) file_info.fi_ino = LOSTFOUNDINO; memcpy(sump, &file_info, sizeof(FINFO)); - ((daddr_t *)ipagep)[LFS_SUMMARY_SIZE / sizeof(daddr_t) - 1] = + ((daddr_t *)ipagep)[LFS_SUMMARY_SIZE / sizeof(daddr_t) - 1] = lfsp->lfs_idaddr; - ((SEGSUM *)ipagep)->ss_sumsum = cksum(ipagep+sizeof(summary.ss_sumsum), + ((SEGSUM *)ipagep)->ss_sumsum = cksum(ipagep+sizeof(summary.ss_sumsum), LFS_SUMMARY_SIZE - sizeof(summary.ss_sumsum)); put(fd, LFS_LABELPAD + LFS_SBPAD, ipagep, LFS_SUMMARY_SIZE); @@ -579,9 +579,9 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) put(fd, off, sp, LFS_SUMMARY_SIZE); /* Now, write rest of segments containing superblocks */ - lfsp->lfs_cksum = + lfsp->lfs_cksum = cksum(lfsp, sizeof(struct lfs) - sizeof(lfsp->lfs_cksum)); - for (seg_addr = last_addr = lfsp->lfs_sboffs[0], j = 1, i = 1; + for (seg_addr = last_addr = lfsp->lfs_sboffs[0], j = 1, i = 1; i < lfsp->lfs_nseg; i++) { seg_addr += lfsp->lfs_ssize << lfsp->lfs_fsbtodb; @@ -594,10 +594,10 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) j++; put(fd, seg_seek, lfsp, sizeof(struct lfs)); seg_seek += LFS_SBPAD; - } + } /* Summary */ - sp->ss_sumsum = cksum(&sp->ss_datasum, + sp->ss_sumsum = cksum(&sp->ss_datasum, LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)); put(fd, seg_seek, sp, LFS_SUMMARY_SIZE); } @@ -666,7 +666,7 @@ make_dinode(ino, dip, nblocks, saddr, lfsp) /* * Construct a set of directory entries in "bufp". We assume that all the - * entries in protodir fir in the first DIRBLKSIZ. + * entries in protodir fir in the first DIRBLKSIZ. */ static void make_dir(bufp, protodir, entries) diff --git a/sbin/pdisk/ATA_media.c b/sbin/pdisk/ATA_media.c index 533c6216e2e..5af7ef7ff92 100644 --- a/sbin/pdisk/ATA_media.c +++ b/sbin/pdisk/ATA_media.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -237,7 +237,7 @@ ATAHardwarePresent(void) // Hardware configuration flags configFlags = LMGetHWCfgFlags(); - + return ((configFlags & 0x0080) != 0); } @@ -262,7 +262,7 @@ ata_init(void) return; } ata_inited = 1; - + if (ATAManagerPresent() == 0) { ata_mgr.exists = 0; return; @@ -272,12 +272,12 @@ ata_init(void) ata_mgr.kind = allocate_media_kind(); clear_memory((void *)&pb, sizeof(pb)); - + pb.ataPBFunctionCode = kATAMgrManagerInquiry; pb.ataPBVers = kATAPBVers1; status = ataManager((ataPB*) &pb ); - + if (status != noErr) { ata_mgr.exists = 0; return; @@ -302,7 +302,7 @@ long compute_id(long bus, long device) { long id; - + id = -1; if (ata_mgr.version.major < 3) { if (device != 0) { @@ -346,7 +346,7 @@ get_info(long id, struct ATA_identify_drive_info *ip) pb.ataPBFlags = mATAFlagIORead | mATAFlagByteSwap; pb.ataPBTimeOut = kATAtimeout; pb.ataPBBuffer = (void*) ip; - + status = ataManager((ataPB*) &pb ); if (status != noErr) { @@ -397,11 +397,11 @@ open_ata_as_media(long bus, long device) struct ATA_identify_drive_info info; unsigned char *buf; unsigned long total; - + if (ata_inited == 0) { ata_init(); } - + if (ata_mgr.exists == 0) { //printf("ATA manager does not exist\n"); return 0; @@ -475,7 +475,7 @@ read_ata_media(MEDIA m, long long offset, unsigned long count, void *address) long block_size; unsigned char *buffer; int i; - + a = (ATA_MEDIA) m; rtn_value = 0; if (a == 0) { @@ -518,7 +518,7 @@ write_ata_media(MEDIA m, long long offset, unsigned long count, void *address) long block_size; unsigned char *buffer; int i; - + a = (ATA_MEDIA) m; rtn_value = 0; if (a == 0) { @@ -555,7 +555,7 @@ long close_ata_media(MEDIA m) { ATA_MEDIA a; - + a = (ATA_MEDIA) m; if (a == 0) { return 0; @@ -590,7 +590,7 @@ ATA_ReadBlock(UInt32 deviceID, ATA_INFO info, UInt32 block_size, UInt32 block, U pb.ataPBDeviceID = deviceID; pb.ataPBFlags = mATAFlagTFRead | mATAFlagIORead ; pb.ataPBTimeOut = kATAtimeout; - + pb.ataPBLogicalBlockSize = block_size; pb.ataPBBuffer = address; pb.ataPBByteCount = block_size; @@ -644,7 +644,7 @@ ATA_WriteBlock(UInt32 deviceID, ATA_INFO info, UInt32 block_size, UInt32 block, pb.ataPBDeviceID = deviceID; pb.ataPBFlags = mATAFlagTFRead | mATAFlagIOWrite ; pb.ataPBTimeOut = kATAtimeout; - + pb.ataPBLogicalBlockSize = block_size; pb.ataPBBuffer = address; pb.ataPBByteCount = block_size; @@ -707,7 +707,7 @@ get_pi_info(long id, struct ATAPI_identify_drive_info *ip) pb.ataPBFlags = mATAFlagIORead | mATAFlagByteSwap | mATAFlagProtocol1; pb.ataPBTimeOut = kATAtimeout; pb.ataPBBuffer = (void*) ip; - + status = ataManager((ataPB*) &pb ); if (status != noErr) { @@ -728,12 +728,12 @@ open_atapi_as_media(long bus, long device) struct ATAPI_identify_drive_info info; unsigned char *buf; unsigned long block_size; - unsigned long blocks; - + unsigned long blocks; + if (ata_inited == 0) { ata_init(); } - + if (ata_mgr.exists == 0) { return 0; } @@ -786,7 +786,7 @@ read_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) long block_size; unsigned char *buffer; int i; - + a = (ATA_MEDIA) m; rtn_value = 0; if (a == 0) { @@ -821,7 +821,7 @@ read_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) long write_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) -{ +{ return 0; } @@ -842,7 +842,7 @@ ATAPI_ReadBlock(UInt32 deviceID, UInt32 block_size, UInt32 block, UInt8 *address pb.ataPBDeviceID = deviceID; pb.ataPBFlags = mATAFlagTFRead | mATAFlagIORead | mATAFlagProtocol1; pb.ataPBTimeOut = kATAtimeout; - + pb.ataPBBuffer = address; pb.ataPBByteCount = block_size; pb.ataPBTaskFile.ataTFCylinder = block_size; @@ -855,7 +855,7 @@ ATAPI_ReadBlock(UInt32 deviceID, UInt32 block_size, UInt32 block, UInt8 *address pb.ataPBTaskFile.ataTFSDH = 0xA0 | 0x40 | slave; pb.ataPBTaskFile.ataTFCommand = kATAcmdATAPIPacket; pb.ataPBPacketPtr = &cmdPacket; - + cmdPacket.atapiPacketSize = 16; clear_memory((void *)&cmdPacket.atapiCommandByte, 16); gRead = (SCSI_10_Byte_Command *) &cmdPacket.atapiCommandByte[0]; @@ -898,7 +898,7 @@ ATAPI_TestUnitReady(UInt32 deviceID) pb.ataPBDeviceID = deviceID; pb.ataPBFlags = mATAFlagTFRead | mATAFlagIORead | mATAFlagProtocol1; pb.ataPBTimeOut = kATAtimeout; - + if (deviceID & 0x0FF00) { slave = 0x10; } else { @@ -908,7 +908,7 @@ ATAPI_TestUnitReady(UInt32 deviceID) pb.ataPBTaskFile.ataTFSDH = 0xA0 | 0x40 | slave; pb.ataPBTaskFile.ataTFCommand = kATAcmdATAPIPacket; pb.ataPBPacketPtr = &cmdPacket; - + cmdPacket.atapiPacketSize = 16; clear_memory((void *)&cmdPacket.atapiCommandByte, 16); gTestUnit = (SCSI_10_Byte_Command *) &cmdPacket.atapiCommandByte[0]; @@ -946,7 +946,7 @@ ATAPI_ReadCapacity(UInt32 deviceID, unsigned long *block_size, unsigned long *bl pb.ataPBDeviceID = deviceID; pb.ataPBFlags = mATAFlagTFRead | mATAFlagIORead | mATAFlagProtocol1; pb.ataPBTimeOut = kATAtimeout; - + pb.ataPBBuffer = (unsigned char *)&rcd; pb.ataPBByteCount = 8; pb.ataPBTaskFile.ataTFCylinder = 8; @@ -959,7 +959,7 @@ ATAPI_ReadCapacity(UInt32 deviceID, unsigned long *block_size, unsigned long *bl pb.ataPBTaskFile.ataTFSDH = 0xA0 | 0x40 | slave; pb.ataPBTaskFile.ataTFCommand = kATAcmdATAPIPacket; pb.ataPBPacketPtr = &cmdPacket; - + cmdPacket.atapiPacketSize = 16; clear_memory((void *)&cmdPacket.atapiCommandByte, 16); gReadCap = (SCSI_10_Byte_Command *) &cmdPacket.atapiCommandByte[0]; @@ -994,10 +994,10 @@ ATA_FindDevice(long dRefNum) pb.ataPBDeviceID = 0xFFFF; pb.ataPBTimeOut = kATAtimeout; - pb.ataDeviceNextID = 1; + pb.ataDeviceNextID = 1; do { status = ataManager((ataPB*) &pb); - + if (status != noErr) { break; } else if (pb.ataDrvrRefNum == dRefNum @@ -1027,11 +1027,11 @@ MEDIA_ITERATOR create_ata_iterator(void) { ATA_MEDIA_ITERATOR a; - + if (ata_inited == 0) { ata_init(); } - + if (ata_mgr.exists == 0) { return 0; } @@ -1055,7 +1055,7 @@ void reset_ata_iterator(MEDIA_ITERATOR m) { ATA_MEDIA_ITERATOR a; - + a = (ATA_MEDIA_ITERATOR) m; if (a == 0) { /* no media */ @@ -1072,7 +1072,7 @@ step_ata_iterator(MEDIA_ITERATOR m) { ATA_MEDIA_ITERATOR a; char *result; - + a = (ATA_MEDIA_ITERATOR) m; if (a == 0) { /* no media */ @@ -1134,7 +1134,7 @@ open_mklinux_ata_as_media(long index) { long bus; long id; - + bus = index / 2; id = index % 2; diff --git a/sbin/pdisk/ATA_media.h b/sbin/pdisk/ATA_media.h index 96a83172233..39e0f7c2bdd 100644 --- a/sbin/pdisk/ATA_media.h +++ b/sbin/pdisk/ATA_media.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __ATA_media__ diff --git a/sbin/pdisk/DoSCSICommand.c b/sbin/pdisk/DoSCSICommand.c index ea9cd49a373..3e30a07a5bf 100644 --- a/sbin/pdisk/DoSCSICommand.c +++ b/sbin/pdisk/DoSCSICommand.c @@ -11,23 +11,23 @@ /* * Copyright 1992, 1993, 1997, 1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "DoScsiCommand.h" @@ -576,7 +576,7 @@ exit: && (scsiFlags & scsiDirectionMask) != scsiDirectionNone && myTransferCount != dataLength) { status = scsiDataRunError; - } + } if (scsiStatusBytePtr != NULL) { *scsiStatusBytePtr = scsiStatusByte; } @@ -612,7 +612,7 @@ IsVirtualMemoryRunning(void) { OSErr status; long response; - + status = Gestalt(gestaltVMAttr, &response); /* * VM is active iff Gestalt succeeded and the response is appropriate. diff --git a/sbin/pdisk/DoSCSICommand.h b/sbin/pdisk/DoSCSICommand.h index 34d7e6cd8dd..22aea57916d 100644 --- a/sbin/pdisk/DoSCSICommand.h +++ b/sbin/pdisk/DoSCSICommand.h @@ -7,23 +7,23 @@ /* * Copyright 1993-1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __DoScsiCommand__ diff --git a/sbin/pdisk/MacSCSICommand.h b/sbin/pdisk/MacSCSICommand.h index b02b66f90ae..4cae2387eb3 100644 --- a/sbin/pdisk/MacSCSICommand.h +++ b/sbin/pdisk/MacSCSICommand.h @@ -9,23 +9,23 @@ /* * Copyright 1995, 1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* @@ -193,7 +193,7 @@ struct SCSI_Sense_Data { /* Request Sense result */ unsigned char additionalSenseLength; unsigned char reservedForCopy[4]; unsigned char additionalSenseCode; - unsigned char additionalSenseQualifier; + unsigned char additionalSenseQualifier; unsigned char fruCode; /* Field replacable unit code */ unsigned char senseKeySpecific[2]; unsigned char additional[101]; diff --git a/sbin/pdisk/README b/sbin/pdisk/README index aeda6d7405b..5c5a309f1e1 100644 --- a/sbin/pdisk/README +++ b/sbin/pdisk/README @@ -27,23 +27,23 @@ Price: Free Legalese: Copyright 1996,1997,1998 by Apple Computer, Inc. - All Rights Reserved - - Permission to use, copy, modify, and distribute this software and - its documentation for any purpose and without fee is hereby granted, - provided that the above copyright notice appears in all copies and - that both the copyright notice and this permission notice appear in - supporting documentation. - - APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE. - - IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + All Rights Reserved + + Permission to use, copy, modify, and distribute this software and + its documentation for any purpose and without fee is hereby granted, + provided that the above copyright notice appears in all copies and + that both the copyright notice and this permission notice appear in + supporting documentation. + + APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Contact Info: Go to <http://www.mklinux.apple.com> to find out about MkLinux. diff --git a/sbin/pdisk/SCSI_media.c b/sbin/pdisk/SCSI_media.c index fb7bb587ecc..cbf7b54797d 100644 --- a/sbin/pdisk/SCSI_media.c +++ b/sbin/pdisk/SCSI_media.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -162,12 +162,12 @@ scsi_init(void) { int i; int old_scsi; - + if (scsi_inited != 0) { return; } scsi_inited = 1; - + scsi_mgr.exists = 1; scsi_mgr.kind = allocate_media_kind(); @@ -180,10 +180,10 @@ scsi_init(void) scsi_mgr.bus_count = 1; old_scsi = 1; } - + scsi_mgr.bus_list = (struct bus_entry *) calloc(scsi_mgr.bus_count, sizeof(struct bus_entry)); - + if (scsi_mgr.bus_list == 0) { scsi_mgr.bus_count = 0; } else { @@ -200,7 +200,7 @@ scsi_init(void) sizeof(struct bus_entry), /* size of element */ bus_entry_compare); /* element comparison routine */ } - + init_mklinux_cache(); } @@ -257,10 +257,10 @@ int bus_entry_compare(const void* a, const void* b) { long result; - + const struct bus_entry *x = (const struct bus_entry *) a; const struct bus_entry *y = (const struct bus_entry *) b; - + result = x->sort_value - y->sort_value; if (result == 0) { result = x->bus - y->bus; @@ -289,11 +289,11 @@ open_scsi_as_media(long bus, long device) SCSI_MEDIA a; UInt32 blockCount; UInt32 blockSize; - + if (scsi_inited == 0) { scsi_init(); } - + if (scsi_mgr.exists == 0) { return 0; } @@ -329,7 +329,7 @@ read_scsi_media(MEDIA m, long long offset, unsigned long count, void *address) long block_size; unsigned char *buffer; int i; - + block = (long) offset; //printf("scsi %d count %d\n", block, count); a = (SCSI_MEDIA) m; @@ -374,7 +374,7 @@ write_scsi_media(MEDIA m, long long offset, unsigned long count, void *address) long block_size; unsigned char *buffer; int i; - + a = (SCSI_MEDIA) m; rtn_value = 0; if (a == 0) { @@ -411,7 +411,7 @@ long close_scsi_media(MEDIA m) { SCSI_MEDIA a; - + a = (SCSI_MEDIA) m; if (a == 0) { return 0; @@ -675,7 +675,7 @@ SCSI_FindDevice(long dRefNum) SCSIDriverPB pb; OSErr status; short targetID; - + status = nsvErr; if (AsyncSCSIPresent()) { clear_memory((Ptr) &pb, sizeof pb); @@ -688,7 +688,7 @@ SCSI_FindDevice(long dRefNum) do { status = SCSIAction((SCSI_PB *) &pb); - + if (status != noErr) { break; } else if (pb.scsiDriver == dRefNum @@ -728,11 +728,11 @@ MEDIA_ITERATOR create_scsi_iterator(void) { SCSI_MEDIA_ITERATOR a; - + if (scsi_inited == 0) { scsi_init(); } - + if (scsi_mgr.exists == 0) { return 0; } @@ -757,7 +757,7 @@ void reset_scsi_iterator(MEDIA_ITERATOR m) { SCSI_MEDIA_ITERATOR a; - + a = (SCSI_MEDIA_ITERATOR) m; if (a == 0) { /* no media */ @@ -774,7 +774,7 @@ step_scsi_iterator(MEDIA_ITERATOR m) { SCSI_MEDIA_ITERATOR a; char *result; - + a = (SCSI_MEDIA_ITERATOR) m; if (a == 0) { /* no media */ @@ -852,13 +852,13 @@ open_mklinux_scsi_as_media(long index, int is_cdrom) MEDIA m; long bus; long id; - + if (lookup_scsi_index(index, is_cdrom, &bus, &id) > 0) { m = open_scsi_as_media(bus, id); } else { m = 0; } - + return m; } @@ -930,7 +930,7 @@ void probe_scsi_device(long bus, long id, int unsure) { UInt32 devType; - + if (DoInquiry(id, bus, &devType)) { if (devType == kScsiDevTypeDirect || devType == kScsiDevTypeWorm || devType == kScsiDevTypeOptical) { @@ -954,7 +954,7 @@ lookup_scsi_device(long bus, long id, int *is_cdrom, int *unsure) struct cache_item *next; long result = -1; int count = 0; - + if (scsi_inited == 0) { scsi_init(); } @@ -991,7 +991,7 @@ lookup_scsi_index(long index, int is_cdrom, long *bus, long *id) struct cache_item *next; long result = 0; int count = 0; - + if (scsi_inited == 0) { scsi_init(); } @@ -1022,7 +1022,7 @@ void add_to_cache(long bus, long id, int is_cdrom, int unsure) { struct cache_item *item; - + item = malloc(sizeof(struct cache_item)); if (item == NULL) { return; @@ -1063,7 +1063,7 @@ clear_mklinux_cache(void) { struct cache_item *item; struct cache_item *next; - + for (item = mklinux_order.first; item != NULL; item = next) { next = item->next; free(item); diff --git a/sbin/pdisk/SCSI_media.h b/sbin/pdisk/SCSI_media.h index 481c0ff289a..e7b17776c3e 100644 --- a/sbin/pdisk/SCSI_media.h +++ b/sbin/pdisk/SCSI_media.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __SCSI_media__ diff --git a/sbin/pdisk/bitfield.c b/sbin/pdisk/bitfield.c index 795cffcae45..fbb23716505 100644 --- a/sbin/pdisk/bitfield.c +++ b/sbin/pdisk/bitfield.c @@ -8,23 +8,23 @@ /* * Copyright 1996, 1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "bitfield.h" diff --git a/sbin/pdisk/bitfield.h b/sbin/pdisk/bitfield.h index 4114ec28f46..57e7f5c810e 100644 --- a/sbin/pdisk/bitfield.h +++ b/sbin/pdisk/bitfield.h @@ -20,23 +20,23 @@ /* * Copyright 1996,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __bitfield__ diff --git a/sbin/pdisk/convert.c b/sbin/pdisk/convert.c index e7f8016bc1a..023cefbffcb 100644 --- a/sbin/pdisk/convert.c +++ b/sbin/pdisk/convert.c @@ -8,23 +8,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifdef __linux__ diff --git a/sbin/pdisk/convert.h b/sbin/pdisk/convert.h index c905c6f5bf9..69da1878c48 100644 --- a/sbin/pdisk/convert.h +++ b/sbin/pdisk/convert.h @@ -10,23 +10,23 @@ /* * Copyright 1996,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __convert__ diff --git a/sbin/pdisk/deblock_media.c b/sbin/pdisk/deblock_media.c index cb752d70554..75531cd25d9 100644 --- a/sbin/pdisk/deblock_media.c +++ b/sbin/pdisk/deblock_media.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -90,7 +90,7 @@ deblock_init(void) return; } deblock_inited = 1; - + deblock_info.kind = allocate_media_kind(); } @@ -107,11 +107,11 @@ open_deblock_media(long new_block_size, MEDIA m) { DEBLOCK_MEDIA a; unsigned long block_size; - + if (deblock_inited == 0) { deblock_init(); } - + a = 0; if (m != 0) { block_size = media_granularity(m); @@ -237,7 +237,7 @@ write_deblock_media(MEDIA m, long long offset, unsigned long count, void *addres long long cur_offset; unsigned long remainder; unsigned char *addr; - + a = (DEBLOCK_MEDIA) m; rtn_value = 0; if (a == 0) { @@ -301,7 +301,7 @@ long close_deblock_media(MEDIA m) { DEBLOCK_MEDIA a; - + a = (DEBLOCK_MEDIA) m; if (a == 0) { return 0; @@ -309,7 +309,7 @@ close_deblock_media(MEDIA m) /* XXX need to error here - this is an internal problem */ return 0; } - + close_media(a->next_media); free(a->buffer); return 1; @@ -320,7 +320,7 @@ long os_reload_deblock_media(MEDIA m) { DEBLOCK_MEDIA a; - + a = (DEBLOCK_MEDIA) m; if (a == 0) { return 0; @@ -328,7 +328,7 @@ os_reload_deblock_media(MEDIA m) /* XXX need to error here - this is an internal problem */ return 0; } - + os_reload_media(a->next_media); return 1; } diff --git a/sbin/pdisk/deblock_media.h b/sbin/pdisk/deblock_media.h index 04c5dfeba33..ffd27b44aac 100644 --- a/sbin/pdisk/deblock_media.h +++ b/sbin/pdisk/deblock_media.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __deblock_media__ diff --git a/sbin/pdisk/dpme.h b/sbin/pdisk/dpme.h index e3d7084dfe5..b50fa87ea7c 100644 --- a/sbin/pdisk/dpme.h +++ b/sbin/pdisk/dpme.h @@ -19,23 +19,23 @@ /* * Copyright 1996 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __dpme__ #define __dpme__ diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c index 7c326c824c0..01d47fcdb2d 100644 --- a/sbin/pdisk/dump.c +++ b/sbin/pdisk/dump.c @@ -6,23 +6,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for *printf() @@ -124,7 +124,7 @@ dump(char *name) dump_partition_map(map, 1); close_partition_map(map); - + return 1; } @@ -154,7 +154,7 @@ dump_block_zero(partition_map_header *map) printf("Drivers-\n"); m = (DDMap *) p->sbMap; for (i = 0; i < p->sbDrvrCount; i++) { - printf("%u: @ %lu for %u, type=0x%x\n", i+1, + printf("%u: @ %lu for %u, type=0x%x\n", i+1, get_align_long(&m[i].ddBlock), m[i].ddSize, m[i].ddType); } @@ -272,7 +272,7 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int } else { printf("@~%-*lu", digits, p->dpme_pblock_start + p->dpme_lblock_start); } - + bytes = ((double)size) * map->logical_block; adjust_value_and_compute_prefix(&bytes, &j); if (j != ' ' && j != 'K') { @@ -346,7 +346,7 @@ list_all_disks() error(errno, "can't allocate memory for try buffer"); return; } - + for (iter = first_media_kind(&mark); iter != 0; iter = next_media_kind(&mark)) { while ((name = step_media_iterator(iter)) != 0) { @@ -415,7 +415,7 @@ show_data_structures(partition_map_header *map) (zp->sbDrvrCount>1)?"s":kStringEmpty); m = (DDMap *) zp->sbMap; for (i = 0; i < zp->sbDrvrCount; i++) { - printf("%u: @ %lu for %u, type=0x%x\n", i+1, + printf("%u: @ %lu for %u, type=0x%x\n", i+1, get_align_long(&m[i].ddBlock), m[i].ddSize, m[i].ddType); } @@ -531,7 +531,7 @@ full_dump_partition_entry(partition_map_header *map, int index) printf("No such partition\n"); return; } - + p = cur->data; printf(" signature: 0x%x\n", p->dpme_signature); printf(" reserved1: 0x%x\n", p->dpme_reserved_1); @@ -564,7 +564,7 @@ full_dump_partition_entry(partition_map_header *map, int index) printf("boot length (in bytes): %10lu\n", p->dpme_boot_bytes); printf(" load address: 0x%08lx 0x%08lx\n", (u32)p->dpme_load_addr, (u32)p->dpme_load_addr_2); - printf(" start address: 0x%08lx 0x%08lx\n", + printf(" start address: 0x%08lx 0x%08lx\n", (u32)p->dpme_goto_addr, (u32)p->dpme_goto_addr_2); printf(" checksum: 0x%08lx\n", p->dpme_checksum); printf(" processor: '%.32s'\n", p->dpme_process_id); @@ -663,7 +663,7 @@ display_patches(partition_map *entry) long long offset; MEDIA m; static unsigned char *patch_block; - + offset = entry->data->dpme_pblock_start; m = entry->the_map->m; offset = ((long long) entry->data->dpme_pblock_start) * entry->the_map->logical_block; diff --git a/sbin/pdisk/dump.h b/sbin/pdisk/dump.h index f6dcd0ab600..3f84bcc0313 100644 --- a/sbin/pdisk/dump.h +++ b/sbin/pdisk/dump.h @@ -6,23 +6,23 @@ /* * Copyright 1996,1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __dump__ diff --git a/sbin/pdisk/errors.c b/sbin/pdisk/errors.c index 4396fc2114d..9c19bee955a 100644 --- a/sbin/pdisk/errors.c +++ b/sbin/pdisk/errors.c @@ -6,23 +6,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for *printf() diff --git a/sbin/pdisk/errors.h b/sbin/pdisk/errors.h index bd2861d3006..c90319bef94 100644 --- a/sbin/pdisk/errors.h +++ b/sbin/pdisk/errors.h @@ -6,23 +6,23 @@ /* * Copyright 1996 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __errors__ diff --git a/sbin/pdisk/file_media.c b/sbin/pdisk/file_media.c index 9e518958f3f..d5dd989b52e 100644 --- a/sbin/pdisk/file_media.c +++ b/sbin/pdisk/file_media.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for printf() @@ -139,7 +139,7 @@ file_init(void) return; } file_inited = 1; - + file_info.kind = allocate_media_kind(); } @@ -160,7 +160,7 @@ compute_block_size(int fd) long t; int i; char *buffer; - + max_size = 0; for (i = 0; ; i++) { size = potential_block_sizes[i]; @@ -171,7 +171,7 @@ compute_block_size(int fd) max_size = size; } } - + buffer = malloc(max_size); if (buffer != 0) { for (i = 0; ; i++) { @@ -206,7 +206,7 @@ open_file_as_media(char *file, int oflag) if (file_inited == 0) { file_init(); } - + a = 0; fd = open(file, oflag); if (fd >= 0) { @@ -328,7 +328,7 @@ long close_file_media(MEDIA m) { FILE_MEDIA a; - + a = (FILE_MEDIA) m; if (a == 0) { return 0; @@ -336,7 +336,7 @@ close_file_media(MEDIA m) /* XXX need to error here - this is an internal problem */ return 0; } - + close(a->fd); return 1; } @@ -408,11 +408,11 @@ MEDIA_ITERATOR create_file_iterator(void) { FILE_MEDIA_ITERATOR a; - + if (file_inited == 0) { file_init(); } - + a = new_file_iterator(); if (a != 0) { a->m.kind = file_info.kind; @@ -432,7 +432,7 @@ void reset_file_iterator(MEDIA_ITERATOR m) { FILE_MEDIA_ITERATOR a; - + a = (FILE_MEDIA_ITERATOR) m; if (a == 0) { /* no media */ @@ -450,7 +450,7 @@ step_file_iterator(MEDIA_ITERATOR m) FILE_MEDIA_ITERATOR a; char *result; struct stat info; - + a = (FILE_MEDIA_ITERATOR) m; if (a == 0) { /* no media */ diff --git a/sbin/pdisk/file_media.h b/sbin/pdisk/file_media.h index 27e477b2504..1360b93e994 100644 --- a/sbin/pdisk/file_media.h +++ b/sbin/pdisk/file_media.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __file_media__ diff --git a/sbin/pdisk/io.c b/sbin/pdisk/io.c index bec60465782..84584e3f710 100644 --- a/sbin/pdisk/io.c +++ b/sbin/pdisk/io.c @@ -6,23 +6,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for *printf() diff --git a/sbin/pdisk/io.h b/sbin/pdisk/io.h index dd5a2525187..197ca7ab884 100644 --- a/sbin/pdisk/io.h +++ b/sbin/pdisk/io.h @@ -6,23 +6,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __io__ diff --git a/sbin/pdisk/layout_dump.c b/sbin/pdisk/layout_dump.c index 5f5140ef56b..c76ab2a398f 100644 --- a/sbin/pdisk/layout_dump.c +++ b/sbin/pdisk/layout_dump.c @@ -6,23 +6,23 @@ /* * Copyright 1996,1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for printf() @@ -72,7 +72,7 @@ dump_using_layout(void *buffer, layout *desc) long value; int max_name; int i; - + max_name = 0; for (entry = desc; entry->format != kEnd; entry++) { value = strlen(entry->name); @@ -80,20 +80,20 @@ dump_using_layout(void *buffer, layout *desc) max_name = value; } } - - + + for (entry = desc; entry->format != kEnd; entry++) { if (entry->format != kBit) { printf("%*s: ", max_name, entry->name); byte_length = entry->bit_length / 8; - + if (entry->bit_offset != 0 || (entry->bit_length % 8) != 0) { printf("entry %d, can't handle bitfields yet.\n", entry - desc); continue; } - + value = 0; for (i = entry->byte_offset; byte_length > 0;i++) { value = value << 8; @@ -104,7 +104,7 @@ dump_using_layout(void *buffer, layout *desc) if (entry->bit_offset < 0 || entry->bit_offset > 8) { printf("entry %d, bad bit offset (%d).\n", entry - desc, entry->bit_offset); continue; - } else if (entry->bit_length <= 0 + } else if (entry->bit_length <= 0 || entry->bit_length > (entry->bit_offset + 1)) { printf("entry %d, bad bit length (%d,%d).\n", entry - desc, entry->bit_offset, entry->bit_length); diff --git a/sbin/pdisk/layout_dump.h b/sbin/pdisk/layout_dump.h index a7c352ff086..67a01472810 100644 --- a/sbin/pdisk/layout_dump.h +++ b/sbin/pdisk/layout_dump.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __layout_dump__ diff --git a/sbin/pdisk/media.c b/sbin/pdisk/media.c index 85fa899ce6c..a9330cb3a4b 100644 --- a/sbin/pdisk/media.c +++ b/sbin/pdisk/media.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -113,7 +113,7 @@ long read_media(MEDIA m, long long offset, unsigned long count, void *address) { long result; - + if (m != 0 && m->do_read != 0) { //printf("media: read type %d, offset %Ld, count %d\n\t", m->kind, offset, count); result = (*m->do_read)(m, offset, count, address); @@ -129,7 +129,7 @@ long write_media(MEDIA m, long long offset, unsigned long count, void *address) { long result; - + if (m != 0 && m->do_write != 0) { //printf("media: write type %d, offset %Ld, count %d\n\t", m->kind, offset, count); result = (*m->do_write)(m, offset, count, address); @@ -200,7 +200,7 @@ char * step_media_iterator(MEDIA_ITERATOR m) { char *result; - + if (m != 0 && m->do_step != 0) { result = (*m->do_step)(m); } else { diff --git a/sbin/pdisk/media.h b/sbin/pdisk/media.h index f631e157a52..1b4209073be 100644 --- a/sbin/pdisk/media.h +++ b/sbin/pdisk/media.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __media__ @@ -35,7 +35,7 @@ * A media object has the following visible attributes: * * a granularity (e.g. 512, 1024, 1, etc.) - * a total size in bytes + * a total size in bytes * * And the following operations are available: * diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c index 48738221b84..f109d899ebc 100644 --- a/sbin/pdisk/partition_map.c +++ b/sbin/pdisk/partition_map.c @@ -6,23 +6,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for *printf() @@ -501,7 +501,7 @@ create_partition_map(char *name, partition_map_header *oldmap) default_number = number; flush_to_newline(0); do { - if (get_number_argument("what should be the size? ", + if (get_number_argument("what should be the size? ", (long *)&number, default_number) == 0) { printf("Not a number\n"); flush_to_newline(1); @@ -613,7 +613,7 @@ add_partition_to_map(const char *name, const char *dptype, u32 base, u32 length, // find a block that starts includes base and length cur = map->base_order; while (cur != NULL) { - if (cur->data->dpme_pblock_start <= base + if (cur->data->dpme_pblock_start <= base && (base + length) <= (cur->data->dpme_pblock_start + cur->data->dpme_pblocks)) { break; @@ -769,7 +769,7 @@ compute_device_size(partition_map_header *map, partition_map_header *oldmap) if (fstat(fd, &info) < 0) { printf("stat of device failed\n"); } else { - printf("stat: mode = 0%o, type=%s\n", info.st_mode, + printf("stat: mode = 0%o, type=%s\n", info.st_mode, (S_ISREG(info.st_mode)? "Regular": (S_ISBLK(info.st_mode)?"Block":"Other"))); printf("size = %d, blocks = %d\n", @@ -809,9 +809,9 @@ compute_device_size(partition_map_header *map, partition_map_header *oldmap) if (size != 0) { return (long)(size / map->logical_block); } - + // else case - + data = (char *) malloc(PBLOCK_SIZE); if (data == NULL) { error(errno, "can't allocate memory for try buffer"); diff --git a/sbin/pdisk/partition_map.h b/sbin/pdisk/partition_map.h index 5390bfe543e..d53032bcfde 100644 --- a/sbin/pdisk/partition_map.h +++ b/sbin/pdisk/partition_map.h @@ -6,23 +6,23 @@ /* * Copyright 1996,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __partition_map__ diff --git a/sbin/pdisk/pathname.c b/sbin/pdisk/pathname.c index aba083a00bc..81198433f36 100644 --- a/sbin/pdisk/pathname.c +++ b/sbin/pdisk/pathname.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -164,7 +164,7 @@ get_mklinux_name(char *path) } } #endif - + return result; } @@ -221,7 +221,7 @@ next_media_kind(long *state) default: break; } - + *state = index; return result; } diff --git a/sbin/pdisk/pathname.h b/sbin/pdisk/pathname.h index 598287ae873..eddf78a8c06 100644 --- a/sbin/pdisk/pathname.h +++ b/sbin/pdisk/pathname.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __pathname__ diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c index e8623e22db3..a8e7800ba9d 100644 --- a/sbin/pdisk/pdisk.c +++ b/sbin/pdisk/pdisk.c @@ -8,23 +8,23 @@ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // for printf() @@ -148,7 +148,7 @@ main(int argc, char **argv) printf("This app uses the SIOUX console library\n"); printf("Choose 'Quit' from the file menu to quit.\n\n"); printf("Use fake disk names (/dev/scsi<bus>.<id>; i.e. /dev/scsi0.1, /dev/scsi1.3, etc.).\n\n"); - + SIOUXSettings.autocloseonquit = 0; /* Do we close the SIOUX window on program termination ... */ SIOUXSettings.asktosaveonclose = 0; /* Do we offer to save on a close ... */ #endif diff --git a/sbin/pdisk/pdisk.h b/sbin/pdisk/pdisk.h index 3f32c9c3841..29a745c0ce4 100644 --- a/sbin/pdisk/pdisk.h +++ b/sbin/pdisk/pdisk.h @@ -6,23 +6,23 @@ /* * Copyright 1996,1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __pdisk__ diff --git a/sbin/pdisk/pdisk.html b/sbin/pdisk/pdisk.html index cb757faa8c7..0ea70428793 100644 --- a/sbin/pdisk/pdisk.html +++ b/sbin/pdisk/pdisk.html @@ -68,16 +68,16 @@ DriveSetup, etc) are:</P> <UL> <LI>unlike the Apple partitioners, it does not restrict the set of drives it can operate on - + <LI>it allows partitions to be reordered (helpful, as MkLinux depends on the order) - + <LI>it creates MkLinux partitions by default - + <LI>it allows the size of the partition map to be changed - + <LI>it allows the name of a partition to be changed - + <LI>it allows you to edit the partition map of your boot disk </UL> @@ -85,9 +85,9 @@ DriveSetup, etc) are:</P> <UL> <LI>it doesn't automatically initialize HFS partitions - + <LI>it can't install disk drivers - + <LI>it allows you to edit the partition map of your boot disk </UL> @@ -140,40 +140,40 @@ when the upper case letter does a variant form of the operation.</P> <DL> <DT><B>h</B> - + <DD>Prints just the command help. The difference between <B>h</B> and <B>?</B> is the latter prints some helpful notes as well. - + <DT><B>v</B> - + <DD>Prints a version number and release date. Matches the version in the GetInfo window for the application. - + <DT><B>l</B> - + <DD>Prompts for the name of the device and then lists the partition map on that device. - + <DT><B>L</B> - + <DD>Lists all the devices. - + <DT><B>e</B> - + <DD>Prompts for the name of the device and then opens the partition map for editing. - + <DT><B>E</B> - + <DD>Same as <B>e</B>, except also prompts for block size. - + <DT><B>r</B> - + <DD>Toggles read-only setting. When read-only is on pdisk will not write a partition map. - + <DT><B>q</B> - + <DD>Quit pdisk. </DL> @@ -184,10 +184,10 @@ like.</P> <PRE>Partition map (with 512 byte blocks) on '/dev/scsi0.2' (/dev/sda) #: type name length base ( size ) - 1: Apple_partition_map Apple 63 @ 1 - 2: Apple_Driver43*Macintosh 54 @ 64 - 3: Apple_Driver43*Macintosh 74 @ 118 - 4: Apple_Patches Patch Partition 512 @ 192 + 1: Apple_partition_map Apple 63 @ 1 + 2: Apple_Driver43*Macintosh 54 @ 64 + 3: Apple_Driver43*Macintosh 74 @ 118 + 4: Apple_Patches Patch Partition 512 @ 192 5: Apple_HFS untitled 2117430 @ 704 ( 1.0G) 6: Apple_Free Extra 10 @ 2118134 @@ -212,18 +212,18 @@ index. For each entry, the following information is displayed:</P> <LI>index - where the partition entry is in the map. This does not correspond the relative order of the partition contents and can change when the partition map is edited. - + <LI>type - the sort of data expected to be in the partition. pdisk doesn't put data into the contents of any partition except the partition map partition. The type is a case-insensitive string. - + <LI>name - the name is for the user's information. - + <LI>length - the number of partition blocks the partition takes. - + <LI>base - the first block of the partition, measured in partition blocks, starting from zero. - + <LI>size - this is the length in bytes. Only shown if the size is at least one megabyte. </UL> @@ -276,96 +276,96 @@ map.</P> <DL> <DT><B>h</B> - + <DD>Prints just the command help. The difference between <B>h</B> and <B>?</B> is the latter prints some helpful notes as well. - + <DT><B>p</B> - + <DD>Prints the partition table. The form is identical to the listing described above. - + <DT><B>P</B> - + <DD>Identical to <B>p</B>, except the entries are listed in the order of the partitions on the disk (i.e. by the increasing base value) rather than in index order. - + <DT><B>i</B> - + <DD>Initializes the partition map (rarely used). This command prompts for the size of the device. WARNING - if you write the map after initializing it you will delete all the drivers on the device. That makes the device invisible to the Mac OS. pdisk is not able to install drivers. - + <DT><B>s</B> - + <DD>Change the size of the partition map partition. The partition map's size must be less than or equal to the size of the partition it is contained in. This is mostly useful when you want to do tricky things like making a disk with multiple partitioning schemes on it. - + <DT><B>c</B> - + <DD>Create a new partition takes three arguments.<BR> - + The first argument is the base address (in partition blocks) of the partition. Besides a raw number, you can also specify a partition number followed by the letter 'p' to indicate that the first block of the new partition should be the same as the first block of that existing free space partition.<BR> - + The second argument is the length of the partition in partition blocks. This can be a raw number or can be a partition number followed by the letter 'p' to use the size of that partition or can be a number followed by 'k', 'm', or 'g' to indicate the size in kilobytes, megabytes, or gigabytes respectively. (These are powers of 1024, of course, not powers of 1000.)<BR> - + The last argument is the name of the partition. This can be a single word without quotes, or a string surrounded by single or double quotes.<BR> - + The type of the created partition is set to the correct type for MkLinux ("Apple_UNIX_SVR2"). - + <DT><B>C</B> - + <DD>Identical to the <B>c</B> command, with the addition of a prompt for the partition type after the other arguments. The type can be a single word without quotes, or a string surrounded by single or double quotes. - + <DT><B>n</B> - + <DD>Rename a partition. Do not change the name of any partition whose type starts with "Apple_Driver". The MacOS looks at the names of those partitions. All other partitions should be okay to change. <DT><B>d</B> - + <DD>Delete a partition. When a partition is deleted it's type is changed to free ("Apple_Free") and then it is combined with any adjacent free space. - + <DT><B>r</B> - + <DD>Reorder takes the current index and the desired new index. If you give a new index which is greater than the last index the entry will be moved to the last index. - + <DT><B>w</B> - + <DD>Write does write the partition map out, but pdisk does not yet flush the appropriate caches and unmount volumes so the partition map is not reinterpreted. In order to use the new partition map you must reboot your machine. Sorry. - + <DT><B>q</B> - + <DD>Quit out of editing. Returns to the top level prompt. If you have modified the partition map you are NOT asked if you want to save the changes, instead the changes are quietly thrown away. @@ -376,12 +376,12 @@ map.</P> <DL> <DD>This is an awful Mac OS application, it should be rewritten to look the way a Mac OS app should look. - + <DD>The code assumes a better understanding of the partitioning scheme than most people care to acquire. - + <DD> - + <DD>Even more help should be available during user input. </DL> diff --git a/sbin/pdisk/pdisk.r b/sbin/pdisk/pdisk.r index 090a678f11a..3ae7ab9a7ee 100644 --- a/sbin/pdisk/pdisk.r +++ b/sbin/pdisk/pdisk.r @@ -4,23 +4,23 @@ /* * Copyright 1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef SystemSevenOrLater diff --git a/sbin/pdisk/util.c b/sbin/pdisk/util.c index 725c4cc7ba5..c555a510789 100644 --- a/sbin/pdisk/util.c +++ b/sbin/pdisk/util.c @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -134,7 +134,7 @@ get_version_string(void) int stage; /* "copy" of stuff from SysTypes.r, since we can't include that*/ enum {development = 0x20, alpha = 0x40, beta = 0x60, final = 0x80, /* or */ release = 0x80}; - + switch (kVersionStage) { case development: stage = 'd'; break; case alpha: stage = 'a'; break; @@ -142,7 +142,7 @@ get_version_string(void) case final: stage = 'f'; break; default: stage = '?'; break; } - + if (kVersionBugFix != 0) { if (kVersionStage == final) { sprintf(dynamic_version, "%d.%d.%d", diff --git a/sbin/pdisk/util.h b/sbin/pdisk/util.h index 77ce624a9c6..0a1ec52afb3 100644 --- a/sbin/pdisk/util.h +++ b/sbin/pdisk/util.h @@ -6,23 +6,23 @@ /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __util__ diff --git a/sbin/pdisk/validate.c b/sbin/pdisk/validate.c index 1c331383665..779d3296899 100644 --- a/sbin/pdisk/validate.c +++ b/sbin/pdisk/validate.c @@ -1,28 +1,28 @@ // -// validate.c - +// validate.c - // // Written by Eryk Vershen (eryk@apple.com) // /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -108,7 +108,7 @@ int get_block_zero(void) { int rtn_value; - + if (the_map != NULL) { b0 = the_map->misc; rtn_value = 1; @@ -130,7 +130,7 @@ get_block_n(int n) { partition_map * entry; int rtn_value; - + if (the_map != NULL) { entry = find_entry_by_disk_address(n, the_map); if (entry != 0) { @@ -156,7 +156,7 @@ range_list * new_range_list_item(enum range_state state, int valid, u32 low, u32 high) { range_list *item; - + item = (range_list *) malloc(sizeof(struct range_list)); item->next = 0; item->prev = 0; @@ -172,7 +172,7 @@ void initialize_list(range_list **list) { range_list *item; - + item = new_range_list_item(kUnallocated, 0, 0, 0xFFFFFFFF); *list = item; } @@ -183,7 +183,7 @@ delete_list(range_list *list) { range_list *item; range_list *cur; - + for (cur = list; cur != 0; ) { item = cur; cur = cur->next; @@ -199,12 +199,12 @@ add_range(range_list **list, u32 base, u32 len, int allocate) range_list *cur; u32 low; u32 high; - + if (list == 0 || *list == 0) { /* XXX initialized list will always have one element */ return; } - + low = base; high = base + len - 1; if (len == 0 || high < len - 1) { @@ -301,7 +301,7 @@ print_range_list(range_list *list) range_list *cur; int printed; char *s; - + if (list == 0) { printf("Empty range list\n"); return; @@ -355,9 +355,9 @@ validate_map(partition_map_header *map) int i; u32 limit; int printed; - + //printf("Validation not implemented yet.\n"); - + if (map == NULL) { the_map = 0; if (get_string_argument("Name of device: ", &name, 1) == 0) { @@ -480,13 +480,13 @@ check_map: post_processing: // properties of whole map - + // every block on disk in one & only one partition coalesce_list(list); print_range_list(list); // there is a partition for the map // map fits within partition that contains it - + // try to detect 512/2048 mixed partition map? done: diff --git a/sbin/pdisk/validate.h b/sbin/pdisk/validate.h index 4ef6e737f7e..550bbc4dfd0 100644 --- a/sbin/pdisk/validate.h +++ b/sbin/pdisk/validate.h @@ -1,28 +1,28 @@ // -// validate.h - +// validate.h - // // Written by Eryk Vershen (eryk@apple.com) // /* * Copyright 1997,1998 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __validate__ diff --git a/sbin/pdisk/version.h b/sbin/pdisk/version.h index 378fb6dabee..21181c6bb53 100644 --- a/sbin/pdisk/version.h +++ b/sbin/pdisk/version.h @@ -6,23 +6,23 @@ /* * Copyright 1997 by Apple Computer, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __version__ #define __version__ @@ -35,7 +35,7 @@ * TO ADJUST THE VERSION - change the following six macros. * * A version is of the form: N.M{.X}{yZ} - * + * * N is two digits indicating the major version * M is a single digit indicating relative revision * X is a single digit indicating a bug fix revision diff --git a/sbin/photurisd/README b/sbin/photurisd/README index 3d421aa4211..b831f5786f7 100644 --- a/sbin/photurisd/README +++ b/sbin/photurisd/README @@ -7,8 +7,8 @@ For quick installation instructions read INSTALL, or otherwise README.howtouse for more complete information. At the moment only the PF_ENCAP kernel interface for John Ioannidis' -and Angelos D. Keromytis' IPsec as to be found in OpenBSD is supported. -It should be fairly easy to adapt the daemon to other implementations, +and Angelos D. Keromytis' IPsec as to be found in OpenBSD is supported. +It should be fairly easy to adapt the daemon to other implementations, just look at the sections found by 'grep IPSEC *.c' I am grateful for the help provided by Angelos D. Keromytis diff --git a/sbin/photurisd/README.howtouse b/sbin/photurisd/README.howtouse index 12a93fa10ba..a1045acf10d 100644 --- a/sbin/photurisd/README.howtouse +++ b/sbin/photurisd/README.howtouse @@ -1,27 +1,27 @@ How to use Photuris with IPsec ? - + What is IPsec ? IP Security is a framework providing authentication/integrity and privacy to network traffic. Authenticated data can not be modified by third parties and encryption conceals the content of packets. - + What has Photuris to do with IPsec ? In order to transmit encrypted or authenticated data between two hosts, those two hosts have to agree on session keys which are used as input for the encryption and authentication functions. - + The Photuris protocol exchanges keys in such a way that no eavesdropper will have knowledge of the session keys. It also allows for frequent changes of the session keys, forward secrecy and party privacy protection. - + How to get it working ? Compiling the daemon - + Get the Photuris sources and also the following libraries: gmp-2.0.2 and libdes-4.01. Put those libraries in one dir and if you like you can do the following steps afterwards: @@ -39,7 +39,7 @@ How to get it working ? If you compiled the photuris daemon with -DDEBUG you should see an exchange of values now and finally the shared secret from which the session keys are derived. - + If you compiled the photuris daemon with -DIPSEC and also have a kernel with IPsec compiled into it, you could start for example @@ -53,15 +53,15 @@ How to get it working ? 11. netstat -rn will show you some information also. - + Enabling IPsec in the OpenBSD kernel - + Add the following two lines into your kernel config file: config IPSEC pseudo-device enc 1 Possible configuration - + There are three files which can be configured locally. * photuris.conf - contains the moduli for the Diffie-Hellmann Keyexchange, the offered schemes and various timeouts. @@ -69,8 +69,8 @@ pseudo-device enc 1 parties * secrets.conf - the preconfigured symmetric secrets which should hopefully soon be replaced by public keys. - + _________________________________________________________________ - + If you have any questions write mail to provos@physnet.uni-hamburg.de diff --git a/sbin/photurisd/api.c b/sbin/photurisd/api.c index b4fbab9adbd..40ac12fa7be 100644 --- a/sbin/photurisd/api.c +++ b/sbin/photurisd/api.c @@ -1,4 +1,4 @@ -/* $OpenBSD: api.c,v 1.6 2001/11/30 20:31:49 provos Exp $ */ +/* $OpenBSD: api.c,v 1.7 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -39,7 +39,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: api.c,v 1.6 2001/11/30 20:31:49 provos Exp $"; +static char rcsid[] = "$OpenBSD: api.c,v 1.7 2002/06/09 08:13:08 todd Exp $"; #endif #define _API_C_ @@ -73,7 +73,7 @@ start_exchange(int sd, struct stateob *st, char *address, int port) st->address[15] = '\0'; st->port = port; st->initiator = 1; - + /* Determine sender address before we invalidate buffer */ sin.sin_addr.s_addr = inet_addr(st->address); @@ -90,7 +90,7 @@ start_exchange(int sd, struct stateob *st, char *address, int port) /* Save the packets for later retransmits */ packet_save(st, packet_buffer, packet_size); - if (sendto(sd, packet_buffer, packet_size, 0, + if (sendto(sd, packet_buffer, packet_size, 0, (struct sockaddr *) &sin, sizeof(sin)) != packet_size) { /* XXX Code to notify kernel of failure */ log_error("sendto() in start_exchange() for %s:%d", @@ -99,6 +99,6 @@ start_exchange(int sd, struct stateob *st, char *address, int port) } schedule_insert(TIMEOUT, retrans_timeout, st->icookie, COOKIE_SIZE); - + return 0; } diff --git a/sbin/photurisd/attributes.c b/sbin/photurisd/attributes.c index 1bff2b41b7e..1a59b9ab4a1 100644 --- a/sbin/photurisd/attributes.c +++ b/sbin/photurisd/attributes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: attributes.c,v 1.3 2001/01/28 22:45:06 niklas Exp $ */ +/* $OpenBSD: attributes.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: attributes.c,v 1.3 2001/01/28 22:45:06 niklas Exp $"; +static char rcsid[] = "$OpenBSD: attributes.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #define _ATTRIBUTES_C_ @@ -63,7 +63,7 @@ putattrib(attrib_t *attrib) } attrib_t * -getattrib(u_int8_t id) +getattrib(u_int8_t id) { u_int8_t hashval = id % ATTRIBHASHMOD; attrib_t *attrib; @@ -94,7 +94,7 @@ isinattrib(u_int8_t *attributes, u_int16_t attribsize, u_int8_t attribute) while(attribsize>0) { if(*attributes==attribute) return 1; - if(attribsize - (*(attributes+1)+2) > attribsize) + if(attribsize - (*(attributes+1)+2) > attribsize) return 0; attribsize -= *(attributes+1)+2; @@ -104,7 +104,7 @@ isinattrib(u_int8_t *attributes, u_int16_t attribsize, u_int8_t attribute) } void -get_attrib_section(u_int8_t *set, u_int16_t setsize, +get_attrib_section(u_int8_t *set, u_int16_t setsize, u_int8_t **subset, u_int16_t *subsetsize, u_int8_t section) { @@ -138,8 +138,8 @@ get_attrib_section(u_int8_t *set, u_int16_t setsize, } -int -isattribsubset(u_int8_t *set, u_int16_t setsize, +int +isattribsubset(u_int8_t *set, u_int16_t setsize, u_int8_t *subset, u_int16_t subsetsize) { while(subsetsize>0) { @@ -164,7 +164,7 @@ attrib_insert(attribute_list *ob) attribob = ob; return 1; } - + tmp=attribob; while(tmp->next!=NULL) tmp = tmp->next; @@ -206,7 +206,7 @@ attrib_new(void) int attrib_value_reset(attribute_list *ob) -{ +{ if (ob->address != NULL) free(ob->address); if (ob->attributes != NULL) @@ -216,7 +216,7 @@ attrib_value_reset(attribute_list *ob) return 1; } -/* +/* * find the attributes to the address or 0 address. * if passed a null pointer as first argument we return our default * list. diff --git a/sbin/photurisd/attributes.h b/sbin/photurisd/attributes.h index 6efc5180d10..51d82821262 100644 --- a/sbin/photurisd/attributes.h +++ b/sbin/photurisd/attributes.h @@ -1,4 +1,4 @@ -/* $OpenBSD: attributes.h,v 1.3 2001/01/28 22:45:06 niklas Exp $ */ +/* $OpenBSD: attributes.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -56,7 +56,7 @@ /* XXX - Only for the moment */ #define DH_G_2_MD5 2 #define DH_G_3_MD5 3 -#define DH_G_2_DES_MD5 4 +#define DH_G_2_DES_MD5 4 #define DH_G_5_MD5 5 #define DH_G_3_DES_MD5 6 #define DH_G_VAR_MD5 7 @@ -91,9 +91,9 @@ EXTERN void clearattrib(void); EXTERN void get_attrib_section(u_int8_t *, u_int16_t, u_int8_t **, u_int16_t *, u_int8_t); -EXTERN int isinattrib(u_int8_t *attributes, u_int16_t attribsize, +EXTERN int isinattrib(u_int8_t *attributes, u_int16_t attribsize, u_int8_t attribute); -EXTERN int isattribsubset(u_int8_t *set, u_int16_t setsize, +EXTERN int isattribsubset(u_int8_t *set, u_int16_t setsize, u_int8_t *subset, u_int16_t subsetsize); EXTERN attribute_list *attrib_new(void); EXTERN int attrib_insert(attribute_list *); diff --git a/sbin/photurisd/buffer.h b/sbin/photurisd/buffer.h index 5cf6f5491e5..c780ca85022 100644 --- a/sbin/photurisd/buffer.h +++ b/sbin/photurisd/buffer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.h,v 1.3 2001/01/28 22:45:06 niklas Exp $ */ +/* $OpenBSD: buffer.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,10 +29,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * buffer.h: + * buffer.h: * variables with buffers. */ - + #ifndef _BUFFER_H_ #define _BUFFER_H_ diff --git a/sbin/photurisd/compute_secrets.c b/sbin/photurisd/compute_secrets.c index 9e110d71ad4..ec18bbd7bd2 100644 --- a/sbin/photurisd/compute_secrets.c +++ b/sbin/photurisd/compute_secrets.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compute_secrets.c,v 1.5 2001/01/28 22:45:07 niklas Exp $ */ +/* $OpenBSD: compute_secrets.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,9 +35,9 @@ * cryptographic hashes for session keys */ -#ifndef lint -static char rcsid[] = "$OpenBSD: compute_secrets.c,v 1.5 2001/01/28 22:45:07 niklas Exp $"; -#endif +#ifndef lint +static char rcsid[] = "$OpenBSD: compute_secrets.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; +#endif #define _SECRETS_C_ @@ -45,9 +45,9 @@ static char rcsid[] = "$OpenBSD: compute_secrets.c,v 1.5 2001/01/28 22:45:07 nik #include <string.h> #include <stdlib.h> #include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <ssl/bn.h> #include <md5.h> #include "state.h" @@ -63,11 +63,11 @@ static char rcsid[] = "$OpenBSD: compute_secrets.c,v 1.5 2001/01/28 22:45:07 nik #include "scheme.h" #include "log.h" -int privacykey(struct stateob *st, struct idxform *hash, u_int8_t *key, +int privacykey(struct stateob *st, struct idxform *hash, u_int8_t *key, u_int8_t *packet, u_int16_t bytes, u_int16_t *order, int owner); int -compute_shared_secret(struct stateob *st, +compute_shared_secret(struct stateob *st, u_int8_t **shared, size_t *sharedsize) { struct moduli_cache *mod; @@ -155,36 +155,36 @@ make_session_keys(struct stateob *st, struct spiob *spi) count = 0; p = *secret; for (i = 0; i<attribsize; i += attributes[i+1] + 2) { - if (attributes[i] != AT_AH_ATTRIB && + if (attributes[i] != AT_AH_ATTRIB && attributes[i] != AT_ESP_ATTRIB) { - bits = compute_session_key(st, p, attributes+i, - spi->flags & SPI_OWNER, + bits = compute_session_key(st, p, attributes+i, + spi->flags & SPI_OWNER, &count); if (bits == -1) return -1; if (bits > 0) { #ifdef DEBUG - { + { int d = BUFFER_SIZE; - printf("%s session key for AT %d: ", - spi->flags & SPI_OWNER ? + printf("%s session key for AT %d: ", + spi->flags & SPI_OWNER ? "Owner" : "User", (int)attributes[i]); - bin2hex(buffer, &d, p, + bin2hex(buffer, &d, p, bits & 7 ? (bits >> 3) + 1 : bits >> 3); printf("0x%s\n", buffer); } #endif /* DEBUG */ - + p += bits & 7 ? (bits >> 3) + 1 : bits >> 3; } } } - + return 0; } /* - * Return length of requried session key in bits. + * Return length of requried session key in bits. * DES would be 64 bits. */ @@ -194,7 +194,7 @@ get_session_key_length(u_int8_t *attribute) attrib_t *ob; if ((ob = getattrib(*attribute)) == NULL) { - log_print("Unknown attribute %d in get_session_key_length()", + log_print("Unknown attribute %d in get_session_key_length()", *attribute); return -1; } @@ -209,7 +209,7 @@ get_session_key_length(u_int8_t *attribute) */ int -compute_session_key(struct stateob *st, u_int8_t *key, +compute_session_key(struct stateob *st, u_int8_t *key, u_int8_t *attribute, int owner, u_int16_t *order) { @@ -219,28 +219,28 @@ compute_session_key(struct stateob *st, u_int8_t *key, int bits; switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_2_DES_MD5: - case DH_G_5_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: - case DH_G_VAR_MD5: - case DH_G_VAR_DES_MD5: + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_2_DES_MD5: + case DH_G_5_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: + case DH_G_VAR_MD5: + case DH_G_VAR_DES_MD5: hash = get_hash(HASH_MD5); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: case DH_G_5_3DES_SHA1: - case DH_G_VAR_3DES_SHA1: + case DH_G_VAR_3DES_SHA1: hash = get_hash(HASH_SHA1); break; default: log_print("Unkown scheme %d in compute_session_key()", ntohs(*((u_int16_t *)st->scheme))); return -1; - } - + } + if ((bits = get_session_key_length(attribute)) == -1) return -1; @@ -261,8 +261,8 @@ compute_session_key(struct stateob *st, u_int8_t *key, hash->Update(hash->ctx,st->oSPIsecret,st->oSPIsecretsize); hash->Update(hash->ctx,st->uSPIsecret,st->uSPIsecretsize); } else { /* Session key for User SPI */ - hash->Update(hash->ctx,st->uSPIsecret,st->uSPIsecretsize); - hash->Update(hash->ctx,st->oSPIsecret,st->oSPIsecretsize); + hash->Update(hash->ctx,st->uSPIsecret,st->uSPIsecretsize); + hash->Update(hash->ctx,st->oSPIsecret,st->oSPIsecretsize); } /* Message Verification field */ @@ -285,8 +285,8 @@ compute_session_key(struct stateob *st, u_int8_t *key, /* Unsigned integer arithmetic */ size -= size>hash->hashsize ? hash->hashsize : size; - } while(size > 0); - + } while(size > 0); + *order = n; return bits; @@ -318,24 +318,24 @@ init_privacy_key(struct stateob *st, int owner) secondsize = st->exchangesize; } - switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: - case DH_G_2_DES_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: + switch(ntohs(*((u_int16_t *)st->scheme))) { + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: + case DH_G_2_DES_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: hash = get_hash(HASH_MD5); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: hash = get_hash(HASH_SHA1); break; - default: + default: log_print("Unknown exchange scheme in init_privacy_key()"); - return -1; - } + return -1; + } if (hash == NULL) return -1; @@ -364,28 +364,28 @@ compute_privacy_key(struct stateob *st, u_int8_t *key, u_int8_t *packet, u_int16_t size; struct idxform *hash; - size = bits >> 3; - if(bits & 0x7) - size++; - - switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: - case DH_G_2_DES_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: + size = bits >> 3; + if(bits & 0x7) + size++; + + switch(ntohs(*((u_int16_t *)st->scheme))) { + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: + case DH_G_2_DES_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: hash = get_hash(HASH_MD5); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: hash = get_hash(HASH_SHA1); break; - default: + default: log_print("Unknown exchange scheme in compute_privacy_key()"); - return -1; - } + return -1; + } if (hash == NULL) return -1; @@ -395,39 +395,39 @@ compute_privacy_key(struct stateob *st, u_int8_t *key, u_int8_t *packet, int -privacykey(struct stateob *st, struct idxform *hash, - u_int8_t *key, u_int8_t *packet, - u_int16_t bytes, u_int16_t *order, int owner) +privacykey(struct stateob *st, struct idxform *hash, + u_int8_t *key, u_int8_t *packet, + u_int16_t bytes, u_int16_t *order, int owner) { u_int16_t i, n; u_int8_t digest[HASH_MAX]; - + /* SPIprivacyctx contains the hashed exchangevalues */ - bcopy(owner ? st->oSPIprivacyctx : st->uSPIprivacyctx, + bcopy(owner ? st->oSPIprivacyctx : st->uSPIprivacyctx, hash->ctx2, hash->ctxsize); - - hash->Update(hash->ctx2, packet, 2*COOKIE_SIZE + 4 + SPI_SIZE); - - /* As many shared secrets we used already */ + + hash->Update(hash->ctx2, packet, 2*COOKIE_SIZE + 4 + SPI_SIZE); + + /* As many shared secrets we used already */ n = *order; - for(i=0; i<n; i++) - hash->Update(hash->ctx2, st->shared, st->sharedsize); + for(i=0; i<n; i++) + hash->Update(hash->ctx2, st->shared, st->sharedsize); do { bcopy(hash->ctx2, hash->ctx, hash->ctxsize); hash->Update(hash->ctx, st->shared, st->sharedsize); bcopy(hash->ctx, hash->ctx2, hash->ctxsize); - + hash->Final(digest, hash->ctx); - bcopy(digest, key, bytes>hash->hashsize ? hash->hashsize : bytes); + bcopy(digest, key, bytes>hash->hashsize ? hash->hashsize : bytes); key += bytes>hash->hashsize ? hash->hashsize : bytes; - - /* Unsigned integer arithmetic */ - bytes -= bytes>hash->hashsize ? hash->hashsize : bytes; - + + /* Unsigned integer arithmetic */ + bytes -= bytes>hash->hashsize ? hash->hashsize : bytes; + /* Increment the times we called Final */ i++; - } while(bytes > 0); + } while(bytes > 0); *order = i; return 0; diff --git a/sbin/photurisd/config.c b/sbin/photurisd/config.c index b2bf7a950a1..f0fc08aa7e9 100644 --- a/sbin/photurisd/config.c +++ b/sbin/photurisd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.8 2001/11/17 19:54:57 deraadt Exp $ */ +/* $OpenBSD: config.c,v 1.9 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: config.c,v 1.8 2001/11/17 19:54:57 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: config.c,v 1.9 2002/06/09 08:13:08 todd Exp $"; #endif #define _CONFIG_C_ @@ -78,7 +78,7 @@ static char rcsid[] = "$OpenBSD: config.c,v 1.8 2001/11/17 19:54:57 deraadt Exp static FILE *config_fp; static struct cfgx *cfgxroot; -static void +static void open_config_file(char *file) { char *p; @@ -88,12 +88,12 @@ open_config_file(char *file) else p = config_file; - if (p == NULL) - log_fatal("no file in open_config_file()"); - - config_fp = fopen(p, "r"); - if (config_fp == (FILE *) NULL) - log_fatal("can't open file %s in open_config_file()", p); + if (p == NULL) + log_fatal("no file in open_config_file()"); + + config_fp = fopen(p, "r"); + if (config_fp == (FILE *) NULL) + log_fatal("can't open file %s in open_config_file()", p); } static void @@ -107,18 +107,18 @@ config_get(char *token) { char *p; while(fgets(buffer, BUFFER_SIZE, config_fp)) { - p = buffer; + p = buffer; chomp(p); - while(isspace(*p)) - p++; + while(isspace(*p)) + p++; while(isspace(p[strlen(p)-1])) p[strlen(p)-1] = '\0'; - if (*p == '#') - continue; - - if (!strncmp(p, token, strlen(token))) - return p; + if (*p == '#') + continue; + + if (!strncmp(p, token, strlen(token))) + return p; } @@ -146,7 +146,7 @@ struct cfgx * cfgx_get(char *name) { struct cfgx *ob; - + for(ob = cfgxroot; ob; ob = ob->next) if (ob->name && !strcmp(name, ob->name)) break; @@ -170,7 +170,7 @@ cfgx_clear(void) */ int -parse_type(char *line) +parse_type(char *line) { int type = 0; @@ -220,7 +220,7 @@ init_attributes(void) if (p == NULL) continue; - if (p2 == NULL || inet_addr(p) == -1 || + if (p2 == NULL || inet_addr(p) == -1 || inet_network(p2) == -1) { /* Attributes follow now */ cfgattrib = cfgx_get(p); @@ -256,7 +256,7 @@ init_attributes(void) continue; } - while (isspace(*p3)) + while (isspace(*p3)) p3++; i = strlen(p3) - 1; while (isspace(p3[i]) && i > 0) @@ -274,7 +274,7 @@ init_attributes(void) continue; } #endif - + if ((ob = calloc(1, sizeof(attrib_t))) == NULL) log_fatal("calloc() in init_attributes()"); @@ -288,21 +288,21 @@ init_attributes(void) } if (cfgattrib == NULL) { - log_print("Unknown attribute %s in init_attributes()", + log_print("Unknown attribute %s in init_attributes()", p); continue; } - if (ob == NULL && (ob = attrib_new()) == NULL) + if (ob == NULL && (ob = attrib_new()) == NULL) log_fatal("attribute_new() in init_attributes()"); - else + else def_flag = 1; attrib[0] = cfgattrib->id; attrib[1] = 0; - + /* Copy attributes in object */ - newbuf = realloc(ob->attributes, + newbuf = realloc(ob->attributes, ob->attribsize + attrib[1] +2); if (newbuf == NULL) { if (ob->attributes != NULL) @@ -310,7 +310,7 @@ init_attributes(void) log_fatal("realloc() in init_attributes()"); } ob->attributes = newbuf; - + bcopy(attrib, ob->attributes + ob->attribsize, attrib[1] + 2); ob->attribsize += attrib[1] + 2; @@ -332,7 +332,7 @@ init_attributes(void) ob->netmask = inet_addr(p2); in.s_addr = inet_addr(p) & ob->netmask; - if ((ob->address = calloc(strlen(inet_ntoa(in))+1, + if ((ob->address = calloc(strlen(inet_ntoa(in))+1, sizeof(char))) == NULL) log_fatal("calloc() in init_attributes()"); strcpy(ob->address, inet_ntoa(in)); @@ -381,13 +381,13 @@ init_schemes(void) p = p2 + 11; BN_set_word(generator, 2); *(u_int16_t *)buffer = htons(DH_G_2_MD5); - } else if (!strncmp(p2, "DH_G_2_DES_MD5", 14)) { + } else if (!strncmp(p2, "DH_G_2_DES_MD5", 14)) { p = p2 + 15; - BN_set_word(generator, 2); + BN_set_word(generator, 2); *(u_int16_t *)buffer = htons(DH_G_2_DES_MD5); - } else if (!strncmp(p2, "DH_G_2_3DES_SHA1", 16)) { + } else if (!strncmp(p2, "DH_G_2_3DES_SHA1", 16)) { p = p2 + 17; - BN_set_word(generator, 2); + BN_set_word(generator, 2); *(u_int16_t *)buffer = htons(DH_G_2_3DES_SHA1); } else { log_print("Unknown scheme %s in init_schemes()", p2); @@ -395,12 +395,12 @@ init_schemes(void) } /* Base schemes need a modulus */ - if ((scheme_bits = strtol(p, NULL, 10)) == 0 && + if ((scheme_bits = strtol(p, NULL, 10)) == 0 && ntohs(*(u_int16_t *)buffer) == scheme_get_ref(buffer) ) { log_print("No bits in scheme %s in init_schemes()", p2); continue; } - + if (scheme_bits != 0) { if ((tmp = mod_find_generator(generator)) == NULL) continue; @@ -423,7 +423,7 @@ init_schemes(void) size = 2; buffer[2] = buffer[3] = 0; } - + newbuf = realloc(global_schemes, global_schemesize + size + 2); if (newbuf == NULL) { if (global_schemes != NULL) @@ -446,14 +446,14 @@ init_schemes(void) if (!gen_flag) { log_print("DH_G_2_MD5 not in config file, inserting it"); - BN_set_word(generator, 2); - if ((tmp = mod_find_generator(generator)) == NULL) + BN_set_word(generator, 2); + if ((tmp = mod_find_generator(generator)) == NULL) log_fatal("no modulus for generator 2 in init_schemes()"); - size = BUFFER_SIZE - 2; - if (BN_bn2varpre(tmp->modulus, buffer+2, &size) == -1) + size = BUFFER_SIZE - 2; + if (BN_bn2varpre(tmp->modulus, buffer+2, &size) == -1) log_fatal("BN_bn2varpre() in init_schemes()"); - + *(u_int16_t *)buffer = htons(DH_G_2_MD5); } @@ -472,7 +472,7 @@ init_moduli(int primes) mod_init(); open_config_file(NULL); - + #ifdef DEBUG printf("[Bootstrapping moduli]\n"); #endif @@ -495,7 +495,7 @@ init_moduli(int primes) p += 2; if (!BN_hex2bn(&a, p)) continue; - + /* Get modulus */ a = m; if (!strncmp(p2, "0x", 2)) @@ -513,7 +513,7 @@ init_moduli(int primes) tmp->status = MOD_PRIME; } } - + close_config_file(); BN_free(m); @@ -532,7 +532,7 @@ init_times(void) char *p, *p2; int i, *value; open_config_file(NULL); - + #ifdef DEBUG printf("[Setting up times]\n"); #endif @@ -602,7 +602,7 @@ startup_parse(struct stateob *st, char *p2) log_error("invalid destination address: %s", p3); continue; } - if (hp == NULL) + if (hp == NULL) strncpy(st->address, p3, 15); else { struct sockaddr_in sin; @@ -668,7 +668,7 @@ startup_end(struct stateob *st) st->flags = IPSEC_OPT_ENC | IPSEC_OPT_AUTH; #ifdef DEBUG - printf("Starting exchange with: %s:%d and options:", + printf("Starting exchange with: %s:%d and options:", st->address, st->port); if (st->flags & IPSEC_OPT_ENC) printf("%s ", OPT_ENC); @@ -678,12 +678,12 @@ startup_end(struct stateob *st) printf("for user %s", st->user); printf("\n"); #endif - if (start_exchange(global_socket, st, + if (start_exchange(global_socket, st, st->address, st->port) == -1) { log_print("start_exchange in startup_end()"); state_value_reset(st); free(st); - } else + } else state_insert(st); } @@ -736,7 +736,7 @@ reconfig(int sig) identity_cleanup(NULL); mod_cleanup(); - + free(global_schemes); global_schemes = NULL; global_schemesize = 0; @@ -772,8 +772,8 @@ init_signals(void) } #endif -int -pick_scheme(u_int8_t **scheme, u_int16_t *schemesize, +int +pick_scheme(u_int8_t **scheme, u_int16_t *schemesize, u_int8_t *offered, u_int16_t offeredsize) { u_int32_t size = 0; @@ -791,7 +791,7 @@ pick_scheme(u_int8_t **scheme, u_int16_t *schemesize, p = scheme_get_mod(offered + osize); actsize = varpre2octets(p); - if (schemep == NULL && + if (schemep == NULL && !bcmp(offered+osize, global_schemes + size, 2)) { /* We found a scheme we want use, now we need to get the * modulus for it. @@ -828,7 +828,7 @@ pick_scheme(u_int8_t **scheme, u_int16_t *schemesize, modsize = actsize; } } - + osize += scheme_get_len(offered + osize); } } else { @@ -868,17 +868,17 @@ pick_scheme(u_int8_t **scheme, u_int16_t *schemesize, return 0; } -/* +/* * Fills attrib, with attributes we offer to other parties, * read the necessary values from some config file */ -int +int pick_attrib(struct stateob *st, u_int8_t **attrib, u_int16_t *attribsize) { attribute_list *ob; int mode = 0, i, n, count, first; - + if ((ob = attrib_find(st->address)) == NULL) { log_print("attrib_find() in pick_attrib()"); return -1; @@ -901,7 +901,7 @@ pick_attrib(struct stateob *st, u_int8_t **attrib, u_int16_t *attribsize) count += 2; first = 0; } - bcopy(ob->attributes+i, buffer+count, + bcopy(ob->attributes+i, buffer+count, ob->attributes[i+1]+2); count += ob->attributes[i+1]+2; } @@ -914,8 +914,8 @@ pick_attrib(struct stateob *st, u_int8_t **attrib, u_int16_t *attribsize) } if ((*attrib = calloc(count, sizeof(u_int8_t))) == NULL) { - log_error("calloc() in in pick_attrib()"); - return -1; + log_error("calloc() in in pick_attrib()"); + return -1; } bcopy(buffer, *attrib, count); *attribsize = count; @@ -934,28 +934,28 @@ select_attrib(struct stateob *st, u_int8_t **attributes, u_int16_t *attribsize) u_int16_t count = 0; u_int8_t *wantesp, *wantah, *offeresp, *offerah, *p; u_int16_t wantespsize, wantahsize, offerespsize, offerahsize; - attribute_list *ob; + attribute_list *ob; attrib_t *attprop; - - if ((ob = attrib_find(NULL)) == NULL) { + + if ((ob = attrib_find(NULL)) == NULL) { log_print("attrib_find() for default in select_attrib() in " - "exchange to %s", st->address); - return -1; - } - + "exchange to %s", st->address); + return -1; + } + /* Take from Owner */ - get_attrib_section(ob->attributes, ob->attribsize, + get_attrib_section(ob->attributes, ob->attribsize, &wantesp, &wantespsize, AT_ESP_ATTRIB); - get_attrib_section(ob->attributes, ob->attribsize, + get_attrib_section(ob->attributes, ob->attribsize, &wantah, &wantahsize, AT_AH_ATTRIB); - + /* Take from User */ get_attrib_section(st->uSPIoattrib, st->uSPIoattribsize, &offeresp, &offerespsize, AT_ESP_ATTRIB); get_attrib_section(st->uSPIoattrib, st->uSPIoattribsize, &offerah, &offerahsize, AT_AH_ATTRIB); - + p = buffer; if (wantesp != NULL && offeresp != NULL && (st->flags & IPSEC_OPT_ENC)) { /* Take the ESP section */ @@ -964,8 +964,8 @@ select_attrib(struct stateob *st, u_int8_t **attributes, u_int16_t *attribsize) u_int8_t flag[20], flagc, hmac = 0; int res; attrib_t *attah = NULL; - - /* + + /* * We travers the ESP section and look for flags, * perhaps mutually exclusive flags should be handled * but at the moment we only support the HMAC indicator @@ -1015,23 +1015,23 @@ select_attrib(struct stateob *st, u_int8_t **attributes, u_int16_t *attribsize) res = 0; #endif if (res == AT_ENC) { - /* - * Our ESP attribute does not allow AH, but - * since the ESP attribute is our first choice, + /* + * Our ESP attribute does not allow AH, but + * since the ESP attribute is our first choice, * dont try for other. */ attah = NULL; break; - } else if (res != AT_AUTH) + } else if (res != AT_AUTH) break; } } - + tasize += ta[tasize+1]+2; } if (tasize >= wantespsize) attah = NULL; - + if (attprop != NULL) { /* Put proper header in there */ p[0] = AT_ESP_ATTRIB; @@ -1151,9 +1151,9 @@ chomp(char *p) return p; } -static const char hextab[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' +static const char hextab[] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; int @@ -1163,7 +1163,7 @@ bin2hex(char *buffer, int *size, u_int8_t *data, u_int16_t len) if (*size < 2*len+1) return -1; - + off = 0; while(len > 0) { buffer[off++] = hextab[*data >> 4]; diff --git a/sbin/photurisd/config.h b/sbin/photurisd/config.h index 88e957998b4..1685879a90b 100644 --- a/sbin/photurisd/config.h +++ b/sbin/photurisd/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.5 2001/07/07 18:26:17 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,7 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * config.h: + * config.h: * handling config */ diff --git a/sbin/photurisd/cookie.c b/sbin/photurisd/cookie.c index 20672dfafed..052c3a83051 100644 --- a/sbin/photurisd/cookie.c +++ b/sbin/photurisd/cookie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cookie.c,v 1.3 2001/01/28 22:45:07 niklas Exp $ */ +/* $OpenBSD: cookie.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: cookie.c,v 1.3 2001/01/28 22:45:07 niklas Exp $"; +static char rcsid[] = "$OpenBSD: cookie.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #define _COOKIE_C_ @@ -63,13 +63,13 @@ secret_generate(u_int8_t *secret, u_int16_t size) size--; if (i++ % 4 == 0) tmp = arc4random(); - + secret[size] = tmp & 0xFF; tmp = tmp >> 8; } return 1; } - + int cookie_generate(struct stateob *st, u_int8_t *cookie, u_int16_t size, u_int8_t *data, u_int16_t dsize) @@ -84,7 +84,7 @@ cookie_generate(struct stateob *st, u_int8_t *cookie, u_int16_t size, } else secret = rsecret; - /* Generate a cookie which depends on both parties and on local + /* Generate a cookie which depends on both parties and on local * information, which is fast computed. */ MD5Init(&ctx); diff --git a/sbin/photurisd/cookie.h b/sbin/photurisd/cookie.h index 3846a605e20..e41828c0791 100644 --- a/sbin/photurisd/cookie.h +++ b/sbin/photurisd/cookie.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cookie.h,v 1.3 2001/01/28 22:45:07 niklas Exp $ */ +/* $OpenBSD: cookie.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -28,29 +28,29 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * cookie.h: +/* + * cookie.h: * cookie generation header file - */ + */ #ifndef _COOKIE_H_ #define _COOKIE_H_ #include "state.h" - + #define SECRET_SIZE 16 #undef EXTERN #ifdef _COOKIE_C_ #define EXTERN -static u_int8_t rsecret[SECRET_SIZE]; /* Responder secret */ +static u_int8_t rsecret[SECRET_SIZE]; /* Responder secret */ #else #define EXTERN extern #endif EXTERN void reset_secret(void); EXTERN int secret_generate(u_int8_t *secret, u_int16_t size); -EXTERN int cookie_generate(struct stateob *st, +EXTERN int cookie_generate(struct stateob *st, u_int8_t *cookie, u_int16_t size, u_int8_t *data, u_int16_t dsize); #endif diff --git a/sbin/photurisd/encrypt.h b/sbin/photurisd/encrypt.h index b2d0a25d022..f40411ceb5c 100644 --- a/sbin/photurisd/encrypt.h +++ b/sbin/photurisd/encrypt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: encrypt.h,v 1.3 2001/01/28 22:45:07 niklas Exp $ */ +/* $OpenBSD: encrypt.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -33,24 +33,24 @@ * prototypes for photuris_packet_encrypt.c */ -#ifndef _ENCRYPT_H_ -#define _ENCRYPT_H_ - -#include "state.h" - -#undef EXTERN - -#ifdef _ENCRYPT_C_ -#define EXTERN -#else -#define EXTERN extern +#ifndef _ENCRYPT_H_ +#define _ENCRYPT_H_ + +#include "state.h" + +#undef EXTERN + +#ifdef _ENCRYPT_C_ +#define EXTERN +#else +#define EXTERN extern #endif -EXTERN int packet_create_padding(struct stateob *st, u_int16_t size, +EXTERN int packet_create_padding(struct stateob *st, u_int16_t size, u_int8_t *padd, u_int16_t *rsize); -EXTERN int packet_encrypt(struct stateob *st, +EXTERN int packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen); -EXTERN int packet_decrypt(struct stateob *st, +EXTERN int packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen); #endif /* _ENCRYPT_H_ */ diff --git a/sbin/photurisd/exchange.c b/sbin/photurisd/exchange.c index 5a80d8f1d04..40fdd5f013f 100644 --- a/sbin/photurisd/exchange.c +++ b/sbin/photurisd/exchange.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exchange.c,v 1.5 2001/01/28 22:45:07 niklas Exp $ */ +/* $OpenBSD: exchange.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: exchange.c,v 1.5 2001/01/28 22:45:07 niklas Exp $"; +static char rcsid[] = "$OpenBSD: exchange.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; #endif #define _EXCHANGE_C_ @@ -44,9 +44,9 @@ static char rcsid[] = "$OpenBSD: exchange.c,v 1.5 2001/01/28 22:45:07 niklas Exp #include <stdlib.h> #include <time.h> #include <string.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <ssl/bn.h> #include "config.h" @@ -64,26 +64,26 @@ static char rcsid[] = "$OpenBSD: exchange.c,v 1.5 2001/01/28 22:45:07 niklas Exp * Get the number of bits from a variable precision number * according to draft-simpson-photuris-11 */ - + u_int8_t * varpre_get_number_bits(size_t *nbits, u_int8_t *varpre) -{ +{ int blocks; size_t bits; if (varpre == NULL) return (NULL); - + /* We don't support numbers, that long */ if (*varpre == 255 && *(varpre+1) == 255) return (NULL); bits = 0; - if (*varpre == 255) { + if (*varpre == 255) { blocks = 3; bits = 65280; - varpre++; - } else + varpre++; + } else blocks = 2; while (blocks-- > 0) { @@ -123,7 +123,7 @@ BN_varpre2bn(u_int8_t *varpre, size_t size, BIGNUM *a) bytes--; p++; } - + return (p); } @@ -163,7 +163,7 @@ BN_bn2varpre(BIGNUM *p, u_int8_t *value, size_t *size) while (bytes > 0) { bytes--; value[bytes + header] = BN_mod_word(a, 256); - BN_rshift(a, a, 8); + BN_rshift(a, a, 8); } BN_clear_free(a); @@ -176,7 +176,7 @@ exchange_check_value(BIGNUM *exchange, BIGNUM *gen, BIGNUM *mod) { size_t bits; BIGNUM *test; - + bits = BN_num_bits(mod); if (BN_num_bits(exchange) < bits/2) return (0); @@ -195,7 +195,7 @@ exchange_check_value(BIGNUM *exchange, BIGNUM *gen, BIGNUM *mod) return (1); } -/* +/* * Finds to a given modulus and generator cached information * which is used to create the private value and exchange value */ @@ -237,19 +237,19 @@ exchange_make_values(struct stateob *st, BIGNUM *modulus, BIGNUM *generator) log_error("calloc() in exchange_make_values()"); return (-1); } - bcopy(tmp->exchangevalue, p->exchangevalue, + bcopy(tmp->exchangevalue, p->exchangevalue, tmp->exchangesize); p->exchangesize = tmp->exchangesize; } else p->exchangevalue = NULL; - + p->iterations = tmp->iterations; p->status = tmp->status; p->lifetime = tmp->lifetime; } else { size_t bits; - /* + /* * Make a new private value and change responder secrets * as required by draft. */ @@ -280,7 +280,7 @@ exchange_make_values(struct stateob *st, BIGNUM *modulus, BIGNUM *generator) BN_mod_exp(tmp, p->generator, p->private_value, p->modulus, ctx); - /* + /* * If our exchange value is defective we need to make a new one * to avoid subgroup confinement. */ @@ -341,17 +341,17 @@ exchange_set_generator(BIGNUM *generator, u_int8_t *scheme, u_int8_t *gen) case DH_G_5_MD5: case DH_G_5_DES_MD5: case DH_G_5_3DES_SHA1: - BN_set_word(generator,5); + BN_set_word(generator,5); break; default: log_print("Unsupported exchange scheme %d", - *((u_int16_t *)scheme)); + *((u_int16_t *)scheme)); return (-1); } return (0); } -/* +/* * Generates the exchange values needed for the value_request * and value_response packets. */ diff --git a/sbin/photurisd/exchange.h b/sbin/photurisd/exchange.h index b5ddb139cff..7d3b365496b 100644 --- a/sbin/photurisd/exchange.h +++ b/sbin/photurisd/exchange.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exchange.h,v 1.4 2001/01/28 22:45:08 niklas Exp $ */ +/* $OpenBSD: exchange.h,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -28,14 +28,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * exchange.h: +/* + * exchange.h: * exchange generation header file - */ + */ #ifndef _EXCHANGE_H_ #define _EXCHANGE_H_ - + #undef EXTERN #ifdef _EXCHANGE_C_ diff --git a/sbin/photurisd/handle_bad_cookie.c b/sbin/photurisd/handle_bad_cookie.c index 25e3e523737..53b5420f824 100644 --- a/sbin/photurisd/handle_bad_cookie.c +++ b/sbin/photurisd/handle_bad_cookie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_bad_cookie.c,v 1.4 2001/01/28 22:45:08 niklas Exp $ */ +/* $OpenBSD: handle_bad_cookie.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_bad_cookie.c,v 1.4 2001/01/28 22:45:08 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_bad_cookie.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -68,19 +68,19 @@ handle_bad_cookie(u_char *packet, int size, char *address) header = (struct error_message *) packet; - if ((st = state_find_cookies(address, header->icookie, + if ((st = state_find_cookies(address, header->icookie, header->rcookie)) == NULL) { - log_print("No state for BAD_COOKIE message from %s", + log_print("No state for BAD_COOKIE message from %s", address); return -1; } - if ((st->retries < max_retries && + if ((st->retries < max_retries && (st->phase == VALUE_REQUEST || st->phase == IDENTITY_REQUEST)) || (st->phase != VALUE_REQUEST && st->phase != IDENTITY_REQUEST && st->phase != SPI_NEEDED && st->phase != SPI_UPDATE)) { - log_print("Ignored BAD_COOKIE message from %s", address); - + log_print("Ignored BAD_COOKIE message from %s", address); + return 0; /* Nothing needs to be done */ } diff --git a/sbin/photurisd/handle_cookie_request.c b/sbin/photurisd/handle_cookie_request.c index 1e40cf943bd..e6a0839d6b7 100644 --- a/sbin/photurisd/handle_cookie_request.c +++ b/sbin/photurisd/handle_cookie_request.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_cookie_request.c,v 1.3 2001/01/28 22:45:08 niklas Exp $ */ +/* $OpenBSD: handle_cookie_request.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_cookie_request.c,v 1.3 2001/01/28 22:45:08 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_cookie_request.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -53,8 +53,8 @@ static char rcsid[] = "$OpenBSD: handle_cookie_request.c,v 1.3 2001/01/28 22:45: int handle_cookie_request(u_char *packet, int size, - u_int8_t *address, u_int16_t port, - u_int8_t *schemes, u_int16_t ssize) + u_int8_t *address, u_int16_t port, + u_int8_t *schemes, u_int16_t ssize) { struct cookie_request *header; @@ -75,7 +75,7 @@ handle_cookie_request(u_char *packet, int size, st = prev_st; - /* + /* * Find exchanges which are not timed out and the rcookie doesnt * match any exchange -> resource limit. */ @@ -88,9 +88,9 @@ handle_cookie_request(u_char *packet, int size, if (prev_st->lifetime > st->lifetime) st = prev_st; - if ((!prev_st->initiator && + if ((!prev_st->initiator && !bcmp(prev_st->rcookie, header->rcookie, COOKIE_SIZE))|| - (prev_st->initiator && + (prev_st->initiator && !bcmp(prev_st->icookie, header->rcookie, COOKIE_SIZE))) match = 1; prev_st = state_find_next(prev_st, address); @@ -109,8 +109,8 @@ handle_cookie_request(u_char *packet, int size, bcopy(header->icookie, icookie, COOKIE_SIZE); packet_size = PACKET_BUFFER_SIZE; - if (photuris_cookie_response(st != NULL && - st->lifetime > tm ? st : NULL, + if (photuris_cookie_response(st != NULL && + st->lifetime > tm ? st : NULL, packet_buffer, &packet_size, icookie, header->counter, address, port, diff --git a/sbin/photurisd/handle_cookie_response.c b/sbin/photurisd/handle_cookie_response.c index b26311faee1..b83ecfa629f 100644 --- a/sbin/photurisd/handle_cookie_response.c +++ b/sbin/photurisd/handle_cookie_response.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_cookie_response.c,v 1.6 2001/01/28 22:45:08 niklas Exp $ */ +/* $OpenBSD: handle_cookie_response.c,v 1.7 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_cookie_response.c,v 1.6 2001/01/28 22:45:08 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_cookie_response.c,v 1.7 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -112,10 +112,10 @@ handle_cookie_response(u_char *packet, int size, if (pick_scheme(&(st->scheme), &(st->schemesize), p, i) == -1) { state_value_reset(st); state_unlink(st); - return -1; + return -1; } - if (pick_attrib(st, &(st->oSPIoattrib), + if (pick_attrib(st, &(st->oSPIoattrib), &(st->oSPIoattribsize)) == -1) { state_value_reset(st); state_unlink(st); @@ -124,7 +124,7 @@ handle_cookie_response(u_char *packet, int size, /* Take the counter from the cookie response */ st->counter = header->counter; - + packet_size = PACKET_BUFFER_SIZE; if (photuris_value_request(st, packet_buffer, &packet_size) == -1) return -1; diff --git a/sbin/photurisd/handle_identity_request.c b/sbin/photurisd/handle_identity_request.c index ecb0a0d8db9..1f2b777b1d1 100644 --- a/sbin/photurisd/handle_identity_request.c +++ b/sbin/photurisd/handle_identity_request.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_identity_request.c,v 1.6 2001/01/28 22:45:08 niklas Exp $ */ +/* $OpenBSD: handle_identity_request.c,v 1.7 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_identity_request.c,v 1.6 2001/01/28 22:45:08 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_identity_request.c,v 1.7 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -64,7 +64,7 @@ static char rcsid[] = "$OpenBSD: handle_identity_request.c,v 1.6 2001/01/28 22:4 #endif int -handle_identity_request(u_char *packet, int size, char *address, +handle_identity_request(u_char *packet, int size, char *address, char *local_address) { struct packet_sub parts[] = { @@ -76,7 +76,7 @@ handle_identity_request(u_char *packet, int size, char *address, }; struct packet id_msg = { - "Identity Request", + "Identity Request", IDENTITY_MESSAGE_MIN, 0, parts }; @@ -133,7 +133,7 @@ handle_identity_request(u_char *packet, int size, char *address, MD5Final(signature, &ctx); if (st->phase != VALUE_RESPONSE) { - /* + /* * Compare with the identity request which got verified * initially. If matching resend our response. */ @@ -144,7 +144,7 @@ handle_identity_request(u_char *packet, int size, char *address, /* We got send the old packet again */ bcopy(st->packet, packet_buffer, st->packetlen); packet_size = st->packetlen; - + send_packet(); return 0; } else @@ -169,8 +169,8 @@ handle_identity_request(u_char *packet, int size, char *address, /* Fill the state object, but only if we have not dont so before */ if (st->uSPIidentver == NULL) { - if((st->uSPIidentver = calloc(i, sizeof(u_int8_t))) == NULL) { - log_error("calloc() in handle_identity_request()"); + if((st->uSPIidentver = calloc(i, sizeof(u_int8_t))) == NULL) { + log_error("calloc() in handle_identity_request()"); goto verification_failed; } bcopy(signature, st->uSPIidentver, i); @@ -190,7 +190,7 @@ handle_identity_request(u_char *packet, int size, char *address, p += p[1] + 2; if (st->uSPIident == NULL) { if((st->uSPIident = calloc(varpre2octets(p), sizeof(u_int8_t))) == NULL) { - log_error("calloc() in handle_identity_request()"); + log_error("calloc() in handle_identity_request()"); goto verification_failed; } bcopy(p, st->uSPIident, varpre2octets(p)); @@ -205,15 +205,15 @@ handle_identity_request(u_char *packet, int size, char *address, st->uSPIattribsize = attribsize; } - if (st->oSPIident == NULL && + if (st->oSPIident == NULL && get_secrets(st, (ID_REMOTE|ID_LOCAL)) == -1) { log_print("get_secrets() in in handle_identity_request()"); goto verification_failed; } if (!verify_identity_verification(st, signature, packet, size)) { - /* - * Clean up everything used from this packet + /* + * Clean up everything used from this packet * but only if we did not get a valid packet before. * Otherwise this could be used as Denial of Service. */ @@ -227,13 +227,13 @@ handle_identity_request(u_char *packet, int size, char *address, st->uSPIident = NULL; free(st->oSPIident); st->oSPIident = NULL; - + /* Clean up secrets */ free(st->oSPIsecret); st->oSPIsecret = NULL; st->oSPIsecretsize = 0; free(st->uSPIsecret); st->uSPIsecret = NULL; st->uSPIsecretsize = 0; - + verification_failed: log_print("verification failed in handle_identity_request()"); packet_size = PACKET_BUFFER_SIZE; @@ -245,7 +245,7 @@ handle_identity_request(u_char *packet, int size, char *address, } /* Create SPI + choice of attributes */ - if(make_spi(st, local_address, st->oSPI, &(st->olifetime), + if(make_spi(st, local_address, st->oSPI, &(st->olifetime), &(st->oSPIattrib), &(st->oSPIattribsize)) == -1) { log_print("make_spi() in handle_identity_request()"); return -1; @@ -264,37 +264,37 @@ handle_identity_request(u_char *packet, int size, char *address, free(st->exchangevalue); st->exchangevalue = NULL; bcopy(header->SPI, st->uSPI, SPI_SIZE); - st->ulifetime = (header->lifetime[0] << 16) + + st->ulifetime = (header->lifetime[0] << 16) + (header->lifetime[1] << 8) + header->lifetime[2]; if (st->oSPI[0] || st->oSPI[1] || st->oSPI[2] || st->oSPI[3]) { - /* Insert Owner SPI */ - if ((spi = spi_new(st->address, st->oSPI)) == NULL) { - log_print("spi_new() in handle_identity_request()"); - return -1; - } + /* Insert Owner SPI */ + if ((spi = spi_new(st->address, st->oSPI)) == NULL) { + log_print("spi_new() in handle_identity_request()"); + return -1; + } if ((spi->local_address = strdup(local_address)) == NULL) { log_print("strdup() in handle_identity_request()"); return -1; } - bcopy(st->icookie, spi->icookie, COOKIE_SIZE); + bcopy(st->icookie, spi->icookie, COOKIE_SIZE); spi->flags |= SPI_OWNER; - spi->attribsize = st->oSPIattribsize; - spi->attributes = calloc(spi->attribsize, sizeof(u_int8_t)); - if (spi->attributes == NULL) { - log_error("calloc() in handle_identity_request()"); - spi_value_reset(spi); - return -1; - } - bcopy(st->oSPIattrib, spi->attributes, spi->attribsize); - spi->lifetime = time(NULL) + st->olifetime; + spi->attribsize = st->oSPIattribsize; + spi->attributes = calloc(spi->attribsize, sizeof(u_int8_t)); + if (spi->attributes == NULL) { + log_error("calloc() in handle_identity_request()"); + spi_value_reset(spi); + return -1; + } + bcopy(st->oSPIattrib, spi->attributes, spi->attribsize); + spi->lifetime = time(NULL) + st->olifetime; /* Cludge for getting the right verification field */ state_save_verification(st, st->oSPIidentver, st->oSPIidentversize); /* Make session keys for Owner */ make_session_keys(st, spi); - spi_insert(spi); + spi_insert(spi); #ifdef IPSEC kernel_insert_spi(st, spi); #endif diff --git a/sbin/photurisd/handle_identity_response.c b/sbin/photurisd/handle_identity_response.c index 73e60ed117b..b9a216533a2 100644 --- a/sbin/photurisd/handle_identity_response.c +++ b/sbin/photurisd/handle_identity_response.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_identity_response.c,v 1.6 2001/01/28 22:45:09 niklas Exp $ */ +/* $OpenBSD: handle_identity_response.c,v 1.7 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_identity_response.c,v 1.6 2001/01/28 22:45:09 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_identity_response.c,v 1.7 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -137,8 +137,8 @@ handle_identity_response(u_char *packet, int size, char *address, /* Fill the state object */ - if((st->uSPIidentver = calloc(i, sizeof(u_int8_t))) == NULL) { - log_error("calloc() in handle_identity_response()"); + if((st->uSPIidentver = calloc(i, sizeof(u_int8_t))) == NULL) { + log_error("calloc() in handle_identity_response()"); goto verification_failed; } bcopy(signature, st->uSPIidentver, i); @@ -152,7 +152,7 @@ handle_identity_response(u_char *packet, int size, char *address, st->uSPIidentchoicesize = parts[0].size; if((st->uSPIident = calloc(parts[1].size, sizeof(u_int8_t))) == NULL) { - log_error("calloc() in handle_identity_response()"); + log_error("calloc() in handle_identity_response()"); goto verification_failed; } bcopy(parts[1].where, st->uSPIident, parts[1].size); @@ -170,8 +170,8 @@ handle_identity_response(u_char *packet, int size, char *address, } if (!verify_identity_verification(st, signature, packet, size)) { - /* - * Clean up everything used from this packet + /* + * Clean up everything used from this packet */ free(st->uSPIidentchoice); st->uSPIidentchoice = NULL; st->uSPIidentchoicesize = 0; @@ -196,7 +196,7 @@ handle_identity_response(u_char *packet, int size, char *address, } bcopy(header->SPI, st->uSPI, SPI_SIZE); - st->ulifetime = (header->lifetime[0] << 16) + + st->ulifetime = (header->lifetime[0] << 16) + (header->lifetime[1] << 8) + header->lifetime[2]; st->lifetime = st->exchange_lifetime + time(NULL) + random() % 20; @@ -211,7 +211,7 @@ handle_identity_response(u_char *packet, int size, char *address, st->packet = NULL; st->packetlen = 0; } - + /* At this point we do not need the exchange values any longer */ free(st->texchange); st->texchange = NULL; free(st->exchangevalue); st->exchangevalue = NULL; diff --git a/sbin/photurisd/handle_message_reject.c b/sbin/photurisd/handle_message_reject.c index 20cd40b5d51..74f477d0dd8 100644 --- a/sbin/photurisd/handle_message_reject.c +++ b/sbin/photurisd/handle_message_reject.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_message_reject.c,v 1.4 2001/01/28 22:45:09 niklas Exp $ */ +/* $OpenBSD: handle_message_reject.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_message_reject.c,v 1.4 2001/01/28 22:45:09 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_message_reject.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -63,15 +63,15 @@ handle_message_reject(u_char *packet, int size, char *address) header = (struct message_reject *) packet; - if ((st = state_find_cookies(address, header->icookie, + if ((st = state_find_cookies(address, header->icookie, header->rcookie)) == NULL) { - log_print("No state for MESSAGE_REJECT message from %s", + log_print("No state for MESSAGE_REJECT message from %s", address); return -1; } log_print("Received MESSAGE_REJECT from %s on message type %d " "offending offset %d", address, header->badtype, - header->offset); + header->offset); return 0; } diff --git a/sbin/photurisd/handle_resource_limit.c b/sbin/photurisd/handle_resource_limit.c index 0c3a5210cb1..566d1b069f6 100644 --- a/sbin/photurisd/handle_resource_limit.c +++ b/sbin/photurisd/handle_resource_limit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_resource_limit.c,v 1.4 2001/01/28 22:45:09 niklas Exp $ */ +/* $OpenBSD: handle_resource_limit.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_resource_limit.c,v 1.4 2001/01/28 22:45:09 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_resource_limit.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -66,14 +66,14 @@ handle_resource_limit(u_char *packet, int size, char *address) counter = packet[ERROR_MESSAGE_PACKET_SIZE]; if ((st = state_find_cookies(NULL, header->icookie, NULL)) == NULL) { - log_print("No state for RESOURCE_LIMIT message from %s", + log_print("No state for RESOURCE_LIMIT message from %s", address); return -1; } switch(st->phase) { case COOKIE_REQUEST: - /* + /* * The other party has still an exchange which has been * purged on our side. */ @@ -94,7 +94,7 @@ handle_resource_limit(u_char *packet, int size, char *address) if (offset > exchange_timeout/2) offset = exchange_timeout/2; } - + schedule_remove(TIMEOUT, st->icookie); schedule_insert(TIMEOUT, offset, st->icookie, COOKIE_SIZE); break; @@ -102,8 +102,8 @@ handle_resource_limit(u_char *packet, int size, char *address) /* XXX - we have to wait for expiring of another SPI */ break; default: - log_print("Wrong phase for RESOURCE_LIMIT from %s", - address); + log_print("Wrong phase for RESOURCE_LIMIT from %s", + address); return 0; } diff --git a/sbin/photurisd/handle_spi_needed.c b/sbin/photurisd/handle_spi_needed.c index f29a1ee06b8..a44e576e898 100644 --- a/sbin/photurisd/handle_spi_needed.c +++ b/sbin/photurisd/handle_spi_needed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_spi_needed.c,v 1.5 2001/01/28 22:45:09 niklas Exp $ */ +/* $OpenBSD: handle_spi_needed.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_spi_needed.c,v 1.5 2001/01/28 22:45:09 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_spi_needed.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -61,7 +61,7 @@ static char rcsid[] = "$OpenBSD: handle_spi_needed.c,v 1.5 2001/01/28 22:45:09 n #endif int -handle_spi_needed(u_char *packet, int size, char *address, +handle_spi_needed(u_char *packet, int size, char *address, char *local_address) { struct packet_sub parts[] = { @@ -70,7 +70,7 @@ handle_spi_needed(u_char *packet, int size, char *address, { NULL } }; struct packet spi_msg = { - "SPI Needed", + "SPI Needed", SPI_NEEDED_MIN, 0, parts }; struct spi_needed *header; @@ -158,12 +158,12 @@ handle_spi_needed(u_char *packet, int size, char *address, &(st->oSPIattrib), &(st->oSPIattribsize)) == -1) return -1; - packet_size = PACKET_BUFFER_SIZE; + packet_size = PACKET_BUFFER_SIZE; if (photuris_spi_update(st, packet_buffer, &packet_size) == -1) { log_print("photuris_spi_update() in handle_spi_needed()"); return -1; } - send_packet(); + send_packet(); /* Insert Owner SPI */ if ((spi = spi_new(st->address, st->oSPI)) == NULL) { diff --git a/sbin/photurisd/handle_spi_update.c b/sbin/photurisd/handle_spi_update.c index 57ccf518289..7e39d73e68b 100644 --- a/sbin/photurisd/handle_spi_update.c +++ b/sbin/photurisd/handle_spi_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_spi_update.c,v 1.7 2001/01/28 22:45:10 niklas Exp $ */ +/* $OpenBSD: handle_spi_update.c,v 1.8 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_spi_update.c,v 1.7 2001/01/28 22:45:10 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_spi_update.c,v 1.8 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -62,7 +62,7 @@ static char rcsid[] = "$OpenBSD: handle_spi_update.c,v 1.7 2001/01/28 22:45:10 n #endif int -handle_spi_update(u_char *packet, int size, char *address, +handle_spi_update(u_char *packet, int size, char *address, char *local_address) { struct packet_sub parts[] = { @@ -71,7 +71,7 @@ handle_spi_update(u_char *packet, int size, char *address, { NULL } }; struct packet spi_msg = { - "SPI Update", + "SPI Update", SPI_UPDATE_MIN, 0, parts }; struct spi_update *header; @@ -155,14 +155,14 @@ handle_spi_update(u_char *packet, int size, char *address, spi_value_reset(spi); spi_unlink(spi); return 0; - } + } /* The State object always retains the latest SPI pairs */ bcopy(header->SPI, st->uSPI, SPI_SIZE); if ((spi = spi_new(st->address, header->SPI)) == NULL) { - log_print("spi_new() in handle_spi_update()"); - return -1; + log_print("spi_new() in handle_spi_update()"); + return -1; } if ((spi->local_address = strdup(local_address)) == NULL) { log_error("strdup() in handle_spi_update()"); diff --git a/sbin/photurisd/handle_value_request.c b/sbin/photurisd/handle_value_request.c index bb63a2a9dc4..e16d5a9bec7 100644 --- a/sbin/photurisd/handle_value_request.c +++ b/sbin/photurisd/handle_value_request.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_value_request.c,v 1.7 2001/01/28 22:45:10 niklas Exp $ */ +/* $OpenBSD: handle_value_request.c,v 1.8 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_value_request.c,v 1.7 2001/01/28 22:45:10 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_value_request.c,v 1.8 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -98,14 +98,14 @@ handle_value_request(u_char *packet, int size, st = state_find_cookies(address, header->icookie, header->rcookie); if (st == NULL) { struct stateob tempst; - bzero((char *)&tempst, sizeof(tempst)); /* Set up temp. state */ - tempst.initiator = 0; /* We are the Responder */ - bcopy(header->icookie, tempst.icookie, COOKIE_SIZE); - strncpy(tempst.address, address, 15); - tempst.port = global_port; + bzero((char *)&tempst, sizeof(tempst)); /* Set up temp. state */ + tempst.initiator = 0; /* We are the Responder */ + bcopy(header->icookie, tempst.icookie, COOKIE_SIZE); + strncpy(tempst.address, address, 15); + tempst.port = global_port; tempst.counter = header->counter; - - cookie_generate(&tempst, rcookie, COOKIE_SIZE, schemes, ssize); + + cookie_generate(&tempst, rcookie, COOKIE_SIZE, schemes, ssize); /* Check for invalid cookie */ if (bcmp(rcookie, header->rcookie, COOKIE_SIZE)) { @@ -151,7 +151,7 @@ handle_value_request(u_char *packet, int size, refp = p; refpsize = modsize; } - + sstart += scheme_get_len(schemes+sstart); } if (sstart >= ssize) @@ -195,8 +195,8 @@ handle_value_request(u_char *packet, int size, state_value_reset(st); goto resourcefail; } - bcopy(parts[1].where, st->uSPIoattrib, parts[1].size); - st->uSPIoattribsize = parts[1].size; + bcopy(parts[1].where, st->uSPIoattrib, parts[1].size); + st->uSPIoattribsize = parts[1].size; /* Save scheme, which will be used by both parties */ vsize = 2 + varpre2octets(modp); @@ -207,9 +207,9 @@ handle_value_request(u_char *packet, int size, st->scheme = calloc(vsize, sizeof(u_int8_t)); if (st->scheme == NULL) { - state_value_reset(st); - goto resourcefail; - } + state_value_reset(st); + goto resourcefail; + } bcopy(header->scheme, st->scheme, 2); if (genp != NULL) { st->scheme[2] = (vsize-4) >> 8; @@ -218,7 +218,7 @@ handle_value_request(u_char *packet, int size, } bcopy(modp, st->scheme + 2 + (genp == NULL ? 0 : 2 + varpre2octets(genp)), varpre2octets(modp));; - + st->schemesize = vsize; #ifdef DEBUG @@ -241,11 +241,11 @@ handle_value_request(u_char *packet, int size, /* Fill in the state object with generic data */ - strncpy(st->address, address, 15); - st->port = port; + strncpy(st->address, address, 15); + st->port = port; st->counter = header->counter; - bcopy(header->icookie, st->icookie, COOKIE_SIZE); - bcopy(header->rcookie, st->rcookie, COOKIE_SIZE); + bcopy(header->icookie, st->icookie, COOKIE_SIZE); + bcopy(header->rcookie, st->rcookie, COOKIE_SIZE); bcopy(&header->counter, st->uSPITBV, 3); if ((st->roschemes = calloc(ssize, sizeof(u_int8_t))) == NULL) { @@ -256,7 +256,7 @@ handle_value_request(u_char *packet, int size, bcopy(schemes, st->roschemes, ssize); st->roschemesize = ssize; - if (pick_attrib(st, &(st->oSPIoattrib), + if (pick_attrib(st, &(st->oSPIoattrib), &(st->oSPIoattribsize)) == -1) { state_value_reset(st); goto resourcefail; @@ -272,7 +272,7 @@ handle_value_request(u_char *packet, int size, st->address, st->phase)); return (-1); } - + packet_size = PACKET_BUFFER_SIZE; if (photuris_value_response(st, packet_buffer, &packet_size) == -1) return (-1); @@ -281,13 +281,13 @@ handle_value_request(u_char *packet, int size, /* Compute the shared secret now */ compute_shared_secret(st, &(st->shared), &(st->sharedsize)); -#ifdef DEBUG +#ifdef DEBUG { int i = BUFFER_SIZE; bin2hex(buffer, &i, st->shared, st->sharedsize); - printf("Shared secret is: 0x%s\n", buffer); + printf("Shared secret is: 0x%s\n", buffer); } -#endif +#endif if (st->oSPIprivacyctx == NULL) { /* Initialize Privacy Keys from Exchange Values */ diff --git a/sbin/photurisd/handle_value_response.c b/sbin/photurisd/handle_value_response.c index 9ffee8aaf7b..31b875a1aa0 100644 --- a/sbin/photurisd/handle_value_response.c +++ b/sbin/photurisd/handle_value_response.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_value_response.c,v 1.5 2001/01/28 22:45:10 niklas Exp $ */ +/* $OpenBSD: handle_value_response.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_value_response.c,v 1.5 2001/01/28 22:45:10 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_value_response.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdlib.h> @@ -60,7 +60,7 @@ static char rcsid[] = "$OpenBSD: handle_value_response.c,v 1.5 2001/01/28 22:45: #endif int -handle_value_response(u_char *packet, int size, char *address, +handle_value_response(u_char *packet, int size, char *address, char *local_address) { @@ -113,16 +113,16 @@ handle_value_response(u_char *packet, int size, char *address, state_unlink(st); return -1; } - bcopy(parts[1].where, st->uSPIoattrib, parts[1].size); - st->uSPIoattribsize = parts[1].size; + bcopy(parts[1].where, st->uSPIoattrib, parts[1].size); + st->uSPIoattribsize = parts[1].size; -#ifdef DEBUG +#ifdef DEBUG { - int i = BUFFER_SIZE; + int i = BUFFER_SIZE; bin2hex(buffer, &i, parts[0].where, parts[0].size); - printf("Got exchange value 0x%s\n", buffer); + printf("Got exchange value 0x%s\n", buffer); } -#endif +#endif /* Set exchange value */ st->texchangesize = parts[0].size; @@ -135,13 +135,13 @@ handle_value_response(u_char *packet, int size, char *address, /* Compute the shared secret now */ compute_shared_secret(st, &(st->shared), &(st->sharedsize)); -#ifdef DEBUG +#ifdef DEBUG { int i = BUFFER_SIZE; bin2hex(buffer, &i, st->shared, st->sharedsize); - printf("Shared secret is: 0x%s\n", buffer); + printf("Shared secret is: 0x%s\n", buffer); } -#endif +#endif /* Create SPI + choice of attributes */ if (make_spi(st, local_address, st->oSPI, &(st->olifetime), diff --git a/sbin/photurisd/handle_verification_failure.c b/sbin/photurisd/handle_verification_failure.c index bafaae6d98d..1bd9d86d6ba 100644 --- a/sbin/photurisd/handle_verification_failure.c +++ b/sbin/photurisd/handle_verification_failure.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle_verification_failure.c,v 1.4 2001/01/28 22:45:10 niklas Exp $ */ +/* $OpenBSD: handle_verification_failure.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: handle_verification_failure.c,v 1.4 2001/01/28 22:45:10 niklas Exp $"; +static char rcsid[] = "$OpenBSD: handle_verification_failure.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -63,9 +63,9 @@ handle_verification_failure(u_char *packet, int size, char *address) header = (struct error_message *) packet; - if ((st = state_find_cookies(address, header->icookie, + if ((st = state_find_cookies(address, header->icookie, header->rcookie)) == NULL) { - log_print("No state for VERIFICATION_FAILURE message from %s", + log_print("No state for VERIFICATION_FAILURE message from %s", address); return -1; } diff --git a/sbin/photurisd/identity.c b/sbin/photurisd/identity.c index 39083d26a5d..d6aa48540bf 100644 --- a/sbin/photurisd/identity.c +++ b/sbin/photurisd/identity.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identity.c,v 1.5 2001/01/28 22:45:10 niklas Exp $ */ +/* $OpenBSD: identity.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: identity.c,v 1.5 2001/01/28 22:45:10 niklas Exp $"; +static char rcsid[] = "$OpenBSD: identity.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; #endif #define _IDENTITY_C_ @@ -48,9 +48,9 @@ static char rcsid[] = "$OpenBSD: identity.c,v 1.5 2001/01/28 22:45:10 niklas Exp #include <sys/types.h> #include <pwd.h> #include <sys/stat.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <md5.h> #include <ssl/bn.h> #include <sha1.h> @@ -80,15 +80,15 @@ static union { /* XXX - argh, cast the funtions */ static struct idxform idxform[] = { - { HASH_MD5, 5, MD5_SIZE, (void *)&Ctx.md5ctx, + { HASH_MD5, 5, MD5_SIZE, (void *)&Ctx.md5ctx, sizeof(MD5_CTX), (void *)&Ctx2.md5ctx, - (void (*)(void *))MD5Init, - (void (*)(void *, unsigned char *, unsigned int))MD5Update, + (void (*)(void *))MD5Init, + (void (*)(void *, unsigned char *, unsigned int))MD5Update, (void (*)(unsigned char *, void *))MD5Final }, - { HASH_SHA1, 6, SHA1_SIZE, (void *)&Ctx.sha1ctx, + { HASH_SHA1, 6, SHA1_SIZE, (void *)&Ctx.sha1ctx, sizeof(SHA1_CTX), (void *)&Ctx2.sha1ctx, - (void (*)(void *))SHA1Init, - (void (*)(void *, unsigned char *, unsigned int))SHA1Update, + (void (*)(void *))SHA1Init, + (void (*)(void *, unsigned char *, unsigned int))SHA1Update, (void (*)(unsigned char *, void *))SHA1Final }, }; @@ -162,9 +162,9 @@ init_identities(char *name, struct identity *root) p2 = p; if (!isspace(*p2)) continue; - + /* Tokens are braced with "token" */ - if((p=strsep(&p2, "\"\'")) == NULL || + if((p=strsep(&p2, "\"\'")) == NULL || (p=strsep(&p2, "\"\'")) == NULL) continue; @@ -185,7 +185,7 @@ init_identities(char *name, struct identity *root) } } /* Tokens are braced with "token" */ - if((p=strsep(&p2, "\"\'")) == NULL || + if((p=strsep(&p2, "\"\'")) == NULL || (p=strsep(&p2, "\"\'")) == NULL) { identity_value_reset(tmp); continue; @@ -194,14 +194,14 @@ init_identities(char *name, struct identity *root) break; case ID_LOCALPAIR: /* Tokens are braced with "token" */ - if((p=strsep(&p2, "\"\'")) == NULL || + if((p=strsep(&p2, "\"\'")) == NULL || (p=strsep(&p2, "\"\'")) == NULL) { identity_value_reset(tmp); continue; } tmp->pairid = strdup(p); /* Tokens are braced with "token" */ - if((p=strsep(&p2, "\"\'")) == NULL || + if((p=strsep(&p2, "\"\'")) == NULL || (p=strsep(&p2, "\"\'")) == NULL) { identity_value_reset(tmp); continue; @@ -254,7 +254,7 @@ init_identities(char *name, struct identity *root) return 0; } -/* +/* * Get shared symmetric keys and identity, put the values in * the state object. If a SPI User ident is given, we look up * the matching remote secret. @@ -265,7 +265,7 @@ get_secrets(struct stateob *st, int mode) { u_int8_t local_ident[MAX_IDENT]; u_int8_t local_secret[MAX_IDENT_SECRET]; - u_int8_t remote_secret[MAX_IDENT_SECRET]; + u_int8_t remote_secret[MAX_IDENT_SECRET]; struct identity *id, *root = idob; @@ -273,34 +273,34 @@ get_secrets(struct stateob *st, int mode) local_secret[0] = '\0'; remote_secret[0] = '\0'; - /* - * Remote secret first, if we find the remote secret in + /* + * Remote secret first, if we find the remote secret in * a user secret file, we restrict our local searches * to that tree. */ - if(st->uSPIident != NULL && st->uSPIsecret == NULL && + if(st->uSPIident != NULL && st->uSPIsecret == NULL && (mode & ID_REMOTE)) { int skip; - if (st->uSPIident[0] == 255 && st->uSPIident[1] == 255) - skip = 8; - else if (st->uSPIident[0] == 255) - skip = 4; - else - skip = 2; + if (st->uSPIident[0] == 255 && st->uSPIident[1] == 255) + skip = 8; + else if (st->uSPIident[0] == 255) + skip = 4; + else + skip = 2; id = identity_find(root, st->uSPIident+skip, ID_REMOTE); if (id != NULL) { - strncpy(remote_secret, id->object, MAX_IDENT_SECRET-1); - remote_secret[MAX_IDENT_SECRET-1] = '\0'; - + strncpy(remote_secret, id->object, MAX_IDENT_SECRET-1); + remote_secret[MAX_IDENT_SECRET-1] = '\0'; + if (id->root) root = (struct identity *)id->root->object; } } - - if (st->user != NULL && + + if (st->user != NULL && (id = identity_find(idob, st->user, ID_LOOKUP)) != NULL) { /* User keying */ id = identity_find((struct identity *)id->object, NULL, ID_LOCAL); @@ -318,14 +318,14 @@ get_secrets(struct stateob *st, int mode) strncpy(local_ident, id->root->tag, MAX_IDENT-1); local_ident[MAX_IDENT-1] = '\0'; } - strncpy(local_ident+strlen(local_ident), id->tag, + strncpy(local_ident+strlen(local_ident), id->tag, MAX_IDENT-1-strlen(local_ident)); - local_ident[MAX_IDENT_SECRET-1] = '\0'; + local_ident[MAX_IDENT_SECRET-1] = '\0'; strncpy(local_secret, id->object, MAX_IDENT_SECRET-1); - local_secret[MAX_IDENT_SECRET-1] = '\0'; + local_secret[MAX_IDENT_SECRET-1] = '\0'; } - if (st->uSPIident != NULL && st->oSPIident == NULL && + if (st->uSPIident != NULL && st->oSPIident == NULL && (mode & (ID_LOCAL|ID_LOCALPAIR))) { int skip; if (st->uSPIident[0] == 255 && st->uSPIident[1] == 255) @@ -343,15 +343,15 @@ get_secrets(struct stateob *st, int mode) strncpy(local_ident, id->root->tag, MAX_IDENT-1); local_ident[MAX_IDENT-1] = '\0'; } - strncpy(local_ident+strlen(local_ident), id->pairid, + strncpy(local_ident+strlen(local_ident), id->pairid, MAX_IDENT-1-strlen(local_ident)); - local_ident[MAX_IDENT-1] = '\0'; - - strncpy(local_secret, id->object, MAX_IDENT_SECRET-1); - local_secret[MAX_IDENT_SECRET-1] = '\0'; + local_ident[MAX_IDENT-1] = '\0'; + + strncpy(local_secret, id->object, MAX_IDENT_SECRET-1); + local_secret[MAX_IDENT_SECRET-1] = '\0'; } } - + if(strlen(remote_secret) == 0 && (mode & ID_REMOTE)) { log_print("Can't find remote secret for %s in get_secrets()", st->uSPIident+2); @@ -366,7 +366,7 @@ get_secrets(struct stateob *st, int mode) if(st->oSPIident == NULL && (mode & (ID_LOCAL|ID_LOCALPAIR))) { st->oSPIident = calloc(2+strlen(local_ident)+1,sizeof(u_int8_t)); if(st->oSPIident == NULL) - return -1; + return -1; strcpy(st->oSPIident+2,local_ident); st->oSPIident[0] = ((strlen(local_ident)+1) >> 5) & 0xFF; st->oSPIident[1] = ((strlen(local_ident)+1) << 3) & 0xFF; @@ -374,17 +374,17 @@ get_secrets(struct stateob *st, int mode) st->oSPIsecretsize = strlen(local_secret); st->oSPIsecret = calloc(st->oSPIsecretsize,sizeof(u_int8_t)); if(st->oSPIsecret == NULL) - return -1; + return -1; strncpy(st->oSPIsecret, local_secret, st->oSPIsecretsize); } - if(st->uSPIident != NULL && st->uSPIsecret == NULL && + if(st->uSPIident != NULL && st->uSPIsecret == NULL && (mode & ID_REMOTE)) { st->uSPIsecretsize = strlen(remote_secret); - st->uSPIsecret = calloc(st->uSPIsecretsize,sizeof(u_int8_t)); - if(st->uSPIsecret == NULL) - return -1; - strncpy(st->uSPIsecret, remote_secret, st->uSPIsecretsize); - } + st->uSPIsecret = calloc(st->uSPIsecretsize,sizeof(u_int8_t)); + if(st->uSPIsecret == NULL) + return -1; + strncpy(st->uSPIsecret, remote_secret, st->uSPIsecretsize); + } return 0; } @@ -418,7 +418,7 @@ choose_identity(struct stateob *st, u_int8_t *packet, u_int16_t *size, "in choose_identity()"); return -1; } - + if(rsize < *(attributes+1)+2) return -1; @@ -448,7 +448,7 @@ choose_identity(struct stateob *st, u_int8_t *packet, u_int16_t *size, tmp = varpre2octets(st->oSPIident); if(rsize < tmp) return -1; - + bcopy(st->oSPIident, packet, tmp); *size = asize + tmp; @@ -502,7 +502,7 @@ create_verification_key(struct stateob *st, u_int8_t *buffer, u_int16_t *size, if ((hash = get_hash_id(id)) == NULL) { log_print("Unkown identity choice %d in create_verification_key", id); - return -1; + return -1; } if (*size < hash->hashsize) @@ -522,7 +522,7 @@ create_verification_key(struct stateob *st, u_int8_t *buffer, u_int16_t *size, } int -create_identity_verification(struct stateob *st, u_int8_t *buffer, +create_identity_verification(struct stateob *st, u_int8_t *buffer, u_int8_t *packet, u_int16_t size) { int hash_size; @@ -531,7 +531,7 @@ create_identity_verification(struct stateob *st, u_int8_t *buffer, if ((hash = get_hash_id(*(st->oSPIidentchoice))) == NULL) { log_print("Unkown identity choice %d in create_verification_key", *(st->oSPIidentchoice)); - return 0; + return 0; } hash_size = idsign(st, hash, buffer+2, packet,size); @@ -558,16 +558,16 @@ create_identity_verification(struct stateob *st, u_int8_t *buffer, return hash_size+2; } -int -verify_identity_verification(struct stateob *st, u_int8_t *buffer, - u_int8_t *packet, u_int16_t size) -{ +int +verify_identity_verification(struct stateob *st, u_int8_t *buffer, + u_int8_t *packet, u_int16_t size) +{ struct idxform *hash; if ((hash = get_hash_id(*(st->uSPIidentchoice))) == NULL) { log_print("Unkown identity choice %d in create_verification_key", *(st->uSPIidentchoice)); - return 0; + return 0; } if (varpre2octets(buffer) != hash->hashsize +2) @@ -575,13 +575,13 @@ verify_identity_verification(struct stateob *st, u_int8_t *buffer, state_save_verification(st, buffer, hash->hashsize+2); - return idverify(st, hash, buffer+2, packet, size); -} + return idverify(st, hash, buffer+2, packet, size); +} int -idsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, - u_int8_t *packet, u_int16_t psize) +idsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, + u_int8_t *packet, u_int16_t psize) { u_int8_t key[HASH_MAX]; u_int16_t keylen = HASH_MAX; @@ -591,15 +591,15 @@ idsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, hash->Init(hash->ctx); /* Our verification key */ - hash->Update(hash->ctx, key, keylen); + hash->Update(hash->ctx, key, keylen); /* Key fill */ hash->Final(NULL, hash->ctx); - /* + /* * Hash Cookies, type, lifetime + spi fields + - * SPI owner Identity Choice + Identity + * SPI owner Identity Choice + Identity */ - hash->Update(hash->ctx, packet, IDENTITY_MESSAGE_MIN + + hash->Update(hash->ctx, packet, IDENTITY_MESSAGE_MIN + st->oSPIidentchoicesize + varpre2octets(st->oSPIident)); if(st->uSPIident != NULL) { @@ -617,7 +617,7 @@ idsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, /* Our exchange value */ hash->Update(hash->ctx, st->oSPITBV, 3); - hash->Update(hash->ctx, st->exchangevalue, st->exchangesize); + hash->Update(hash->ctx, st->exchangevalue, st->exchangesize); hash->Update(hash->ctx, st->oSPIoattrib, st->oSPIoattribsize); /* Their exchange value */ @@ -640,7 +640,7 @@ idsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, } int -idverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, +idverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, u_int8_t *packet, u_int16_t psize) { u_int8_t digest[HASH_MAX]; @@ -649,26 +649,26 @@ idverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, struct identity_message *p = (struct identity_message *)packet; create_verification_key(st, key, &keylen, 0); /* User direction */ - - hash->Init(hash->ctx); - + + hash->Init(hash->ctx); + /* Their verification key */ - hash->Update(hash->ctx, key, keylen); + hash->Update(hash->ctx, key, keylen); /* Key fill */ hash->Final(NULL, hash->ctx); - - /* + + /* * Hash Cookies, type, lifetime + spi fields + - * SPI owner Identity Choice + Identity + * SPI owner Identity Choice + Identity */ hash->Update(hash->ctx, packet, IDENTITY_MESSAGE_MIN + - st->uSPIidentchoicesize + varpre2octets(st->uSPIident)); + st->uSPIidentchoicesize + varpre2octets(st->uSPIident)); /* Determine if the sender knew our secret already */ if(p->type != IDENTITY_REQUEST) { - hash->Update(hash->ctx, st->oSPIidentver, st->oSPIidentversize); + hash->Update(hash->ctx, st->oSPIidentver, st->oSPIidentversize); } - + packet += IDENTITY_MESSAGE_MIN; psize -= IDENTITY_MESSAGE_MIN + packet[1] + 2; packet += packet[1] + 2; @@ -676,26 +676,26 @@ idverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, packet += varpre2octets(packet) + 2 + hash->hashsize; hash->Update(hash->ctx, packet, psize); - /* Their exchange value */ + /* Their exchange value */ hash->Update(hash->ctx, st->uSPITBV, 3); - hash->Update(hash->ctx, st->texchange, st->texchangesize); - hash->Update(hash->ctx, st->uSPIoattrib, st->uSPIoattribsize); - - /* Our exchange value */ + hash->Update(hash->ctx, st->texchange, st->texchangesize); + hash->Update(hash->ctx, st->uSPIoattrib, st->uSPIoattribsize); + + /* Our exchange value */ hash->Update(hash->ctx, st->oSPITBV, 3); - hash->Update(hash->ctx, st->exchangevalue, st->exchangesize); - hash->Update(hash->ctx, st->oSPIoattrib, st->oSPIoattribsize); + hash->Update(hash->ctx, st->exchangevalue, st->exchangesize); + hash->Update(hash->ctx, st->oSPIoattrib, st->oSPIoattribsize); /* Responder offered schemes */ - hash->Update(hash->ctx, st->roschemes, st->roschemesize); - + hash->Update(hash->ctx, st->roschemes, st->roschemesize); + /* Data fill */ - hash->Final(NULL, hash->ctx); + hash->Final(NULL, hash->ctx); /* And finally the trailing key */ hash->Update(hash->ctx, key, keylen); - hash->Final(digest, hash->ctx); + hash->Final(digest, hash->ctx); return !bcmp(digest, signature, hash->hashsize); } @@ -713,7 +713,7 @@ identity_insert(struct identity **idob, struct identity *ob) *idob = ob; return 1; } - + tmp=*idob; while(tmp->next!=NULL) tmp = tmp->next; @@ -755,7 +755,7 @@ identity_new(void) int identity_value_reset(struct identity *ob) -{ +{ if (ob->tag != NULL) free(ob->tag); if (ob->pairid != NULL) @@ -766,7 +766,7 @@ identity_value_reset(struct identity *ob) return 1; } -/* +/* * find the state ob with matching address */ diff --git a/sbin/photurisd/identity.h b/sbin/photurisd/identity.h index b5032f8e7a3..c4d7adf09a1 100644 --- a/sbin/photurisd/identity.h +++ b/sbin/photurisd/identity.h @@ -105,7 +105,7 @@ int get_secrets(struct stateob *st, int mode); int choose_identity(struct stateob *st, u_int8_t *packet, u_int16_t *size, u_int8_t *attributes, u_int16_t attribsize); u_int16_t get_identity_verification_size(struct stateob *st, u_int8_t *choice); -int create_identity_verification(struct stateob *st, u_int8_t *buffer, +int create_identity_verification(struct stateob *st, u_int8_t *buffer, u_int8_t *packet, u_int16_t size); int verify_identity_verification(struct stateob *st, u_int8_t *buffer, u_int8_t *packet, u_int16_t size); @@ -114,8 +114,8 @@ struct idxform *get_hash_id(int id); struct idxform *get_hash(enum hashes hashtype); int create_verification_key(struct stateob *, u_int8_t *, u_int16_t *, int); -int idsign(struct stateob *, struct idxform *, u_int8_t *, +int idsign(struct stateob *, struct idxform *, u_int8_t *, u_int8_t *, u_int16_t); -int idverify(struct stateob *, struct idxform *, u_int8_t *, +int idverify(struct stateob *, struct idxform *, u_int8_t *, u_int8_t *, u_int16_t); #endif diff --git a/sbin/photurisd/kernel.c b/sbin/photurisd/kernel.c index 32b424b164c..e39d2bffba5 100644 --- a/sbin/photurisd/kernel.c +++ b/sbin/photurisd/kernel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kernel.c,v 1.24 2001/07/07 18:26:18 deraadt Exp $ */ +/* $OpenBSD: kernel.c,v 1.25 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -41,7 +41,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: kernel.c,v 1.24 2001/07/07 18:26:18 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: kernel.c,v 1.25 2002/06/09 08:13:08 todd Exp $"; #endif #include <time.h> @@ -106,7 +106,7 @@ struct pfmsg { TAILQ_HEAD(pflist, pfmsg) pfqueue; /* - * Translate a Photuris ID into a data structure for the + * Translate a Photuris ID into a data structure for the * corresponding Kernel transform. */ @@ -115,7 +115,7 @@ kernel_get_transform(int id) { int i; - for (i=sizeof(xf)/sizeof(transform)-1; i >= 0; i--) + for (i=sizeof(xf)/sizeof(transform)-1; i >= 0; i--) if (xf[i].photuris_id == id) return &xf[i]; return NULL; @@ -130,7 +130,7 @@ kernel_transform_seen(int id, int type) { int i; - for (i=sizeof(xf)/sizeof(transform)-1; i >= 0; i--) + for (i=sizeof(xf)/sizeof(transform)-1; i >= 0; i--) if (xf[i].kernel_id == id && (xf[i].flags & type)) { LOG_DBG((LOG_KERNEL, 50, __FUNCTION__ ": %s algorithm %d", @@ -185,7 +185,7 @@ kernel_valid(attrib_t *enc, attrib_t *auth) xf_enc = kernel_get_transform(enc->id); xf_auth = kernel_get_transform(auth->id); - if (xf_enc->flags & ESP_OLD) + if (xf_enc->flags & ESP_OLD) return AT_ENC; if (!(xf_auth->flags & ESP_NEW)) return AT_AUTH; @@ -222,16 +222,16 @@ kernel_valid_auth(attrib_t *auth, u_int8_t *flag, u_int16_t size) return (-1); return (0); -} +} int init_kernel(void) { TAILQ_INIT(&pfqueue); - if ((sd = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) == -1) + if ((sd = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) == -1) log_fatal(__FUNCTION__": socket(PF_KEY) for IPsec key engine"); - if ((regsd = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) == -1) + if ((regsd = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) == -1) log_fatal(__FUNCTION__": socket() for PFKEY register"); pfkey_seq = 0; @@ -239,7 +239,7 @@ init_kernel(void) if (kernel_register(regsd) == -1) log_fatal(__FUNCTION__": PFKEY socket registration failed"); - + return (1); } @@ -373,8 +373,8 @@ kernel_xf_read(int sd, char *buffer, int blen, int seq) log_error(__FUNCTION__": read()"); return (0); } - - forus = !(sres->sadb_msg_pid && + + forus = !(sres->sadb_msg_pid && sres->sadb_msg_pid != pfkey_pid) && !(seq && sres->sadb_msg_seq != seq); @@ -391,9 +391,9 @@ kernel_xf_read(int sd, char *buffer, int blen, int seq) break; } } - + } while (!forus); - + if (sres->sadb_msg_errno) { LOG_DBG((LOG_KERNEL, 40, __FUNCTION__": PFKEYV2 result: %s", strerror(sres->sadb_msg_errno))); @@ -485,7 +485,7 @@ kernel_register(int sd) authfound == 0 ? "authentication" : ""); return (-1); } - + return (0); } @@ -499,7 +499,7 @@ kernel_reserve_spi(char *src, char *dst, int options) options & IPSEC_OPT_ENC ? "ESP" : "", options & IPSEC_OPT_AUTH ? "AH" : "")); - if ((options & (IPSEC_OPT_ENC|IPSEC_OPT_AUTH)) != + if ((options & (IPSEC_OPT_ENC|IPSEC_OPT_AUTH)) != (IPSEC_OPT_ENC|IPSEC_OPT_AUTH)) { switch(options & (IPSEC_OPT_ENC|IPSEC_OPT_AUTH)) { case IPSEC_OPT_ENC: @@ -514,7 +514,7 @@ kernel_reserve_spi(char *src, char *dst, int options) if (!(spi = kernel_reserve_single_spi(src, dst, 0, IPPROTO_ESP))) return spi; - + /* Try to get the same spi for ah and esp */ while (!kernel_reserve_single_spi(src, dst, spi, IPPROTO_AH)) { kernel_delete_spi(src, spi, IPPROTO_ESP); @@ -551,7 +551,7 @@ kernel_reserve_single_spi(char *srcaddress, char *dstaddress, u_int32_t spi, smsg.sadb_msg_seq = pfkey_seq++; smsg.sadb_msg_pid = pfkey_pid; smsg.sadb_msg_type = SADB_GETSPI; - smsg.sadb_msg_satype = proto == IPPROTO_AH ? + smsg.sadb_msg_satype = proto == IPPROTO_AH ? SADB_SATYPE_AH : SADB_SATYPE_ESP; iov[cnt].iov_base = &smsg; iov[cnt++].iov_len = sizeof(smsg); @@ -597,7 +597,7 @@ kernel_reserve_single_spi(char *srcaddress, char *dstaddress, u_int32_t spi, iov[cnt].iov_base = &sspi; iov[cnt++].iov_len = sizeof(sspi); smsg.sadb_msg_len += sspi.sadb_spirange_len; - + /* get back SADB_EXT_SA */ if (!KERNEL_XF_SET(smsg.sadb_msg_len*8)) { @@ -682,7 +682,7 @@ kernel_ah(attrib_t *ob, struct spiob *SPI, u_int8_t *secrets, int hmac) sa.sadb_msg_len = sizeof(sa) / 8; sa.sadb_msg_version = PF_KEY_V2; - sa.sadb_msg_type = SPI->flags & SPI_OWNER ? + sa.sadb_msg_type = SPI->flags & SPI_OWNER ? SADB_UPDATE : SADB_ADD; sa.sadb_msg_satype = SADB_SATYPE_AH; sa.sadb_msg_seq = pfkey_seq++; @@ -695,7 +695,7 @@ kernel_ah(attrib_t *ob, struct spiob *SPI, u_int8_t *secrets, int hmac) sad1.sadb_address_exttype = SADB_EXT_ADDRESS_SRC; src.sin_family = AF_INET; src.sin_len = sizeof(struct sockaddr_in); - src.sin_addr.s_addr = inet_addr(SPI->flags & SPI_OWNER ? + src.sin_addr.s_addr = inet_addr(SPI->flags & SPI_OWNER ? SPI->address : SPI->local_address); sa.sadb_msg_len += sad1.sadb_address_len; @@ -842,7 +842,7 @@ kernel_esp(attrib_t *ob, attrib_t *ob2, struct spiob *SPI, u_int8_t *secrets) sad1.sadb_address_exttype = SADB_EXT_ADDRESS_SRC; src.sin_family = AF_INET; src.sin_len = sizeof(struct sockaddr_in); - src.sin_addr.s_addr = inet_addr(SPI->flags & SPI_OWNER ? + src.sin_addr.s_addr = inet_addr(SPI->flags & SPI_OWNER ? SPI->address : SPI->local_address); sa.sadb_msg_len += sad1.sadb_address_len; @@ -895,7 +895,7 @@ kernel_esp(attrib_t *ob, attrib_t *ob2, struct spiob *SPI, u_int8_t *secrets) log_error(__FUNCTION__": kernel_xf_set()"); return (-1); } - + return attenc->klen + (attauth ? attauth->klen : 0); } @@ -906,63 +906,63 @@ kernel_esp(attrib_t *ob, attrib_t *ob2, struct spiob *SPI, u_int8_t *secrets) int kernel_delete_spi(char *address, u_int32_t spi, int proto) { - struct sadb_msg sa; - struct sadb_sa sr; - struct sadb_address sad1; - struct sadb_address sad2; + struct sadb_msg sa; + struct sadb_sa sr; + struct sadb_address sad1; + struct sadb_address sad2; union sockaddr_union src, dst; - struct iovec iov[10]; - int cnt = 0; - - bzero(&sa, sizeof(sa)); - bzero(&sad1, sizeof(sad1)); - bzero(&sad2, sizeof(sad2)); - bzero(&sr, sizeof(sr)); - bzero(&src, sizeof(src)); - bzero(&dst, sizeof(dst)); - - sa.sadb_msg_version = PF_KEY_V2; - sa.sadb_msg_type = SADB_DELETE; + struct iovec iov[10]; + int cnt = 0; + + bzero(&sa, sizeof(sa)); + bzero(&sad1, sizeof(sad1)); + bzero(&sad2, sizeof(sad2)); + bzero(&sr, sizeof(sr)); + bzero(&src, sizeof(src)); + bzero(&dst, sizeof(dst)); + + sa.sadb_msg_version = PF_KEY_V2; + sa.sadb_msg_type = SADB_DELETE; sa.sadb_msg_satype = proto == IPPROTO_ESP ? - SADB_SATYPE_ESP : SADB_SATYPE_AH; - sa.sadb_msg_seq = pfkey_seq++; - sa.sadb_msg_pid = pfkey_pid; - + SADB_SATYPE_ESP : SADB_SATYPE_AH; + sa.sadb_msg_seq = pfkey_seq++; + sa.sadb_msg_pid = pfkey_pid; + /* Source Address */ - sad1.sadb_address_len = 1 + sizeof(struct sockaddr_in) / 8; - sad1.sadb_address_exttype = SADB_EXT_ADDRESS_SRC; + sad1.sadb_address_len = 1 + sizeof(struct sockaddr_in) / 8; + sad1.sadb_address_exttype = SADB_EXT_ADDRESS_SRC; + + src.sin.sin_family = AF_INET; + src.sin.sin_len = sizeof(struct sockaddr_in); - src.sin.sin_family = AF_INET; - src.sin.sin_len = sizeof(struct sockaddr_in); - /* Destination Address */ - sad2.sadb_address_len = 1 + sizeof(struct sockaddr_in) / 8; - sad2.sadb_address_exttype = SADB_EXT_ADDRESS_DST; - - dst.sin.sin_family = AF_INET; - dst.sin.sin_len = sizeof(struct sockaddr_in); - dst.sin.sin_addr.s_addr = inet_addr(address); - - sr.sadb_sa_exttype = SADB_EXT_SA; + sad2.sadb_address_len = 1 + sizeof(struct sockaddr_in) / 8; + sad2.sadb_address_exttype = SADB_EXT_ADDRESS_DST; + + dst.sin.sin_family = AF_INET; + dst.sin.sin_len = sizeof(struct sockaddr_in); + dst.sin.sin_addr.s_addr = inet_addr(address); + + sr.sadb_sa_exttype = SADB_EXT_SA; sr.sadb_sa_spi = htonl(spi); - sr.sadb_sa_len = sizeof(sr) / 8; - - sa.sadb_msg_len = 2 + sr.sadb_sa_len + sad2.sadb_address_len + - sad1.sadb_address_len; - - iov[cnt].iov_base = &sa; - iov[cnt++].iov_len = sizeof(sa); - iov[cnt].iov_base = &sad1; - iov[cnt++].iov_len = sizeof(sad1); - iov[cnt].iov_base = &src; - iov[cnt++].iov_len = sizeof(struct sockaddr); - iov[cnt].iov_base = &sad2; - iov[cnt++].iov_len = sizeof(sad2); + sr.sadb_sa_len = sizeof(sr) / 8; + + sa.sadb_msg_len = 2 + sr.sadb_sa_len + sad2.sadb_address_len + + sad1.sadb_address_len; + + iov[cnt].iov_base = &sa; + iov[cnt++].iov_len = sizeof(sa); + iov[cnt].iov_base = &sad1; + iov[cnt++].iov_len = sizeof(sad1); + iov[cnt].iov_base = &src; + iov[cnt++].iov_len = sizeof(struct sockaddr); + iov[cnt].iov_base = &sad2; + iov[cnt++].iov_len = sizeof(sad2); iov[cnt].iov_base = &dst; - iov[cnt++].iov_len = sizeof(struct sockaddr); - iov[cnt].iov_base = &sr; - iov[cnt++].iov_len = sizeof(sr); - + iov[cnt++].iov_len = sizeof(struct sockaddr); + iov[cnt].iov_base = &sr; + iov[cnt++].iov_len = sizeof(sr); + LOG_DBG((LOG_KERNEL, 30, __FUNCTION__": %08x", spi)); @@ -1063,7 +1063,7 @@ kernel_insert_spi(struct stateob *st, struct spiob *SPI) offset = kernel_ah(atah, SPI, secrets, hmac); if (offset == -1) return (-1); - secrets += offset; + secrets += offset; } if (esp != NULL) { @@ -1074,7 +1074,7 @@ kernel_insert_spi(struct stateob *st, struct spiob *SPI) SPI->flags &= ~SPI_ESP; } - /* + /* * Inform the kernel that we obtained the requested SA */ kernel_notify_result(st, SPI, proto); @@ -1105,17 +1105,17 @@ kernel_unlink_spi(struct spiob *ospi) p = ospi->address; else p = ospi->local_address; - + get_attrib_section(ospi->attributes, ospi->attribsize, &esp, &espsize, AT_ESP_ATTRIB); get_attrib_section(ospi->attributes, ospi->attribsize, &ah, &ahsize, AT_AH_ATTRIB); - + if (esp != NULL) { if (kernel_delete_spi(p, SPITOINT(ospi->SPI), IPPROTO_ESP) == -1) log_print(__FUNCTION__": kernel_delete_spi() failed"); } - + if (ah != NULL) { if (kernel_delete_spi(p, SPITOINT(ospi->SPI), IPPROTO_AH) == -1) log_print(__FUNCTION__": kernel_delete_spi() failed"); @@ -1141,13 +1141,13 @@ kernel_dispatch_notify(struct sadb_msg *sres) sres->sadb_msg_len * 8)); LOG_DBG_BUF((LOG_KERNEL, 60, "acquire buf", (u_char *)sres, sres->sadb_msg_len * 8)); - + kernel_request_sa(sres); break; default: /* discard silently */ - return; + return; } } @@ -1283,7 +1283,7 @@ kernel_handle_expire(struct sadb_msg *sadb) break; default: log_error(__FUNCTION__ - ": unsupported address family %d", + ": unsupported address family %d", dstaddr->sa_family); return (-1); } @@ -1399,12 +1399,12 @@ kernel_new_exchange(char *address, int type) } /* - * Tries to establish a new SA according to the information in a + * Tries to establish a new SA according to the information in a * REQUEST_SA notify message received from the kernel. */ int -kernel_request_sa(struct sadb_msg *sadb) +kernel_request_sa(struct sadb_msg *sadb) { struct stateob *st; time_t tm; @@ -1439,7 +1439,7 @@ kernel_request_sa(struct sadb_msg *sadb) break; default: log_error(__FUNCTION__ - ": unsupported address family %d", + ": unsupported address family %d", dstaddr->sa_family); return (-1); } @@ -1456,12 +1456,12 @@ kernel_request_sa(struct sadb_msg *sadb) if (st) { struct sockaddr_in sin; - /* + /* * We need different attributes for this exchange, send * an SPI_NEEDED message. */ - packet_size = PACKET_BUFFER_SIZE; + packet_size = PACKET_BUFFER_SIZE; if (photuris_spi_needed(st, packet_buffer, &packet_size, st->uSPIattrib, st->uSPIattribsize) == -1) { @@ -1470,10 +1470,10 @@ kernel_request_sa(struct sadb_msg *sadb) } /* Send the packet */ - sin.sin_port = htons(st->port); - sin.sin_family = AF_INET; + sin.sin_port = htons(st->port); + sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(st->address); - + if (sendto(global_socket, packet_buffer, packet_size, 0, (struct sockaddr *)&sin, sizeof(sin)) != packet_size) { log_error(__FUNCTION__": sendto()"); @@ -1507,12 +1507,12 @@ kernel_notify_result(struct stateob *st, struct spiob *spi, int proto) em.em_version = PFENCAP_VERSION_1; em.em_not_type = NOTIFY_REQUEST_SA; if (spi != NULL) { - em.em_not_spi = htonl((spi->SPI[0]<<24) + (spi->SPI[1]<<16) + + em.em_not_spi = htonl((spi->SPI[0]<<24) + (spi->SPI[1]<<16) + (spi->SPI[2]<<8) + spi->SPI[3]); em.em_not_dst.s_addr = inet_addr(spi->address); em.em_not_src.s_addr = inet_addr(spi->local_address); em.em_not_sproto = proto; - } + } if (st != NULL) { em.em_not_dst.s_addr = inet_addr(st->address); em.em_not_sport = st->sport; diff --git a/sbin/photurisd/kernel.h b/sbin/photurisd/kernel.h index 5f23c6c1567..3903ba476d5 100644 --- a/sbin/photurisd/kernel.h +++ b/sbin/photurisd/kernel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kernel.h,v 1.12 2001/01/28 22:45:11 niklas Exp $ */ +/* $OpenBSD: kernel.h,v 1.13 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,10 +29,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * kernel.h: + * kernel.h: * security paramter index creation. */ - + #ifndef _KERNEL_H_ #define _KERNEL_H_ @@ -55,7 +55,7 @@ typedef struct { int kernel_id, flags; } transform; -/* +/* * Translation from Photuris Attributes to Kernel Transforms. * For the actual ids see: draft-simpson-photuris-*.txt and * draft-simpson-photuris-schemes-*.txt @@ -84,7 +84,7 @@ int kernel_xf_set(int sd, char *buf, int blen, struct iovec *io, int cnt, int kernel_xf_read(int sd, char *buf, int blen, int seq); int kernel_ah(attrib_t *ob, struct spiob *SPI, u_int8_t *secrets, int hmac); -int kernel_esp(attrib_t *ob, attrib_t *ob2, struct spiob *SPI, +int kernel_esp(attrib_t *ob, attrib_t *ob2, struct spiob *SPI, u_int8_t *secrets); int kernel_group_spi(char *address, u_int8_t *spi); @@ -104,7 +104,7 @@ EXTERN int kernel_known_transform(int id); EXTERN int kernel_valid(attrib_t *enc, attrib_t *auth); EXTERN int kernel_valid_auth(attrib_t *auth, u_int8_t *flag, u_int16_t size); -EXTERN u_int32_t kernel_reserve_spi(char *srcaddress, char *dstaddress, +EXTERN u_int32_t kernel_reserve_spi(char *srcaddress, char *dstaddress, int options); EXTERN u_int32_t kernel_reserve_single_spi(char *srcaddress, char *dstaddress, u_int32_t spi, int proto); diff --git a/sbin/photurisd/log.c b/sbin/photurisd/log.c index 06aebe15216..73f8912803a 100644 --- a/sbin/photurisd/log.c +++ b/sbin/photurisd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.3 2002/02/19 19:39:38 millert Exp $ */ +/* $OpenBSD: log.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* $EOM: log.c,v 1.30 2000/09/29 08:19:23 niklas Exp $ */ /* @@ -88,11 +88,11 @@ _log_get_class (int error_class) } static void -_log_print (int error, int syslog_level, const char *fmt, va_list ap, +_log_print (int error, int syslog_level, const char *fmt, va_list ap, int class, int level) { char buffer[LOG_SIZE], nbuf[LOG_SIZE + 32]; - static const char fallback_msg[] = + static const char fallback_msg[] = "write to log file failed (errno %d), redirecting output to syslog"; int len; struct tm *tm; @@ -108,11 +108,11 @@ _log_print (int error, int syslog_level, const char *fmt, va_list ap, t = now.tv_sec; tm = localtime (&t); if (class >= 0) - sprintf (nbuf, "%02d%02d%02d.%06ld %s %02d ", tm->tm_hour, - tm->tm_min, tm->tm_sec, now.tv_usec, _log_get_class (class), + sprintf (nbuf, "%02d%02d%02d.%06ld %s %02d ", tm->tm_hour, + tm->tm_min, tm->tm_sec, now.tv_usec, _log_get_class (class), level); else /* LOG_PRINT (-1) or LOG_REPORT (-2) */ - sprintf (nbuf, "%02d%02d%02d.%06ld %s ", tm->tm_hour, + sprintf (nbuf, "%02d%02d%02d.%06ld %s ", tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec, class == LOG_PRINT ? "Default" : "Report>"); strcat (nbuf, buffer); @@ -124,11 +124,11 @@ _log_print (int error, int syslog_level, const char *fmt, va_list ap, syslog (LOG_ALERT, fallback_msg, errno); fprintf (log_output, fallback_msg, errno); - /* + /* * Close log_output to prevent isakmpd from locking the file. * We may need to explicitly close stdout to do this properly. * XXX - Figure out how to match two FILE *'s and rewrite. - */ + */ if (fileno (log_output) != -1) if (fileno (stdout) == fileno (log_output)) fclose (stdout); diff --git a/sbin/photurisd/log.h b/sbin/photurisd/log.h index 53c4d774a4b..9a0e6f4626c 100644 --- a/sbin/photurisd/log.h +++ b/sbin/photurisd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.3 2000/12/15 07:29:45 provos Exp $ */ +/* $OpenBSD: log.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* $EOM: log.h,v 1.19 2000/03/30 14:27:23 ho Exp $ */ /* @@ -47,7 +47,7 @@ #define LOG_SIZE 200 enum log_classes { - LOG_MISC, LOG_PROTOCOL, LOG_CRYPTO, LOG_TIMER, LOG_SPI, LOG_KERNEL, + LOG_MISC, LOG_PROTOCOL, LOG_CRYPTO, LOG_TIMER, LOG_SPI, LOG_KERNEL, LOG_ENDCLASS }; #define LOG_CLASSES_TEXT \ diff --git a/sbin/photurisd/modulus.c b/sbin/photurisd/modulus.c index 682bca9b53c..8c81e66049d 100644 --- a/sbin/photurisd/modulus.c +++ b/sbin/photurisd/modulus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modulus.c,v 1.6 2001/07/07 18:26:18 deraadt Exp $ */ +/* $OpenBSD: modulus.c,v 1.7 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -72,7 +72,7 @@ mod_unlink(struct moduli_cache *ob) return (0); } -/* +/* * Check moduli for primality: * check iter iterations, remain at max tm seconds here * tm == 0, check all. @@ -113,7 +113,7 @@ mod_check_prime(int iter, int tm) } tmp = mod_find_modulus_next(tmp, p->modulus); } -#ifdef USE_DEBUG +#ifdef USE_DEBUG { char *hex, *msg; if (!flag) @@ -122,14 +122,14 @@ mod_check_prime(int iter, int tm) msg = "probably prime."; else msg = "undecided."; - hex = BN_bn2hex(p->modulus); + hex = BN_bn2hex(p->modulus); LOG_DBG((LOG_CRYPTO, 50, __FUNCTION__ - ": check prime: %s: %s", + ": check prime: %s: %s", hex, msg)); - free(hex); + free(hex); } #endif - } + } if (p->status == MOD_NOTPRIME && p->lifetime < now) { LOG_DBG((LOG_CRYPTO, 40, __FUNCTION__ @@ -161,9 +161,9 @@ mod_new_modgen(BIGNUM *m, BIGNUM *g) return p; } -struct moduli_cache * -mod_new_modulus(BIGNUM *m) -{ +struct moduli_cache * +mod_new_modulus(BIGNUM *m) +{ struct moduli_cache *tmp; BIGNUM *generator; @@ -176,7 +176,7 @@ mod_new_modulus(BIGNUM *m) int mod_value_reset(struct moduli_cache *ob) -{ +{ BN_clear_free(ob->private_value); BN_clear_free(ob->modulus); BN_clear_free(ob->generator); @@ -200,14 +200,14 @@ mod_find_modgen_next(struct moduli_cache *ob, BIGNUM *modulus, else ob = TAILQ_FIRST(&modhead); - for ( ; ob; ob = TAILQ_NEXT(ob, next)) { - if ((BN_is_zero(generator) || - !BN_cmp(ob->generator, generator)) && - (BN_is_zero(modulus) || !BN_cmp(modulus, ob->modulus))) - break; - } + for ( ; ob; ob = TAILQ_NEXT(ob, next)) { + if ((BN_is_zero(generator) || + !BN_cmp(ob->generator, generator)) && + (BN_is_zero(modulus) || !BN_cmp(modulus, ob->modulus))) + break; + } - return (ob); + return (ob); } struct moduli_cache * @@ -216,56 +216,56 @@ mod_find_modgen(BIGNUM *modulus, BIGNUM *generator) return (mod_find_modgen_next(NULL, modulus, generator)); } -struct moduli_cache * +struct moduli_cache * mod_find_generator_next(struct moduli_cache *ob, BIGNUM *generator) { struct moduli_cache *tmp; - BIGNUM *modulus; - + BIGNUM *modulus; + modulus = BN_new(); BN_zero(modulus); - tmp = mod_find_modgen_next(ob, modulus, generator); + tmp = mod_find_modgen_next(ob, modulus, generator); + + BN_free(modulus); - BN_free(modulus); - - return (tmp); -} + return (tmp); +} -struct moduli_cache * -mod_find_generator(BIGNUM *generator) -{ +struct moduli_cache * +mod_find_generator(BIGNUM *generator) +{ struct moduli_cache *tmp; - BIGNUM *modulus; - + BIGNUM *modulus; + modulus = BN_new(); BN_zero(modulus); - tmp = mod_find_modgen(modulus,generator); + tmp = mod_find_modgen(modulus,generator); + + BN_free(modulus); - BN_free(modulus); - - return (tmp); -} + return (tmp); +} -struct moduli_cache * -mod_find_modulus_next(struct moduli_cache *ob, BIGNUM *modulus) -{ +struct moduli_cache * +mod_find_modulus_next(struct moduli_cache *ob, BIGNUM *modulus) +{ struct moduli_cache *tmp; - BIGNUM *generator; - + BIGNUM *generator; + generator = BN_new(); BN_zero(generator); - tmp = mod_find_modgen_next(ob, modulus, generator); + tmp = mod_find_modgen_next(ob, modulus, generator); + + BN_free(generator); - BN_free(generator); - - return (tmp); -} + return (tmp); +} -struct moduli_cache * -mod_find_modulus(BIGNUM *modulus) +struct moduli_cache * +mod_find_modulus(BIGNUM *modulus) { struct moduli_cache *tmp; BIGNUM *generator; diff --git a/sbin/photurisd/modulus.h b/sbin/photurisd/modulus.h index 935f06abe94..8fdf7539230 100644 --- a/sbin/photurisd/modulus.h +++ b/sbin/photurisd/modulus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: modulus.h,v 1.4 2001/01/28 22:45:12 niklas Exp $ */ +/* $OpenBSD: modulus.h,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -28,10 +28,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * modulus.h: +/* + * modulus.h: * modulus handling functions - */ + */ #ifndef _MODULUS_H_ #define _MODULUS_H_ diff --git a/sbin/photurisd/packet.c b/sbin/photurisd/packet.c index a7c85787a3a..2b2d6c141ef 100644 --- a/sbin/photurisd/packet.c +++ b/sbin/photurisd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.4 2001/01/28 22:45:12 niklas Exp $ */ +/* $OpenBSD: packet.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,20 +35,20 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: packet.c,v 1.4 2001/01/28 22:45:12 niklas Exp $"; +static char rcsid[] = "$OpenBSD: packet.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; #endif #define _PACKET_C_ #include <stdlib.h> -#include <stdio.h> +#include <stdio.h> #include <string.h> #include <ctype.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <sys/time.h> -#include <arpa/inet.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <sys/time.h> +#include <arpa/inet.h> #include "state.h" #include "photuris.h" #include "packets.h" @@ -81,17 +81,17 @@ int handle_packet(int sock, char *address) #ifdef DEBUG i = BUFFER_SIZE; bin2hex(buffer, &i, header->icookie, 16); - printf("%s: Received %d bytes from %s, type %d with icookie: 0x%s\n", + printf("%s: Received %d bytes from %s, type %d with icookie: 0x%s\n", address, size, inet_ntoa(sin.sin_addr), header->type, buffer); #endif switch(header->type) { case COOKIE_REQUEST: - if (handle_cookie_request(recv_buffer, size, - inet_ntoa(sin.sin_addr), + if (handle_cookie_request(recv_buffer, size, + inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), - global_schemes, global_schemesize) + global_schemes, global_schemesize) == -1) { log_print("handle_cookie_request() in handle_packet()"); return -1; @@ -101,9 +101,9 @@ int handle_packet(int sock, char *address) if (handle_cookie_response(recv_buffer, size, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)) == -1) { - log_print("handle_cookie_response() in handle_packet()"); - return -1; - } + log_print("handle_cookie_response() in handle_packet()"); + return -1; + } break; case VALUE_REQUEST: if (handle_value_request(recv_buffer, size, @@ -111,49 +111,49 @@ int handle_packet(int sock, char *address) ntohs(sin.sin_port), global_schemes, global_schemesize) == -1) { - log_print("handle_value_request() in handle_packet()"); - return -1; - } + log_print("handle_value_request() in handle_packet()"); + return -1; + } break; case VALUE_RESPONSE: - if (handle_value_response(recv_buffer, size, + if (handle_value_response(recv_buffer, size, inet_ntoa(sin.sin_addr), - address) == -1) { - log_print("handle_value_response() in handle_packet()"); - return -1; - } + address) == -1) { + log_print("handle_value_response() in handle_packet()"); + return -1; + } break; case IDENTITY_REQUEST: - if (handle_identity_request(recv_buffer, size, + if (handle_identity_request(recv_buffer, size, inet_ntoa(sin.sin_addr), - address) == -1) { - log_print("handle_identity_request() in handle_packet()"); - return -1; - } + address) == -1) { + log_print("handle_identity_request() in handle_packet()"); + return -1; + } break; - case IDENTITY_RESPONSE: - if (handle_identity_response(recv_buffer, size, - inet_ntoa(sin.sin_addr), - address) == -1) { + case IDENTITY_RESPONSE: + if (handle_identity_response(recv_buffer, size, + inet_ntoa(sin.sin_addr), + address) == -1) { log_print("handle_identity_response() in handle_packet()"); - return -1; - } - break; + return -1; + } + break; case SPI_UPDATE: if (handle_spi_update(recv_buffer, size, inet_ntoa(sin.sin_addr), address) == -1) { log_print("handle_spi_update() in handle_packet()"); - return -1; - } + return -1; + } break; case SPI_NEEDED: if (handle_spi_needed(recv_buffer, size, inet_ntoa(sin.sin_addr), address) == -1) { log_print("handle_spi_needed() in handle_packet()"); - return -1; - } + return -1; + } break; case BAD_COOKIE: if (handle_bad_cookie(recv_buffer, size, @@ -163,28 +163,28 @@ int handle_packet(int sock, char *address) } break; case RESOURCE_LIMIT: - if (handle_resource_limit(recv_buffer, size, - inet_ntoa(sin.sin_addr)) == -1) { - log_print("handle_resource_limit() in handle_packet()"); - return -1; - } + if (handle_resource_limit(recv_buffer, size, + inet_ntoa(sin.sin_addr)) == -1) { + log_print("handle_resource_limit() in handle_packet()"); + return -1; + } break; case VERIFICATION_FAILURE: - if (handle_verification_failure(recv_buffer, size, - inet_ntoa(sin.sin_addr)) == -1) { + if (handle_verification_failure(recv_buffer, size, + inet_ntoa(sin.sin_addr)) == -1) { log_print("handle_verification_failure() in handle_packet()"); - return -1; - } - break; + return -1; + } + break; case MESSAGE_REJECT: - if (handle_message_reject(recv_buffer, size, + if (handle_message_reject(recv_buffer, size, inet_ntoa(sin.sin_addr)) == -1) { log_print("handle_message_reject() in handle_packet()"); return -1; } break; default: - log_print("Unknown packet type %d in handle_packet()", + log_print("Unknown packet type %d in handle_packet()", header->type); return 0; } @@ -195,20 +195,20 @@ int handle_packet(int sock, char *address) void send_packet(void) { -#ifdef DEBUG +#ifdef DEBUG struct cookie_request *header = (struct cookie_request *)packet_buffer; - int i = BUFFER_SIZE; - bin2hex(buffer, &i, header->icookie, 16); - printf("Sending %d bytes to %s, type %d with icookie: 0x%s\n", - packet_size, inet_ntoa(sin.sin_addr), header->type, buffer); -#endif + int i = BUFFER_SIZE; + bin2hex(buffer, &i, header->icookie, 16); + printf("Sending %d bytes to %s, type %d with icookie: 0x%s\n", + packet_size, inet_ntoa(sin.sin_addr), header->type, buffer); +#endif /* We constructed a valid response packet here, send it off. */ - if (sendto(global_socket, packet_buffer, packet_size, 0, - (struct sockaddr *) &sin, sizeof(sin)) != packet_size) { - /* XXX Code to notify kernel of failure */ - log_error("sendto() in handle_packet()"); - return; - } + if (sendto(global_socket, packet_buffer, packet_size, 0, + (struct sockaddr *) &sin, sizeof(sin)) != packet_size) { + /* XXX Code to notify kernel of failure */ + log_error("sendto() in handle_packet()"); + return; + } } /* @@ -319,7 +319,7 @@ packet_dump(u_int8_t *packet, u_int16_t plen, u_int16_t start) { char tmp[73], dump[33]; int i, size, len, off; - + off = 0; while (off < plen) { memset(tmp, ' ', sizeof(tmp)); diff --git a/sbin/photurisd/packet.h b/sbin/photurisd/packet.h index 88ed44902b9..f87b2311c10 100644 --- a/sbin/photurisd/packet.h +++ b/sbin/photurisd/packet.h @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.h,v 1.3 2001/01/28 22:45:12 niklas Exp $ */ +/* $OpenBSD: packet.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,10 +29,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * packet.h: + * packet.h: * prototyped for receiving and anwsering packets */ - + #ifndef _PACKET_H_ #define _PACKET_H_ diff --git a/sbin/photurisd/packets.h b/sbin/photurisd/packets.h index b149b94d55e..6ff00dd7da7 100644 --- a/sbin/photurisd/packets.h +++ b/sbin/photurisd/packets.h @@ -1,4 +1,4 @@ -/* $OpenBSD: packets.h,v 1.3 2001/01/28 22:45:12 niklas Exp $ */ +/* $OpenBSD: packets.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -130,39 +130,39 @@ struct identity_message { #define IDENTITY_MESSAGE_CHOICE(p) (((u_int8_t *)(p))+IDENTITY_MESSAGE_MIN) #define IDENTITY_MESSAGE_IDENT(p) (IDENTITY_MESSAGE_CHOICE(p)+*((u_int8_t *)(p)+1)) -struct spi_needed { - u_int8_t icookie[COOKIE_SIZE]; - u_int8_t rcookie[COOKIE_SIZE]; - u_int8_t type; - u_int8_t reserved[7]; -}; +struct spi_needed { + u_int8_t icookie[COOKIE_SIZE]; + u_int8_t rcookie[COOKIE_SIZE]; + u_int8_t type; + u_int8_t reserved[7]; +}; #define SPI_NEEDED_MIN sizeof(struct spi_needed) #define SPI_NEEDED_VERIFICATION(p) (((u_int8_t *)(p))+SPI_NEEDED_MIN) -struct spi_update { - u_int8_t icookie[COOKIE_SIZE]; - u_int8_t rcookie[COOKIE_SIZE]; - u_int8_t type; - u_int8_t lifetime[3]; - u_int8_t SPI[SPI_SIZE]; -}; - -#define SPI_UPDATE_MIN sizeof(struct spi_update) -#define SPI_UPDATE_VERIFICATION(p) (((u_int8_t *)(p))+SPI_UPDATE_MIN) - -struct error_message { - u_int8_t icookie[COOKIE_SIZE]; - u_int8_t rcookie[COOKIE_SIZE]; - u_int8_t type; +struct spi_update { + u_int8_t icookie[COOKIE_SIZE]; + u_int8_t rcookie[COOKIE_SIZE]; + u_int8_t type; + u_int8_t lifetime[3]; + u_int8_t SPI[SPI_SIZE]; +}; + +#define SPI_UPDATE_MIN sizeof(struct spi_update) +#define SPI_UPDATE_VERIFICATION(p) (((u_int8_t *)(p))+SPI_UPDATE_MIN) + +struct error_message { + u_int8_t icookie[COOKIE_SIZE]; + u_int8_t rcookie[COOKIE_SIZE]; + u_int8_t type; }; #define ERROR_MESSAGE_PACKET_SIZE sizeof(struct error_message) -struct message_reject { - u_int8_t icookie[COOKIE_SIZE]; - u_int8_t rcookie[COOKIE_SIZE]; - u_int8_t type; +struct message_reject { + u_int8_t icookie[COOKIE_SIZE]; + u_int8_t rcookie[COOKIE_SIZE]; + u_int8_t type; u_int8_t badtype; u_int16_t offset; }; diff --git a/sbin/photurisd/photuris.h b/sbin/photurisd/photuris.h index 38bada09584..dca40e0bae2 100644 --- a/sbin/photurisd/photuris.h +++ b/sbin/photurisd/photuris.h @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris.h,v 1.4 2001/11/30 20:31:49 provos Exp $ */ +/* $OpenBSD: photuris.h,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -32,7 +32,7 @@ * photuris.h: * general header file */ - + #ifndef _PHOTURIS_H_ #define _PHOTURIS_H_ @@ -74,16 +74,16 @@ EXTERN int num_ifs; /* Packet creation functions */ int photuris_cookie_request(struct stateob *, u_char *, int *); -int photuris_cookie_response(struct stateob *, u_char *, int *, u_int8_t *, +int photuris_cookie_response(struct stateob *, u_char *, int *, u_int8_t *, u_int8_t, u_int8_t *, u_int16_t, u_int8_t *, u_int16_t); int photuris_value_request(struct stateob *, u_char *, int *); int photuris_value_response(struct stateob *, u_char *, int *); int photuris_identity_request(struct stateob *, u_char *, int *); int photuris_identity_response(struct stateob *, u_char *, int *); int photuris_spi_update(struct stateob *, u_char *, int *); -int photuris_spi_needed(struct stateob *, u_char *, int *, u_int8_t *, +int photuris_spi_needed(struct stateob *, u_char *, int *, u_int8_t *, u_int16_t); -int photuris_error_message(struct stateob *, u_char *, int *, char *, char *, +int photuris_error_message(struct stateob *, u_char *, int *, char *, char *, u_int8_t, u_int8_t); /* Packet handling functions */ diff --git a/sbin/photurisd/photuris_cookie_request.c b/sbin/photurisd/photuris_cookie_request.c index 0ea47236aaf..efda3a57021 100644 --- a/sbin/photurisd/photuris_cookie_request.c +++ b/sbin/photurisd/photuris_cookie_request.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_cookie_request.c,v 1.4 2001/01/28 22:45:13 niklas Exp $ */ +/* $OpenBSD: photuris_cookie_request.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_cookie_request.c,v 1.4 2001/01/28 22:45:13 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_cookie_request.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -72,7 +72,7 @@ photuris_cookie_request(struct stateob *st, u_char *buffer, int *size) old_st = prev_st; } } - + /* Check if we have an exchange going already */ if (old_st != NULL && old_st != st && timeout > time(NULL)) { if (old_st->initiator) { diff --git a/sbin/photurisd/photuris_error_message.c b/sbin/photurisd/photuris_error_message.c index 0b7974235e7..e673225b792 100644 --- a/sbin/photurisd/photuris_error_message.c +++ b/sbin/photurisd/photuris_error_message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_error_message.c,v 1.3 2001/01/28 22:45:13 niklas Exp $ */ +/* $OpenBSD: photuris_error_message.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_error_message.c,v 1.3 2001/01/28 22:45:13 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_error_message.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -54,12 +54,12 @@ photuris_error_message(struct stateob *st, u_char *buffer, int *size, { struct error_message *header; - if (*size < ERROR_MESSAGE_PACKET_SIZE + + if (*size < ERROR_MESSAGE_PACKET_SIZE + (error_type == RESOURCE_LIMIT ? 1 : 0)) return -1; /* buffer not large enough */ header = (struct error_message *) buffer; - *size = ERROR_MESSAGE_PACKET_SIZE + + *size = ERROR_MESSAGE_PACKET_SIZE + (error_type == RESOURCE_LIMIT ? 1 : 0); bcopy(icookie, header->icookie, COOKIE_SIZE); @@ -70,7 +70,7 @@ photuris_error_message(struct stateob *st, u_char *buffer, int *size, if (error_type == RESOURCE_LIMIT) { int i; buffer[ERROR_MESSAGE_PACKET_SIZE] = counter; - + for(i = 0; i<COOKIE_SIZE; i++) if (rcookie[i] != 0) break; diff --git a/sbin/photurisd/photuris_identity_request.c b/sbin/photurisd/photuris_identity_request.c index 17b8cb67996..ee3a7d971a4 100644 --- a/sbin/photurisd/photuris_identity_request.c +++ b/sbin/photurisd/photuris_identity_request.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_identity_request.c,v 1.3 2001/01/28 22:45:14 niklas Exp $ */ +/* $OpenBSD: photuris_identity_request.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_identity_request.c,v 1.3 2001/01/28 22:45:14 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_identity_request.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -82,19 +82,19 @@ photuris_identity_request(struct stateob *st, u_char *buffer, int *size) tmp = rsize; /* Remaining size */ /* Choose and Copy choice */ - if (choose_identity(st, p, &tmp, st->uSPIoattrib, - st->uSPIoattribsize) == -1 ) + if (choose_identity(st, p, &tmp, st->uSPIoattrib, + st->uSPIoattribsize) == -1 ) return -1; p += tmp; asize += tmp; rsize -= tmp; verifyp = p; - /* Leave space for verification data */ - tmp = get_identity_verification_size(st, IDENTITY_MESSAGE_CHOICE(header)); - - if (rsize < tmp) - return -1; /* buffer not large enough */ + /* Leave space for verification data */ + tmp = get_identity_verification_size(st, IDENTITY_MESSAGE_CHOICE(header)); + + if (rsize < tmp) + return -1; /* buffer not large enough */ /* Zero the buffer, so we can hash over it */ bzero(verifyp, tmp); @@ -111,14 +111,14 @@ photuris_identity_request(struct stateob *st, u_char *buffer, int *size) p += st->oSPIattribsize; tmp = rsize; - if(packet_create_padding(st, asize - IDENTITY_MESSAGE_MIN, - p, &tmp) == -1) - return -1; - - p += tmp; asize += tmp; rsize -= tmp; - - /* Create verification data */ - create_identity_verification(st, verifyp, (u_int8_t *)header, asize); + if(packet_create_padding(st, asize - IDENTITY_MESSAGE_MIN, + p, &tmp) == -1) + return -1; + + p += tmp; asize += tmp; rsize -= tmp; + + /* Create verification data */ + create_identity_verification(st, verifyp, (u_int8_t *)header, asize); #ifdef DEBUG2 printf("Identity-Request (before encryption):\n"); diff --git a/sbin/photurisd/photuris_identity_response.c b/sbin/photurisd/photuris_identity_response.c index cde263b6e79..822dc69d4bc 100644 --- a/sbin/photurisd/photuris_identity_response.c +++ b/sbin/photurisd/photuris_identity_response.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_identity_response.c,v 1.3 2001/01/28 22:45:14 niklas Exp $ */ +/* $OpenBSD: photuris_identity_response.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_identity_response.c,v 1.3 2001/01/28 22:45:14 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_identity_response.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -83,22 +83,22 @@ photuris_identity_response(struct stateob *st, u_char *buffer, int *size) /* Choose and Copy choice */ if (choose_identity(st, p, &tmp, st->uSPIoattrib, - st->uSPIoattribsize) == -1 ) + st->uSPIoattribsize) == -1 ) return -1; p += tmp; asize += tmp; rsize -= tmp; - verifyp = p; - - /* Leave space for verification data */ - tmp = get_identity_verification_size(st, IDENTITY_MESSAGE_CHOICE(header)); - - if (rsize < tmp) - return -1; /* buffer not large enough */ - - /* Zero the buffer, so we can hash over it */ - bzero(verifyp, tmp); - + verifyp = p; + + /* Leave space for verification data */ + tmp = get_identity_verification_size(st, IDENTITY_MESSAGE_CHOICE(header)); + + if (rsize < tmp) + return -1; /* buffer not large enough */ + + /* Zero the buffer, so we can hash over it */ + bzero(verifyp, tmp); + p += tmp; asize += tmp; rsize -= tmp; if (rsize < st->oSPIattribsize) @@ -111,22 +111,22 @@ photuris_identity_response(struct stateob *st, u_char *buffer, int *size) p += st->oSPIattribsize; tmp = rsize; - if(packet_create_padding(st, asize - IDENTITY_MESSAGE_MIN, + if(packet_create_padding(st, asize - IDENTITY_MESSAGE_MIN, p, &tmp) == -1) return -1; p += tmp; asize += tmp; rsize -= tmp; - /* Create verification data */ - create_identity_verification(st, verifyp, (u_int8_t *)header, asize); + /* Create verification data */ + create_identity_verification(st, verifyp, (u_int8_t *)header, asize); #ifdef DEBUG2 printf("Identity-Response (before encryption):\n"); packet_dump((u_int8_t *)header, asize, 0); #endif - + /* Encrypt the packet after SPI if wished for */ - packet_encrypt(st, IDENTITY_MESSAGE_CHOICE(header), + packet_encrypt(st, IDENTITY_MESSAGE_CHOICE(header), asize - IDENTITY_MESSAGE_MIN); *size = asize; diff --git a/sbin/photurisd/photuris_packet_encrypt.c b/sbin/photurisd/photuris_packet_encrypt.c index 69ca85a485e..579be12941f 100644 --- a/sbin/photurisd/photuris_packet_encrypt.c +++ b/sbin/photurisd/photuris_packet_encrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_packet_encrypt.c,v 1.4 2001/01/28 22:45:14 niklas Exp $ */ +/* $OpenBSD: photuris_packet_encrypt.c,v 1.5 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -34,13 +34,13 @@ * encrypts packets with the privacy choice. */ -#ifndef lint -static char rcsid[] = "$OpenBSD: photuris_packet_encrypt.c,v 1.4 2001/01/28 22:45:14 niklas Exp $"; -#endif +#ifndef lint +static char rcsid[] = "$OpenBSD: photuris_packet_encrypt.c,v 1.5 2002/06/09 08:13:08 todd Exp $"; +#endif #define _ENCRYPT_C_ - -#include <stdio.h> + +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -48,9 +48,9 @@ static char rcsid[] = "$OpenBSD: photuris_packet_encrypt.c,v 1.4 2001/01/28 22:4 #include <netinet/in.h> #include <arpa/inet.h> #include <des.h> -#include "config.h" -#include "packets.h" -#include "state.h" +#include "config.h" +#include "packets.h" +#include "state.h" #include "attributes.h" #include "encrypt.h" #include "secrets.h" @@ -68,15 +68,15 @@ packet_mask(u_int8_t *packet, u_int16_t len, u_int8_t *key) } int -packet_create_padding(struct stateob *st, u_int16_t size, u_int8_t *padd, +packet_create_padding(struct stateob *st, u_int16_t size, u_int8_t *padd, u_int16_t *rsize) { u_int8_t padlength, i; - switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: + switch(ntohs(*((u_int16_t *)st->scheme))) { + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: padlength = (arc4random() & 0xf0) - (size%16); if (padlength < 8) padlength += 8; @@ -87,13 +87,13 @@ packet_create_padding(struct stateob *st, u_int16_t size, u_int8_t *padd, padlength += 8; break; } - - if(*rsize < padlength) - return -1; - - /* Pad the rest of the payload */ - for(i=1;i<=padlength;i++) - padd[i-1] = i; + + if(*rsize < padlength) + return -1; + + /* Pad the rest of the payload */ + for(i=1;i<=padlength;i++) + padd[i-1] = i; *rsize = padlength; @@ -108,14 +108,14 @@ packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen) u_int8_t *pkey; u_int16_t order = 0; int i; - + input = (des_cblock *)payload; /* No encryption needed */ switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: #ifdef DEBUG printf("[Packet encryption: None]\n"); #endif @@ -124,24 +124,24 @@ packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen) log_error("Not enough memory for privacy secret"); return -1; } - if(compute_privacy_key(st, pkey, + if(compute_privacy_key(st, pkey, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, payloadlen*8, &order, 1) == -1) return -1; -#ifdef DEBUG - { - int i; - char buffer[3000]; - i = 3000; - bin2hex(buffer, &i, pkey, payloadlen); - printf("Encrypt key: %s\n", buffer ); - } -#endif +#ifdef DEBUG + { + int i; + char buffer[3000]; + i = 3000; + bin2hex(buffer, &i, pkey, payloadlen); + printf("Encrypt key: %s\n", buffer ); + } +#endif packet_mask(payload, payloadlen, pkey); return 0; - case DH_G_2_DES_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: + case DH_G_2_DES_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: #ifdef DEBUG printf("[Packet encryption: DES]\n"); #endif @@ -151,24 +151,24 @@ packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen) return -1; } /* XOR Mask */ - if(compute_privacy_key(st, pkey, + if(compute_privacy_key(st, pkey, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, payloadlen*8, &order, 1) == -1) return -1; /* DES Key */ - if(compute_privacy_key(st, pkey+payloadlen, + if(compute_privacy_key(st, pkey+payloadlen, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, 64, &order, 1) == -1) return -1; -#ifdef DEBUG - { - int i; - char buffer[3000]; - i = 3000; - bin2hex(buffer, &i, pkey, payloadlen+8); - printf("Encrypt key: %s\n", buffer ); - } -#endif +#ifdef DEBUG + { + int i; + char buffer[3000]; + i = 3000; + bin2hex(buffer, &i, pkey, payloadlen+8); + printf("Encrypt key: %s\n", buffer ); + } +#endif bcopy(pkey+payloadlen, &keys[0], 8); des_set_odd_parity(&keys[0]); @@ -181,9 +181,9 @@ packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen) des_cbc_encrypt(input,input,payloadlen, key1,&keys[1], DES_ENCRYPT); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: #ifdef DEBUG printf("[Packet encryption: 3DES]\n"); #endif @@ -193,19 +193,19 @@ packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen) return -1; } /* XOR Mask */ - if(compute_privacy_key(st, pkey, + if(compute_privacy_key(st, pkey, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, payloadlen*8, &order, 1) == -1) return -1; /* 3 DES Keys */ for (i=0; i<3; i++) { - if(compute_privacy_key(st, pkey+payloadlen + (i<<3), + if(compute_privacy_key(st, pkey+payloadlen + (i<<3), payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, 64, &order, 1) == -1) return -1; } #ifdef DEBUG - { + { int i; char buffer[3000]; i = 3000; @@ -232,16 +232,16 @@ packet_encrypt(struct stateob *st, u_int8_t *payload, u_int16_t payloadlen) des_ede3_cbc_encrypt(input, input, payloadlen, key1, key2, key3, &keys[3], DES_ENCRYPT); break; - default: - log_print("Unknown exchange scheme: %d\n", - *((u_int16_t *)st->scheme)); - return -1; + default: + log_print("Unknown exchange scheme: %d\n", + *((u_int16_t *)st->scheme)); + return -1; } free(pkey); return 0; -} +} int packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) @@ -256,9 +256,9 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) /* No encryption needed */ switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: #ifdef DEBUG printf("[Packet decryption: None]\n"); #endif @@ -267,23 +267,23 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) log_error("Not enough memory for privacy secret"); return -1; } - if(compute_privacy_key(st, pkey, + if(compute_privacy_key(st, pkey, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, *payloadlen*8, &order, 0) == -1) return -1; -#ifdef DEBUG - { - int i = 3000; - char buffer[3000]; - bin2hex(buffer, &i, pkey, *payloadlen); - printf("Decrypt key: %s\n", buffer ); - } -#endif +#ifdef DEBUG + { + int i = 3000; + char buffer[3000]; + bin2hex(buffer, &i, pkey, *payloadlen); + printf("Decrypt key: %s\n", buffer ); + } +#endif packet_mask(payload, *payloadlen, pkey); return 0; - case DH_G_2_DES_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: + case DH_G_2_DES_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: #ifdef DEBUG printf("[Packet decryption: DES]\n"); #endif @@ -293,23 +293,23 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) return -1; } /* XOR Mask */ - if(compute_privacy_key(st, pkey, + if(compute_privacy_key(st, pkey, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, *payloadlen*8, &order, 0) == -1) return -1; /* DES Key */ - if(compute_privacy_key(st, pkey + *payloadlen, + if(compute_privacy_key(st, pkey + *payloadlen, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, 64, &order, 0) == -1) return -1; -#ifdef DEBUG - { - int i = 3000; - char buffer[3000]; - bin2hex(buffer, &i, pkey, *payloadlen + 8); - printf("Decrypt key: %s\n", buffer ); - } -#endif +#ifdef DEBUG + { + int i = 3000; + char buffer[3000]; + bin2hex(buffer, &i, pkey, *payloadlen + 8); + printf("Decrypt key: %s\n", buffer ); + } +#endif bcopy(pkey+*payloadlen, &keys[0], 8); des_set_odd_parity(&keys[0]); @@ -322,9 +322,9 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) packet_mask(payload, *payloadlen, pkey); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: #ifdef DEBUG printf("[Packet decryption: 3DES]\n"); #endif @@ -334,19 +334,19 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) return -1; } /* XOR Mask */ - if(compute_privacy_key(st, pkey, + if(compute_privacy_key(st, pkey, payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, *payloadlen*8, &order, 0) == -1) return -1; /* 3 DES keys + 1 DES IV */ for (i=0; i<3; i++) { - if(compute_privacy_key(st, pkey + *payloadlen + (i<<3), + if(compute_privacy_key(st, pkey + *payloadlen + (i<<3), payload - 2*COOKIE_SIZE - 4 - SPI_SIZE, 64, &order, 0) == -1) return -1; } #ifdef DEBUG - { + { int i = 3000; char buffer[3000]; bin2hex(buffer, &i, pkey, *payloadlen+24); @@ -372,10 +372,10 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) packet_mask(payload, *payloadlen, pkey); break; - default: - log_error("Unknown exchange scheme: %d\n", - *((u_int16_t *)st->scheme)); - return -1; + default: + log_error("Unknown exchange scheme: %d\n", + *((u_int16_t *)st->scheme)); + return -1; } padlength = *(payload+(*payloadlen)-1); @@ -392,5 +392,5 @@ packet_decrypt(struct stateob *st, u_int8_t *payload, u_int16_t *payloadlen) return -1; return 0; -} - +} + diff --git a/sbin/photurisd/photuris_spi_needed.c b/sbin/photurisd/photuris_spi_needed.c index f58f20d162e..d84166eb5ad 100644 --- a/sbin/photurisd/photuris_spi_needed.c +++ b/sbin/photurisd/photuris_spi_needed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_spi_needed.c,v 1.3 2001/01/28 22:45:14 niklas Exp $ */ +/* $OpenBSD: photuris_spi_needed.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -31,11 +31,11 @@ */ /* * photuris_spi_needed: - * + * */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_spi_needed.c,v 1.3 2001/01/28 22:45:14 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_spi_needed.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -53,56 +53,56 @@ photuris_spi_needed(struct stateob *st, u_char *buffer, int *size, struct spi_needed *header; u_int16_t rsize, asize, tmp; u_int8_t *p; - + rsize = *size; if (rsize < SPI_NEEDED_MIN) return -1; /* buffer not large enough */ asize = SPI_NEEDED_MIN; /* Actual size */ rsize -= asize; /* Remaining size */ - + header = (struct spi_needed *) buffer; header->type = SPI_NEEDED; bzero(header->reserved, sizeof(header->reserved)); - + /* Copy the cookies */ bcopy(st->icookie, header->icookie, COOKIE_SIZE); bcopy(st->rcookie, header->rcookie, COOKIE_SIZE); p = SPI_NEEDED_VERIFICATION(header); - /* Leave space for verification data */ - tmp = get_validity_verification_size(st); - - if (rsize < tmp) - return -1; /* buffer not large enough */ - + /* Leave space for verification data */ + tmp = get_validity_verification_size(st); + + if (rsize < tmp) + return -1; /* buffer not large enough */ + p += tmp; asize += tmp; rsize -= tmp; - + if (rsize < attribsize) return -1; /* buffer not large enough */ - + /* Copy attributes and padding */ bcopy(attributes, p, attribsize); asize += attribsize; rsize -= attribsize; p += attribsize; - + tmp = rsize; - if(packet_create_padding(st, asize - SPI_NEEDED_MIN, p, &tmp) == -1) - return -1; - - p += tmp; asize += tmp; rsize -= tmp; + if(packet_create_padding(st, asize - SPI_NEEDED_MIN, p, &tmp) == -1) + return -1; - /* Create verification data */ + p += tmp; asize += tmp; rsize -= tmp; + + /* Create verification data */ create_validity_verification(st,SPI_UPDATE_VERIFICATION(header), - (u_int8_t *)header,asize); - + (u_int8_t *)header,asize); + /* Encrypt the packet after header if wished for */ packet_encrypt(st, SPI_NEEDED_VERIFICATION(header), asize - SPI_NEEDED_MIN); - + *size = asize; return 0; } diff --git a/sbin/photurisd/photuris_spi_update.c b/sbin/photurisd/photuris_spi_update.c index 3a9cfcdbae1..5a680186ae3 100644 --- a/sbin/photurisd/photuris_spi_update.c +++ b/sbin/photurisd/photuris_spi_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_spi_update.c,v 1.3 2001/01/28 22:45:15 niklas Exp $ */ +/* $OpenBSD: photuris_spi_update.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_spi_update.c,v 1.3 2001/01/28 22:45:15 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_spi_update.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -71,7 +71,7 @@ photuris_spi_update(struct stateob *st, u_char *buffer, int *size) bcopy(st->rcookie, header->rcookie, COOKIE_SIZE); /* Copy SPI and life time */ - bcopy(st->oSPI, header->SPI, SPI_SIZE ); + bcopy(st->oSPI, header->SPI, SPI_SIZE ); header->lifetime[0] = (st->olifetime >> 16) & 0xFF; header->lifetime[1] = (st->olifetime >> 8) & 0xFF; header->lifetime[2] = st->olifetime & 0xFF; @@ -96,17 +96,17 @@ photuris_spi_update(struct stateob *st, u_char *buffer, int *size) p += st->oSPIattribsize; tmp = rsize; - if(packet_create_padding(st, asize - SPI_UPDATE_MIN, p, &tmp) == -1) - return -1; - - p += tmp; asize += tmp; rsize -= tmp; + if(packet_create_padding(st, asize - SPI_UPDATE_MIN, p, &tmp) == -1) + return -1; + + p += tmp; asize += tmp; rsize -= tmp; /* Create validity verification data */ create_validity_verification(st,SPI_UPDATE_VERIFICATION(header), (u_int8_t *)header,asize); /* Encrypt the packet after SPI if wished for */ - packet_encrypt(st, SPI_UPDATE_VERIFICATION(header), + packet_encrypt(st, SPI_UPDATE_VERIFICATION(header), asize - SPI_UPDATE_MIN); *size = asize; diff --git a/sbin/photurisd/photuris_value_request.c b/sbin/photurisd/photuris_value_request.c index 43985492381..d145ba923e1 100644 --- a/sbin/photurisd/photuris_value_request.c +++ b/sbin/photurisd/photuris_value_request.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_value_request.c,v 1.3 2001/01/28 22:45:15 niklas Exp $ */ +/* $OpenBSD: photuris_value_request.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_value_request.c,v 1.3 2001/01/28 22:45:15 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_value_request.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -49,7 +49,7 @@ static char rcsid[] = "$OpenBSD: photuris_value_request.c,v 1.3 2001/01/28 22:45 int photuris_value_request(struct stateob *st, u_char *buffer, int *size) - + { struct value_request *header; u_int16_t rsize, asize, tmp; @@ -70,7 +70,7 @@ photuris_value_request(struct stateob *st, u_char *buffer, int *size) return -1; asize += tmp; - bcopy(st->oSPIoattrib, VALUE_REQUEST_VALUE(header)+tmp, + bcopy(st->oSPIoattrib, VALUE_REQUEST_VALUE(header)+tmp, st->oSPIoattribsize); header = (struct value_request *) buffer; diff --git a/sbin/photurisd/photuris_value_response.c b/sbin/photurisd/photuris_value_response.c index 66bc7f7b253..7589aea5d7c 100644 --- a/sbin/photurisd/photuris_value_response.c +++ b/sbin/photurisd/photuris_value_response.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photuris_value_response.c,v 1.3 2001/01/28 22:45:15 niklas Exp $ */ +/* $OpenBSD: photuris_value_response.c,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -36,7 +36,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: photuris_value_response.c,v 1.3 2001/01/28 22:45:15 niklas Exp $"; +static char rcsid[] = "$OpenBSD: photuris_value_response.c,v 1.4 2002/06/09 08:13:08 todd Exp $"; #endif #include <stdio.h> @@ -49,29 +49,29 @@ static char rcsid[] = "$OpenBSD: photuris_value_response.c,v 1.3 2001/01/28 22:4 int photuris_value_response(struct stateob *st, u_char *buffer, int *size) - + { struct value_response *header; u_int16_t asize, rsize, tmp; rsize = *size; - if (rsize < VALUE_RESPONSE_MIN + st->oSPIoattribsize) - return -1; /* buffer not large enough */ - + if (rsize < VALUE_RESPONSE_MIN + st->oSPIoattribsize) + return -1; /* buffer not large enough */ + header = (struct value_response *)buffer; - asize = VALUE_RESPONSE_MIN + st->oSPIoattribsize; - rsize -= asize; - - /* Generate an exchangevalue if not done already */ - tmp = rsize; + asize = VALUE_RESPONSE_MIN + st->oSPIoattribsize; + rsize -= asize; + + /* Generate an exchangevalue if not done already */ + tmp = rsize; if(exchange_value_generate(st, VALUE_RESPONSE_VALUE(header), &tmp) == -1\ -) - return -1; - - asize += tmp; - bcopy(st->oSPIoattrib, VALUE_RESPONSE_VALUE(header)+tmp, - st->oSPIoattribsize); +) + return -1; + + asize += tmp; + bcopy(st->oSPIoattrib, VALUE_RESPONSE_VALUE(header)+tmp, + st->oSPIoattribsize); header = (struct value_response *) buffer; header->type = VALUE_RESPONSE; diff --git a/sbin/photurisd/photurisd.c b/sbin/photurisd/photurisd.c index e343f28448c..53dba24f774 100644 --- a/sbin/photurisd/photurisd.c +++ b/sbin/photurisd/photurisd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: photurisd.c,v 1.12 2001/07/07 18:26:18 deraadt Exp $ */ +/* $OpenBSD: photurisd.c,v 1.13 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -29,23 +29,23 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* * photurisd.c: photuris daemon and stuff. */ -#ifndef lint -static char rcsid[] = "$OpenBSD: photurisd.c,v 1.12 2001/07/07 18:26:18 deraadt Exp $"; -#endif +#ifndef lint +static char rcsid[] = "$OpenBSD: photurisd.c,v 1.13 2002/06/09 08:13:08 todd Exp $"; +#endif #define _PHOTURIS_C_ -#include <stdio.h> +#include <stdio.h> #include <stdlib.h> -#include <sys/types.h> +#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> -#include <signal.h> -#include <errno.h> +#include <signal.h> +#include <errno.h> #include <string.h> #include <unistd.h> #include "config.h" @@ -78,9 +78,9 @@ usage(void) fprintf(f, "\t-p specifies the local port to bind to\n"); exit(1); } - -static int + +static int init_vars(void) { global_schemes = NULL; @@ -161,11 +161,11 @@ main(int argc, char **argv) if (chdir(dir) == -1) log_fatal("chdir(\"%s\") in main()", dir); - + argc -= optind; argv += optind; - + spi_init(); state_init(); @@ -189,11 +189,11 @@ main(int argc, char **argv) #endif /* Depends on the available attributes in the kernel, init_kernel() */ - init_attributes(); + init_attributes(); if (init_identities(NULL,NULL) == -1) exit(1); - + init_schedule(); init_server(); diff --git a/sbin/photurisd/schedule.c b/sbin/photurisd/schedule.c index ecdc04f5695..b42c047b662 100644 --- a/sbin/photurisd/schedule.c +++ b/sbin/photurisd/schedule.c @@ -1,11 +1,11 @@ -/* $OpenBSD: schedule.c,v 1.7 2001/09/19 10:58:07 mpech Exp $ */ +/* $OpenBSD: schedule.c,v 1.8 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. - * - * Parts derived from code by Angelos D. Keromytis, kermit@forthnet.gr - * + * + * Parts derived from code by Angelos D. Keromytis, kermit@forthnet.gr + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -37,7 +37,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: schedule.c,v 1.7 2001/09/19 10:58:07 mpech Exp $"; +static char rcsid[] = "$OpenBSD: schedule.c,v 1.8 2002/06/09 08:13:08 todd Exp $"; #endif #define _SCHEDULE_C_ @@ -47,10 +47,10 @@ static char rcsid[] = "$OpenBSD: schedule.c,v 1.7 2001/09/19 10:58:07 mpech Exp #include <string.h> #include <time.h> #include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> +#include <sys/socket.h> +#include <netinet/in.h> #include <sys/time.h> -#include <arpa/inet.h> +#include <arpa/inet.h> #include "state.h" #include "spi.h" #include "photuris.h" @@ -85,7 +85,7 @@ schedule_insert(int type, int off, u_int8_t *cookie, u_int16_t cookie_size) type, off, cookie == NULL ? "None" : (char *)buffer); } #endif - + if ((tmp = calloc(1, sizeof(struct schedule))) == NULL) { log_error("calloc() in schedule_insert()"); return; @@ -143,9 +143,9 @@ int schedule_offset(int type, u_int8_t *cookie) { struct schedule *tmp = schedob; - while (tmp != NULL) { - if (tmp->event == type && - ((tmp->cookie == NULL && cookie == NULL) || + while (tmp != NULL) { + if (tmp->event == type && + ((tmp->cookie == NULL && cookie == NULL) || !bcmp(tmp->cookie, cookie, tmp->cookie_size))) return tmp->offset; tmp = tmp->next; @@ -161,8 +161,8 @@ schedule_remove(int type, u_int8_t *cookie) tmp = schedob; while (tmp != NULL) { - if (tmp->event == type && - ((tmp->cookie == NULL && cookie == NULL) || + if (tmp->event == type && + ((tmp->cookie == NULL && cookie == NULL) || !bcmp(tmp->cookie, cookie, tmp->cookie_size))) { if (tmp == schedob) schedob = tmp->next; @@ -202,13 +202,13 @@ schedule_process(int sock) reset_secret(); tmp->tm = time(NULL) + REKEY_TIMEOUT; break; - case MODULUS: + case MODULUS: #ifdef DEBUG2 - printf("Checking moduli\n"); -#endif - mod_check_prime(MOD_PRIME_ITER, MOD_PRIME_TIME); - tmp->tm = time(NULL) + MODULUS_TIMEOUT; - break; + printf("Checking moduli\n"); +#endif + mod_check_prime(MOD_PRIME_ITER, MOD_PRIME_TIME); + tmp->tm = time(NULL) + MODULUS_TIMEOUT; + break; case CLEANUP: #ifdef DEBUG2 printf("Cleaning up states\n"); @@ -257,7 +257,7 @@ schedule_process(int sock) } } - + if (st->packet == NULL || st->packetlen == 0) { log_print("no packet in schedule_process()"); remove = 1; @@ -268,18 +268,18 @@ schedule_process(int sock) if (!remove) { st->retries++; - sin.sin_port = htons(st->port); - sin.sin_family = AF_INET; + sin.sin_port = htons(st->port); + sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(st->address); - + if (sendto(sock, st->packet, st->packetlen, 0, - (struct sockaddr *) &sin, sizeof(sin)) + (struct sockaddr *) &sin, sizeof(sin)) != st->packetlen) { log_error("sendto() in schedule_process()"); remove = 1; break; } - + #ifdef DEBUG printf("Resending packet to %s type %d, length %d.\n", st->address, st->phase, st->packetlen); diff --git a/sbin/photurisd/schedule.h b/sbin/photurisd/schedule.h index 38b0560b0a1..2e14412c726 100644 --- a/sbin/photurisd/schedule.h +++ b/sbin/photurisd/schedule.h @@ -1,4 +1,4 @@ -/* $OpenBSD: schedule.h,v 1.3 2001/01/28 22:45:16 niklas Exp $ */ +/* $OpenBSD: schedule.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,10 +29,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * schedule.h: + * schedule.h: * schedule events like retransmission and clean ups. */ - + #ifndef _SCHEDULE_H_ #define _SCHEDULE_H_ @@ -40,7 +40,7 @@ #include "packets.h" #undef EXTERN - + #ifdef _SCHEDULE_C_ #define EXTERN #else @@ -73,7 +73,7 @@ struct schedule { EXTERN void schedule_process(int sock); EXTERN int schedule_next(void); EXTERN int schedule_offset(int type, u_int8_t *cookie); -EXTERN void schedule_insert(int type, int off, u_int8_t *cookie, +EXTERN void schedule_insert(int type, int off, u_int8_t *cookie, u_int16_t cookie_size); EXTERN void schedule_remove(int type, u_int8_t *cookie); EXTERN void init_schedule(void); diff --git a/sbin/photurisd/scheme.c b/sbin/photurisd/scheme.c index 54d07f1aac2..19268828303 100644 --- a/sbin/photurisd/scheme.c +++ b/sbin/photurisd/scheme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheme.c,v 1.5 2001/01/28 22:45:16 niklas Exp $ */ +/* $OpenBSD: scheme.c,v 1.6 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,16 +35,16 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: scheme.c,v 1.5 2001/01/28 22:45:16 niklas Exp $"; +static char rcsid[] = "$OpenBSD: scheme.c,v 1.6 2002/06/09 08:13:08 todd Exp $"; #endif #define _SCHEME_C_ #include <stdlib.h> #include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include "config.h" #include "attributes.h" #include "buffer.h" @@ -55,20 +55,20 @@ u_int8_t * scheme_get_gen(u_int8_t *scheme) { int header; - switch(ntohs(*(u_int16_t *)scheme)) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_2_DES_MD5: - case DH_G_5_MD5: - case DH_G_3_DES_MD5: - case DH_G_2_3DES_SHA1: - case DH_G_5_DES_MD5: - case DH_G_3_3DES_SHA1: + switch(ntohs(*(u_int16_t *)scheme)) { + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_2_DES_MD5: + case DH_G_5_MD5: + case DH_G_3_DES_MD5: + case DH_G_2_3DES_SHA1: + case DH_G_5_DES_MD5: + case DH_G_3_3DES_SHA1: case DH_G_5_3DES_SHA1: return NULL; - case DH_G_VAR_MD5: - case DH_G_VAR_DES_MD5: - case DH_G_VAR_3DES_SHA1: + case DH_G_VAR_MD5: + case DH_G_VAR_DES_MD5: + case DH_G_VAR_3DES_SHA1: if (scheme[2] == 255 && scheme[3] == 255) header = 8; else if (scheme[2] == 255) @@ -76,26 +76,26 @@ scheme_get_gen(u_int8_t *scheme) else header = 2; return scheme+2+header; - default: - log_print("Unknown scheme in scheme_get_gen()"); - return NULL; + default: + log_print("Unknown scheme in scheme_get_gen()"); + return NULL; } } - -u_int8_t * -scheme_get_mod(u_int8_t *scheme) + +u_int8_t * +scheme_get_mod(u_int8_t *scheme) { int header; switch(ntohs(*(u_int16_t *)scheme)) { case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_2_DES_MD5: - case DH_G_5_MD5: - case DH_G_3_DES_MD5: - case DH_G_2_3DES_SHA1: - case DH_G_5_DES_MD5: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_3_MD5: + case DH_G_2_DES_MD5: + case DH_G_5_MD5: + case DH_G_3_DES_MD5: + case DH_G_2_3DES_SHA1: + case DH_G_5_DES_MD5: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: return scheme+2; break; case DH_G_VAR_MD5: @@ -121,36 +121,36 @@ scheme_get_mod(u_int8_t *scheme) size_t scheme_get_len(u_int8_t *scheme) { - return 2 + varpre2octets(scheme + 2); + return 2 + varpre2octets(scheme + 2); } u_int16_t scheme_get_ref(u_int8_t *scheme) { - switch(ntohs(*(u_int16_t *)scheme)) { - case DH_G_2_MD5: - case DH_G_2_DES_MD5: - case DH_G_2_3DES_SHA1: + switch(ntohs(*(u_int16_t *)scheme)) { + case DH_G_2_MD5: + case DH_G_2_DES_MD5: + case DH_G_2_3DES_SHA1: return DH_G_2_MD5; - case DH_G_3_MD5: - case DH_G_3_DES_MD5: - case DH_G_3_3DES_SHA1: + case DH_G_3_MD5: + case DH_G_3_DES_MD5: + case DH_G_3_3DES_SHA1: return DH_G_3_MD5; - case DH_G_5_MD5: - case DH_G_5_DES_MD5: - case DH_G_5_3DES_SHA1: + case DH_G_5_MD5: + case DH_G_5_DES_MD5: + case DH_G_5_3DES_SHA1: return DH_G_5_MD5; - case DH_G_VAR_MD5: - case DH_G_VAR_DES_MD5: - case DH_G_VAR_3DES_SHA1: + case DH_G_VAR_MD5: + case DH_G_VAR_DES_MD5: + case DH_G_VAR_3DES_SHA1: return DH_G_VAR_MD5; - default: - log_print("Unknown scheme in scheme_get_ref()"); - return 0; - } + default: + log_print("Unknown scheme in scheme_get_ref()"); + return 0; + } } -size_t +size_t varpre2octets(u_int8_t *varpre) { int blocks, header; @@ -159,7 +159,7 @@ varpre2octets(u_int8_t *varpre) /* XXX - only support a few octets at the moment */ if(varpre[0] == 255 && varpre[1] == 255) return (0); - + size = 0; if (varpre[0] == 255) { blocks = 3; diff --git a/sbin/photurisd/scheme.h b/sbin/photurisd/scheme.h index 481438d9a88..ecd7a054213 100644 --- a/sbin/photurisd/scheme.h +++ b/sbin/photurisd/scheme.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scheme.h,v 1.3 2001/01/28 22:45:16 niklas Exp $ */ +/* $OpenBSD: scheme.h,v 1.4 2002/06/09 08:13:08 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,10 +29,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * scheme.h: + * scheme.h: * security paramter index creation. */ - + #ifndef _SCHEME_H_ #define _SCHEME_H_ @@ -40,7 +40,7 @@ #include "state.h" #undef EXTERN - + #ifdef _SCHEME_C_ #define EXTERN #else diff --git a/sbin/photurisd/secrets.h b/sbin/photurisd/secrets.h index 2eb4561bae9..e884649166f 100644 --- a/sbin/photurisd/secrets.h +++ b/sbin/photurisd/secrets.h @@ -1,4 +1,4 @@ -/* $OpenBSD: secrets.h,v 1.4 2001/01/28 22:45:16 niklas Exp $ */ +/* $OpenBSD: secrets.h,v 1.5 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -33,29 +33,29 @@ * prototypes for compute_secrets.c */ -#ifndef _SECRETS_H_ -#define _SECRETS_H_ - -#include "state.h" +#ifndef _SECRETS_H_ +#define _SECRETS_H_ + +#include "state.h" #include "spi.h" - -#undef EXTERN - -#ifdef _SECRETS_C_ -#define EXTERN -#else -#define EXTERN extern + +#undef EXTERN + +#ifdef _SECRETS_C_ +#define EXTERN +#else +#define EXTERN extern #endif EXTERN int compute_shared_secret(struct stateob *, u_int8_t **, size_t *); -EXTERN int compute_session_key(struct stateob *st, u_int8_t *key, - u_int8_t *attribute, int owner, +EXTERN int compute_session_key(struct stateob *st, u_int8_t *key, + u_int8_t *attribute, int owner, u_int16_t *order); EXTERN int get_session_key_length(u_int8_t *attribute); EXTERN int init_privacy_key(struct stateob *st, int owner); -EXTERN int compute_privacy_key(struct stateob *st, u_int8_t *key, - u_int8_t *packet, u_int16_t bits, +EXTERN int compute_privacy_key(struct stateob *st, u_int8_t *key, + u_int8_t *packet, u_int16_t bits, u_int16_t *order, int owner); EXTERN int make_session_keys(struct stateob *st, struct spiob *spi); diff --git a/sbin/photurisd/server.c b/sbin/photurisd/server.c index 41712d50b22..85881f5fe4b 100644 --- a/sbin/photurisd/server.c +++ b/sbin/photurisd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.12 2002/03/29 20:35:55 deraadt Exp $ */ +/* $OpenBSD: server.c,v 1.13 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -37,27 +37,27 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: server.c,v 1.12 2002/03/29 20:35:55 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: server.c,v 1.13 2002/06/09 08:13:09 todd Exp $"; #endif #define _SERVER_C_ #include <stdio.h> -#include <stdlib.h> +#include <stdlib.h> #include <fcntl.h> -#include <sys/types.h> +#include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <sys/ioctl.h> -#include <net/if.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <netdb.h> +#include <sys/ioctl.h> +#include <net/if.h> #include <string.h> #include <unistd.h> -#ifdef _AIX -#include <sys/select.h> -#endif +#ifdef _AIX +#include <sys/select.h> +#endif #include <errno.h> #include "config.h" #include "photuris.h" @@ -76,56 +76,56 @@ static char rcsid[] = "$OpenBSD: server.c,v 1.12 2002/03/29 20:35:55 deraadt Exp int init_server(void) { - struct sockaddr_in sin, *sin2; - struct protoent *proto; - int sock, d, i, ip, on = 1; - struct ifconf ifconf; + struct sockaddr_in sin, *sin2; + struct protoent *proto; + int sock, d, i, ip, on = 1; + struct ifconf ifconf; void *newbuf; char buf[4096]; readfds = normfds = NULL; if (global_port == 0) { -#ifndef PHOTURIS_PORT +#ifndef PHOTURIS_PORT struct servent *ser; if ((ser = getservbyname("photuris", "udp")) == (struct servent *) NULL) log_fatal("getservbyname(\"photuris\") in init_server()"); global_port = ser->s_port; -#else +#else global_port = PHOTURIS_PORT; -#endif +#endif } if ((proto = getprotobyname("udp")) == (struct protoent *) NULL) - log_fatal("getprotobyname() in init_server()"); - + log_fatal("getprotobyname() in init_server()"); + if ((global_socket = socket(PF_INET, SOCK_DGRAM, proto->p_proto)) < 0) - log_fatal("socket() in init_server()"); - - setsockopt(global_socket, SOL_SOCKET, SO_REUSEADDR, (void *)&on, + log_fatal("socket() in init_server()"); + + setsockopt(global_socket, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)); #ifdef IPSEC kernel_set_socket_policy(global_socket); -#endif +#endif + + /* get the local addresses */ - /* get the local addresses */ - - ifconf.ifc_len = sizeof(buf); - ifconf.ifc_buf = buf; - bzero(buf, 1024); - - if (ioctl(global_socket, SIOCGIFCONF, &ifconf) == -1) - log_fatal("ioctl() in init_server()"); + ifconf.ifc_len = sizeof(buf); + ifconf.ifc_buf = buf; + bzero(buf, 1024); + + if (ioctl(global_socket, SIOCGIFCONF, &ifconf) == -1) + log_fatal("ioctl() in init_server()"); sin.sin_port = htons(global_port); - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_family = AF_INET; - + sin.sin_addr.s_addr = INADDR_ANY; + sin.sin_family = AF_INET; + if (bind(global_socket, (struct sockaddr *)&sin, sizeof(struct sockaddr)) < 0) - log_fatal("bind() in init_server()"); - + log_fatal("bind() in init_server()"); + /* Save interfaces addresses here */ addresses = NULL; sockets = NULL; @@ -133,15 +133,15 @@ init_server(void) #ifdef IPSEC /* We also listen on pfkeyv2 for notify messages */ - newbuf = realloc(addresses, (i + 1) * sizeof(char *)); + newbuf = realloc(addresses, (i + 1) * sizeof(char *)); if (newbuf == NULL) { if (addresses != NULL) free (addresses); - log_fatal("realloc() in init_server()"); + log_fatal("realloc() in init_server()"); } addresses = (char **) newbuf; - - addresses[i + 1] = (char *) NULL; + + addresses[i + 1] = (char *) NULL; newbuf = realloc(sockets, (i + 1) * sizeof(int)); if (newbuf == NULL) { @@ -156,31 +156,31 @@ init_server(void) i++; /* Next interface */ #endif - for (ip = 0, d = 0; d < ifconf.ifc_len; d += IFNAMSIZ + + for (ip = 0, d = 0; d < ifconf.ifc_len; d += IFNAMSIZ + #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(_AIX) - buf[IFNAMSIZ + d] -#else - sizeof(struct sockaddr) -#endif + buf[IFNAMSIZ + d] +#else + sizeof(struct sockaddr) +#endif , i++, ip++) { - sin2 = (struct sockaddr_in *) &buf[IFNAMSIZ + d]; - - if (sin2->sin_family != AF_INET) { + sin2 = (struct sockaddr_in *) &buf[IFNAMSIZ + d]; + + if (sin2->sin_family != AF_INET) { i--; ip--; - continue; - } - - newbuf = realloc(addresses, (i + 1) * sizeof(char *)); + continue; + } + + newbuf = realloc(addresses, (i + 1) * sizeof(char *)); if (newbuf == NULL) { if (addresses != NULL) free (addresses); - log_fatal("realloc() in init_server()"); + log_fatal("realloc() in init_server()"); } addresses = (char **) newbuf; - - addresses[i] = strdup(inet_ntoa(sin2->sin_addr)); - if (addresses[i] == (char *) NULL) - log_fatal("strdup() in init_server()"); + + addresses[i] = strdup(inet_ntoa(sin2->sin_addr)); + if (addresses[i] == (char *) NULL) + log_fatal("strdup() in init_server()"); newbuf = realloc(sockets, (i + 1)* sizeof(int)); if (newbuf == NULL) { @@ -191,43 +191,43 @@ init_server(void) sockets = (int *) newbuf; if ((sock = socket(PF_INET, SOCK_DGRAM, proto->p_proto)) < 0) - log_fatal("socket() in init_server()"); - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, - sizeof(on)); + log_fatal("socket() in init_server()"); + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, + sizeof(on)); #ifdef IPSEC kernel_set_socket_policy(sock); -#endif +#endif sockets[i] = sock; -#ifdef DEBUG - printf("Local interface %s, address %s.\n", buf + d, - addresses[i]); -#endif +#ifdef DEBUG + printf("Local interface %s, address %s.\n", buf + d, + addresses[i]); +#endif bzero((void *)&sin, sizeof(sin)); sin.sin_port = htons(global_port); sin.sin_addr.s_addr = inet_addr(addresses[i]); - sin.sin_family = AF_INET; - + sin.sin_family = AF_INET; + if (bind(sockets[i], (struct sockaddr *)&sin, sizeof(struct sockaddr)) < 0) - log_fatal("bind() in init_server()"); - - } + log_fatal("bind() in init_server()"); + + } num_ifs = i; - -#ifdef DEBUG - printf("%d local interfaces supporting IP found.\n", ip); -#endif + +#ifdef DEBUG + printf("%d local interfaces supporting IP found.\n", ip); +#endif return 1; } -int +int server(void) { - struct sockaddr_in sin; - struct timeval timeout; + struct sockaddr_in sin; + struct timeval timeout; int i, d, size; setvbuf(stdout, (char *)NULL, _IOLBF, 0); @@ -241,7 +241,7 @@ server(void) if (readfds == NULL) log_fatal("malloc(%d) for fd_set", size); - memset((void *)normfds, 0, size); + memset((void *)normfds, 0, size); for (i = 0; i < num_ifs; i++) FD_SET(sockets[i], normfds); @@ -264,13 +264,13 @@ server(void) printf("Sleeping for %ld seconds\n", timeout.tv_sec); #endif - if (select(sockets[num_ifs-1]+1, - readfds, (fd_set *) NULL, (fd_set *) NULL, + if (select(sockets[num_ifs-1]+1, + readfds, (fd_set *) NULL, (fd_set *) NULL, (timeout.tv_sec == -1 ? NULL : &timeout)) < 0) { - if (errno == EINTR) - continue; + if (errno == EINTR) + continue; else - log_fatal("select() in server()"); + log_fatal("select() in server()"); } for (i=0; i<num_ifs; i++) { @@ -281,15 +281,15 @@ server(void) else { #endif d = sizeof(struct sockaddr_in); - if (recvfrom(sockets[i], + if (recvfrom(sockets[i], #ifdef BROKEN_RECVFROM (char *) buffer, 1, #else - (char *) NULL, 0, + (char *) NULL, 0, #endif MSG_PEEK, (struct sockaddr *)&sin, &d) == -1) { - log_error("recvfrom() in server()"); + log_error("recvfrom() in server()"); return -1; } handle_packet(sockets[i], addresses[i]); @@ -298,7 +298,7 @@ server(void) } #ifdef IPSEC - /* + /* * Deal with queue acquire and expire message, since we * dont have proper timeout code, it needs to go here. */ diff --git a/sbin/photurisd/server.h b/sbin/photurisd/server.h index 3b16db30def..cf0f3adfc4e 100644 --- a/sbin/photurisd/server.h +++ b/sbin/photurisd/server.h @@ -1,4 +1,4 @@ -/* $OpenBSD: server.h,v 1.3 2001/01/28 22:45:17 niklas Exp $ */ +/* $OpenBSD: server.h,v 1.4 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,10 +29,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * server.h: + * server.h: * handling interfaces and communication */ - + #ifndef _SERVER_H_ #define _SERVER_H_ diff --git a/sbin/photurisd/spi.c b/sbin/photurisd/spi.c index 76155ca7284..c5f01d4c929 100644 --- a/sbin/photurisd/spi.c +++ b/sbin/photurisd/spi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spi.c,v 1.8 2001/01/28 22:45:17 niklas Exp $ */ +/* $OpenBSD: spi.c,v 1.9 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: spi.c,v 1.8 2001/01/28 22:45:17 niklas Exp $"; +static char rcsid[] = "$OpenBSD: spi.c,v 1.9 2002/06/09 08:13:09 todd Exp $"; #endif #define _SPI_C_ @@ -46,9 +46,9 @@ static char rcsid[] = "$OpenBSD: spi.c,v 1.8 2001/01/28 22:45:17 niklas Exp $"; #include <stdlib.h> #include <string.h> #include <time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include "config.h" #include "photuris.h" #include "state.h" @@ -100,7 +100,7 @@ make_spi(struct stateob *st, char *local_address, flags |= IPSEC_OPT_ENC; else if ((*attributes)[i] == AT_AH_ATTRIB) flags |= IPSEC_OPT_AUTH; - + tmp = kernel_reserve_spi(local_address, st->address, flags); #else /* Just grab a random number, this should be uniq */ @@ -110,7 +110,7 @@ make_spi(struct stateob *st, char *local_address, SPI[i] = tmp & 0xFF; tmp = tmp >> 8; } - + *lifetime = getspilifetime(st) + (arc4random() & 0x1F); return (0); @@ -153,13 +153,13 @@ spi_new(char *address, u_int8_t *spi) return (NULL); } bcopy(spi, p->SPI, SPI_SIZE); - + return (p); } int spi_value_reset(struct spiob *ob) -{ +{ if (ob->address != NULL) { free(ob->address); ob->address = NULL; @@ -182,16 +182,16 @@ spi_value_reset(struct spiob *ob) } -struct spiob * -spi_find_attrib(char *address, u_int8_t *attrib, u_int16_t attribsize) -{ - struct spiob *tmp; +struct spiob * +spi_find_attrib(char *address, u_int8_t *attrib, u_int16_t attribsize) +{ + struct spiob *tmp; u_int16_t i; - for (tmp = TAILQ_FIRST(&spihead); tmp; tmp = TAILQ_NEXT(tmp, next)) { + for (tmp = TAILQ_FIRST(&spihead); tmp; tmp = TAILQ_NEXT(tmp, next)) { if (!strcmp(address, tmp->address)) { for (i = 0; i < attribsize; i += attrib[i + 1] + 2) { - if (attrib[i] == AT_AH_ATTRIB || + if (attrib[i] == AT_AH_ATTRIB || attrib[i] == AT_ESP_ATTRIB) continue; if (!isinattrib(tmp->attributes, tmp->attribsize, attrib[i])) @@ -200,12 +200,12 @@ spi_find_attrib(char *address, u_int8_t *attrib, u_int16_t attribsize) if (i == attribsize) return (tmp); } - } + } - return (NULL); -} + return (NULL); +} -/* +/* * find the spi ob with matching address * Alas this is tweaked, for SPI_OWNER compare with local_address * and for user compare with address. @@ -299,7 +299,7 @@ spi_update(int sock, u_int8_t *spinr) if ((st = state_find_cookies(spi->address, spi->icookie, NULL)) == NULL) { - /* + /* * This happens always when an exchange expires but * updates are still scheduled for it. */ @@ -323,23 +323,23 @@ spi_update(int sock, u_int8_t *spinr) return; } - packet_size = PACKET_BUFFER_SIZE; + packet_size = PACKET_BUFFER_SIZE; if (photuris_spi_update(st, packet_buffer, &packet_size) == -1) { log_print(__FUNCTION__": photuris_spi_update()"); return; } /* Send the packet */ - sin.sin_port = htons(st->port); - sin.sin_family = AF_INET; + sin.sin_port = htons(st->port); + sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(st->address); - + if (sendto(sock, packet_buffer, packet_size, 0, (struct sockaddr *) &sin, sizeof(sin)) != packet_size) { log_error("sendto() in schedule_process()"); return; } - + #ifdef DEBUG printf("Sending SPI UPDATE to %s.\n", st->address); #endif diff --git a/sbin/photurisd/spi.h b/sbin/photurisd/spi.h index 015ca2f1c94..8a1fffca164 100644 --- a/sbin/photurisd/spi.h +++ b/sbin/photurisd/spi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: spi.h,v 1.7 2001/01/28 22:45:17 niklas Exp $ */ +/* $OpenBSD: spi.h,v 1.8 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,17 +29,17 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * spi.h: + * spi.h: * security paramter index creation. */ - + #ifndef _SPI_H_ #define _SPI_H_ #include <sys/queue.h> #include "state.h" #undef EXTERN - + #ifdef _SPI_C_ #define EXTERN #else @@ -59,19 +59,19 @@ struct spiob { char *address; char *local_address; int flags; - u_int8_t SPI[SPI_SIZE]; /* SPI */ + u_int8_t SPI[SPI_SIZE]; /* SPI */ u_int8_t icookie[COOKIE_SIZE]; /* Initator cookie */ u_int8_t *attributes; /* SPI attributes */ u_int16_t attribsize; u_int8_t *sessionkey; /* to be delete after use */ - u_int16_t sessionkeysize; + u_int16_t sessionkeysize; time_t lifetime; /* Lifetime for the SPI */ }; EXTERN void spi_init(void); EXTERN time_t getspilifetime(struct stateob *st); EXTERN int make_spi(struct stateob *st, char *local_address, - u_int8_t *SPI, time_t *lifetime, + u_int8_t *SPI, time_t *lifetime, u_int8_t **attributes, u_int16_t *attribsize); EXTERN int spi_insert(struct spiob *); diff --git a/sbin/photurisd/state.c b/sbin/photurisd/state.c index 5eefea4c62a..29f6e1fb926 100644 --- a/sbin/photurisd/state.c +++ b/sbin/photurisd/state.c @@ -1,4 +1,4 @@ -/* $OpenBSD: state.c,v 1.8 2001/01/28 22:45:18 niklas Exp $ */ +/* $OpenBSD: state.c,v 1.9 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -73,7 +73,7 @@ state_unlink(struct stateob *ob) return (1); } -int +int state_save_verification(struct stateob *st, u_int8_t *buf, u_int16_t len) { if (st->verification == NULL || len > st->versize) { @@ -102,7 +102,7 @@ void state_copy_flags(struct stateob *src, struct stateob *dst) { dst->initiator = src->initiator; - + if (src->user != NULL) dst->user = strdup(src->user); @@ -128,7 +128,7 @@ state_new(void) p->modulus = BN_new(); p->generator = BN_new(); - + p->exchange_lifetime = exchange_lifetime; p->spi_lifetime = spi_lifetime; @@ -137,7 +137,7 @@ state_new(void) int state_value_reset(struct stateob *ob) -{ +{ BN_clear_free(ob->modulus); BN_clear_free(ob->generator); @@ -194,7 +194,7 @@ state_value_reset(struct stateob *ob) return (1); } -/* +/* * find the state ob with matching address */ @@ -211,18 +211,18 @@ state_find(char *address) return (tmp); } -struct stateob * -state_find_next(struct stateob *prev, char *address) -{ - struct stateob *tmp; +struct stateob * +state_find_next(struct stateob *prev, char *address) +{ + struct stateob *tmp; for (tmp = TAILQ_NEXT(prev, next); tmp; tmp = TAILQ_NEXT(tmp, next)) { - if (address == NULL || !strcmp(address, tmp->address)) + if (address == NULL || !strcmp(address, tmp->address)) break; - } + } - return (tmp); -} + return (tmp); +} struct stateob * state_find_icookie(u_int8_t *cookie) @@ -237,15 +237,15 @@ state_find_icookie(u_int8_t *cookie) return (tmp); } -struct stateob * -state_find_cookies(char *address, u_int8_t *icookie, u_int8_t *rcookie) +struct stateob * +state_find_cookies(char *address, u_int8_t *icookie, u_int8_t *rcookie) { struct stateob *tmp; - + for (tmp = state_find(address); tmp; tmp = state_find_next(tmp, address)) { - if (!bcmp(tmp->icookie, icookie, COOKIE_SIZE) && + if (!bcmp(tmp->icookie, icookie, COOKIE_SIZE) && (rcookie == NULL || !bcmp(tmp->rcookie, rcookie, COOKIE_SIZE))) break; } diff --git a/sbin/photurisd/state.h b/sbin/photurisd/state.h index 23d4a58c359..962cd002759 100644 --- a/sbin/photurisd/state.h +++ b/sbin/photurisd/state.h @@ -1,4 +1,4 @@ -/* $OpenBSD: state.h,v 1.7 2001/01/28 22:45:18 niklas Exp $ */ +/* $OpenBSD: state.h,v 1.8 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,7 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * state.h: + * state.h: * state object */ @@ -65,7 +65,7 @@ struct stateob { char *user; /* User name for which do the exchange */ int flags; /* Possible flags for this exchange */ - + char address[16]; /* Remote address */ u_int16_t port; /* Remote port for Photuris daemon */ u_int16_t sport, dport; /* Only used by notify at the moment */ @@ -85,7 +85,7 @@ struct stateob { u_int8_t *roschemes; /* Responder offered schemes */ u_int16_t roschemesize; /* Responder offered schemes size */ - u_int8_t oSPI[SPI_SIZE]; /* Owner SPI */ + u_int8_t oSPI[SPI_SIZE]; /* Owner SPI */ u_int8_t oSPITBV[3]; /* Three Byte Value */ u_int8_t *oSPIident; /* Owner SPI identification */ u_int8_t *oSPIattrib; /* Owner SPI attributes */ diff --git a/sbin/photurisd/userdefs.h b/sbin/photurisd/userdefs.h index bcabe3a5d70..c69bbd5eefd 100644 --- a/sbin/photurisd/userdefs.h +++ b/sbin/photurisd/userdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: userdefs.h,v 1.4 2002/02/17 19:42:28 millert Exp $ */ +/* $OpenBSD: userdefs.h,v 1.5 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,7 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * userdefs.h: + * userdefs.h: * handling userdefs */ diff --git a/sbin/photurisd/validity.c b/sbin/photurisd/validity.c index fa75d0e900c..c5b182f180d 100644 --- a/sbin/photurisd/validity.c +++ b/sbin/photurisd/validity.c @@ -1,4 +1,4 @@ -/* $OpenBSD: validity.c,v 1.4 2001/01/28 22:45:18 niklas Exp $ */ +/* $OpenBSD: validity.c,v 1.5 2002/06/09 08:13:09 todd Exp $ */ /* * Copyright 1997-2000 Niels Provos <provos@citi.umich.edu> @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: validity.c,v 1.4 2001/01/28 22:45:18 niklas Exp $"; +static char rcsid[] = "$OpenBSD: validity.c,v 1.5 2002/06/09 08:13:09 todd Exp $"; #endif #define _VALIDITY_C_ @@ -44,9 +44,9 @@ static char rcsid[] = "$OpenBSD: validity.c,v 1.4 2001/01/28 22:45:18 niklas Exp #include <stdlib.h> #include <string.h> #include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <md5.h> #include <sha1.h> #include "config.h" @@ -80,96 +80,96 @@ get_validity_verification_size(struct stateob *st) case DH_G_5_3DES_SHA1: return (160/8)+2; default: - log_print("validitiy.c: Unknown exchange scheme: %d\n", + log_print("validitiy.c: Unknown exchange scheme: %d\n", *((u_int16_t *)st->scheme)); return 0; } } int -create_validity_verification(struct stateob *st, u_int8_t *buffer, +create_validity_verification(struct stateob *st, u_int8_t *buffer, u_int8_t *packet, u_int16_t size) { struct idxform *hash; - switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: - case DH_G_2_DES_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: + switch(ntohs(*((u_int16_t *)st->scheme))) { + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: + case DH_G_2_DES_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: hash = get_hash(HASH_MD5); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: hash = get_hash(HASH_SHA1); break; - default: - log_print("validity.c: Unknown exchange scheme: %d\n", - *((u_int16_t *)st->scheme)); - return 0; + default: + log_print("validity.c: Unknown exchange scheme: %d\n", + *((u_int16_t *)st->scheme)); + return 0; } - if(valsign(st, hash, buffer+2, packet, size)) { - /* Create varpre number from digest */ - buffer[0] = (hash->hashsize >> 5) & 0xFF; - buffer[1] = (hash->hashsize << 3) & 0xFF; - } + if(valsign(st, hash, buffer+2, packet, size)) { + /* Create varpre number from digest */ + buffer[0] = (hash->hashsize >> 5) & 0xFF; + buffer[1] = (hash->hashsize << 3) & 0xFF; + } state_save_verification(st, buffer, hash->hashsize+2); return hash->hashsize+2; } -int -verify_validity_verification(struct stateob *st, u_int8_t *buffer, - u_int8_t *packet, u_int16_t size) -{ +int +verify_validity_verification(struct stateob *st, u_int8_t *buffer, + u_int8_t *packet, u_int16_t size) +{ struct idxform *hash; - switch(ntohs(*((u_int16_t *)st->scheme))) { - case DH_G_2_MD5: - case DH_G_3_MD5: - case DH_G_5_MD5: - case DH_G_2_DES_MD5: - case DH_G_3_DES_MD5: - case DH_G_5_DES_MD5: + switch(ntohs(*((u_int16_t *)st->scheme))) { + case DH_G_2_MD5: + case DH_G_3_MD5: + case DH_G_5_MD5: + case DH_G_2_DES_MD5: + case DH_G_3_DES_MD5: + case DH_G_5_DES_MD5: if (varpre2octets(buffer) != 18) return 0; hash = get_hash(HASH_MD5); break; - case DH_G_2_3DES_SHA1: - case DH_G_3_3DES_SHA1: - case DH_G_5_3DES_SHA1: + case DH_G_2_3DES_SHA1: + case DH_G_3_3DES_SHA1: + case DH_G_5_3DES_SHA1: if (varpre2octets(buffer) != 22) return 0; hash = get_hash(HASH_SHA1); break; - default: - log_print("validity.c: Unknown exchange scheme: %d\n", - *((u_int16_t *)st->scheme)); - return 0; - } + default: + log_print("validity.c: Unknown exchange scheme: %d\n", + *((u_int16_t *)st->scheme)); + return 0; + } state_save_verification(st, buffer, hash->hashsize+2); return valverify(st, hash, buffer+2, packet, size); -} +} int -valsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, - u_int8_t *packet, u_int16_t psize) +valsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, + u_int8_t *packet, u_int16_t psize) { u_int8_t key[HASH_MAX]; u_int16_t keylen = HASH_MAX; create_verification_key(st, key, &keylen, 1); /* Owner direction */ - - hash->Init(hash->ctx); - + + hash->Init(hash->ctx); + hash->Update(hash->ctx, key, keylen); hash->Update(hash->ctx, st->icookie, COOKIE_SIZE); @@ -181,15 +181,15 @@ valsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, hash->Update(hash->ctx, st->oSPIidentver, st->oSPIidentversize); hash->Update(hash->ctx, st->uSPIidentver, st->uSPIidentversize); - packet += 4 + SPI_SIZE + hash->hashsize + 2; + packet += 4 + SPI_SIZE + hash->hashsize + 2; psize -= 4 + SPI_SIZE + hash->hashsize + 2; hash->Update(hash->ctx, packet, psize); /* Data fill */ - hash->Final(NULL, hash->ctx); + hash->Final(NULL, hash->ctx); hash->Update(hash->ctx, key, keylen); - hash->Final(signature, hash->ctx); + hash->Final(signature, hash->ctx); return hash->hashsize; } @@ -197,7 +197,7 @@ valsign(struct stateob *st, struct idxform *hash, u_int8_t *signature, /* We assume that the verification field is zeroed */ int -valverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, +valverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, u_int8_t *packet, u_int16_t psize) { u_int8_t digest[HASH_MAX]; @@ -205,9 +205,9 @@ valverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, u_int16_t keylen = HASH_MAX; create_verification_key(st, key, &keylen, 0); /* User direction */ - - hash->Init(hash->ctx); - + + hash->Init(hash->ctx); + hash->Update(hash->ctx, key, keylen); hash->Update(hash->ctx, st->icookie, COOKIE_SIZE); @@ -219,15 +219,15 @@ valverify(struct stateob *st, struct idxform *hash, u_int8_t *signature, hash->Update(hash->ctx, st->uSPIidentver, st->uSPIidentversize); hash->Update(hash->ctx, st->oSPIidentver, st->oSPIidentversize); - packet += 4 + SPI_SIZE + hash->hashsize + 2; + packet += 4 + SPI_SIZE + hash->hashsize + 2; psize -= 4 + SPI_SIZE + hash->hashsize + 2; hash->Update(hash->ctx, packet, psize); /* Data fill */ - hash->Final(NULL, hash->ctx); + hash->Final(NULL, hash->ctx); hash->Update(hash->ctx, key, keylen); - hash->Final(digest, hash->ctx); + hash->Final(digest, hash->ctx); return !bcmp(digest,signature,hash->hashsize); } diff --git a/sbin/photurisd/validity.h b/sbin/photurisd/validity.h index 16b77cf3a76..69407bc06af 100644 --- a/sbin/photurisd/validity.h +++ b/sbin/photurisd/validity.h @@ -38,7 +38,7 @@ #include "state.h" #undef EXTERN - + #ifdef _VALIDITY_C_ #define EXTERN #else diff --git a/sbin/raidctl/Makefile b/sbin/raidctl/Makefile index 5b254eed896..25b3c163f95 100644 --- a/sbin/raidctl/Makefile +++ b/sbin/raidctl/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.6 2001/12/29 21:54:57 tdeval Exp $ +# $OpenBSD: Makefile,v 1.7 2002/06/09 08:13:09 todd Exp $ # $NetBSD: Makefile,v 1.8 2001/01/27 19:32:47 oster Exp $ -PROG= raidctl +PROG= raidctl SRCS= rf_configure.c raidctl.c MAN= raidctl.8 diff --git a/sbin/raidctl/raidctl.8 b/sbin/raidctl/raidctl.8 index 795ef13295b..3f38c6a43c4 100644 --- a/sbin/raidctl/raidctl.8 +++ b/sbin/raidctl/raidctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: raidctl.8,v 1.23 2002/02/18 22:57:05 tdeval Exp $ +.\" $OpenBSD: raidctl.8,v 1.24 2002/06/09 08:13:09 todd Exp $ .\" $NetBSD: raidctl.8,v 1.24 2001/07/10 01:30:52 lukem Exp $ .\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -114,7 +114,7 @@ will execute the requested action for all the configured .Xr raid 4 devices. .Pp -The command-line options for +The command-line options for .Nm are as follows: .Bl -tag -width indent @@ -125,7 +125,7 @@ as a hot spare for the device .Ar dev . .It Fl A Ic yes Ar dev Make the RAID set auto-configurable. The RAID set will be -automatically configured at boot +automatically configured at boot .Ar before the root file system is mounted. Note that all components of the set must be of type RAID in the @@ -135,21 +135,21 @@ Turn off auto-configuration for the RAID set. .It Fl A Ic root Ar dev Make the RAID set auto-configurable, and also mark the set as being eligible to be the root partition. A RAID set configured this way -will +will .Ar override the use of the boot disk as the root device. All components of the set must be of type RAID in the disklabel. Note that the kernel being booted must currently reside on a non-RAID set. .It Fl B Ar dev Initiate a copyback of reconstructed data from a spare disk to -its original disk. This is performed after a component has failed, +its original disk. This is performed after a component has failed, and the failed drive has been reconstructed onto a spare drive. .It Fl c Ar config_file Ar dev Configure the RAIDframe device .Ar dev according to the configuration given in -.Ar config_file . -A description of the contents of +.Ar config_file . +A description of the contents of .Ar config_file is given later. .It Fl C Ar config_file Ar dev @@ -179,10 +179,10 @@ or .Fl C . .It Fl i Ar dev Initialize the RAID device. In particular, (re-write) the parity on -the selected device. This +the selected device. This .Ar MUST -be done for -.Ar all +be done for +.Ar all RAID sets before the RAID device is labeled and before file systems are created on the RAID device. .It Fl I Ar serial_number Ar dev @@ -191,7 +191,7 @@ Initialize the component labels on each component of the device. is used as one of the keys in determining whether a particular set of components belong to the same RAID set. While not strictly enforced, different serial numbers should be used for -different RAID sets. This step +different RAID sets. This step .Ar MUST be performed when a new RAID set is created. .It Fl p Ar dev @@ -231,27 +231,27 @@ re-writing, and copybacks, provide a progress indicator. .Ss Configuration file The format of the configuration file is complex, and only an abbreviated treatment is given here. In the configuration -files, a +files, a .Sq # indicates the beginning of a comment. .Pp There are 4 required sections of a configuration file, and 2 -optional sections. Each section begins with a -.Sq START , +optional sections. Each section begins with a +.Sq START , followed by the section name, and the configuration parameters associated with that -section. The first section is the +section. The first section is the .Sq array section, and it specifies the number of rows, columns, and spare disks in the RAID set. For -example: +example: .Bd -unfilled -offset indent START array 1 3 0 .Ed .Pp indicates an array with 1 row, 3 columns, and 0 spare disks. Note -that although multi-dimensional arrays may be specified, they are +that although multi-dimensional arrays may be specified, they are .Ar NOT supported in the driver. .Pp @@ -269,28 +269,28 @@ START disks specifies the three component disks to be used in the RAID device. If any of the specified drives cannot be found when the RAID device is configured, then they will be marked as -.Sq failed , +.Sq failed , and the system will -operate in degraded mode. Note that it is +operate in degraded mode. Note that it is .Ar imperative that the order of the components in the configuration file does not change between configurations of a RAID device. Changing the order of the components will result in data loss if the set is configured -with the +with the .Fl C option. In normal circumstances, the RAID set will not configure if only .Fl c -is specified, and the components are out-of-order. +is specified, and the components are out-of-order. .Pp -The next section, which is the +The next section, which is the .Sq spare section, is optional, and, if -present, specifies the devices to be used as +present, specifies the devices to be used as .Sq hot spares -- devices which are on-line, but are not actively used by the RAID driver unless -one of the main components fail. A simple +one of the main components fail. A simple .Sq spare section might be: .Bd -unfilled -offset indent @@ -299,7 +299,7 @@ START spare .Ed .Pp for a configuration with a single spare component. If no spare drives -are to be used in the configuration, then the +are to be used in the configuration, then the .Sq spare section may be omitted. .Pp @@ -326,7 +326,7 @@ While certain values above 1 are permitted, a discussion of valid values and the consequences of using anything other than 1 are outside the scope of this document. The last value in this section (5 in this example) indicates the parity configuration desired. Valid entries -include: +include: .Bl -tag -width inde .It 0 RAID level 0. No parity, only simple striping. @@ -356,7 +356,7 @@ fifo 100 .Ed .Pp where the queuing method is specified as fifo (first-in, first-out), -and the size of the per-component queue is limited to 100 requests. +and the size of the per-component queue is limited to 100 requests. Other queuing methods may also be specified, but a discussion of them is beyond the scope of this document. .Pp @@ -364,7 +364,7 @@ The final section, the .Sq debug section, is optional. For more details on this the reader is referred to the RAIDframe documentation -discussed in the +discussed in the .Sx HISTORY section. @@ -381,14 +381,14 @@ with the use of and that they understand how the component reconstruction process works. The examples in this section will focus on configuring a number of different RAID sets of varying degrees of redundancy. -By working through these examples, administrators should be able to +By working through these examples, administrators should be able to develop a good feel for how to configure a RAID set, and how to initiate reconstruction of failed components. .Pp In the following examples .Sq raid0 -will be used to denote the RAID device. -.Sq /dev/rraid0c +will be used to denote the RAID device. +.Sq /dev/rraid0c may be used in place of .Sq raid0 . .Pp @@ -404,9 +404,9 @@ f: 1800000 200495 RAID # (Cyl. 405*- 4041*) .Ed .Pp While -.Dv FS_BSDFFS +.Dv FS_BSDFFS (e.g. 4.2BSD) will also work as the component type, the type -.Dv FS_RAID +.Dv FS_RAID (e.g. RAID) is preferred for RAIDframe use, as it is required for features such as auto-configuration. As part of the initial configuration of each RAID set, each component will be given a @@ -425,7 +425,7 @@ required for the auto-detection and auto-configuration of RAID sets at boot time. For a component label to be considered valid, that particular component label must be in agreement with the other component labels in the set. For example, the serial number, -.Sq modification counter , +.Sq modification counter , number of rows and number of columns must all be in agreement. If any of these are different, then the component is not considered to be part of the set. See @@ -433,10 +433,10 @@ not considered to be part of the set. See for more information about component labels. .Pp Once the components have been identified, and the disks have -appropriate labels, +appropriate labels, .Nm "" is then used to configure the -.Xr raid 4 +.Xr raid 4 device. To configure the device, a configuration file which looks something like: .Bd -unfilled -offset indent @@ -516,16 +516,16 @@ the RAID 5 case above. Note as well that RAID 1 sets are currently limited to only 2 components. At present, n-way mirroring is not possible. .Pp -The first time a RAID set is configured, the +The first time a RAID set is configured, the .Fl C option must be used: .Bd -unfilled -offset indent # raidctl -C raid0.conf raid0 .Ed .Pp -where +where .Sq raid0.conf -is the name of the RAID configuration file. The +is the name of the RAID configuration file. The .Fl C forces the configuration to succeed, even if any of the component labels are incorrect. The @@ -534,7 +534,7 @@ option should not be used lightly in situations other than initial configurations, as if the system is refusing to configure a RAID set, there is probably a very good reason for it. After the initial configuration is done (and -appropriate component labels are added with the +appropriate component labels are added with the .Fl I option) then raid0 can be configured normally with: .Bd -unfilled -offset indent @@ -551,19 +551,19 @@ parity on the RAID set. Initializing the component labels is done with: where .Sq 112341 is a user-specified serial number for the RAID set. This -initialization step is -.Ar required +initialization step is +.Ar required for all RAID sets. As well, using different -serial numbers between RAID sets is -.Ar strongly encouraged , +serial numbers between RAID sets is +.Ar strongly encouraged , as using the same serial number for all RAID sets will only serve to decrease the usefulness of the component label checking. .Pp Initializing the RAID set is done via the .Fl i -option. This initialization +option. This initialization .Ar MUST -be done for +be done for .Ar all RAID sets, since among other things it verifies that the parity (if any) on the RAID set is correct. Since this initialization may be @@ -583,7 +583,7 @@ Parity Re-write status: 10% |**** | ETA: 06:03 / .Ed .Pp -The output provides a +The output provides a .Sq Percent Complete in both a numeric and graphical format, as well as an estimated time to completion of the operation. @@ -594,7 +594,7 @@ part of RAID, it is critical that the parity is correct as much as possible. If the parity is not correct, then there is no guarantee that data will not be lost if a component fails. .Pp -Once the parity is known to be correct, +Once the parity is known to be correct, it is then safe to perform .Xr disklabel 8 , .Xr newfs 8 , @@ -631,13 +631,13 @@ fifo 100 /dev/sd0e is the real component, and will be the second disk of a RAID 1 set. The component /dev/sd6e, which must exist, but have no physical device associated with it, is simply used as a placeholder. -Configuration (using +Configuration (using .Fl C -and +and .Fl I Ar 12345 as above) proceeds normally, but initialization of the RAID set will have to wait until all physical components are present. After -configuration, this set can be used normally, but will be operating +configuration, this set can be used normally, but will be operating in degraded mode. Once a second physical component is obtained, it can be hot-added, the existing data mirrored, and normal operation resumed. @@ -685,11 +685,11 @@ Copyback is 100% complete. This indicates that all is well with the RAID set. Of importance here are the component lines which read .Sq optimal , -and the +and the .Sq Parity status line which indicates that the parity is up-to-date. Note that if there are file systems open on the RAID set, the individual components -will not be +will not be .Sq clean but the set as a whole can still be clean. .Pp @@ -781,7 +781,7 @@ Spares: Note that with the use of .Fl f a reconstruction has not been started. To both fail the disk and -start a reconstruction, the +start a reconstruction, the .Fl F option must be used: .Bd -unfilled -offset indent @@ -809,7 +809,7 @@ Copyback is 100% complete. .Ed .Pp This indicates that a reconstruction is in progress. To find out how -the reconstruction is progressing the +the reconstruction is progressing the .Fl S option may be used. This will indicate the progress in terms of the percentage of the reconstruction that is completed. When the @@ -831,7 +831,7 @@ Copyback is 100% complete. .Ed .Pp At this point there are at least two options. First, if /dev/sd2e is -known to be good (i.e. the failure was either caused by +known to be good (i.e. the failure was either caused by .Fl f or .Fl F , @@ -866,12 +866,12 @@ START drives .Ed .Pp This can be done as /dev/sd4e is completely interchangeable with -/dev/sd2e at this point. Note that extreme care must be taken when +/dev/sd2e at this point. Note that extreme care must be taken when changing the order of the drives in a configuration. This is one of the few instances where the devices and/or their orderings can be changed without loss of data! In general, the ordering of components -in a configuration file should -.Ar never +in a configuration file should +.Ar never be changed. .Pp If a component fails and there are no hot spares @@ -904,7 +904,7 @@ Reconstruction could then take place using .Fl F as describe above. .Pp -A second option is to rebuild directly onto /dev/sd2e. Once the disk +A second option is to rebuild directly onto /dev/sd2e. Once the disk containing /dev/sd2e has been replaced, one can simply use: .Bd -unfilled -offset indent # raidctl -R /dev/sd2e raid0 @@ -950,8 +950,8 @@ spare, the following could be done: # raidctl -F component1 raid0 .Ed .Pp -at which point the data missing from -.Sq component1 +at which point the data missing from +.Sq component1 would be reconstructed onto /dev/sd3e. .Pp .Ss RAID on RAID @@ -1008,7 +1008,7 @@ have become scrambled. Having a system's root file system .Pq Pa / on a RAID set is also allowed, -with the +with the .Sq a partition of such a RAID set being used for .Pa / . @@ -1022,12 +1022,12 @@ To return raid0a to be just an auto-configuring set simply use the arguments. .Pp .\" Note that kernels can only be directly read from RAID 1 components on -.\" alpha and pmax architectures. On those architectures, the +.\" alpha and pmax architectures. On those architectures, the .\" .Dv FS_RAID .\" file system is recognized by the bootblocks, and will properly load the -.\" kernel directly from a RAID 1 component. +.\" kernel directly from a RAID 1 component. .\" For other architectures, or -Note that kernels can't be directly read from a RAID component. +Note that kernels can't be directly read from a RAID component. To support the root file system on RAID sets, some mechanism must be used to get a kernel booting. For example, a small partition containing only the secondary boot-blocks and an alternate kernel (or two) could be @@ -1040,32 +1040,32 @@ as root devices. .Pp A typical RAID 1 setup with root on RAID might be as follows: .Bl -enum -.It +.It wd0a - a small partition, which contains a complete, bootable, basic .Ox -installation. +installation. .It wd1a - also contains a complete, bootable, basic .Ox installation. -.It +.It wd0e and wd1e - a RAID 1 set, raid0, used for the root file system. .It wd0f and wd1f - a RAID 1 set, raid1, which will be used only for -swap space. +swap space. .It wd0g and wd1g - a RAID 1 set, raid2, used for .Pa /usr , .Pa /home , or other data, if desired. -.It +.It wd0h and wd0h - a RAID 1 set, raid3, if desired. .El .Pp RAID sets raid0, raid1, and raid2 are all marked as auto-configurable. raid0 is marked as being a root file system. When new kernels are installed, the kernel is not only copied to -.Pa / , +.Pa / , but also to wd0a and wd1a. The kernel on wd0a is required, since that is the kernel the system boots from. The kernel on wd1a is also required, since that will be the kernel used should wd0 fail. The @@ -1074,7 +1074,7 @@ available, in the event that one of the drives fail. .Pp There is no requirement that the root file system be on the same disk as the kernel. For example, obtaining the kernel from wd0a, and using -sd0e and sd1e for raid0, and the root file system, is fine. It +sd0e and sd1e for raid0, and the root file system, is fine. It .Ar is critical, however, that there be multiple kernels available, in the event of media failure. @@ -1083,7 +1083,7 @@ Multi-layered RAID devices (such as a RAID 0 set made up of RAID 1 sets) are .Ar not supported as root devices or auto-configurable devices at this point. -(Multi-layered RAID devices +(Multi-layered RAID devices .Ar are supported in general, however, as mentioned earlier.) Note that in order to enable component auto-detection and auto-configuration of @@ -1124,7 +1124,7 @@ Distribution of components among controllers IO bandwidth .It file system access patterns -.It +.It CPU speed .El .Pp @@ -1151,13 +1151,13 @@ be calculated before the stripe is written, and then the stripe data and parity can be written in parallel. When the amount of data being written is less than a full stripe worth, the .Sq small write -problem occurs. Since a +problem occurs. Since a .Sq small write means only a portion of the stripe on the components is going to change, the data (and parity) on the components must be updated -slightly differently. First, the +slightly differently. First, the .Sq old parity -and +and .Sq old data must be read from the components. Then the new parity is constructed, using the new data to be written, and the old data and old parity. @@ -1171,7 +1171,7 @@ from the system will use exactly one large stripe write. As is seen later, there are some file system dependencies which may come into play here as well. .Pp -Since the size of a +Since the size of a .Sq large IO is often (currently) only 32K or 64K, on a 5-drive RAID 5 set it may be desirable to select a SectPerSU value of 16 blocks (8K) or 32 @@ -1181,8 +1181,8 @@ empirical measurement will provide the best indicators of which values will yeild better performance. .Pp The parameters used for the file system are also critical to good -performance. For -.Xr newfs 8 , +performance. For +.Xr newfs 8 , for example, increasing the block size to 32K or 64K may improve performance dramatically. As well, changing the cylinders-per-group parameter from 16 to 32 or higher is often not only necessary for @@ -1194,57 +1194,57 @@ Despite the length of this man-page, configuring a RAID set is a relatively straight-forward process. All that needs to be done is the following steps: .Bl -enum -.It -Use -.Xr disklabel 8 +.It +Use +.Xr disklabel 8 to create the components (of type RAID). -.It -Construct a RAID configuration file: e.g. -.Sq raid0.conf -.It -Configure the RAID set with: +.It +Construct a RAID configuration file: e.g. +.Sq raid0.conf +.It +Configure the RAID set with: .Bd -unfilled -offset indent # raidctl -C raid0.conf raid0 .Ed .Pp -.It -Initialize the component labels with: +.It +Initialize the component labels with: .Bd -unfilled -offset indent # raidctl -I 123456 raid0 .Ed .Pp -.It -Initialize other important parts of the set with: +.It +Initialize other important parts of the set with: .Bd -unfilled -offset indent # raidctl -i raid0 .Ed .Pp .It -Get the default label for the RAID set: +Get the default label for the RAID set: .Bd -unfilled -offset indent # disklabel raid0 > /tmp/label .Ed .Pp -.It -Edit the label: +.It +Edit the label: .Bd -unfilled -offset indent # vi /tmp/label .Ed .Pp -.It -Put the new label on the RAID set: +.It +Put the new label on the RAID set: .Bd -unfilled -offset indent # disklabel -R -r raid0 /tmp/label .Ed .Pp -.It -Create the file system: +.It +Create the file system: .Bd -unfilled -offset indent -# newfs /dev/rraid0e +# newfs /dev/rraid0e .Ed .Pp .It -Mount the file system: +Mount the file system: .Bd -unfilled -offset indent # mount /dev/raid0e /mnt .Ed @@ -1256,7 +1256,7 @@ Use: .Ed .Pp To re-configure the RAID set the next time it is needed, or put -raid0.conf into /etc where it will automatically be started by +raid0.conf into /etc where it will automatically be started by the /etc/rc scripts. .El .Pp diff --git a/sbin/raidctl/raidctl.c b/sbin/raidctl/raidctl.c index ca1e49266d0..57f2d8f3db7 100644 --- a/sbin/raidctl/raidctl.c +++ b/sbin/raidctl/raidctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raidctl.c,v 1.17 2002/03/31 13:12:09 tdeval Exp $ */ +/* $OpenBSD: raidctl.c,v 1.18 2002/06/09 08:13:09 todd Exp $ */ /* $NetBSD: raidctl.c,v 1.27 2001/07/10 01:30:52 lukem Exp $ */ /*- @@ -37,8 +37,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * This program is a re-write of the original rf_ctrl program +/* + * This program is a re-write of the original rf_ctrl program * distributed by CMU with RAIDframe 1.1. * * This program is the userland interface to the RAIDframe kernel @@ -133,7 +133,7 @@ main(argc, argv) force = 0; actionstr = NULL; - while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:r:R:sSpPuv")) + while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:r:R:sSpPuv")) != -1) switch(ch) { case 'a': @@ -193,7 +193,7 @@ main(argc, argv) serial_number = atoi(optarg); num_options++; break; - case 'l': + case 'l': action = RAIDFRAME_SET_COMPONENT_LABEL; strlcpy(component, optarg, PATH_MAX); num_options++; @@ -238,7 +238,7 @@ main(argc, argv) argc -= optind; argv += optind; - if ((num_options > 1) || (argc == NULL)) + if ((num_options > 1) || (argc == NULL)) usage(); strlcpy(name, argv[0], PATH_MAX); @@ -305,7 +305,7 @@ main(argc, argv) case RAIDFRAME_REWRITEPARITY: i = nfd; while (i--) { - do_ioctl(fds[i].fd, RAIDFRAME_REWRITEPARITY, NULL, + do_ioctl(fds[i].fd, RAIDFRAME_REWRITEPARITY, NULL, "RAIDFRAME_REWRITEPARITY"); } actionstr = "Parity Re-Write"; @@ -377,10 +377,10 @@ rf_configure(fds, config_file, force) cfg.force = force; - /* + /* * Note the extra level of redirection needed here, since - * what we really want to pass in is a pointer to the pointer to - * the configuration structure. + * what we really want to pass in is a pointer to the pointer to + * the configuration structure. */ generic = (void *) &cfg; @@ -432,14 +432,14 @@ rf_get_device_status(fds, nfd) printf("raid%d Components:\n", fds[i].id); for (j = 0; j < device_config.ndevs; j++) { - printf("%20s: %s\n", device_config.devs[j].devname, + printf("%20s: %s\n", device_config.devs[j].devname, device_status(device_config.devs[j].status)); } if (device_config.nspares > 0) { printf("Spares:\n"); for (j = 0; j < device_config.nspares; j++) { printf("%20s: %s\n", - device_config.spares[j].devname, + device_config.spares[j].devname, device_status(device_config.spares[j].status)); } } else { @@ -461,11 +461,11 @@ rf_get_device_status(fds, nfd) if (device_config.nspares > 0) { for(j=0; j < device_config.nspares; j++) { - if ((device_config.spares[j].status == + if ((device_config.spares[j].status == rf_ds_optimal) || - (device_config.spares[j].status == + (device_config.spares[j].status == rf_ds_used_spare)) { - get_component_label(&fds[i], + get_component_label(&fds[i], device_config.spares[j].devname); } else { printf("%s status is: %s. " @@ -554,8 +554,8 @@ rf_output_configuration(fds, nfd) "# sectPerSU SUsPerParityUnit SUsPerReconUnit " "RAID_level_%c\n", (char) component_label.parityConfig); - printf("%d %d %d %c\n", - component_label.sectPerSU, component_label.SUsPerPU, + printf("%d %d %d %c\n", + component_label.sectPerSU, component_label.SUsPerPU, component_label.SUsPerRU, (char) component_label.parityConfig); printf("\n"); @@ -595,14 +595,14 @@ get_component_number(fds, component_name, component_number, num_columns) } if (!found) { /* maybe it's a spare? */ for (i = 0; i < device_config.nspares; i++) { - if (strncmp(component_name, + if (strncmp(component_name, device_config.spares[i].devname, PATH_MAX) == 0) { found = 1; *component_number = i + device_config.ndevs; /* the way spares are done should really change... */ - *num_columns = device_config.cols + + *num_columns = device_config.cols + device_config.nspares; } } @@ -631,7 +631,7 @@ rf_fail_disk(fds, component_to_fail, do_recon) } else { recon_request.flags = RF_FDFLAGS_NONE; } - do_ioctl(fds->fd, RAIDFRAME_FAIL_DISK, &recon_request, + do_ioctl(fds->fd, RAIDFRAME_FAIL_DISK, &recon_request, "RAIDFRAME_FAIL_DISK"); if (do_recon && verbose) { printf("Reconstruction status:\n"); @@ -663,22 +663,22 @@ get_component_label(fds, component) printf("Component label for %s:\n", component); printf(" Row: %d, Column: %d, Num Rows: %d, Num Columns: %d\n", - component_label.row, component_label.column, + component_label.row, component_label.column, component_label.num_rows, component_label.num_columns); printf(" Version: %d, Serial Number: %d, Mod Counter: %d\n", component_label.version, component_label.serial_number, component_label.mod_counter); printf(" Clean: %s, Status: %d\n", - component_label.clean ? "Yes" : "No", + component_label.clean ? "Yes" : "No", component_label.status); printf(" sectPerSU: %d, SUsPerPU: %d, SUsPerRU: %d\n", - component_label.sectPerSU, component_label.SUsPerPU, + component_label.sectPerSU, component_label.SUsPerPU, component_label.SUsPerRU); printf(" Queue size: %d, blocksize: %d, numBlocks: %d\n", component_label.maxOutstanding, component_label.blockSize, component_label.numBlocks); printf(" RAID Level: %c\n", (char) component_label.parityConfig); - printf(" Autoconfig: %s\n", + printf(" Autoconfig: %s\n", component_label.autoconfigure ? "Yes" : "No"); printf(" Root partition: %s\n", component_label.root_partition ? "Yes" : "No"); @@ -733,7 +733,7 @@ init_component_labels(fds, serial_number) do_ioctl(fds->fd, RAIDFRAME_INIT_LABELS, &component_label, "RAIDFRAME_SET_COMPONENT_LABEL"); } - + static void set_autoconfig(fds, autoconf) fdidpair *fds; @@ -778,7 +778,7 @@ add_hot_spare(fds, component) hot_spare.row = 0; hot_spare.column = 0; - strlcpy(hot_spare.component_name, component, + strlcpy(hot_spare.component_name, component, sizeof(hot_spare.component_name)); do_ioctl(fds->fd, RAIDFRAME_ADD_HOT_SPARE, &hot_spare, @@ -799,7 +799,7 @@ remove_hot_spare(fds, component) hot_spare.row = component_num / num_cols; hot_spare.column = component_num % num_cols; - strlcpy(hot_spare.component_name, component, + strlcpy(hot_spare.component_name, component, sizeof(hot_spare.component_name)); do_ioctl(fds->fd, RAIDFRAME_REMOVE_HOT_SPARE, &hot_spare, @@ -882,9 +882,9 @@ check_parity(fds, nfd, do_rewrite) } else { i = nfd; while (i--) { - do_ioctl(fds[i].fd, - RAIDFRAME_CHECK_PARITYREWRITE_STATUS, - &percent_done, + do_ioctl(fds[i].fd, + RAIDFRAME_CHECK_PARITYREWRITE_STATUS, + &percent_done, "RAIDFRAME_CHECK_PARITYREWRITE_STATUS" ); if (percent_done == 100) { @@ -919,15 +919,15 @@ check_status(fds, nfd, meter) printf("raid%d Status:\n", fds[i].id); } do_ioctl(fds[i].fd, RAIDFRAME_CHECK_RECON_STATUS, - &recon_percent_done, + &recon_percent_done, "RAIDFRAME_CHECK_RECON_STATUS"); printf("Reconstruction is %d%% complete.\n", recon_percent_done); if (recon_percent_done < 100) { do_recon |= 1 << fds[i].id; } - do_ioctl(fds[i].fd, RAIDFRAME_CHECK_PARITYREWRITE_STATUS, - &parity_percent_done, + do_ioctl(fds[i].fd, RAIDFRAME_CHECK_PARITYREWRITE_STATUS, + &parity_percent_done, "RAIDFRAME_CHECK_PARITYREWRITE_STATUS"); printf("Parity Re-write is %d%% complete.\n", parity_percent_done); @@ -935,7 +935,7 @@ check_status(fds, nfd, meter) do_parity |= 1 << fds[i].id; } do_ioctl(fds[i].fd, RAIDFRAME_CHECK_COPYBACK_STATUS, - ©back_percent_done, + ©back_percent_done, "RAIDFRAME_CHECK_COPYBACK_STATUS"); printf("Copyback is %d%% complete.\n", copyback_percent_done); @@ -1044,7 +1044,7 @@ do_meter(fds, nfd, option) elapsed_sec--; } - elapsed = (double) elapsed_sec + + elapsed = (double) elapsed_sec + (double) elapsed_usec / 1000000.0; if (amount <= 0) { /* we don't do negatives (yet?) */ @@ -1058,14 +1058,14 @@ do_meter(fds, nfd, option) if (rate > 0.0) { simple_eta = (int) - (((double)progress_total - - (double) progress_completed) + (((double)progress_total - + (double) progress_completed) / rate); } else { simple_eta = -1; } - if (simple_eta <= 0) { + if (simple_eta <= 0) { simple_eta = last_eta; } else { last_eta = simple_eta; @@ -1081,7 +1081,7 @@ do_meter(fds, nfd, option) write(fileno(stdout), buffer, strlen(buffer)); fflush(stdout); - if (++tbit_value > 3) + if (++tbit_value > 3) tbit_value = 0; if (not_done) @@ -1117,7 +1117,7 @@ get_bar(string, percent, max_strlen) if (max_strlen > STAR_MIDPOINT) { max_strlen = STAR_MIDPOINT; } - offset = STAR_MIDPOINT - + offset = STAR_MIDPOINT - (int)((percent * max_strlen) / 100); if (offset < 0) offset = 0; diff --git a/sbin/raidctl/rf_configure.c b/sbin/raidctl/rf_configure.c index 198f5433c33..5d1bb0b91b9 100644 --- a/sbin/raidctl/rf_configure.c +++ b/sbin/raidctl/rf_configure.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_configure.c,v 1.8 2002/05/22 21:23:49 tdeval Exp $ */ +/* $OpenBSD: rf_configure.c,v 1.9 2002/06/09 08:13:09 todd Exp $ */ /* $NetBSD: rf_configure.c,v 1.14 2001/02/04 21:05:42 christos Exp $ */ /* @@ -67,7 +67,7 @@ #define ATTRIBUTE_UNUSED #endif -/* +/* * XXX we include this here so we don't need to drag rf_debugMem.c into * the picture... This is userland, afterall... */ @@ -152,7 +152,7 @@ int rf_get_next_nonblank_line(char *buf, int len, FILE *fp, * version of the driver, and in the user-level program that configures * the system via ioctl. */ -int +int rf_MakeConfig(configname, cfgPtr) char *configname; RF_Config_t *cfgPtr; @@ -310,7 +310,7 @@ out: /* used in architectures such as RAID0 where there is no layout-specific * information to be passed into the configuration code. */ -int +int rf_MakeLayoutSpecificNULL(fp, cfgPtr, ignored) FILE *fp ATTRIBUTE_UNUSED; RF_Config_t *cfgPtr; @@ -321,7 +321,7 @@ rf_MakeLayoutSpecificNULL(fp, cfgPtr, ignored) return(0); } -int +int rf_MakeLayoutSpecificDeclustered(configfp, cfgPtr, arg) FILE *configfp; RF_Config_t *cfgPtr; @@ -379,7 +379,7 @@ rf_MakeLayoutSpecificDeclustered(configfp, cfgPtr, arg) cfgPtr->layoutSpecificSize = RF_SPAREMAP_NAME_LEN + 6 * sizeof(int) + b * k; /* can't use RF_Malloc here b/c debugMem module not yet init'd */ - cfgBuf = (char *) malloc(cfgPtr->layoutSpecificSize); + cfgBuf = (char *) malloc(cfgPtr->layoutSpecificSize); cfgPtr->layoutSpecific = (void *) cfgBuf; p = cfgBuf; @@ -424,7 +424,7 @@ rf_MakeLayoutSpecificDeclustered(configfp, cfgPtr, arg) * utilities * ***************************************************************************/ - + /* finds a non-white character in the line */ char * rf_find_non_white(char *p) @@ -445,7 +445,7 @@ rf_find_white(char *p) * searches a file for a line that says "START string", where string is * specified as a parameter */ -int +int rf_search_file_for_start_of(string, buf, len, fp) const char *string; char *buf; @@ -468,7 +468,7 @@ rf_search_file_for_start_of(string, buf, len, fp) } /* reads from file fp into buf until it finds an interesting line */ -int +int rf_get_next_nonblank_line(buf, len, fp, errmsg) char *buf; int len ATTRIBUTE_UNUSED; diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 2fe36fd831f..70495b7dd60 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.81 2002/06/09 04:49:19 angelos Exp $ */ +/* $OpenBSD: sysctl.c,v 1.82 2002/06/09 08:13:09 todd Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static char *rcsid = "$OpenBSD: sysctl.c,v 1.81 2002/06/09 04:49:19 angelos Exp $"; +static char *rcsid = "$OpenBSD: sysctl.c,v 1.82 2002/06/09 08:13:09 todd Exp $"; #endif #endif /* not lint */ @@ -1645,7 +1645,7 @@ sysctl_chipset(string, bufpp, mib, flags, typep) if ((indx = findname(string, "third", bufpp, &chipsetlist)) == -1) return(-1); mib[2] = indx; - if (!nflag) + if (!nflag) printf("%s = ", string); switch(mib[2]) { case CPU_CHIPSET_MEM: @@ -1659,7 +1659,7 @@ sysctl_chipset(string, bufpp, mib, flags, typep) break; case CPU_CHIPSET_BWX: len = sizeof(int); - if (sysctl(mib, 3, &bwx, &len, NULL, 0) < 0) + if (sysctl(mib, 3, &bwx, &len, NULL, 0) < 0) return (-1); printf("%d\n", bwx); break; diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c index d0a372fb022..7674725d66c 100644 --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tunefs.c,v 1.19 2002/02/16 21:27:38 millert Exp $ */ +/* $OpenBSD: tunefs.c,v 1.20 2002/06/09 08:13:09 todd Exp $ */ /* $NetBSD: tunefs.c,v 1.10 1995/03/18 15:01:31 cgd Exp $ */ /* @@ -45,7 +45,7 @@ static const char copyright[] = static char sccsid[] = "@(#)tunefs.c 8.2 (Berkeley) 4/19/94"; #else static const char rcsid[] = - "$OpenBSD: tunefs.c,v 1.19 2002/02/16 21:27:38 millert Exp $"; + "$OpenBSD: tunefs.c,v 1.20 2002/06/09 08:13:09 todd Exp $"; #endif #endif /* not lint */ @@ -98,7 +98,7 @@ main(argc, argv) struct fstab *fs; char *chg[2], device[MAXPATHLEN]; - argc--, argv++; + argc--, argv++; if (argc < 2) usage(); special = argv[argc - 1]; diff --git a/sbin/wicontrol/wicontrol.8 b/sbin/wicontrol/wicontrol.8 index 50f5f4f332f..29ea743e637 100644 --- a/sbin/wicontrol/wicontrol.8 +++ b/sbin/wicontrol/wicontrol.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: wicontrol.8,v 1.39 2002/06/09 05:03:59 deraadt Exp $ +.\" $OpenBSD: wicontrol.8,v 1.40 2002/06/09 08:13:09 todd Exp $ .\" .\" Copyright (c) 1997, 1998, 1999 .\" Bill Paul <wpaul@ctr.columbia.edu> All rights reserved. @@ -332,7 +332,7 @@ The default is 0 (Autoselect). Enable or disable processing of 802.11b frames. When enabled, the .Xr wi 4 -driver will process entire frames instead of stripping +driver will process entire frames instead of stripping off the 802.11b header that is provided by the card. Only the superuser may use this option. .It Fl M Ar 0|1 diff --git a/sbin/wsconsctl/map_scan.l b/sbin/wsconsctl/map_scan.l index 7f02c060c34..4bc6db12352 100644 --- a/sbin/wsconsctl/map_scan.l +++ b/sbin/wsconsctl/map_scan.l @@ -1,4 +1,4 @@ -/* $OpenBSD: map_scan.l,v 1.1 2000/07/01 23:52:45 mickey Exp $ */ +/* $OpenBSD: map_scan.l,v 1.2 2002/06/09 08:13:09 todd Exp $ */ /* $NetBSD: map_scan.l 1.1 1998/12/28 14:01:17 hannken Exp $ */ /*- @@ -89,7 +89,7 @@ keysym { } [0-9]+ { - yylval.ival = atoi(yytext); + yylval.ival = atoi(yytext); return(T_NUMBER); } |