Re: cksum(1) patch
On 2009/05/13 10:40, Otto Moerbeek wrote: I did some research on different operating systems regarding checksumming and found that solaris had a nice option called digest -l which prints the available algorithms and exits. I wrote this functionality into cksum(1) that you can have if you want it. Patch follows. -peter I kinda like this, but comments inline. it might be nice to display the list of algorithms when an unsupported algorithm is chosen, e.g. $ cksum -a foo cksum: unknown algorithm foo, available algorithms: cksum, md4, md5, rmd160, sha1, sha256, sha384, sha512, sum, sysvsum. usage: cksum [-bpqrtx] [-a algorithms] [-c [checklist ...]] [-o 1 | 2] [-s string] [file ...]
Re: cksum(1) patch
On Wed, May 13, 2009 at 10:40:13AM +0200, Otto Moerbeek wrote: Come to think of it, why don't you just putchar(tolower(hf-name[i])) in a loop? Saves you the calloc and error handling. Also, don't forget to fix usage(). -Otto Yeah, thanks. Well I got good and critical feedback and Otto's prodding was good enough to make me rewrite this puny patch. Gone are errno, calloc() and in is the putchar(). I stayed away from adding sthen's idea, perhaps he can do the patch for that. Patch follows: ? cksum.1-orig ? cksum.patch ? md5.c-orig Index: cksum.1 === RCS file: /cvs/src/bin/md5/cksum.1,v retrieving revision 1.19 diff -u -r1.19 cksum.1 --- cksum.1 8 Feb 2009 17:15:09 - 1.19 +++ cksum.1 13 May 2009 10:03:46 - @@ -42,7 +42,7 @@ .Sh SYNOPSIS .Nm cksum .Bk -words -.Op Fl bpqrtx +.Op Fl blpqrtx .Op Fl a Ar algorithms .Op Fl c Op Ar checklist ... .Op Fl o Ar 1 | 2 @@ -162,6 +162,8 @@ option may not be used in conjunction with more than a single .Fl a option. +.It Fl l +outputs the algorithms available and exits. .It Fl o Ar 1 | 2 Use historic algorithms instead of the (superior) default one (see below). Index: md5.c === RCS file: /cvs/src/bin/md5/md5.c,v retrieving revision 1.50 diff -u -r1.50 md5.c --- md5.c 6 Sep 2008 12:01:34 - 1.50 +++ md5.c 13 May 2009 10:03:46 - @@ -210,14 +210,14 @@ struct hash_list hl; size_t len; char *cp, *input_string; - int fl, error, base64; + int fl, error, base64, i; int bflag, cflag, pflag, rflag, tflag, xflag; static const char *optstr[5] = { bcpqrs:tx, bcpqrs:tx, bcpqrs:tx, - a:bco:pqrs:tx, + a:bco:lpqrs:tx, a:bco:pqrs:tx }; @@ -315,6 +315,15 @@ if (hftmp == TAILQ_END(hl)) hash_insert(hl, hf, 0); break; + case 'l': + for (hf = functions; hf-name != NULL; hf++) { + len = strlen(hf-name); + for (i = 0; i len; i++) { + putchar(tolower(hf-name[i])); + } + putchar('\n'); + } + exit(0); case 'p': pflag = 1; break;
Re: cksum(1) patch
On Wed, May 13, 2009 at 12:20:44PM +0200, Otto Moerbeek wrote: You forgot to fix usage(). Also, I think it makes sense to allow -l for sum(1) too, so that both commands that take -a also take -l. -Otto Eeek. Ok this will do then: Regards, -p ? cksum.1-orig ? cksum.patch ? md5.c-orig Index: cksum.1 === RCS file: /cvs/src/bin/md5/cksum.1,v retrieving revision 1.19 diff -u -r1.19 cksum.1 --- cksum.1 8 Feb 2009 17:15:09 - 1.19 +++ cksum.1 13 May 2009 11:27:53 - @@ -42,7 +42,7 @@ .Sh SYNOPSIS .Nm cksum .Bk -words -.Op Fl bpqrtx +.Op Fl blpqrtx .Op Fl a Ar algorithms .Op Fl c Op Ar checklist ... .Op Fl o Ar 1 | 2 @@ -50,7 +50,7 @@ .Op Ar file ... .Ek .Nm sum -.Op Fl bpqrtx +.Op Fl blpqrtx .Op Fl a Ar algorithms .Op Fl c Op Ar checklist ... .Op Fl o Ar 1 | 2 @@ -162,6 +162,8 @@ option may not be used in conjunction with more than a single .Fl a option. +.It Fl l +outputs the algorithms available and exits. .It Fl o Ar 1 | 2 Use historic algorithms instead of the (superior) default one (see below). Index: md5.c === RCS file: /cvs/src/bin/md5/md5.c,v retrieving revision 1.50 diff -u -r1.50 md5.c --- md5.c 6 Sep 2008 12:01:34 - 1.50 +++ md5.c 13 May 2009 11:27:53 - @@ -210,15 +210,15 @@ struct hash_list hl; size_t len; char *cp, *input_string; - int fl, error, base64; + int fl, error, base64, i; int bflag, cflag, pflag, rflag, tflag, xflag; static const char *optstr[5] = { bcpqrs:tx, bcpqrs:tx, bcpqrs:tx, - a:bco:pqrs:tx, - a:bco:pqrs:tx + a:bco:lpqrs:tx, + a:bco:lpqrs:tx }; TAILQ_INIT(hl); @@ -315,6 +315,15 @@ if (hftmp == TAILQ_END(hl)) hash_insert(hl, hf, 0); break; + case 'l': + for (hf = functions; hf-name != NULL; hf++) { + len = strlen(hf-name); + for (i = 0; i len; i++) { + putchar(tolower(hf-name[i])); + } + putchar('\n'); + } + exit(0); case 'p': pflag = 1; break; @@ -794,7 +803,7 @@ break; case MODE_CKSUM: case MODE_SUM: - fprintf(stderr, usage: %s [-bpqrtx] [-a algorithms] + fprintf(stderr, usage: %s [-blpqrtx] [-a algorithms] [-c [checklist ...]] [-o 1 | 2]\n %*s [-s string] [file ...]\n, __progname, (int)strlen(__progname), );
Re: usr.sbin/smtpd/aliases.c diif
On Tue, May 12, 2009 at 11:50:28AM -0400, Daniel Ouellet wrote: The ret integer is define and assign a value a few times, however, never used, so could also be removed as well. Currently it's not but it may be used for db error logging. Index: aliases.c === RCS file: /cvs/src/usr.sbin/smtpd/aliases.c,v retrieving revision 1.17 diff -u -p -r1.17 aliases.c --- aliases.c 24 Apr 2009 10:02:35 - 1.17 +++ aliases.c 13 May 2009 12:10:17 - @@ -56,21 +56,22 @@ aliases_exist(struct smtpd *env, char *u return 0; aliasesdb = dbopen(map-m_config, O_RDONLY, 0600, DB_HASH, NULL); - if (aliasesdb == NULL) + if (aliasesdb == NULL) { + log_warn(aliases_exist: dbopen); return 0; + } lowercase(buf, username, sizeof(buf)); key.data = buf; key.size = strlen(key.data) + 1; - if ((ret = aliasesdb-get(aliasesdb, key, val, 0)) == -1) { - aliasesdb-close(aliasesdb); - return 0; - } + ret = aliasesdb-get(aliasesdb, key, val, 0); + if (ret == -1) + log_warn(aliases_exist); aliasesdb-close(aliasesdb); - return ret == 0 ? 1 : 0; + return (ret == 0); } int @@ -92,8 +93,10 @@ aliases_get(struct smtpd *env, struct al return 0; aliasesdb = dbopen(map-m_config, O_RDONLY, 0600, DB_HASH, NULL); - if (aliasesdb == NULL) + if (aliasesdb == NULL) { + log_warn(aliases_get: dbopen); return 0; + } lowercase(buf, username, sizeof(buf)); @@ -101,6 +104,8 @@ aliases_get(struct smtpd *env, struct al key.size = strlen(key.data) + 1; if ((ret = aliasesdb-get(aliasesdb, key, val, 0)) != 0) { + if (ret == -1) + log_warn(aliases_get); aliasesdb-close(aliasesdb); return 0; } @@ -145,8 +150,10 @@ aliases_virtual_exist(struct smtpd *env, return 0; aliasesdb = dbopen(map-m_config, O_RDONLY, 0600, DB_HASH, NULL); - if (aliasesdb == NULL) + if (aliasesdb == NULL) { + log_warn(aliases_virtual_exist: dbopen); return 0; + } if (! bsnprintf(strkey, sizeof(strkey), %...@%s, path-user, path-domain)) { @@ -160,6 +167,8 @@ aliases_virtual_exist(struct smtpd *env, key.size = strlen(key.data) + 1; if ((ret = aliasesdb-get(aliasesdb, key, val, 0)) != 0) { + if (ret == -1) + log_warn(aliases_virtual_exist); if (! bsnprintf(strkey, sizeof(strkey), @%s, path-domain)) { aliasesdb-close(aliasesdb); @@ -171,14 +180,13 @@ aliases_virtual_exist(struct smtpd *env, key.data = strkey; key.size = strlen(key.data) + 1; - if ((ret = aliasesdb-get(aliasesdb, key, val, 0)) != 0) { - aliasesdb-close(aliasesdb); - return 0; - } + ret = aliasesdb-get(aliasesdb, key, val, 0); } + if (ret == -1) + log_warn(aliases_virtual_exist); aliasesdb-close(aliasesdb); - return ret == 0 ? 1 : 0; + return (ret == 0); } int @@ -201,8 +209,10 @@ aliases_virtual_get(struct smtpd *env, s return 0; aliasesdb = dbopen(map-m_config, O_RDONLY, 0600, DB_HASH, NULL); - if (aliasesdb == NULL) + if (aliasesdb == NULL) { + log_warn(aliases_virtual_get: dbopen); return 0; + } if (! bsnprintf(strkey, sizeof(strkey), %...@%s, path-user, path-domain)) { @@ -216,6 +226,8 @@ aliases_virtual_get(struct smtpd *env, s key.size = strlen(key.data) + 1; if ((ret = aliasesdb-get(aliasesdb, key, val, 0)) != 0) { + if (ret == -1) + log_warn(aliases_virtual_get); if (! bsnprintf(strkey, sizeof(strkey), @%s, path-domain)) { aliasesdb-close(aliasesdb); @@ -228,6 +240,8 @@ aliases_virtual_get(struct smtpd *env, s key.size = strlen(key.data) + 1; if ((ret = aliasesdb-get(aliasesdb, key, val, 0)) != 0) { + if (ret == -1) + log_warn(aliases_virtual_get); aliasesdb-close(aliasesdb); return 0; } @@ -271,7 +285,7 @@ aliases_expand_include(struct aliaseslis fp = fopen(filename, r); if (fp == NULL) { - log_warnx(failed to open include file \%s\., filename); + log_warn(failed to open include file \%s\., filename); return 0; } Index: map.c === RCS file:
Re: cksum(1) patch
On Wed, May 13, 2009 at 02:16:49PM +0200, Mark Kettenis wrote: Date: Wed, 13 May 2009 12:20:44 +0200 From: Otto Moerbeek o...@drijf.net On Wed, May 13, 2009 at 12:11:35PM +0200, Peter J. Philipp wrote: On Wed, May 13, 2009 at 10:40:13AM +0200, Otto Moerbeek wrote: Come to think of it, why don't you just putchar(tolower(hf-name[i])) in a loop? Saves you the calloc and error handling. Also, don't forget to fix usage(). -Otto Yeah, thanks. Well I got good and critical feedback and Otto's prodding was good enough to make me rewrite this puny patch. Gone are errno, calloc() and in is the putchar(). I stayed away from adding sthen's idea, perhaps he can do the patch for that. Patch follows: You forgot to fix usage(). Also, I think it makes sense to allow -l for sum(1) too, so that both commands that take -a also take -l. That may be true, but I'm fairly certain that we will not add the -l option to either cksum(1) or sum(1). It's not defined by POSIX, nor is it commonly available on other Unix-like systems. Our goal is to not introduce non-standard options since people will start using them in scripts that will become unportable. in the case of sum(1) and chsum(1) we aready deviate a lot. Posix does not define any options for cksum(1) and does not define sum(1) at all. We accept about a dozen options to both. And I seem to remember the diff was inspired by Solaris. -Otto
Re: cksum(1) patch
And I seem to remember the diff was inspired by Solaris. $ uname -a SunOS foo 5.10 Generic_127128-11 i86pc i386 i86pc $ cksum -l cksum: illegal option -- l Usage: cksum [file ...] It was inspired by digest(1) not cksum. sycorax$ uname -a SunOS sycorax 5.10 Generic_137138-09 i86pc i386 i86pc sycorax$ digest -l sha1 md5 sha256 sha384 sha512 sycorax$ Regards, -peter
Re: cksum(1) patch
On Wed, May 13, 2009 at 03:18:05PM +0200, Mark Kettenis wrote: Date: Wed, 13 May 2009 14:28:06 +0200 From: Otto Moerbeek o...@drijf.net On Wed, May 13, 2009 at 02:16:49PM +0200, Mark Kettenis wrote: Date: Wed, 13 May 2009 12:20:44 +0200 From: Otto Moerbeek o...@drijf.net On Wed, May 13, 2009 at 12:11:35PM +0200, Peter J. Philipp wrote: On Wed, May 13, 2009 at 10:40:13AM +0200, Otto Moerbeek wrote: Come to think of it, why don't you just putchar(tolower(hf-name[i])) in a loop? Saves you the calloc and error handling. Also, don't forget to fix usage(). -Otto Yeah, thanks. Well I got good and critical feedback and Otto's prodding was good enough to make me rewrite this puny patch. Gone are errno, calloc() and in is the putchar(). I stayed away from adding sthen's idea, perhaps he can do the patch for that. Patch follows: You forgot to fix usage(). Also, I think it makes sense to allow -l for sum(1) too, so that both commands that take -a also take -l. That may be true, but I'm fairly certain that we will not add the -l option to either cksum(1) or sum(1). It's not defined by POSIX, nor is it commonly available on other Unix-like systems. Our goal is to not introduce non-standard options since people will start using them in scripts that will become unportable. in the case of sum(1) and chsum(1) we aready deviate a lot. Posix does not define any options for cksum(1) and does not define sum(1) at all. We accept about a dozen options to both. I'm afraid, that's not an excuse for adding even more options. And I seem to remember the diff was inspired by Solaris. $ uname -a SunOS foo 5.10 Generic_127128-11 i86pc i386 i86pc $ cksum -l cksum: illegal option -- l Usage: cksum [file ...] It was the digest(1) command on solaris, i remembered that wrong. Anyway, my point is that the cksum(1) already has a bunch of options but also an obviously missing one. But an alternative would be to do what sthen suggested and put the algorithm list into the usage and only that. -Otto
Re: cksum(1) patch
On Wed, May 13, 2009 at 03:28:04PM +0200, Otto Moerbeek wrote: Anyway, my point is that the cksum(1) already has a bunch of options but also an obviously missing one. But an alternative would be to do what sthen suggested and put the algorithm list into the usage and only that. I like this.
Re: azalia: save some power
On Tue, May 12, 2009 at 09:57:33PM +, Jacob Meuser wrote: here's a patch to power down unused widgets. should be safe, but my devices don't support this (about half of all azalia codecs support power modes on the individual widgets) so please test that this doesn't somehow break the ability to use your soundcard. The sound on my ThinkPad X61s no longer seems to work with this patch. =[ mixerctl -v (same w/ and w/o patch) ]= inputs.dac=186,186 inputs.dac2=186,186 inputs.hp_source=sel6,sel5 { sel6 sel5 } inputs.spkr_source=dac2,sel5 { dac2 sel5 } record.adc2_source=mic2 [ mic mic2 ] record.adc2_mute=on [ off on ] record.adc2=124,124 record.adc_source=mic [ mic mic2 ] record.adc_mute=on [ off on ] record.adc=124,124 inputs.sel3_source=dac [ dac dac2 ] inputs.sel4_source=dac [ dac dac2 ] inputs.beep_mute=off [ off on ] inputs.beep=119 outputs.hp_mute=off [ off on ] outputs.hp_boost=off [ off on ] outputs.spkr_mute=off [ off on ] outputs.spkr_boost=off [ off on ] outputs.spkr_eapd=on [ off on ] inputs.mic=85,85 outputs.mic_dir=input-vr80 [ none input input-vr0 input-vr50 input-vr80 input-vr100 ] inputs.mic2=85,85 outputs.mic2_dir=input-vr80 [ none input input-vr0 input-vr50 input-vr80 input-vr100 ] outputs.mic3_mute=on [ off on ] outputs.mic3_dir=input-vr80 [ none output input input-vr0 input-vr50 input-vr80 input-vr100 ] outputs.vendor_source=hp [ hp spkr adc2 adc sel3 sel4 beep hp ] inputs.mix4_source=sel3,sel5 { sel3 sel5 } inputs.mix6_source=mic,mic2 { mic mic2 } inputs.mix6_mic=120,120 inputs.mix6_mic2=120,120 inputs.sel5_source=mix6 [ mix6 ] outputs.sel5_mute=on [ off on ] outputs.sel5=120,120 inputs.sel6_source=dac [ dac dac2 ] inputs.sel7_source=dac [ dac dac2 ] inputs.mic3_source=sel7,sel5 { sel7 sel5 } inputs.mic3=85,85 outputs.vendor2_source=mic [ mic mic2 mic3 ] outputs.hp_sense=unplugged [ unplugged plugged ] outputs.mic_sense=unplugged [ unplugged plugged ] outputs.mic3_sense=unplugged [ unplugged plugged ] outputs.spkr_muters=hp,mic,mic3 { hp mic mic3 } outputs.master=190,190 outputs.master.mute=off [ off on ] outputs.master.slaves=dac,dac2,hp,spkr { dac dac2 beep hp spkr mic3 sel5 mic3 } record.volume=124,124 record.volume.mute=on [ off on ] record.volume.slaves=adc2,adc { adc2 adc mic mic2 } =[ GENERIC.MP + patch + AZALIA_DEBUG ]= OpenBSD 4.5-current (AZALIA.MP) #0: Wed May 13 18:54:27 EDT 2009 d...@ares.localdomain:/usr/src/sys/arch/amd64/compile/AZALIA.MP real mem = 2119892992 (2021MB) avail mem = 2046382080 (1951MB) mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (63 entries) bios0: vendor LENOVO version 7NETB8WW (2.18 ) date 09/26/2008 bios0: LENOVO 7668CTO acpi0 at bios0: rev 2 acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF! SSDT SSDT SSDT SSDT SSDT acpi0: wakeup devices LID_(S3) SLPB(S3) DURT(S3) IGBE(S4) EXP0(S4) EXP1(S4) EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) USB3(S3) USB4(S3) EHC0(S3) EHC1(S3) HDEF(S4) acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee0: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM)2 Duo CPU L7500 @ 1.60GHz, 1596.31 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG cpu0: 4MB 64b/line 16-way L2 cache cpu0: apic clock running at 199MHz cpu1 at mainbus0: apid 1 (application processor) cpu1: Intel(R) Core(TM)2 Duo CPU L7500 @ 1.60GHz, 1596.00 MHz cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG cpu1: 4MB 64b/line 16-way L2 cache ioapic0 at mainbus0 apid 1 pa 0xfec0, version 20, 24 pins ioapic0: misconfigured as apic 2, remapped to apid 1 acpihpet0 at acpi0: 14318179 Hz acpiprt0 at acpi0: bus 0 (PCI0) acpiprt1 at acpi0: bus -1 (AGP_) acpiprt2 at acpi0: bus 2 (EXP0) acpiprt3 at acpi0: bus 3 (EXP1) acpiprt4 at acpi0: bus -1 (EXP2) acpiprt5 at acpi0: bus -1 (EXP3) acpiprt6 at acpi0: bus -1 (EXP4) acpiprt7 at acpi0: bus 5 (PCI1) acpiec0 at acpi0 acpicpu0 at acpi0: C3, C2, C1, PSS acpicpu1 at acpi0: C3, C2, C1, PSS acpitz0 at acpi0: critical temperature 127 degC acpitz1 at acpi0: critical temperature 99 degC acpibtn0 at acpi0: LID_ acpibtn1 at acpi0: SLPB acpibat0 at acpi0: BAT0 model 42T4631 serial 4147 type LION oem SONY acpibat1 at acpi0: BAT1 not present acpibat2 at acpi0: BAT2 not present acpiac0 at acpi0: AC unit online acpithinkpad0 at acpi0 acpidock at acpi0 not configured acpivideo at acpi0 not configured acpivideo at acpi0 not configured cpu0: Enhanced SpeedStep 1596 MHz: speeds: 1601, 1600, 1200, 800 MHz pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 Intel GM965 Host rev 0x0c vga1 at pci0 dev 2 function 0 Intel GM965 Video rev 0x0c wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: