Updated execute calls

This commit is contained in:
Michiel Broek
2004-03-02 20:47:23 +00:00
parent fb1767f5a6
commit e20f1d3f39
30 changed files with 420 additions and 202 deletions

View File

@@ -233,7 +233,7 @@ void Magic_ExecCommand(void)
opts = strtok(NULL, "\0");
MagicResult((char *)"Exec: \"%s %s\"", cmd, opts);
if ((Err = execute(cmd, opts, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) == 0) {
if ((Err = execute_str(cmd, opts, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) == 0) {
Magics++;
} else
Syslog('!', "Mgc Exec: (%s %s) returns %d", cmd, opts, Err);
@@ -287,7 +287,7 @@ void Magic_UnpackFile(void)
if (getarchiver(unarc)) {
cmd = xstrcpy(archiver.munarc);
if (strlen(cmd)) {
rc = execute(cmd, Fn, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
rc = execute_str(cmd, Fn, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
if (rc)
WriteError("$Magic: unpack in %s, error %d", magic.Path, rc);
else

View File

@@ -84,7 +84,7 @@ void die(int onsig)
/*
* In case the child had the tty in raw mode...
*/
system("stty sane");
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
}
signal(onsig, SIG_IGN);
@@ -287,11 +287,11 @@ int main(int argc, char **argv)
die(MBERR_CONFIG_ERROR);
}
if (execute(cmd, nd, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
if (execute_str(cmd, nd, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
WriteError("Warning: unpack error, trying again after a sync");
sync();
sleep(1);
if (execute(cmd, nd, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
if (execute_str(cmd, nd, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
show_log = TRUE;
free(cmd);
free(onl);
@@ -406,7 +406,7 @@ int main(int argc, char **argv)
p = xstrcpy(onl);
p = xstrcat(p, (char *)" ");
p = xstrcat(p, nn);
if (execute(cmd, p, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))
if (execute_str(cmd, p, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))
WriteError("Create %s failed", onl);
else {
CreateSema((char *)"mailin");

View File

@@ -176,7 +176,7 @@ void die(int onsig)
/*
* In case the child had the tty in raw mode, reset the tty.
*/
system("stty sane");
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
}
if (onsig != MBERR_NO_PROGLOCK)
@@ -750,7 +750,7 @@ int TossPkts(void)
* See if "pktdate" from Tobias Ernst (or another preprocessor) is installed.
*/
if (strlen(CFG.pktdate)) {
rc = execute(CFG.pktdate, fname, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
rc = execute_str(CFG.pktdate, fname, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
if (rc)
Syslog('+', "%s preprocessing rc=%d", fname, rc);
}

View File

@@ -659,7 +659,7 @@ void HtmlIndex(char *Lang)
sprintf(linebuf, "%s/%s", area.Path, file.Name);
sprintf(outbuf, "%s/.%s", area.Path, file.Name);
if (file_exist(outbuf, R_OK)) {
if ((j = execute(CFG.www_convert, linebuf, outbuf,
if ((j = execute_str(CFG.www_convert, linebuf, outbuf,
(char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
Syslog('+', "Failed to create thumbnail for %s, rc=% d", file.Name, j);
} else {

View File

@@ -77,7 +77,7 @@ void die(int onsig)
* In case the child had the tty in raw mode...
*/
if (!do_quiet)
system("stty sane");
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
}
signal(onsig, SIG_IGN);
@@ -211,8 +211,8 @@ void DeleteVirusWork()
if (chdir(temp) == 0) {
Syslog('f', "DeleteVirusWork %s/arc", temp);
system("rm -r -f arc");
system("mkdir arc");
execute_pth((char *)"rm", (char *)"-r -f arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
execute_pth((char *)"mkdir", (char *)"arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
} else
WriteError("$Can't chdir to %s", temp);
@@ -282,7 +282,7 @@ int UnpackFile(char *File)
die(MBERR_GENERAL);
}
if (execute(cmd, File, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(cmd, File, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
chdir(pwd);
free(temp);
free(pwd);

View File

@@ -481,7 +481,7 @@ int ProcessTic(fa_list *sbl)
Syslog('!', "No unarc command available");
} else {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
UnPacked = TRUE;
} else {
chdir(TIC.Inbound);
@@ -566,11 +566,11 @@ int ProcessTic(fa_list *sbl)
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
chdir(temp1);
sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.File);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
File_Id = TRUE;
} else {
sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.TicIn.File);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
File_Id = TRUE;
}
}
@@ -658,7 +658,7 @@ int ProcessTic(fa_list *sbl)
} else {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
if (execute(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
if (execute_str(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
WriteError("$Changing the banner failed");
} else {
Syslog('+', "New banner %s", tic.Banner);

View File

@@ -384,13 +384,13 @@ void flush_dir(char *ndir)
flushed = TRUE;
}
if (execute(archiver.marc, arcfile, fname, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(archiver.marc, arcfile, fname, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
unlink(fname);
} else {
WriteError("Create ARCmail failed, trying again after sync()");
sync();
sleep(1);
if (execute(archiver.marc, arcfile, fname, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(archiver.marc, arcfile, fname, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
unlink(fname);
} else {
WriteError("Can't add %s to ARCmail archive", fname);

View File

@@ -90,18 +90,15 @@ int unpack(char *fn)
return 1;
}
if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
// sync();
if ((rc = execute_str(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
unlink(fn);
} else {
sync();
sleep(1);
WriteError("Warning: unpack %s failed, trying again after sync()", fn);
if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
// sync();
if ((rc = execute_str(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
unlink(fn);
} else {
// sync();
strncpy(newname,fn,sizeof(newname)-1);
strcpy(newname+8,".bad");
rename(fn,newname);

View File

@@ -113,7 +113,7 @@ int Rearc(char *unarc)
Syslog('f' , "NewFile=\"%s\", NewFullName=\"%s\"", TIC.NewFile, TIC.NewFullName);
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewFile);
if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
if (execute_str(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
free(cmd);
return TRUE;
}
@@ -142,8 +142,8 @@ void DeleteVirusWork()
if (chdir(temp) == 0) {
Syslog('f', "DeleteVirusWork %s/arc", temp);
system("rm -r -f arc");
system("mkdir arc");
execute_pth((char *)"rm", (char *)"-r -f arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
execute_pth((char *)"mkdir", (char *)"arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
} else
WriteError("$Can't chdir to %s", temp);

View File

@@ -80,7 +80,7 @@ int VirScan(char *path)
cmd = xstrcpy(virscan.scanner);
cmd = xstrcat(cmd, (char *)" ");
cmd = xstrcat(cmd, virscan.options);
if (execute(cmd, (char *)"*", (char *)NULL, (char *)"/dev/null",
if (execute_str(cmd, (char *)"*", (char *)NULL, (char *)"/dev/null",
(char *)"/dev/null" , (char *)"/dev/null") != virscan.error) {
Syslog('!', "Virus found by %s", virscan.comment);
rc = TRUE;