More long filename support added

This commit is contained in:
Michiel Broek 2001-12-01 17:14:49 +00:00
parent cae45854ab
commit cd7bf461e6
11 changed files with 221 additions and 218 deletions

View File

@ -4224,7 +4224,12 @@ v0.33.19 26-Oct-2001
version, or change it by hand. version, or change it by hand.
general: general:
Made the Makefile system more simple. Made the Makefile system more simple. The bbs programs now
don't run setuid anymore! This makes the system more secure
but you can't login with Fidonet style names anymore. You
can't start the bbs from telnet anymore! With a later release
this may change by adding a login wrapper, for now this is how
it works now. Take it or leave it.
lang: lang:
Changed language prompts 6, 71, 429. Changed language prompts 6, 71, 429.
@ -4276,7 +4281,7 @@ v0.33.19 26-Oct-2001
login. Removed IEMSI support, this has no use anymore. New login. Removed IEMSI support, this has no use anymore. New
users need to register with the mbnewuser program, mbsebbs is users need to register with the mbnewuser program, mbsebbs is
only for registered users. This should fix all kinds of setuid only for registered users. This should fix all kinds of setuid
issues with previous versions. and security problems with previous versions.
QuickScan messages in netmail areas now only shows personal QuickScan messages in netmail areas now only shows personal
messages. messages.
The whoson list now uses mbtask to get the information. The whoson list now uses mbtask to get the information.
@ -4284,6 +4289,13 @@ v0.33.19 26-Oct-2001
with mode 0600. with mode 0600.
A lot of code rewrites to make it more modular. A lot of code rewrites to make it more modular.
The bbs datafiles that users create now have mode 0660. The bbs datafiles that users create now have mode 0660.
The file taglists now work internally with long and short
filenames.
The file listings are displayed with the short filenames.
Download files are sent with short filenames.
File search is done on long and short filenames.
Uploaded files are accepted with long filenames, the short
name is created when the upload is processed.
mbnewusr: mbnewusr:
New program, run by user bbs. This is only to register a new New program, run by user bbs. This is only to register a new
@ -4316,14 +4328,17 @@ v0.33.19 26-Oct-2001
the program for 10 minutes before aborting. the program for 10 minutes before aborting.
Fixed the problem that the KillSent flag was set on processed Fixed the problem that the KillSent flag was set on processed
netmail. netmail.
The tic file import function now sorts and tests on long file-
names, with the new mangle function an DOS 8.3 filename is
also stored in the file database.
mbfile: mbfile:
During check the file databases are reset to filemode 0660. During check the file databases are reset to filemode 0660.
Implemented "mbfile adopt" function. Implemented "mbfile adopt" function.
Started working on long filename support. The real name on Started working on long filename support. The real name on
disk is the long filename, the database records also holds disk is the long filename, the database records also holds
an uppercase 8.3 filename. In most cases this is just the an uppercase mangled 8.3 filename. In most cases this is just
same name in upper and lowercase. Name mangling like Win$ the same name in upper and lowercase. Name mangling like Win$
is performed on the long filenames. is performed on the long filenames.
Implemented "mbfile import" function, this imports complete Implemented "mbfile import" function, this imports complete
areas from files.bbs information. areas from files.bbs information.

View File

@ -917,8 +917,8 @@ char *strcasestr(char *, char *);
/* /*
* mangle.c * mangle.c
*/ */
void mangle_name_83( char *); void mangle_name_83( char *); /* Mangle name to 8.3 format */
int name_mangle(char *, int); void name_mangle(char *); /* Mangle name or make uppercase */
#endif #endif

View File

@ -44,7 +44,6 @@ int str_checksum(const char *);
char *safe_strcpy(char *, const char *, size_t); char *safe_strcpy(char *, const char *, size_t);
static void init_chartest(void); static void init_chartest(void);
static int is_reserved_msdos(char *); static int is_reserved_msdos(char *);
static int is_illegal_name(char *);
int is_8_3(char *); int is_8_3(char *);
@ -162,7 +161,7 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength)
len = strlen(src); len = strlen(src);
if (len > maxlength) { if (len > maxlength) {
Syslog('f', "ERROR: string overflow by %d in safe_strcpy [%.50s]", (int)(len-maxlength), src); WriteError("ERROR: string overflow by %d in safe_strcpy [%.50s]", (int)(len-maxlength), src);
len = maxlength; len = maxlength;
} }
@ -256,46 +255,6 @@ static int is_reserved_msdos( char *fname )
/* ************************************************************************** **
* Determine whether or not a given name contains illegal characters, even
* long names.
*
* Input: name - The name to be tested.
*
* Output: True if an illegal character was found in <name>, else False.
*
* Notes: This is used to test a name on the host system, long or short,
* for characters that would be illegal on most client systems,
* particularly DOS and Windows systems. Unix and AmigaOS, for
* example, allow a filenames which contain such oddities as
* quotes ("). If a name is found which does contain an illegal
* character, it is mangled even if it conforms to the 8.3
* format.
*
* ************************************************************************** **
*/
static int is_illegal_name(char *name)
{
unsigned char *s;
if (!name)
return TRUE;
if (!ct_initialized)
init_chartest();
s = (unsigned char *)name;
while (*s) {
if (isillegal(*s))
return TRUE;
else
s++;
}
return FALSE;
}
/* ************************************************************************** ** /* ************************************************************************** **
* Return True if the name is a valid DOS name in 8.3 DOS format. * Return True if the name is a valid DOS name in 8.3 DOS format.
@ -312,7 +271,7 @@ static int is_illegal_name(char *name)
int is_8_3( char *fname) int is_8_3( char *fname)
{ {
int len; int len;
int l; int l, i;
char *p; char *p;
char *dot_pos; char *dot_pos;
char *slash_pos = strrchr( fname, '/' ); char *slash_pos = strrchr( fname, '/' );
@ -322,37 +281,34 @@ int is_8_3( char *fname)
fname = slash_pos + 1; fname = slash_pos + 1;
len = strlen(fname); len = strlen(fname);
// Syslog('f', "Checking %s for 8.3", fname); Syslog('f', "Checking %s for 8.3", fname);
/* Can't be 0 chars or longer than 12 chars */ /* Can't be 0 chars or longer than 12 chars */
if( (len == 0) || (len > 12) ) if ((len == 0) || (len > 12)) {
Syslog('f', "filename length not right");
return FALSE; return FALSE;
}
/* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */ /* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */
if (is_reserved_msdos(fname)) if (is_reserved_msdos(fname)) {
Syslog('f', "is reserved msdos name");
return FALSE; return FALSE;
}
/* Check that all characters are the correct case, if asked to do so. */ init_chartest();
// if (strhaslower(fname)) for (i = 0; i < strlen(fname); i++) {
// return FALSE; if (isillegal(fname[i])) {
Syslog('f', "Illegal character in filename");
return FALSE;
}
}
/* Can't contain invalid dos chars */ /* Can't contain invalid dos chars */
/* Windows use the ANSI charset.
But filenames are translated in the PC charset.
This Translation may be more or less relaxed depending
the Windows application. */
/* %%% A nice improvment to name mangling would be to translate
filename to ANSI charset on the smb server host */
p = fname; p = fname;
dot_pos = NULL; dot_pos = NULL;
while (*p) { while (*p) {
if (*p == '.' && !dot_pos) if (*p == '.' && !dot_pos)
dot_pos = (char *)p; dot_pos = (char *)p;
// else
// if (!isdoschar(*p))
// return FALSE;
p++; p++;
} }
@ -367,23 +323,27 @@ int is_8_3( char *fname)
return(0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." )); return(0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." ));
/* base can't be greater than 8 */ /* base can't be greater than 8 */
if (l > 8) if (l > 8) {
Syslog('f', "filebase longer then 8 chars");
return FALSE; return FALSE;
}
/* see smb.conf(5) for a description of the 'strip dot' parameter. */ if (len - l == 1 && !strchr( dot_pos + 1, '.' )) {
/* strip_dot defaults to no */
if (/* lp_strip_dot() && */ len - l == 1 && !strchr( dot_pos + 1, '.' )) {
*dot_pos = 0; *dot_pos = 0;
return TRUE; return TRUE;
} }
/* extension must be between 1 and 3 */ /* extension must be between 1 and 3 */
if ((len - l < 2 ) || (len - l > 4)) if ((len - l < 2 ) || (len - l > 4)) {
Syslog('f', "extension length not right");
return FALSE; return FALSE;
}
/* extensions may not have a dot */ /* extensions may not have a dot */
if (strchr( dot_pos+1, '.' )) if (strchr( dot_pos+1, '.' )) {
Syslog('f', "extension with a dot in it");
return FALSE; return FALSE;
}
/* must be in 8.3 format */ /* must be in 8.3 format */
return TRUE; return TRUE;
@ -398,8 +358,8 @@ int is_8_3( char *fname)
*/ */
void mangle_name_83(char *s) void mangle_name_83(char *s)
{ {
int csum; int csum, i;
char *p; char *p, *q;
char extension[4]; char extension[4];
char base[9]; char base[9];
int baselen = 0; int baselen = 0;
@ -408,6 +368,53 @@ void mangle_name_83(char *s)
extension[0] = 0; extension[0] = 0;
base[0] = 0; base[0] = 0;
/*
* First, convert some common Unix extensions to extensions of 3
* characters. If none fits, don't change anything now.
*/
if (strcmp(q = s + strlen(s) - strlen(".tar.gz"), ".tar.gz") == 0) {
*q = '\0';
q = (char *)"tgz";
Syslog('f', "mangle_name_83 tar.gz => tgz");
} else if (strcmp(q = s + strlen(s) - strlen(".tar.z"), ".tar.z") == 0) {
*q = '\0';
q = (char *)"tgz";
Syslog('f', "mangle_name_83 tar.z => tgz");
} else if (strcmp(q = s + strlen(s) - strlen(".tar.Z"), ".tar.Z") == 0) {
*q = '\0';
q = (char *)"taz";
Syslog('f', "mangle_name_83 tar.Z => taz");
} else if (strcmp(q = s + strlen(s) - strlen(".html"), ".html") == 0) {
*q = '\0';
q = (char *)"htm";
Syslog('f', "mangle_name_83 html => htm");
} else if (strcmp(q = s + strlen(s) - strlen(".shtml"), ".shtml") == 0) {
*q = '\0';
q = (char *)"stm";
Syslog('f', "mangle_name_83 shtml => stm");
} else if (strcmp(q = s + strlen(s) - strlen(".conf"), ".conf") == 0) {
*q = '\0';
q = (char *)"cnf";
Syslog('f', "mangle_name_83 conf => cnf");
} else {
q = NULL;
}
if (q) {
/*
* Extension is modified, apply changes
*/
p = s + strlen(s);
*p++ = '.';
for (i = 0; i < strlen(q); i++)
*p++ = q[i];
*p++ = '\0';
Syslog('f', "name with new extension => \"%s\"", s);
}
/*
* Now start name mangling
*/
p = strrchr(s,'.'); p = strrchr(s,'.');
if (p && (strlen(p+1) < (size_t)4)) { if (p && (strlen(p+1) < (size_t)4)) {
int all_normal = (!strhaslower(p+1)); /* XXXXXXXXX */ int all_normal = (!strhaslower(p+1)); /* XXXXXXXXX */
@ -422,7 +429,6 @@ void mangle_name_83(char *s)
csum = str_checksum(s); csum = str_checksum(s);
tu(s); tu(s);
// Syslog('f', "Mangling name %s to ",s);
if (p) { if (p) {
if (p == s) if (p == s)
@ -454,46 +460,31 @@ void mangle_name_83(char *s)
(void)strcat(s, "."); (void)strcat(s, ".");
(void)strcat(s, extension); (void)strcat(s, extension);
} }
// Syslog('f', "%s", s);
} }
/***************************************************************************** /*****************************************************************************
* Convert a filename to DOS format. Return True if successful. * Convert a filename to DOS format.
* *
* Input: OutName - Source *and* destination buffer. * Input: OutName - Source *and* destination buffer.
* *
* NOTE that OutName must point to a memory space that * NOTE that OutName must point to a memory space that
* is at least 13 bytes in size! * is at least 13 bytes in size! That should always be
* * the case of course.
* need83 - If False, name mangling will be skipped unless the
* name contains illegal characters. Mapping will still
* be done, if appropriate. This is probably used to
* signal that a client does not require name mangling,
* thus skipping the name mangling even on shares which
* have name-mangling turned on.
*
* Output: Returns False only if the name wanted mangling but the share does
* not have name mangling turned on.
* *
* **************************************************************************** * ****************************************************************************
*/ */
int name_mangle(char *OutName, int need83) void name_mangle(char *OutName)
{ {
Syslog('f', "name_mangle(%s, need83 = %s)", OutName, need83 ? "TRUE" : "FALSE"); char *p;
/*
* Check for characters legal in Unix and illegal in DOS/Win
*/
if (!need83 && is_illegal_name(OutName))
need83 = TRUE;
p = xstrcpy(OutName);
/* /*
* check if it's already in 8.3 format * check if it's already in 8.3 format
*/ */
if (need83 && !is_8_3(OutName)) { if (!is_8_3(OutName)) {
Syslog('f', "is 8.3 = FALSE");
mangle_name_83(OutName); mangle_name_83(OutName);
} else { } else {
/* /*
@ -502,8 +493,8 @@ int name_mangle(char *OutName, int need83)
tu(OutName); tu(OutName);
} }
Syslog('f',"name_mangle() ==> [%s]", OutName); Syslog('f',"name_mangle(%s) ==> [%s]", p, OutName);
return TRUE; free(p);
} }

View File

@ -42,7 +42,8 @@ typedef struct _TagRec {
int Active; /* Not deleted from taglist */ int Active; /* Not deleted from taglist */
int Cost; /* Free download */ int Cost; /* Free download */
off_t Size; /* File Size */ off_t Size; /* File Size */
char File[81]; /* File Name */ char SFile[13]; /* Short File Name */
char LFile[81]; /* Long FIle Name */
} _Tag; } _Tag;

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: mbfido/addbbs.c * $Id$
* Purpose ...............: Add TIC file to the BBS * Purpose ...............: Add TIC file to the BBS
* Last modification date : 21-Aug-2000
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2000 * Copyright (C) 1997-2000
@ -54,8 +53,8 @@ int Add_BBS()
{ {
struct FILERecord frec; struct FILERecord frec;
int i, Insert, Done = FALSE, Found = FALSE; int i, Insert, Done = FALSE, Found = FALSE;
char fdbname[128], fdbtemp[128]; char fdbname[PATH_MAX], fdbtemp[PATH_MAX];
char temp1[128], temp2[128], *fname; char temp1[PATH_MAX], temp2[PATH_MAX], *fname;
FILE *fdb, *fdt; FILE *fdb, *fdt;
int Keep = 0, DidDelete = FALSE; int Keep = 0, DidDelete = FALSE;
fd_list *fdl = NULL; fd_list *fdl = NULL;
@ -64,7 +63,9 @@ int Add_BBS()
* Create filedatabase record. * Create filedatabase record.
*/ */
memset(&frec, 0, sizeof(frec)); memset(&frec, 0, sizeof(frec));
strcpy(frec.Name, TIC.NewName); strcpy(temp1, TIC.NewName);
name_mangle(temp1);
strcpy(frec.Name, temp1);
strcpy(frec.LName, TIC.NewName); strcpy(frec.LName, TIC.NewName);
// strcpy(frec.TicArea, TIC.TicIn.Area); /* TIJDELIJK IVM VELDLENGTE */ // strcpy(frec.TicArea, TIC.TicIn.Area); /* TIJDELIJK IVM VELDLENGTE */
frec.Size = TIC.FileSize; frec.Size = TIC.FileSize;
@ -100,6 +101,7 @@ int Add_BBS()
WriteError("$Can't create %s", fdbname); WriteError("$Can't create %s", fdbname);
return FALSE; return FALSE;
} }
chmod(fdbname, 0660);
} }
/* /*
@ -129,11 +131,11 @@ int Add_BBS()
if (fread(&file, sizeof(file), 1, fdb) != 1) if (fread(&file, sizeof(file), 1, fdb) != 1)
Done = TRUE; Done = TRUE;
if (!Done) { if (!Done) {
if (strcmp(frec.Name, file.Name) == 0) { if (strcmp(frec.LName, file.LName) == 0) {
Found = TRUE; Found = TRUE;
Insert++; Insert++;
} else } else
if (strcmp(frec.Name, file.Name) < 0) if (strcmp(frec.LName, file.LName) < 0)
Found = TRUE; Found = TRUE;
else else
Insert++; Insert++;
@ -158,7 +160,7 @@ int Add_BBS()
* name, if so, don't copy the original database * name, if so, don't copy the original database
* record. The file is also overwritten. * record. The file is also overwritten.
*/ */
if (strcmp(file.Name, frec.Name) != 0) if (strcmp(file.LName, frec.LName) != 0)
fwrite(&file, sizeof(file), 1, fdt); fwrite(&file, sizeof(file), 1, fdt);
} }
@ -178,7 +180,7 @@ int Add_BBS()
* then we skip the record what was origionaly * then we skip the record what was origionaly
* in the database record. * in the database record.
*/ */
if (strcmp(file.Name, frec.Name) != 0) if (strcmp(file.LName, frec.LName) != 0)
fwrite(&file, sizeof(file), 1, fdt); fwrite(&file, sizeof(file), 1, fdt);
} }
@ -228,16 +230,16 @@ int Add_BBS()
if ((fdb = fopen(fdbname, "r+")) != NULL) { if ((fdb = fopen(fdbname, "r+")) != NULL) {
while (fread(&file, sizeof(file), 1, fdb) == 1) { while (fread(&file, sizeof(file), 1, fdb) == 1) {
if (strlen(file.Name) == strlen(TIC.NewName)) { if (strlen(file.LName) == strlen(TIC.NewName)) {
if (strcasecmp(file.Name, TIC.NewName) != 0) { if (strcasecmp(file.LName, TIC.NewName) != 0) {
Found = TRUE; Found = TRUE;
for (i = 0; i < strlen(TIC.NewName); i++) { for (i = 0; i < strlen(TIC.NewName); i++) {
if ((TIC.TicIn.Replace[i] != '?') && if ((TIC.TicIn.Replace[i] != '?') &&
(toupper(TIC.TicIn.Replace[i]) != toupper(file.Name[i]))) (toupper(TIC.TicIn.Replace[i]) != toupper(file.LName[i])))
Found = FALSE; Found = FALSE;
} }
if (Found) { if (Found) {
Syslog('+', "Replace: Deleting: %s", file.Name); Syslog('+', "Replace: Deleting: %s", file.LName);
file.Deleted = TRUE; file.Deleted = TRUE;
fseek(fdb, - sizeof(file), SEEK_CUR); fseek(fdb, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, fdb); fwrite(&file, sizeof(file), 1, fdb);
@ -258,19 +260,19 @@ int Add_BBS()
while (fread(&file, sizeof(file), 1, fdb) == 1) { while (fread(&file, sizeof(file), 1, fdb) == 1) {
if ((strlen(file.Name) == strlen(TIC.NewName)) && (!file.Deleted)) { if ((strlen(file.LName) == strlen(TIC.NewName)) && (!file.Deleted)) {
Found = TRUE; Found = TRUE;
for (i = 0; i < strlen(file.Name); i++) { for (i = 0; i < strlen(file.LName); i++) {
if ((TIC.NewName[i] < '0') || (TIC.NewName[i] > '9')) { if ((TIC.NewName[i] < '0') || (TIC.NewName[i] > '9')) {
if (TIC.NewName[i] != file.Name[i]) { if (TIC.NewName[i] != file.LName[i]) {
Found = FALSE; Found = FALSE;
} }
} }
} }
if (Found) { if (Found) {
Keep++; Keep++;
fill_fdlist(&fdl, file.Name, file.UploadDate); fill_fdlist(&fdl, file.LName, file.UploadDate);
} }
} }
} }
@ -289,8 +291,8 @@ int Add_BBS()
fseek(fdb, 0, SEEK_SET); fseek(fdb, 0, SEEK_SET);
while (fread(&file, sizeof(file), 1, fdb) == 1) { while (fread(&file, sizeof(file), 1, fdb) == 1) {
if (strcmp(file.Name, fname) == 0) { if (strcmp(file.LName, fname) == 0) {
Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, file.Name); Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, file.LName);
file.Deleted = TRUE; file.Deleted = TRUE;
fseek(fdb, - sizeof(file), SEEK_CUR); fseek(fdb, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, fdb); fwrite(&file, sizeof(file), 1, fdb);
@ -315,7 +317,7 @@ int Add_BBS()
if (!file.Deleted) if (!file.Deleted)
fwrite(&file, sizeof(file), 1, fdt); fwrite(&file, sizeof(file), 1, fdt);
else { else {
sprintf(temp2, "%s/%s", area.Path, file.Name); sprintf(temp2, "%s/%s", area.Path, file.LName);
if (unlink(temp2) != 0) if (unlink(temp2) != 0)
WriteError("$Can't unlink file %s", temp2); WriteError("$Can't unlink file %s", temp2);
} }

View File

@ -277,7 +277,7 @@ void AdoptFile(int Area, char *File, char *Description)
* Convert to 8.3 DOS filename * Convert to 8.3 DOS filename
*/ */
strcpy(temp2, File); strcpy(temp2, File);
name_mangle(temp2, TRUE); name_mangle(temp2);
strcpy(fdb.Name, temp2); strcpy(fdb.Name, temp2);
strcpy(fdb.LName, File); strcpy(fdb.LName, File);
fdb.Size = file_size(File); fdb.Size = file_size(File);

View File

@ -157,7 +157,7 @@ void Check(void)
Update = FALSE; Update = FALSE;
strcpy(temp, file.LName); strcpy(temp, file.LName);
name_mangle(temp, TRUE); name_mangle(temp);
if (strcmp(file.Name, temp)) { if (strcmp(file.Name, temp)) {
Syslog('!', "Converted %s to %s", file.Name, temp); Syslog('!', "Converted %s to %s", file.Name, temp);
strncpy(file.Name, temp, 12); strncpy(file.Name, temp, 12);

View File

@ -209,7 +209,7 @@ void ImportFiles(int Area)
* Create DOS 8.3 filename * Create DOS 8.3 filename
*/ */
strcpy(temp, fdb.LName); strcpy(temp, fdb.LName);
name_mangle(temp, TRUE); name_mangle(temp);
strcpy(fdb.Name, temp); strcpy(fdb.Name, temp);
if (do_annon) if (do_annon)

View File

@ -339,11 +339,11 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
if (fread(&file, sizeof(file), 1, fp1) != 1) if (fread(&file, sizeof(file), 1, fp1) != 1)
Done = TRUE; Done = TRUE;
if (!Done) { if (!Done) {
if (strcmp(fdb.Name, file.Name) == 0) { if (strcmp(fdb.LName, file.LName) == 0) {
Found = TRUE; Found = TRUE;
Insert++; Insert++;
} else { } else {
if (strcmp(fdb.Name, file.Name) < 0) if (strcmp(fdb.LName, file.LName) < 0)
Found = TRUE; Found = TRUE;
else else
Insert++; Insert++;
@ -367,7 +367,7 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
* If we are importing a file with the same name, * If we are importing a file with the same name,
* skip the original record and put the new one in place. * skip the original record and put the new one in place.
*/ */
if (strcmp(file.Name, fdb.Name) != 0) if (strcmp(file.LName, fdb.LName) != 0)
fwrite(&file, sizeof(file), 1, fp2); fwrite(&file, sizeof(file), 1, fp2);
} }
@ -378,7 +378,7 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
* Append the rest of the records * Append the rest of the records
*/ */
while (fread(&file, sizeof(file), 1, fp1) == 1) { while (fread(&file, sizeof(file), 1, fp1) == 1) {
if (strcmp(file.Name, fdb.Name) != 0) if (strcmp(file.LName, fdb.LName) != 0)
fwrite(&file, sizeof(file), 1, fp2); fwrite(&file, sizeof(file), 1, fp2);
} }
if (!area.AddAlpha) if (!area.AddAlpha)

View File

@ -57,20 +57,22 @@ int CheckFile(char *, int);
int CheckFile(char *File, int iArea) int CheckFile(char *File, int iArea)
{ {
FILE *pFileB; FILE *pFileB;
int iFile = FALSE;
char *sFileArea; char *sFileArea;
sFileArea = calloc(PATH_MAX, sizeof(char)); sFileArea = calloc(PATH_MAX, sizeof(char));
sprintf(sFileArea,"%s/fdb/fdb%d.dta", getenv("MBSE_ROOT"), iArea); sprintf(sFileArea,"%s/fdb/fdb%d.dta", getenv("MBSE_ROOT"), iArea);
if ((pFileB = fopen(sFileArea,"r+")) == NULL) { if ((pFileB = fopen(sFileArea,"r+")) == NULL) {
mkdir(sFileArea, 755); mkdir(sFileArea, 775);
return FALSE; return FALSE;
} }
free(sFileArea);
/*
* Check long and short filenames, case insensitive
*/
while (fread(&file, sizeof(file), 1, pFileB) == 1) { while (fread(&file, sizeof(file), 1, pFileB) == 1) {
if((strcmp(tl(file.Name), tl(File))) == 0) { if (((strcasecmp(file.Name, File)) == 0) || ((strcasecmp(file.LName, File)) == 0)) {
iFile = TRUE;
fclose(pFileB); fclose(pFileB);
return TRUE; return TRUE;
} }
@ -78,11 +80,7 @@ int CheckFile(char *File, int iArea)
} }
fclose(pFileB); fclose(pFileB);
free(sFileArea);
if(!iFile)
return FALSE; return FALSE;
return 1;
} }
@ -128,7 +126,8 @@ void File_List()
T.Active = FALSE; T.Active = FALSE;
T.Cost = file.Cost; T.Cost = file.Cost;
T.Size = file.Size; T.Size = file.Size;
sprintf(T.File, "%s", file.Name); strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 80);
SetTag(T); SetTag(T);
if (ShowOneFile() == 1) { if (ShowOneFile() == 1) {
@ -138,11 +137,11 @@ void File_List()
if (file.Deleted) if (file.Deleted)
/* D E L E T E D */ /* Uploaded by: */ /* D E L E T E D */ /* Uploaded by: */
printf("%-15s %s [%ld] %s%s\n", file.Name, (char *) Language(239), file.TimesDL, (char *) Language(238), file.Uploader); printf("%-12s %s [%ld] %s%s\n", file.Name, (char *) Language(239), file.TimesDL, (char *) Language(238), file.Uploader);
if (file.Missing) if (file.Missing)
/* M I S S I N G */ /* Uploaded by: */ /* M I S S I N G */ /* Uploaded by: */
printf("%-15s %s [%ld] %s%s\n", file.Name, (char *) Language(240), file.TimesDL, (char *) Language(238), file.Uploader); printf("%-12s %s [%ld] %s%s\n", file.Name, (char *) Language(240), file.TimesDL, (char *) Language(238), file.Uploader);
FileCount++; /* Increase File Counter by 1 */ FileCount++; /* Increase File Counter by 1 */
FileBytes += file.Size; /* Increase File Byte Count */ FileBytes += file.Size; /* Increase File Byte Count */
@ -207,18 +206,18 @@ void Download(void)
if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) { if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) {
while (fread(&file, sizeof(file), 1, fp) == 1) { while (fread(&file, sizeof(file), 1, fp) == 1) {
if (strcmp(file.Name, Tag.File) == 0) if (strcmp(file.LName, Tag.LFile) == 0)
break; break;
} }
fclose(fp); fclose(fp);
} }
if (strcmp(file.Name, Tag.File) == 0) { if (strcmp(file.LName, Tag.LFile) == 0) {
Syslog('b', "Found file %s in area %d", file.Name, Tag.Area); Syslog('b', "Found file %s in area %d", file.LName, Tag.Area);
if ((file.Deleted) || (file.Missing)) { if ((file.Deleted) || (file.Missing)) {
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(248)); pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(248));
/* Sorry that file is unavailable for download */ /* Sorry that file is unavailable for download */
printf("%s (%s)\n", (char *) Language(248), file.Name); printf("%s (%s)\n", (char *) Language(248), file.LName);
Tag.Active = FALSE; Tag.Active = FALSE;
} }
@ -233,7 +232,7 @@ void Download(void)
*/ */
sprintf(symTo, "./tag/filedesc.%ld", exitinfo.Downloads % 256); sprintf(symTo, "./tag/filedesc.%ld", exitinfo.Downloads % 256);
if ((fd = fopen(symTo, "a")) != NULL) { if ((fd = fopen(symTo, "a")) != NULL) {
fprintf(fd, "%s\r\n", file.Name); fprintf(fd, "%s (%s)\r\n", file.LName, file.Name);
for (i = 0; i < 25; i++) { for (i = 0; i < 25; i++) {
if (strlen(file.Desc[i]) > 1) if (strlen(file.Desc[i]) > 1)
fprintf(fd, " %s\r\n", file.Desc[i]); fprintf(fd, " %s\r\n", file.Desc[i]);
@ -245,11 +244,12 @@ void Download(void)
/* /*
* Make a symlink to the users download dir. * Make a symlink to the users download dir.
* First unlink, in case there was an old one. * First unlink, in case there was an old one.
* The shortname is linked to the original longname.
*/ */
chdir("./tag"); chdir("./tag");
unlink(Tag.File); unlink(Tag.SFile);
sprintf(symFrom, "%s", Tag.File); sprintf(symFrom, "%s", Tag.SFile);
sprintf(symTo, "%s/%s", sAreaPath, Tag.File); sprintf(symTo, "%s/%s", sAreaPath, Tag.LFile);
if (symlink(symTo, symFrom)) { if (symlink(symTo, symFrom)) {
WriteError("$Can't create symlink %s %s %d", symTo, symFrom, errno); WriteError("$Can't create symlink %s %s %d", symTo, symFrom, errno);
Tag.Active = FALSE; Tag.Active = FALSE;
@ -392,12 +392,12 @@ void Download(void)
if (Tag.Active) { if (Tag.Active) {
sprintf(symTo, "./tag/%s", Tag.File); sprintf(symTo, "./tag/%s", Tag.SFile);
/* /*
* If symlink is gone the file is sent. * If symlink is gone the file is sent.
*/ */
if ((access(symTo, R_OK)) != 0) { if ((access(symTo, R_OK)) != 0) {
Syslog('+', "File %s from area %d sent ok", Tag.File, Tag.Area); Syslog('+', "File %s from area %d sent ok", Tag.LFile, Tag.Area);
Tag.Active = FALSE; Tag.Active = FALSE;
fseek(tf, - sizeof(Tag), SEEK_CUR); fseek(tf, - sizeof(Tag), SEEK_CUR);
fwrite(&Tag, sizeof(Tag), 1, tf); fwrite(&Tag, sizeof(Tag), 1, tf);
@ -409,7 +409,7 @@ void Download(void)
SetFileArea(Tag.Area); SetFileArea(Tag.Area);
if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) { if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) {
while (fread(&file, sizeof(file), 1, fp) == 1) { while (fread(&file, sizeof(file), 1, fp) == 1) {
if (strcmp(file.Name, Tag.File) == 0) if (strcmp(file.LName, Tag.LFile) == 0)
break; break;
} }
Size += file.Size; Size += file.Size;
@ -421,7 +421,7 @@ void Download(void)
Count++; Count++;
} }
} else { } else {
Syslog('+', "Failed to sent %s from area %d", Tag.File, Tag.Area); Syslog('+', "Failed to sent %s from area %d", Tag.LFile, Tag.Area);
} }
} }
} }
@ -506,7 +506,7 @@ void File_RawDir(char *OpData)
iBytes += statfile.st_size; iBytes += statfile.st_size;
colour(14,0); colour(14,0);
printf("%-20s", dp->d_name); printf("%-12s " , dp->d_name);
colour(13,0); colour(13,0);
printf("%-12ld", (long)(statfile.st_size)); printf("%-12ld", (long)(statfile.st_size));
@ -625,7 +625,8 @@ int KeywordScan()
T.Active = FALSE; T.Active = FALSE;
T.Cost = file.Cost; T.Cost = file.Cost;
T.Size = file.Size; T.Size = file.Size;
sprintf(T.File, "%s", file.Name); strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 80);
SetTag(T); SetTag(T);
Count++; Count++;
if (ShowOneFile() == 1) { if (ShowOneFile() == 1) {
@ -681,13 +682,14 @@ int FilenameScan()
FILE *pAreas, *pFile; FILE *pAreas, *pFile;
int z, y, Found, Count = 0; int z, y, Found, Count = 0;
char *Name; char *Name;
char *tmpname; char *tmpname, *tmpname2;
char temp[81]; char temp[81];
_Tag T; _Tag T;
unsigned long OldArea; unsigned long OldArea;
Name = calloc(81, sizeof(char)); Name = calloc(81, sizeof(char));
tmpname = calloc(81, sizeof(char)); tmpname = calloc(81, sizeof(char));
tmpname2 = calloc(81, sizeof(char));
OldArea = iAreaNumber; OldArea = iAreaNumber;
iLineCount = 2; /* Reset Line Counter to Zero */ iLineCount = 2; /* Reset Line Counter to Zero */
@ -730,6 +732,7 @@ int FilenameScan()
strcat(Name, temp); strcat(Name, temp);
} }
} }
tl(Name);
Syslog('+', "FilenameScan(): \"%s\"", Name); Syslog('+', "FilenameScan(): \"%s\"", Name);
clear(); clear();
@ -752,13 +755,17 @@ int FilenameScan()
while (fread(&file, sizeof(file), 1, pFile) == 1) { while (fread(&file, sizeof(file), 1, pFile) == 1) {
strcpy(tmpname, tl(file.Name)); strcpy(tmpname, file.Name);
if ((strstr(tmpname, Name)) != NULL) { strcpy(tmpname2, file.LName);
tl(tmpname);
tl(tmpname2);
if (((strstr(tmpname, Name)) != NULL) || ((strstr(tmpname2, Name)) != NULL)) {
if (!Found) { if (!Found) {
Enter(2); Enter(2);
if (iLC(2) == 1) { if (iLC(2) == 1) {
free(Name); free(Name);
free(tmpname); free(tmpname);
free(tmpname2);
SetFileArea(OldArea); SetFileArea(OldArea);
return 1; return 1;
} }
@ -769,12 +776,14 @@ int FilenameScan()
T.Active = FALSE; T.Active = FALSE;
T.Cost = file.Cost; T.Cost = file.Cost;
T.Size = file.Size; T.Size = file.Size;
sprintf(T.File, "%s", file.Name); strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 81);
SetTag(T); SetTag(T);
Count++; Count++;
if (ShowOneFile() == 1) { if (ShowOneFile() == 1) {
free(Name); free(Name);
free(tmpname); free(tmpname);
free(tmpname2);
SetFileArea(OldArea); SetFileArea(OldArea);
return 1; return 1;
} }
@ -788,6 +797,7 @@ int FilenameScan()
if (iLC(2) == 1) { if (iLC(2) == 1) {
free(Name); free(Name);
free(tmpname); free(tmpname);
free(tmpname2);
SetFileArea(OldArea); SetFileArea(OldArea);
return 1; return 1;
} }
@ -803,6 +813,7 @@ int FilenameScan()
fclose(pAreas); fclose(pAreas);
free(Name); free(Name);
free(tmpname); free(tmpname);
free(tmpname2);
printf("\n"); printf("\n");
if (Count) if (Count)
Mark(); Mark();
@ -912,7 +923,8 @@ int NewfileScan(int AskStart)
T.Active = FALSE; T.Active = FALSE;
T.Cost = file.Cost; T.Cost = file.Cost;
T.Size = file.Size; T.Size = file.Size;
sprintf(T.File, "%s", file.Name); strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 80);
SetTag(T); SetTag(T);
Count++; Count++;
@ -2027,7 +2039,7 @@ void Copy_Home()
while (fread(&file, sizeof(file), 1, pFile) == 1) { while (fread(&file, sizeof(file), 1, pFile) == 1) {
if (strcmp(File, file.Name) == 0) { if ((strcasecmp(File, file.Name) == 0) || (strcasecmp(File, file.LName) == 0)) {
Found = TRUE; Found = TRUE;
if (((file.Size + Quota()) > (CFG.iQuota * 1048576))) { if (((file.Size + Quota()) > (CFG.iQuota * 1048576))) {
@ -2036,7 +2048,7 @@ void Copy_Home()
printf("%s\n", (char *) Language(279)); printf("%s\n", (char *) Language(279));
Syslog('+', "Copy homedir, not enough quota"); Syslog('+', "Copy homedir, not enough quota");
} else { } else {
sprintf(temp1, "%s/%s", area.Path, File); sprintf(temp1, "%s/%s", area.Path, file.LName); /* Use real longname here */
sprintf(temp2, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File); sprintf(temp2, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File);
colour(CFG.TextColourF, CFG.TextColourB); colour(CFG.TextColourF, CFG.TextColourB);
/* Start copy: */ /* Start copy: */
@ -2130,7 +2142,7 @@ void EditTaglist()
Fg--; Fg--;
colour(Fg, 0); colour(Fg, 0);
printf("%-14s", Tag.File); printf("%-12s", Tag.SFile);
Fg--; Fg--;
colour(Fg, 0); colour(Fg, 0);

View File

@ -319,14 +319,14 @@ void Mark()
i = atoi(temp); i = atoi(temp);
if ((i > 0) && (i < 100)) { if ((i > 0) && (i < 100)) {
if ((Tagbuf[i].Area) && (strlen(Tagbuf[i].File))) { if ((Tagbuf[i].Area) && (strlen(Tagbuf[i].LFile))) {
if (Access(exitinfo.Security, area.DLSec)) { if (Access(exitinfo.Security, area.DLSec)) {
if ((fp = fopen("taglist", "a+")) != NULL) { if ((fp = fopen("taglist", "a+")) != NULL) {
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
Found = FALSE; Found = FALSE;
while (fread(&Tag, sizeof(Tag), 1, fp) == 1) while (fread(&Tag, sizeof(Tag), 1, fp) == 1)
if ((Tag.Area == Tagbuf[i].Area) && (strcmp(Tag.File, Tagbuf[i].File) == 0)) { if ((Tag.Area == Tagbuf[i].Area) && (strcmp(Tag.LFile, Tagbuf[i].LFile) == 0)) {
Found = TRUE; Found = TRUE;
Syslog('b', "Tagbuf[i].File already tagged"); Syslog('b', "Tagbuf[i].File already tagged");
} }
@ -336,7 +336,7 @@ void Mark()
Tag = Tagbuf[i]; Tag = Tagbuf[i];
Tag.Active = TRUE; Tag.Active = TRUE;
fwrite(&Tag, sizeof(Tag), 1, fp); fwrite(&Tag, sizeof(Tag), 1, fp);
Syslog('+', "Tagged file %s from area %d", Tag.File, Tag.Area); Syslog('+', "Tagged file %s from area %d", Tag.LFile, Tag.Area);
} }
fclose(fp); fclose(fp);
@ -416,37 +416,16 @@ int ShowOneFile()
printf(" %02d ", Tagnr); printf(" %02d ", Tagnr);
colour(CFG.FilenameF, CFG.FilenameB); colour(CFG.FilenameF, CFG.FilenameB);
if(strlen(file.Name) < 25) printf("%-12s", file.Name);
printf("%-15s", file.Name);
else {
printf("%-75s", file.Name);
if (iLC(1) == 1)
return 1;
}
colour(CFG.FilesizeF, CFG.FilesizeB); colour(CFG.FilesizeF, CFG.FilesizeB);
if(strlen(file.Name) < 25)
printf("%10lu ", (long)(file.Size)); printf("%10lu ", (long)(file.Size));
else
printf("%25lu ", (long)(file.Size));
colour(CFG.FiledateF, CFG.FiledateB); colour(CFG.FiledateF, CFG.FiledateB);
printf("%-10s ", StrDateDMY(file.UploadDate)); printf("%-10s ", StrDateDMY(file.UploadDate));
colour(12, 0); colour(12, 0);
if(file.TimesDL < 10) printf("[%4ld] ", file.TimesDL);
printf(" ");
if(file.TimesDL < 100)
printf(" ");
if(file.TimesDL < 1000)
printf(" ");
if(file.TimesDL > 9999)
file.TimesDL = 9999;
printf("[%ld] ", file.TimesDL);
if((strcmp(file.Uploader, "")) == 0) if((strcmp(file.Uploader, "")) == 0)
strcpy(file.Uploader, "SysOp"); strcpy(file.Uploader, "SysOp");
@ -891,12 +870,15 @@ int Addfile(char *File, int AreaNum, int fileid)
} }
memset(&file, 0, sizeof(file)); memset(&file, 0, sizeof(file));
strcpy(file.Name, File); strcpy(file.LName, File);
strcpy(temp1, File);
name_mangle(temp1);
strcpy(file.Name, temp1);
sprintf(temp1,"%ld",(long)(statfile.st_size)); sprintf(temp1,"%ld",(long)(statfile.st_size));
file.Size = atoi(temp1); file.Size = atoi(temp1);
file.FileDate = statfile.st_mtime; file.FileDate = statfile.st_mtime;
strcpy(file.Uploader, exitinfo.sUserName); strcpy(file.Uploader, exitinfo.sUserName);
time(&file.UploadDate); file.UploadDate = time(NULL);
if (area.PwdUP) { if (area.PwdUP) {
colour(9,0); colour(9,0);
@ -998,7 +980,7 @@ int Addfile(char *File, int AreaNum, int fileid)
iPrivate = TRUE; iPrivate = TRUE;
fprintf(pPrivate, "****************************************************"); fprintf(pPrivate, "****************************************************");
fprintf(pPrivate, "\nUser : %s", file.Uploader); fprintf(pPrivate, "\nUser : %s", file.Uploader);
fprintf(pPrivate, "\nFile : %s", file.Name); fprintf(pPrivate, "\nFile : %s (%s)", file.LName, file.Name);
fprintf(pPrivate, "\nSize : %lu", (long)(file.Size)); fprintf(pPrivate, "\nSize : %lu", (long)(file.Size));
fprintf(pPrivate, "\nUpload Date : %s\n\n", StrDateDMY(file.UploadDate)); fprintf(pPrivate, "\nUpload Date : %s\n\n", StrDateDMY(file.UploadDate));