On Tue, Mar 16, 2004 at 05:36:46PM -0500, TP Diffenbach wrote: > It runs fine under Windows 2000 and Windows XP, but at least one Windows 98 > user is reporting a problem; > > When the executable is run, it fails with the following message: > creation of C:\WINDOWS\TEMP\par-*\cache-long-hex-looking-number/perl58.dll > failed - aborting with 2.
Oh god. The user is not logged in, so the username is an "\n"...
I've committed the changes below to the snapshot version.
I'd be happy if somebody with C-fu can check the mktmpdir.c patch
and see if that's the right way to do a s/\W/_/g on username.
Thanks,
/Autrijus/
==== //member/autrijus/PAR/lib/PAR.pm#68 -
/usr/home/autrijus/member/autrijus/PAR/lib/PAR.pm ====
@@ -434,6 +434,7 @@
my $username = defined(&Win32::LoginName)
? &Win32::LoginName()
: $ENV{USERNAME} || $ENV{USER} || 'SYSTEM';
+ $username =~ s/\W/_/g;
my $stmpdir = File::Spec->catdir($path, "par-$username");
mkdir $stmpdir, 0755;
==== //member/autrijus/PAR/myldr/mktmpdir.c#35 -
/usr/home/autrijus/member/autrijus/PAR/myldr/mktmpdir.c ====
@@ -3,6 +3,7 @@
vim: expandtab shiftwidth=4
*/
+#include "ctype.h"
#include "mktmpdir.h"
#define PAR_TEMP "PAR_TEMP"
@@ -15,6 +16,7 @@
char *par_mktmpdir ( char **argv ) {
int i;
+ char *c;
const char *tmpdir = NULL;
const char *key = NULL , *val = NULL;
@@ -57,6 +59,11 @@
#endif
if ( username == NULL ) username = "SYSTEM";
+ /* replace all non-alphanumeric letters with '_' */
+ for ( c = username ; *c != '\0' ; c++ ) {
+ if ( !isalnum(*c) ) { *c = '_'; }
+ }
+
for ( i = 0 ; tmpdir == NULL && strlen(key = temp_keys[i]) > 0 ; i++ ) {
if ( (val = (char *)par_getenv(key)) &&
par_lstat(val, &PL_statbuf) == 0 &&
==== //member/autrijus/PAR/script/par.pl#101 -
/usr/home/autrijus/member/autrijus/PAR/script/par.pl ====
@@ -622,6 +622,7 @@
my $username = defined(&Win32::LoginName)
? &Win32::LoginName()
: $ENV{USERNAME} || $ENV{USER} || 'SYSTEM';
+ $username =~ s/\W/_/g;
my $stmpdir = "$path$Config{_delim}par-$username";
mkdir $stmpdir, 0755;
pgp00000.pgp
Description: PGP signature
