diff --git a/ChangeLog b/ChangeLog index b39e73b3..a03584f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4224,7 +4224,12 @@ v0.33.19 26-Oct-2001 version, or change it by hand. 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: 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 users need to register with the mbnewuser program, mbsebbs is 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 messages. The whoson list now uses mbtask to get the information. @@ -4284,6 +4289,13 @@ v0.33.19 26-Oct-2001 with mode 0600. A lot of code rewrites to make it more modular. 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: 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. Fixed the problem that the KillSent flag was set on processed 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: During check the file databases are reset to filemode 0660. Implemented "mbfile adopt" function. Started working on long filename support. The real name on disk is the long filename, the database records also holds - an uppercase 8.3 filename. In most cases this is just the - same name in upper and lowercase. Name mangling like Win$ + an uppercase mangled 8.3 filename. In most cases this is just + the same name in upper and lowercase. Name mangling like Win$ is performed on the long filenames. Implemented "mbfile import" function, this imports complete areas from files.bbs information. diff --git a/lib/common.h b/lib/common.h index 222fc127..687b27be 100644 --- a/lib/common.h +++ b/lib/common.h @@ -917,8 +917,8 @@ char *strcasestr(char *, char *); /* * mangle.c */ -void mangle_name_83( char *); -int name_mangle(char *, int); +void mangle_name_83( char *); /* Mangle name to 8.3 format */ +void name_mangle(char *); /* Mangle name or make uppercase */ #endif diff --git a/lib/mangle.c b/lib/mangle.c index 50262ceb..6d124ac0 100644 --- a/lib/mangle.c +++ b/lib/mangle.c @@ -44,7 +44,6 @@ int str_checksum(const char *); char *safe_strcpy(char *, const char *, size_t); static void init_chartest(void); static int is_reserved_msdos(char *); -static int is_illegal_name(char *); int is_8_3(char *); @@ -162,7 +161,7 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength) len = strlen(src); 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; } @@ -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 , 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. @@ -311,48 +270,45 @@ static int is_illegal_name(char *name) */ int is_8_3( char *fname) { - int len; - int l; - char *p; - char *dot_pos; - char *slash_pos = strrchr( fname, '/' ); + int len; + int l, i; + char *p; + char *dot_pos; + char *slash_pos = strrchr( fname, '/' ); /* If there is a directory path, skip it. */ if (slash_pos) fname = slash_pos + 1; 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 */ - if( (len == 0) || (len > 12) ) + if ((len == 0) || (len > 12)) { + Syslog('f', "filename length not right"); return FALSE; + } /* 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; + } - /* Check that all characters are the correct case, if asked to do so. */ -// if (strhaslower(fname)) -// return FALSE; + init_chartest(); + for (i = 0; i < strlen(fname); i++) { + if (isillegal(fname[i])) { + Syslog('f', "Illegal character in filename"); + return FALSE; + } + } /* 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; dot_pos = NULL; while (*p) { if (*p == '.' && !dot_pos) dot_pos = (char *)p; -// else -// if (!isdoschar(*p)) -// return FALSE; p++; } @@ -367,23 +323,27 @@ int is_8_3( char *fname) return(0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." )); /* base can't be greater than 8 */ - if (l > 8) + if (l > 8) { + Syslog('f', "filebase longer then 8 chars"); return FALSE; + } - /* see smb.conf(5) for a description of the 'strip dot' parameter. */ - /* strip_dot defaults to no */ - if (/* lp_strip_dot() && */ len - l == 1 && !strchr( dot_pos + 1, '.' )) { + if (len - l == 1 && !strchr( dot_pos + 1, '.' )) { *dot_pos = 0; return TRUE; } /* 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; + } /* 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; + } /* must be in 8.3 format */ return TRUE; @@ -398,8 +358,8 @@ int is_8_3( char *fname) */ void mangle_name_83(char *s) { - int csum; - char *p; + int csum, i; + char *p, *q; char extension[4]; char base[9]; int baselen = 0; @@ -408,6 +368,53 @@ void mangle_name_83(char *s) extension[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,'.'); if (p && (strlen(p+1) < (size_t)4)) { int all_normal = (!strhaslower(p+1)); /* XXXXXXXXX */ @@ -422,11 +429,10 @@ void mangle_name_83(char *s) csum = str_checksum(s); tu(s); -// Syslog('f', "Mangling name %s to ",s); if (p) { - if( p == s ) - safe_strcpy( extension, "___", 3 ); + if (p == s) + safe_strcpy(extension, "___", 3); else { *p++ = 0; while (*p && extlen < 3) { @@ -447,63 +453,48 @@ void mangle_name_83(char *s) } base[baselen] = 0; - csum = csum % (MANGLE_BASE*MANGLE_BASE); - sprintf(s, "%s%c%c%c", base, magic_char, mangle(csum/MANGLE_BASE), mangle(csum)); + csum = csum % (MANGLE_BASE * MANGLE_BASE); + sprintf(s, "%s%c%c%c", base, magic_char, mangle(csum / MANGLE_BASE), mangle(csum)); if( *extension ) { (void)strcat(s, "."); (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. * * NOTE that OutName must point to a memory space that - * is at least 13 bytes in size! - * - * 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. + * is at least 13 bytes in size! That should always be + * the case of course. * * **************************************************************************** */ -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; + p = xstrcpy(OutName); + /* + * check if it's already in 8.3 format + */ + if (!is_8_3(OutName)) { + Syslog('f', "is 8.3 = FALSE"); + mangle_name_83(OutName); + } else { /* - * Check for characters legal in Unix and illegal in DOS/Win + * No mangling needed, convert to uppercase */ - if (!need83 && is_illegal_name(OutName)) - need83 = TRUE; + tu(OutName); + } - /* - * check if it's already in 8.3 format - */ - if (need83 && !is_8_3(OutName)) { - mangle_name_83(OutName); - } else { - /* - * No mangling needed, convert to uppercase - */ - tu(OutName); - } - - Syslog('f',"name_mangle() ==> [%s]", OutName); - return TRUE; + Syslog('f',"name_mangle(%s) ==> [%s]", p, OutName); + free(p); } diff --git a/lib/mbse.h b/lib/mbse.h index ac1705d7..13275a5c 100644 --- a/lib/mbse.h +++ b/lib/mbse.h @@ -42,7 +42,8 @@ typedef struct _TagRec { int Active; /* Not deleted from taglist */ int Cost; /* Free download */ off_t Size; /* File Size */ - char File[81]; /* File Name */ + char SFile[13]; /* Short File Name */ + char LFile[81]; /* Long FIle Name */ } _Tag; diff --git a/mbfido/addbbs.c b/mbfido/addbbs.c index 3f115ea6..61da3edd 100644 --- a/mbfido/addbbs.c +++ b/mbfido/addbbs.c @@ -1,8 +1,7 @@ /***************************************************************************** * - * File ..................: mbfido/addbbs.c + * $Id$ * Purpose ...............: Add TIC file to the BBS - * Last modification date : 21-Aug-2000 * ***************************************************************************** * Copyright (C) 1997-2000 @@ -54,8 +53,8 @@ int Add_BBS() { struct FILERecord frec; int i, Insert, Done = FALSE, Found = FALSE; - char fdbname[128], fdbtemp[128]; - char temp1[128], temp2[128], *fname; + char fdbname[PATH_MAX], fdbtemp[PATH_MAX]; + char temp1[PATH_MAX], temp2[PATH_MAX], *fname; FILE *fdb, *fdt; int Keep = 0, DidDelete = FALSE; fd_list *fdl = NULL; @@ -64,7 +63,9 @@ int Add_BBS() * Create filedatabase record. */ 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.TicArea, TIC.TicIn.Area); /* TIJDELIJK IVM VELDLENGTE */ frec.Size = TIC.FileSize; @@ -100,6 +101,7 @@ int Add_BBS() WriteError("$Can't create %s", fdbname); return FALSE; } + chmod(fdbname, 0660); } /* @@ -129,11 +131,11 @@ int Add_BBS() if (fread(&file, sizeof(file), 1, fdb) != 1) Done = TRUE; if (!Done) { - if (strcmp(frec.Name, file.Name) == 0) { + if (strcmp(frec.LName, file.LName) == 0) { Found = TRUE; Insert++; } else - if (strcmp(frec.Name, file.Name) < 0) + if (strcmp(frec.LName, file.LName) < 0) Found = TRUE; else Insert++; @@ -158,7 +160,7 @@ int Add_BBS() * name, if so, don't copy the original database * 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); } @@ -178,7 +180,7 @@ int Add_BBS() * then we skip the record what was origionaly * in the database record. */ - if (strcmp(file.Name, frec.Name) != 0) + if (strcmp(file.LName, frec.LName) != 0) fwrite(&file, sizeof(file), 1, fdt); } @@ -228,16 +230,16 @@ int Add_BBS() if ((fdb = fopen(fdbname, "r+")) != NULL) { while (fread(&file, sizeof(file), 1, fdb) == 1) { - if (strlen(file.Name) == strlen(TIC.NewName)) { - if (strcasecmp(file.Name, TIC.NewName) != 0) { + if (strlen(file.LName) == strlen(TIC.NewName)) { + if (strcasecmp(file.LName, TIC.NewName) != 0) { Found = TRUE; for (i = 0; i < strlen(TIC.NewName); 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; } if (Found) { - Syslog('+', "Replace: Deleting: %s", file.Name); + Syslog('+', "Replace: Deleting: %s", file.LName); file.Deleted = TRUE; fseek(fdb, - sizeof(file), SEEK_CUR); fwrite(&file, sizeof(file), 1, fdb); @@ -258,19 +260,19 @@ int Add_BBS() 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; - 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] != file.Name[i]) { + if (TIC.NewName[i] != file.LName[i]) { Found = FALSE; } } } if (Found) { 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); while (fread(&file, sizeof(file), 1, fdb) == 1) { - if (strcmp(file.Name, fname) == 0) { - Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, file.Name); + if (strcmp(file.LName, fname) == 0) { + Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, file.LName); file.Deleted = TRUE; fseek(fdb, - sizeof(file), SEEK_CUR); fwrite(&file, sizeof(file), 1, fdb); @@ -315,7 +317,7 @@ int Add_BBS() if (!file.Deleted) fwrite(&file, sizeof(file), 1, fdt); else { - sprintf(temp2, "%s/%s", area.Path, file.Name); + sprintf(temp2, "%s/%s", area.Path, file.LName); if (unlink(temp2) != 0) WriteError("$Can't unlink file %s", temp2); } diff --git a/mbfido/mbfadopt.c b/mbfido/mbfadopt.c index 2fe2d740..40c5c560 100644 --- a/mbfido/mbfadopt.c +++ b/mbfido/mbfadopt.c @@ -277,7 +277,7 @@ void AdoptFile(int Area, char *File, char *Description) * Convert to 8.3 DOS filename */ strcpy(temp2, File); - name_mangle(temp2, TRUE); + name_mangle(temp2); strcpy(fdb.Name, temp2); strcpy(fdb.LName, File); fdb.Size = file_size(File); diff --git a/mbfido/mbfcheck.c b/mbfido/mbfcheck.c index 6283436e..35279e4f 100644 --- a/mbfido/mbfcheck.c +++ b/mbfido/mbfcheck.c @@ -157,7 +157,7 @@ void Check(void) Update = FALSE; strcpy(temp, file.LName); - name_mangle(temp, TRUE); + name_mangle(temp); if (strcmp(file.Name, temp)) { Syslog('!', "Converted %s to %s", file.Name, temp); strncpy(file.Name, temp, 12); diff --git a/mbfido/mbfimport.c b/mbfido/mbfimport.c index 9db683b8..914d5a55 100644 --- a/mbfido/mbfimport.c +++ b/mbfido/mbfimport.c @@ -209,7 +209,7 @@ void ImportFiles(int Area) * Create DOS 8.3 filename */ strcpy(temp, fdb.LName); - name_mangle(temp, TRUE); + name_mangle(temp); strcpy(fdb.Name, temp); if (do_annon) diff --git a/mbfido/mbfutil.c b/mbfido/mbfutil.c index a9855797..6bd429ff 100644 --- a/mbfido/mbfutil.c +++ b/mbfido/mbfutil.c @@ -339,11 +339,11 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath) if (fread(&file, sizeof(file), 1, fp1) != 1) Done = TRUE; if (!Done) { - if (strcmp(fdb.Name, file.Name) == 0) { + if (strcmp(fdb.LName, file.LName) == 0) { Found = TRUE; Insert++; } else { - if (strcmp(fdb.Name, file.Name) < 0) + if (strcmp(fdb.LName, file.LName) < 0) Found = TRUE; else 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, * 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); } @@ -378,7 +378,7 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath) * Append the rest of the records */ 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); } if (!area.AddAlpha) diff --git a/mbsebbs/file.c b/mbsebbs/file.c index a8a79568..7f8286dc 100644 --- a/mbsebbs/file.c +++ b/mbsebbs/file.c @@ -57,20 +57,22 @@ int CheckFile(char *, int); int CheckFile(char *File, int iArea) { FILE *pFileB; - int iFile = FALSE; char *sFileArea; sFileArea = calloc(PATH_MAX, sizeof(char)); sprintf(sFileArea,"%s/fdb/fdb%d.dta", getenv("MBSE_ROOT"), iArea); - if(( pFileB = fopen(sFileArea,"r+")) == NULL) { - mkdir(sFileArea, 755); + if ((pFileB = fopen(sFileArea,"r+")) == NULL) { + mkdir(sFileArea, 775); return FALSE; } + free(sFileArea); - while ( fread(&file, sizeof(file), 1, pFileB) == 1) { - if((strcmp(tl(file.Name), tl(File))) == 0) { - iFile = TRUE; + /* + * Check long and short filenames, case insensitive + */ + while (fread(&file, sizeof(file), 1, pFileB) == 1) { + if (((strcasecmp(file.Name, File)) == 0) || ((strcasecmp(file.LName, File)) == 0)) { fclose(pFileB); return TRUE; } @@ -78,11 +80,7 @@ int CheckFile(char *File, int iArea) } fclose(pFileB); - free(sFileArea); - - if(!iFile) - return FALSE; - return 1; + return FALSE; } @@ -128,7 +126,8 @@ void File_List() T.Active = FALSE; T.Cost = file.Cost; T.Size = file.Size; - sprintf(T.File, "%s", file.Name); + strncpy(T.SFile, file.Name, 12); + strncpy(T.LFile, file.LName, 80); SetTag(T); if (ShowOneFile() == 1) { @@ -136,13 +135,13 @@ void File_List() return; } - if(file.Deleted) + if (file.Deleted) /* 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: */ - 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 */ FileBytes += file.Size; /* Increase File Byte Count */ @@ -207,18 +206,18 @@ void Download(void) if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) { while (fread(&file, sizeof(file), 1, fp) == 1) { - if (strcmp(file.Name, Tag.File) == 0) + if (strcmp(file.LName, Tag.LFile) == 0) break; } fclose(fp); } - if (strcmp(file.Name, Tag.File) == 0) { - Syslog('b', "Found file %s in area %d", file.Name, Tag.Area); + if (strcmp(file.LName, Tag.LFile) == 0) { + Syslog('b', "Found file %s in area %d", file.LName, Tag.Area); if ((file.Deleted) || (file.Missing)) { pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(248)); /* 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; } @@ -233,7 +232,7 @@ void Download(void) */ sprintf(symTo, "./tag/filedesc.%ld", exitinfo.Downloads % 256); 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++) { if (strlen(file.Desc[i]) > 1) fprintf(fd, " %s\r\n", file.Desc[i]); @@ -245,11 +244,12 @@ void Download(void) /* * Make a symlink to the users download dir. * First unlink, in case there was an old one. + * The shortname is linked to the original longname. */ chdir("./tag"); - unlink(Tag.File); - sprintf(symFrom, "%s", Tag.File); - sprintf(symTo, "%s/%s", sAreaPath, Tag.File); + unlink(Tag.SFile); + sprintf(symFrom, "%s", Tag.SFile); + sprintf(symTo, "%s/%s", sAreaPath, Tag.LFile); if (symlink(symTo, symFrom)) { WriteError("$Can't create symlink %s %s %d", symTo, symFrom, errno); Tag.Active = FALSE; @@ -392,12 +392,12 @@ void Download(void) if (Tag.Active) { - sprintf(symTo, "./tag/%s", Tag.File); + sprintf(symTo, "./tag/%s", Tag.SFile); /* * If symlink is gone the file is sent. */ 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; fseek(tf, - sizeof(Tag), SEEK_CUR); fwrite(&Tag, sizeof(Tag), 1, tf); @@ -409,7 +409,7 @@ void Download(void) SetFileArea(Tag.Area); if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) { while (fread(&file, sizeof(file), 1, fp) == 1) { - if (strcmp(file.Name, Tag.File) == 0) + if (strcmp(file.LName, Tag.LFile) == 0) break; } Size += file.Size; @@ -421,7 +421,7 @@ void Download(void) Count++; } } 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); } } } @@ -501,12 +501,12 @@ void File_RawDir(char *OpData) if (*(dp->d_name) != '.') { iFileCount++; - if(stat(FileName,&statfile) != 0) - printf("Can't stat file %s\n",FileName); + if (stat(FileName, &statfile) != 0) + printf("Can't stat file %s\n", FileName); iBytes += statfile.st_size; colour(14,0); - printf("%-20s", dp->d_name); + printf("%-12s " , dp->d_name); colour(13,0); printf("%-12ld", (long)(statfile.st_size)); @@ -566,7 +566,7 @@ int KeywordScan() colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Name, 80); - if((strcmp(Name, "")) == 0) + if ((strcmp(Name, "")) == 0) return 0; strcpy(tmpname, tl(Name)); @@ -625,7 +625,8 @@ int KeywordScan() T.Active = FALSE; T.Cost = file.Cost; T.Size = file.Size; - sprintf(T.File, "%s", file.Name); + strncpy(T.SFile, file.Name, 12); + strncpy(T.LFile, file.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { @@ -681,13 +682,14 @@ int FilenameScan() FILE *pAreas, *pFile; int z, y, Found, Count = 0; char *Name; - char *tmpname; + char *tmpname, *tmpname2; char temp[81]; _Tag T; unsigned long OldArea; Name = calloc(81, sizeof(char)); tmpname = calloc(81, sizeof(char)); + tmpname2 = calloc(81, sizeof(char)); OldArea = iAreaNumber; iLineCount = 2; /* Reset Line Counter to Zero */ @@ -730,6 +732,7 @@ int FilenameScan() strcat(Name, temp); } } + tl(Name); Syslog('+', "FilenameScan(): \"%s\"", Name); clear(); @@ -752,13 +755,17 @@ int FilenameScan() while (fread(&file, sizeof(file), 1, pFile) == 1) { - strcpy(tmpname, tl(file.Name)); - if ((strstr(tmpname, Name)) != NULL) { + strcpy(tmpname, file.Name); + strcpy(tmpname2, file.LName); + tl(tmpname); + tl(tmpname2); + if (((strstr(tmpname, Name)) != NULL) || ((strstr(tmpname2, Name)) != NULL)) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(Name); free(tmpname); + free(tmpname2); SetFileArea(OldArea); return 1; } @@ -769,12 +776,14 @@ int FilenameScan() T.Active = FALSE; T.Cost = file.Cost; T.Size = file.Size; - sprintf(T.File, "%s", file.Name); + strncpy(T.SFile, file.Name, 12); + strncpy(T.LFile, file.LName, 81); SetTag(T); Count++; if (ShowOneFile() == 1) { free(Name); free(tmpname); + free(tmpname2); SetFileArea(OldArea); return 1; } @@ -788,6 +797,7 @@ int FilenameScan() if (iLC(2) == 1) { free(Name); free(tmpname); + free(tmpname2); SetFileArea(OldArea); return 1; } @@ -803,6 +813,7 @@ int FilenameScan() fclose(pAreas); free(Name); free(tmpname); + free(tmpname2); printf("\n"); if (Count) Mark(); @@ -912,7 +923,8 @@ int NewfileScan(int AskStart) T.Active = FALSE; T.Cost = file.Cost; T.Size = file.Size; - sprintf(T.File, "%s", file.Name); + strncpy(T.SFile, file.Name, 12); + strncpy(T.LFile, file.LName, 80); SetTag(T); Count++; @@ -1056,7 +1068,7 @@ int Upload() /* MOET IN ALLE AREAS ZOEKEN */ if (area.Dupes) { x = CheckFile(File, Area); - if(x) { + if (x) { Enter(1); /* The file already exists on the system */ pout(15, 3, (char *) Language(282)); @@ -2008,7 +2020,7 @@ void Copy_Home() return; } - if(Access(exitinfo.Security, area.DLSec) == FALSE) { + if (Access(exitinfo.Security, area.DLSec) == FALSE) { colour(14, 0); printf("\n%s\n", (char *) Language(236)); Pause(); @@ -2027,7 +2039,7 @@ void Copy_Home() 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; if (((file.Size + Quota()) > (CFG.iQuota * 1048576))) { @@ -2036,7 +2048,7 @@ void Copy_Home() printf("%s\n", (char *) Language(279)); Syslog('+', "Copy homedir, not enough quota"); } 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); colour(CFG.TextColourF, CFG.TextColourB); /* Start copy: */ @@ -2130,7 +2142,7 @@ void EditTaglist() Fg--; colour(Fg, 0); - printf("%-14s", Tag.File); + printf("%-12s", Tag.SFile); Fg--; colour(Fg, 0); diff --git a/mbsebbs/filesub.c b/mbsebbs/filesub.c index be0245bc..5ff8753b 100644 --- a/mbsebbs/filesub.c +++ b/mbsebbs/filesub.c @@ -319,14 +319,14 @@ void Mark() i = atoi(temp); 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 ((fp = fopen("taglist", "a+")) != NULL) { fseek(fp, 0, SEEK_SET); Found = FALSE; 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; Syslog('b', "Tagbuf[i].File already tagged"); } @@ -336,7 +336,7 @@ void Mark() Tag = Tagbuf[i]; Tag.Active = TRUE; 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); @@ -416,37 +416,16 @@ int ShowOneFile() printf(" %02d ", Tagnr); colour(CFG.FilenameF, CFG.FilenameB); - if(strlen(file.Name) < 25) - printf("%-15s", file.Name); - else { - printf("%-75s", file.Name); - if (iLC(1) == 1) - return 1; - } + printf("%-12s", file.Name); colour(CFG.FilesizeF, CFG.FilesizeB); - if(strlen(file.Name) < 25) - printf("%10lu ", (long)(file.Size)); - else - printf("%25lu ", (long)(file.Size)); + printf("%10lu ", (long)(file.Size)); colour(CFG.FiledateF, CFG.FiledateB); printf("%-10s ", StrDateDMY(file.UploadDate)); colour(12, 0); - if(file.TimesDL < 10) - printf(" "); - - if(file.TimesDL < 100) - printf(" "); - - if(file.TimesDL < 1000) - printf(" "); - - if(file.TimesDL > 9999) - file.TimesDL = 9999; - - printf("[%ld] ", file.TimesDL); + printf("[%4ld] ", file.TimesDL); if((strcmp(file.Uploader, "")) == 0) strcpy(file.Uploader, "SysOp"); @@ -891,14 +870,17 @@ int Addfile(char *File, int AreaNum, int fileid) } 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)); file.Size = atoi(temp1); file.FileDate = statfile.st_mtime; strcpy(file.Uploader, exitinfo.sUserName); - time(&file.UploadDate); + file.UploadDate = time(NULL); - if(area.PwdUP) { + if (area.PwdUP) { colour(9,0); /* Do you want to password protect your upload ? [y/N]: */ printf("\n%s", (char *) Language(285)); @@ -998,7 +980,7 @@ int Addfile(char *File, int AreaNum, int fileid) iPrivate = TRUE; fprintf(pPrivate, "****************************************************"); 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, "\nUpload Date : %s\n\n", StrDateDMY(file.UploadDate));