Absolute path symlinks to symlinks without path info
This commit is contained in:
parent
460011e4de
commit
2ca2ab9158
22
ChangeLog
22
ChangeLog
@ -3,6 +3,28 @@ $Id$
|
|||||||
|
|
||||||
v0.91.6 05-Mar-2007
|
v0.91.6 05-Mar-2007
|
||||||
|
|
||||||
|
upgrade:
|
||||||
|
This upgrade is not needed if you are happy with the current
|
||||||
|
symbolic links in the download fileareas.
|
||||||
|
You need to remove all existing symbolic links with paths, and
|
||||||
|
recreate the symbolic links without pathnames do:
|
||||||
|
|
||||||
|
mbse$ cd /opt/mbse/ftp
|
||||||
|
mbse$ find pub -type l -exec rm '{}' \;
|
||||||
|
mbse$ mbfile check
|
||||||
|
|
||||||
|
mbfido:
|
||||||
|
The add file function now creates links without pathnames.
|
||||||
|
|
||||||
|
mbfile:
|
||||||
|
The check command now repairs filenames without using absolute
|
||||||
|
pathnames.
|
||||||
|
The adopt, import and move functions now make links without
|
||||||
|
path.
|
||||||
|
|
||||||
|
mbsebbs:
|
||||||
|
Uploaded files now have symlinks without pathnames.
|
||||||
|
|
||||||
|
|
||||||
v0.91.5 18-Feb-2007 - 05-Mar-2007
|
v0.91.5 18-Feb-2007 - 05-Mar-2007
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Add TIC file to the BBS
|
* Purpose ...............: Add TIC file to the BBS
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2005
|
* Copyright (C) 1997-2007
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -166,9 +166,15 @@ int Add_BBS(qualify **qal)
|
|||||||
}
|
}
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
lname = calloc(PATH_MAX, sizeof(char));
|
lname = calloc(PATH_MAX, sizeof(char));
|
||||||
snprintf(lname, PATH_MAX, "%s/%s", TIC.BBSpath, frec.LName);
|
if (getcwd(lname, PATH_MAX -1)) {
|
||||||
if (symlink(temp2, lname)) {
|
if (chdir(TIC.BBSpath)) {
|
||||||
WriteError("$Create link %s to %s failed", temp2, lname);
|
WriteError("$Can't chdir %s", TIC.BBSpath);
|
||||||
|
} else {
|
||||||
|
// snprintf(lname, PATH_MAX, "%s/%s", TIC.BBSpath, frec.LName);
|
||||||
|
if (symlink(frec.Name, frec.LName)) {
|
||||||
|
WriteError("$Create link %s to %s failed", frec.Name, frec.LName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(lname);
|
free(lname);
|
||||||
|
|
||||||
|
@ -298,13 +298,18 @@ void CheckArea(int Area)
|
|||||||
inArea = 0;
|
inArea = 0;
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
|
|
||||||
|
if (chdir(area.Path)) {
|
||||||
|
WriteError("$Can't chdir to %s", area.Path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
inArea++;
|
inArea++;
|
||||||
snprintf(newdir, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
snprintf(newdir, PATH_MAX, "%s", fdb.LName);
|
||||||
snprintf(mname, PATH_MAX, "%s/%s", area.Path, fdb.Name);
|
snprintf(mname, PATH_MAX, "%s", fdb.Name);
|
||||||
|
|
||||||
if (file_exist(newdir, R_OK) && file_exist(mname, R_OK)) {
|
if (file_exist(fdb.LName, R_OK) && file_exist(fdb.Name, R_OK)) {
|
||||||
Syslog('+', "File %s area %ld not on disk.", newdir, Area);
|
Syslog('+', "File %s area %ld not on disk.", fdb.Name, Area);
|
||||||
if (!fdb.NoKill) {
|
if (!fdb.NoKill) {
|
||||||
fdb.Deleted = TRUE;
|
fdb.Deleted = TRUE;
|
||||||
do_pack = TRUE;
|
do_pack = TRUE;
|
||||||
@ -324,15 +329,15 @@ void CheckArea(int Area)
|
|||||||
|
|
||||||
strcpy(temp, fdb.LName);
|
strcpy(temp, fdb.LName);
|
||||||
name_mangle(temp);
|
name_mangle(temp);
|
||||||
snprintf(mname, PATH_MAX, "%s/%s", area.Path, temp);
|
snprintf(mname, PATH_MAX, "%s", temp);
|
||||||
if (strcmp(fdb.Name, temp)) {
|
if (strcmp(fdb.Name, temp)) {
|
||||||
Syslog('!', "Converted %s to %s", fdb.Name, temp);
|
Syslog('!', "Converted %s to %s", fdb.Name, temp);
|
||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
snprintf(tname, PATH_MAX, "%s/%s", area.Path, fdb.Name);
|
snprintf(tname, PATH_MAX, "%s", fdb.Name);
|
||||||
rename(tname, mname);
|
rename(fdb.Name, mname);
|
||||||
snprintf(tname, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
snprintf(tname, PATH_MAX, "%s", fdb.LName);
|
||||||
unlink(tname);
|
unlink(fdb.LName);
|
||||||
symlink(mname, tname);
|
symlink(mname, fdb.LName);
|
||||||
free(tname);
|
free(tname);
|
||||||
strncpy(fdb.Name, temp, 12);
|
strncpy(fdb.Name, temp, 12);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
@ -347,12 +352,11 @@ void CheckArea(int Area)
|
|||||||
* 8.3 and LFN are the same.
|
* 8.3 and LFN are the same.
|
||||||
*/
|
*/
|
||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
snprintf(tname, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
snprintf(tname, PATH_MAX, "%s", fdb.LName);
|
||||||
for (j = 0; j < strlen(fdb.LName); j++)
|
for (j = 0; j < strlen(fdb.LName); j++)
|
||||||
fdb.LName[j] = tolower(fdb.LName[j]);
|
fdb.LName[j] = tolower(fdb.LName[j]);
|
||||||
snprintf(newdir, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
if (strcmp(tname, fdb.LName)) {
|
||||||
if (strcmp(tname, newdir)) {
|
Syslog('+', "Rename LFN from %s to %s", tname, fdb.LName);
|
||||||
Syslog('+', "Rename LFN from %s to %s", fdb.Name, fdb.LName);
|
|
||||||
rename(tname, newdir);
|
rename(tname, newdir);
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
}
|
}
|
||||||
@ -365,7 +369,7 @@ void CheckArea(int Area)
|
|||||||
* or both. One of them may also be a symbolic link or not exist
|
* or both. One of them may also be a symbolic link or not exist
|
||||||
* at all. Whatever it was, make it good.
|
* at all. Whatever it was, make it good.
|
||||||
*/
|
*/
|
||||||
if ((lstat(newdir, &stb) == 0) && ((stb.st_mode & S_IFLNK) != S_IFLNK)) {
|
if ((lstat(fdb.LName, &stb) == 0) && ((stb.st_mode & S_IFLNK) != S_IFLNK)) {
|
||||||
/*
|
/*
|
||||||
* Long filename is a regular file and not a symbolic link.
|
* Long filename is a regular file and not a symbolic link.
|
||||||
*/
|
*/
|
||||||
@ -374,17 +378,17 @@ void CheckArea(int Area)
|
|||||||
* 8.3 name exists, is it a real file?
|
* 8.3 name exists, is it a real file?
|
||||||
*/
|
*/
|
||||||
if ((stb.st_mode & S_IFLNK) != S_IFLNK) {
|
if ((stb.st_mode & S_IFLNK) != S_IFLNK) {
|
||||||
unlink(newdir);
|
unlink(fdb.LName);
|
||||||
symlink(mname, newdir);
|
symlink(mname, fdb.LName);
|
||||||
Syslog('+', "%s changed into symbolic link", newdir);
|
Syslog('+', "%s changed into symbolic link", fdb.LName);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* 8.3 is a symbolic link.
|
* 8.3 is a symbolic link.
|
||||||
*/
|
*/
|
||||||
unlink(mname);
|
unlink(mname);
|
||||||
rename(newdir, mname);
|
rename(fdb.LName, mname);
|
||||||
symlink(mname, newdir);
|
symlink(mname, fdb.LName);
|
||||||
Syslog('+', "%s changed to real file", mname);
|
Syslog('+', "%s changed to real file", mname);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
}
|
}
|
||||||
@ -392,8 +396,8 @@ void CheckArea(int Area)
|
|||||||
/*
|
/*
|
||||||
* No 8.3 name on disk.
|
* No 8.3 name on disk.
|
||||||
*/
|
*/
|
||||||
rename(newdir, mname);
|
rename(fdb.LName, mname);
|
||||||
symlink(mname, newdir);
|
symlink(mname, fdb.LName);
|
||||||
Syslog('+', "%s changed to real file and created symbolic link", mname);
|
Syslog('+', "%s changed to real file and created symbolic link", mname);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
}
|
}
|
||||||
@ -401,7 +405,7 @@ void CheckArea(int Area)
|
|||||||
/*
|
/*
|
||||||
* Short filename is a real file.
|
* Short filename is a real file.
|
||||||
*/
|
*/
|
||||||
if (lstat(newdir, &stb) == 0) {
|
if (lstat(fdb.LName, &stb) == 0) {
|
||||||
/*
|
/*
|
||||||
* LFN exists, is it a real file?
|
* LFN exists, is it a real file?
|
||||||
*/
|
*/
|
||||||
@ -409,31 +413,31 @@ void CheckArea(int Area)
|
|||||||
/*
|
/*
|
||||||
* LFN is a real filename too.
|
* LFN is a real filename too.
|
||||||
*/
|
*/
|
||||||
unlink(newdir);
|
unlink(fdb.LName);
|
||||||
symlink(mname, newdir);
|
symlink(mname, fdb.LName);
|
||||||
Syslog('+', "%s changed into symbolic link", newdir);
|
Syslog('+', "%s changed into symbolic link", fdb.LName);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* No LFN, create symbolic link
|
* No LFN, create symbolic link
|
||||||
*/
|
*/
|
||||||
symlink(mname, newdir);
|
symlink(mname, fdb.LName);
|
||||||
Syslog('+', "%s created symbolic link", newdir);
|
Syslog('+', "%s created symbolic link", fdb.LName);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Weird, could not happen
|
* Weird, could not happen
|
||||||
*/
|
*/
|
||||||
Syslog('!', "Weird problem, %s is no regular file", newdir);
|
Syslog('!', "Weird problem, %s is no regular file", fdb.LName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It could be that there is a thumbnail made of the 8.3 filename
|
* It could be that there is a thumbnail made of the 8.3 filename
|
||||||
*/
|
*/
|
||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
snprintf(tname, PATH_MAX, "%s/.%s", area.Path, fdb.Name);
|
snprintf(tname, PATH_MAX, ".%s", fdb.Name);
|
||||||
if (file_exist(tname, R_OK) == 0) {
|
if (file_exist(tname, R_OK) == 0) {
|
||||||
Syslog('+', "Removing wrong 8.3 thumbnail %s", tname);
|
Syslog('+', "Removing wrong 8.3 thumbnail %s", tname);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
@ -442,27 +446,27 @@ void CheckArea(int Area)
|
|||||||
free(tname);
|
free(tname);
|
||||||
|
|
||||||
|
|
||||||
if (file_time(newdir) != fdb.FileDate) {
|
if (file_time(fdb.LName) != fdb.FileDate) {
|
||||||
Syslog('!', "Date mismatch area %ld file %s", Area, fdb.LName);
|
Syslog('!', "Date mismatch area %ld file %s", Area, fdb.LName);
|
||||||
fdb.FileDate = file_time(newdir);
|
fdb.FileDate = file_time(fdb.LName);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
}
|
}
|
||||||
if (file_size(newdir) != fdb.Size) {
|
if (file_size(fdb.LName) != fdb.Size) {
|
||||||
Syslog('!', "Size mismatch area %ld file %s", Area, fdb.LName);
|
Syslog('!', "Size mismatch area %ld file %s", Area, fdb.LName);
|
||||||
fdb.Size = file_size(newdir);
|
fdb.Size = file_size(fdb.LName);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
}
|
}
|
||||||
if (file_crc(newdir, CFG.slow_util && do_quiet) != fdb.Crc32) {
|
if (file_crc(fdb.LName, CFG.slow_util && do_quiet) != fdb.Crc32) {
|
||||||
Syslog('!', "CRC error area %ld, file %s", Area, fdb.LName);
|
Syslog('!', "CRC error area %ld, file %s", Area, fdb.LName);
|
||||||
fdb.Crc32 = file_crc(newdir, CFG.slow_util && do_quiet);
|
fdb.Crc32 = file_crc(fdb.LName, CFG.slow_util && do_quiet);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
Update = TRUE;
|
Update = TRUE;
|
||||||
}
|
}
|
||||||
if (stat(newdir, &stb) == 0) {
|
if (stat(fdb.LName, &stb) == 0) {
|
||||||
if (stb.st_mode != 0100644) {
|
if (stb.st_mode != 0100644) {
|
||||||
if (chmod(newdir, 0644) == 0) {
|
if (chmod(fdb.LName, 0644) == 0) {
|
||||||
Syslog('!', "Fixed filemode area %ld, file %s", Area, fdb.LName);
|
Syslog('!', "Fixed filemode area %ld, file %s", Area, fdb.LName);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose: File Database Maintenance - utilities
|
* Purpose: File Database Maintenance - utilities
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2006
|
* Copyright (C) 1997-2007
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -274,8 +274,9 @@ int UnpackFile(char *File)
|
|||||||
*/
|
*/
|
||||||
int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath)
|
int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
|
char *temp, *dest, *lnk;
|
||||||
|
|
||||||
Syslog('f', "AddFile Area : %d", Area);
|
Syslog('f', "AddFile Area : %d", Area);
|
||||||
Syslog('f', "AddFile DestPath: %s", MBSE_SS(DestPath));
|
Syslog('f', "AddFile DestPath: %s", MBSE_SS(DestPath));
|
||||||
@ -305,16 +306,31 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c
|
|||||||
printf("\nCan't copy file to %s, %s\n", DestPath, strerror(rc));
|
printf("\nCan't copy file to %s, %s\n", DestPath, strerror(rc));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
chmod(DestPath, 0644);
|
chmod(DestPath, 0644);
|
||||||
if (LinkPath) {
|
if (LinkPath) {
|
||||||
unlink(LinkPath);
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
if ((rc = symlink(DestPath, LinkPath))) {
|
if (getcwd(temp, PATH_MAX-1)) {
|
||||||
WriteError("Can't create symbolic link %s", LinkPath);
|
if (chdir(area.Path)) {
|
||||||
if (!do_quiet)
|
WriteError("$Can't chdir to %s", area.Path);
|
||||||
printf("\nCan't create symbolic link %s, %s\n", LinkPath, strerror(rc));
|
free(temp);
|
||||||
unlink(DestPath);
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
|
unlink(LinkPath);
|
||||||
|
dest = xstrcpy(basename(DestPath));
|
||||||
|
lnk = xstrcpy(basename(LinkPath));
|
||||||
|
if ((rc = symlink(dest, lnk))) {
|
||||||
|
WriteError("Can't create symbolic link %s", lnk);
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("\nCan't create symbolic link %s, %s\n", lnk, strerror(rc));
|
||||||
|
unlink(DestPath);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
free(dest);
|
||||||
|
free(lnk);
|
||||||
|
chdir(temp);
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
|
@ -864,20 +864,28 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
fdb.Crc32 = file_crc(Filename, TRUE);
|
fdb.Crc32 = file_crc(Filename, TRUE);
|
||||||
strncpy(fdb.Uploader, exitinfo.sUserName, 35);
|
strncpy(fdb.Uploader, exitinfo.sUserName, 35);
|
||||||
fdb.UploadDate = time(NULL);
|
fdb.UploadDate = time(NULL);
|
||||||
if (strcmp(fdb.Name, fdb.LName)) {
|
|
||||||
/*
|
/*
|
||||||
* Rename the file first to the 8.3 name, this is the
|
* Create the symlink is done in the real directory
|
||||||
* standard way to store files in the filebase.
|
*/
|
||||||
*/
|
if (getcwd(lname, PATH_MAX-1)) {
|
||||||
snprintf(lname, PATH_MAX, "%s/%s", area.Path, fdb.Name);
|
chdir(area.Path);
|
||||||
rename(Filename, lname);
|
if (strcmp(fdb.Name, fdb.LName)) {
|
||||||
/*
|
/*
|
||||||
* Then make a symlink to the 8.3 name
|
* Rename the file first to the 8.3 name, this is the
|
||||||
*/
|
* standard way to store files in the filebase.
|
||||||
if (symlink(lname, Filename)) {
|
*/
|
||||||
WriteError("$Can't create link %s to %s", lname, Filename);
|
rename(fdb.LName, fdb.Name);
|
||||||
|
/*
|
||||||
|
* Then make a symlink to the 8.3 name
|
||||||
|
*/
|
||||||
|
if (symlink(fdb.Name, fdb.LName)) {
|
||||||
|
WriteError("$Can't create link %s to %s", fdb.Name, fdb.LName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
chdir(lname);
|
||||||
}
|
}
|
||||||
|
free(lname);
|
||||||
|
|
||||||
if (area.PwdUP) {
|
if (area.PwdUP) {
|
||||||
Enter(1);
|
Enter(1);
|
||||||
|
Reference in New Issue
Block a user