Changed transfer protocols to use execute()
This commit is contained in:
parent
352224c3f4
commit
92c739f160
@ -4786,6 +4786,9 @@ v0.33.20 10-Feb-2002
|
||||
Doors are now passed the parameter to display a prompt after
|
||||
the door or return silently.
|
||||
Fixed lharc file return code to LHA.
|
||||
Calling file transfer protocols now uses the execute call
|
||||
instead of system.
|
||||
Improved error logging for file downloads.
|
||||
|
||||
mbnewusr:
|
||||
New users have the default internal fullscreen editor.
|
||||
|
@ -139,11 +139,13 @@ void File_List()
|
||||
|
||||
if (file.Deleted)
|
||||
/* D E L E T E D */ /* Uploaded by: */
|
||||
printf(" -- %-12s %s [%4ld] %s%s\n", file.Name, (char *) Language(239), file.TimesDL, (char *) Language(238), file.Uploader);
|
||||
printf(" -- %-12s %s [%4ld] %s%s\n", file.Name, (char *) Language(239),
|
||||
file.TimesDL, (char *) Language(238), file.Uploader);
|
||||
|
||||
if (file.Missing)
|
||||
/* M I S S I N G */ /* Uploaded by: */
|
||||
printf(" -- %-12s %s [%4ld] %s%s\n", file.Name, (char *) Language(240), file.TimesDL, (char *) Language(238), file.Uploader);
|
||||
printf(" -- %-12s %s [%4ld] %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 */
|
||||
@ -167,6 +169,8 @@ void File_List()
|
||||
*/
|
||||
void Download(void)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
FILE *tf, *fp, *fd;
|
||||
int i, err, Count = 0;
|
||||
int OldArea;
|
||||
@ -179,9 +183,10 @@ void Download(void)
|
||||
Enter(2);
|
||||
OldArea = iAreaNumber;
|
||||
WhosDoingWhat(DOWNLOAD);
|
||||
unlink("./tag/filedesc.txt");
|
||||
system("rm -f ./tag/*");
|
||||
|
||||
if ((tf = fopen("taglist", "r+")) == NULL) {
|
||||
Syslog('+', "Download command but no files marked");
|
||||
/* No files marked for download. */
|
||||
pout(12, 0, (char *) Language(258));
|
||||
Enter(2);
|
||||
@ -206,7 +211,6 @@ void Download(void)
|
||||
*/
|
||||
memset(&file, 0, sizeof(file));
|
||||
if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) {
|
||||
|
||||
while (fread(&file, sizeof(file), 1, fp) == 1) {
|
||||
if (strcmp(file.LName, Tag.LFile) == 0)
|
||||
break;
|
||||
@ -221,8 +225,9 @@ void Download(void)
|
||||
/* Sorry that file is unavailable for download */
|
||||
printf("%s (%s)\n", (char *) Language(248), file.LName);
|
||||
Tag.Active = FALSE;
|
||||
Syslog('+', "File %s in area %d unavailable for download, %s",
|
||||
file.LName, Tag.Area, file.Deleted?"deleted":"missing");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Tag.Active) {
|
||||
@ -241,6 +246,9 @@ void Download(void)
|
||||
}
|
||||
fprintf(fd, "\r\n");
|
||||
fclose(fd);
|
||||
Syslog('b', "Added info to %s", symTo);
|
||||
} else {
|
||||
WriteError("Can't add info to %s", symTo);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -255,6 +263,15 @@ void Download(void)
|
||||
if (symlink(symTo, symFrom)) {
|
||||
WriteError("$Can't create symlink %s %s %d", symTo, symFrom, errno);
|
||||
Tag.Active = FALSE;
|
||||
} else {
|
||||
Syslog('b', "Created symlink %s -> %s", symFrom, symTo);
|
||||
}
|
||||
if ((access(symFrom, R_OK)) != 0) {
|
||||
/*
|
||||
* Extra check, is symlink really there?
|
||||
*/
|
||||
WriteError("Symlink %s check failed, unmarking download", symFrom);
|
||||
Tag.Active = FALSE;
|
||||
}
|
||||
Home();
|
||||
}
|
||||
@ -266,6 +283,7 @@ void Download(void)
|
||||
*/
|
||||
fseek(tf, - sizeof(Tag), SEEK_CUR);
|
||||
fwrite(&Tag, sizeof(Tag), 1, tf);
|
||||
Syslog('b', "Download file %s marked inactive in taglist", Tag.LFile);
|
||||
} else {
|
||||
/*
|
||||
* Count file and sizes.
|
||||
@ -274,7 +292,6 @@ void Download(void)
|
||||
Size += file.Size;
|
||||
if ((!file.Free) && (!area.Free))
|
||||
CostSize += file.Size;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,6 +309,7 @@ void Download(void)
|
||||
Pause();
|
||||
free(symTo);
|
||||
free(symFrom);
|
||||
Syslog('+', "No files left to download");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -326,26 +344,18 @@ void Download(void)
|
||||
/* Protocol : */
|
||||
pout( 3, 0, (char *) Language(351)); printf("%s\n", sProtName);
|
||||
|
||||
Syslog('+', "Download tagged files start");
|
||||
Syslog('+', "Download tagged files start, protocol: %s", sProtName);
|
||||
|
||||
printf("%s\n\n", sProtAdvice);
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
|
||||
/* HERE WE SHOULD MAKE A DIFFERENCE BETWEEN BATCHING AND NON
|
||||
* BATCHING PROTOCOLS.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wait a while before download
|
||||
*/
|
||||
sleep(2);
|
||||
ElapstimeStart = time(NULL);
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s ./tag/*", sProtDn);
|
||||
Syslog('+', "Download command %s", temp);
|
||||
|
||||
/*
|
||||
* Transfer the files. Set the Client/Server time at the maximum
|
||||
* time the user has plus 10 minutes. The overall timer 10 seconds
|
||||
@ -353,21 +363,44 @@ void Download(void)
|
||||
*/
|
||||
alarm_set(((exitinfo.iTimeLeft + 10) * 60) - 10);
|
||||
Altime((exitinfo.iTimeLeft + 10) * 60);
|
||||
if ((err = system(temp)) != 0) {
|
||||
/*
|
||||
* Only log the error, we might have sent some files
|
||||
* instead of nothing.
|
||||
*/
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
|
||||
if ((dirp = opendir(temp)) == NULL) {
|
||||
WriteError("$Download: Can't open dir: %s", temp);
|
||||
free(temp);
|
||||
} else {
|
||||
chdir(temp);
|
||||
free(temp);
|
||||
temp = NULL;
|
||||
while ((dp = readdir(dirp)) != NULL ) {
|
||||
if (*(dp->d_name) != '.') {
|
||||
if (temp != NULL) {
|
||||
temp = xstrcat(temp, (char *)" ");
|
||||
temp = xstrcat(temp, dp->d_name);
|
||||
} else {
|
||||
temp = xstrcpy(dp->d_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (temp != NULL) {
|
||||
if ((err = execute(sProtDn, temp, NULL, NULL, NULL, NULL))) {
|
||||
perror("");
|
||||
colour(CFG.HiliteF, CFG.HiliteB);
|
||||
WriteError("Download error %d, prot: %s", err, sProtDn);
|
||||
}
|
||||
free(temp);
|
||||
} else {
|
||||
WriteError("No filebatch created");
|
||||
}
|
||||
closedir(dirp);
|
||||
}
|
||||
Altime(0);
|
||||
alarm_off();
|
||||
alarm_on();
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
free(temp);
|
||||
Home();
|
||||
ElapstimeFin = time(NULL);
|
||||
|
||||
/*
|
||||
@ -389,11 +422,8 @@ void Download(void)
|
||||
Count = Size = 0;
|
||||
|
||||
if ((tf = fopen("taglist", "r+")) != NULL) {
|
||||
|
||||
while (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
|
||||
|
||||
if (Tag.Active) {
|
||||
|
||||
sprintf(symTo, "./tag/%s", Tag.SFile);
|
||||
/*
|
||||
* If symlink is gone the file is sent.
|
||||
@ -405,8 +435,7 @@ void Download(void)
|
||||
fwrite(&Tag, sizeof(Tag), 1, tf);
|
||||
|
||||
/*
|
||||
* Update the download counter and the
|
||||
* last download date.
|
||||
* Update the download counter and the last download date.
|
||||
*/
|
||||
SetFileArea(Tag.Area);
|
||||
if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) {
|
||||
@ -427,7 +456,6 @@ void Download(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1117,8 +1145,6 @@ int Upload()
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(temp, "%s", sProtUp);
|
||||
Syslog('+', "Upload command %s", temp);
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
sleep(2);
|
||||
@ -1131,7 +1157,7 @@ int Upload()
|
||||
*/
|
||||
Altime(7200);
|
||||
alarm_set(7190);
|
||||
if ((err = system(temp))) {
|
||||
if ((err = execute(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
||||
/*
|
||||
* Log any errors
|
||||
*/
|
||||
@ -1234,7 +1260,6 @@ int DownloadDirect(char *Name, int Wait)
|
||||
{
|
||||
int err, rc;
|
||||
char *symTo, *symFrom;
|
||||
char *temp;
|
||||
long Size;
|
||||
time_t ElapstimeStart, ElapstimeFin, iTime;
|
||||
long iTransfer = 0;
|
||||
@ -1294,10 +1319,6 @@ int DownloadDirect(char *Name, int Wait)
|
||||
sleep(2);
|
||||
ElapstimeStart = time(NULL);
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s '%s'", sProtDn, symFrom);
|
||||
Syslog('+', "Download command %s", temp);
|
||||
|
||||
/*
|
||||
* Transfer the file. Set the Client/Server time at the maximum
|
||||
* time the user has plus 10 minutes. The overall timer 10 seconds
|
||||
@ -1305,7 +1326,7 @@ int DownloadDirect(char *Name, int Wait)
|
||||
*/
|
||||
alarm_set(((exitinfo.iTimeLeft + 10) * 60) - 10);
|
||||
Altime((exitinfo.iTimeLeft + 10) * 60);
|
||||
if ((err = system(temp))) {
|
||||
if ((err = execute(sProtDn, symFrom, NULL, NULL, NULL, NULL))) {
|
||||
/*
|
||||
* Only log the error, we might have sent some files
|
||||
* instead of nothing.
|
||||
@ -1319,7 +1340,6 @@ int DownloadDirect(char *Name, int Wait)
|
||||
alarm_on();
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
free(temp);
|
||||
ElapstimeFin = time(NULL);
|
||||
|
||||
/*
|
||||
@ -1656,8 +1676,6 @@ int Upload_Home()
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(temp, "%s", sProtUp);
|
||||
Syslog('+', "Upload command %s", temp);
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
sleep(2);
|
||||
@ -1670,7 +1688,7 @@ int Upload_Home()
|
||||
*/
|
||||
Altime(7200);
|
||||
alarm_set(7190);
|
||||
if ((err = system(temp)) != 0) {
|
||||
if ((err = execute(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
||||
/*
|
||||
* Log any errors
|
||||
*/
|
||||
|
@ -1109,8 +1109,6 @@ void OLR_Upload(void)
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(temp, "%s", sProtUp);
|
||||
Syslog('+', "Upload command %s", temp);
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
sleep(2);
|
||||
@ -1121,7 +1119,7 @@ void OLR_Upload(void)
|
||||
*/
|
||||
Altime(7200);
|
||||
alarm_set(7190);
|
||||
if ((err = system(temp)) != 0) {
|
||||
if ((err = execute(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
||||
colour(CFG.HiliteF, CFG.HiliteB);
|
||||
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
||||
}
|
||||
@ -1220,7 +1218,7 @@ void OLR_Upload(void)
|
||||
Syslog('m', "Unarc %s", temp);
|
||||
colour(CFG.HiliteF, CFG.HiliteB);
|
||||
|
||||
if ((err = system(temp))) {
|
||||
if ((err = execute(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||
WriteError("$Failed %s", temp);
|
||||
/* ERROR */
|
||||
printf("%s\n", (char *) Language(217));
|
||||
|
Reference in New Issue
Block a user