On 2008-08-15 14:42 +0200, Andreas Metzler wrote: > is there actually a reason for using the PID and for limiting the > non-pid part to [[A-Za-z]? > > Why not > --------bugs included----- > --- mktemp-1.5.orig/priv_mktemp.c > +++ mktemp-1.5/priv_mktemp.c > @@ -81,25 +81,20 @@ > register char *start, *trv; > struct stat sbuf; > int pid, rval; > - char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; > + char *alphabet = > "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-=%#_"; > > if (doopen && domkdir) { > errno = EINVAL; > return(0); > } > > - pid = getpid(); > for (trv = path; *trv; ++trv) > ; > --trv; > - while (trv >= path && *trv == 'X' && pid != 0) { > - *trv-- = (pid % 10) + '0'; > - pid /= 10; > - } > while (trv >= path && *trv == 'X') { > char c; > > - pid = (get_random() & 0xffff) % (26+26); > + pid = (get_random() & 0xffff) % (26+26+10+6); > c = alphabet[pid]; > *trv-- = c; > } > -------------------------
The later part starting at /* tricky little algorithm for backward compatibility */ has to be adjusted as well, since the results are a bit funny: ,---- | /usr/local/src/deb-src/mktemp/mktemp-1.5% for i in $(seq 100); do ./mktemp /tmp/foo.X; done | /tmp/foo._ | /tmp/foo.x | /tmp/foo.h | /tmp/foo.5 | /tmp/foo.X | /tmp/foo.o | /tmp/foo.a | /tmp/foo.4 | /tmp/foo.D | /tmp/foo.j | /tmp/foo.S | /tmp/foo.b | /tmp/foo.6 | /tmp/foo.m | /tmp/foo.0 | /tmp/foo.F | /tmp/foo.v | /tmp/foo.y | /tmp/foo.d | /tmp/foo.R | /tmp/foo.Q | /tmp/foo.n | /tmp/foo.s | /tmp/foo.- | /tmp/foo.W | /tmp/foo.Z | /tmp/foo.` | /tmp/foo.c | /tmp/foo.t | /tmp/foo.2 | /tmp/foo.T | /tmp/foo.e | /tmp/foo.9 | /tmp/foo.i | /tmp/foo.f | /tmp/foo.U | /tmp/foo.= | /tmp/foo.u | /tmp/foo.7 | /tmp/foo.. | /tmp/foo.z | /tmp/foo.k | /tmp/foo.V | /tmp/foo.% | /tmp/foo.g | /tmp/foo.> | /tmp/foo.l | /tmp/foo.Y | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.# | /tmp/foo.A | /tmp/foo.J | /tmp/foo.p | /tmp/foo.w | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.1 | /tmp/foo.C | /tmp/foo.M | /tmp/foo.N | /tmp/foo.E | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.? | /tmp/foo.O | /tmp/foo.r | /tmp/foo.3 | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.q | /tmp/foo.B | /tmp/foo.P | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.G | /tmp/foo.H | /tmp/foo.I | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.K | /tmp/foo.L | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.+ | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.8 | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.& | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | /tmp/foo.' | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists | mktemp: cannot create temp file /tmp/foo.a: File exists `---- Note the characters outside the alphabet and the "File exists" message appearing before mktemp actually runs out of file names. Sven -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]