Updated execute calls
This commit is contained in:
parent
fb1767f5a6
commit
e20f1d3f39
33
ChangeLog
33
ChangeLog
@ -17,7 +17,17 @@ v0.51.1 21-Feb-2004
|
|||||||
Changed to support Darwin (OS X). Note that in earlier days
|
Changed to support Darwin (OS X). Note that in earlier days
|
||||||
mbse did compile under OS X, but things are different since
|
mbse did compile under OS X, but things are different since
|
||||||
then. Work is underway to let it compile and run again.
|
then. Work is underway to let it compile and run again.
|
||||||
|
|
||||||
|
libmbse.a:
|
||||||
|
Changed the execute function so it will work on 2.6.x kernels
|
||||||
|
and fast cpu's.
|
||||||
|
Added execute_str function for compatibility with the older
|
||||||
|
api. Added execute_pth function to execute programs in the
|
||||||
|
path.
|
||||||
|
|
||||||
|
mbout:
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
mbsetup:
|
mbsetup:
|
||||||
In edit message groups added setup for default character set.
|
In edit message groups added setup for default character set.
|
||||||
In edit message areas added setup for character set for the
|
In edit message areas added setup for character set for the
|
||||||
@ -30,6 +40,7 @@ v0.51.1 21-Feb-2004
|
|||||||
screen.
|
screen.
|
||||||
Removed users fullscreen chat setting, not used.
|
Removed users fullscreen chat setting, not used.
|
||||||
Added menu setup for change character set, menu 321.
|
Added menu setup for change character set, menu 321.
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
mbsebbs:
|
mbsebbs:
|
||||||
Writes the ^aCHRS: kludge again in new created messages.
|
Writes the ^aCHRS: kludge again in new created messages.
|
||||||
@ -45,6 +56,13 @@ v0.51.1 21-Feb-2004
|
|||||||
Junius Fidogate package.
|
Junius Fidogate package.
|
||||||
In delete file in home directory the Y/N keys were read from
|
In delete file in home directory the Y/N keys were read from
|
||||||
the wrong language prompt.
|
the wrong language prompt.
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
|
mbnewusr:
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
|
mball:
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
mbmsg:
|
mbmsg:
|
||||||
Writes the ^aCHRS: kludge again in new created messages.
|
Writes the ^aCHRS: kludge again in new created messages.
|
||||||
@ -60,17 +78,30 @@ v0.51.1 21-Feb-2004
|
|||||||
For the tic area create and message area create the check is
|
For the tic area create and message area create the check is
|
||||||
now case insensitive, also the area tagnames are forced to
|
now case insensitive, also the area tagnames are forced to
|
||||||
uppercase. This should solve the problems with Linuxnet.
|
uppercase. This should solve the problems with Linuxnet.
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
|
mbdiff:
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
mbfile:
|
mbfile:
|
||||||
For creating www pages of the download areas, the new mapping
|
For creating www pages of the download areas, the new mapping
|
||||||
tables are used to translate from ibmpc characters to
|
tables are used to translate from ibmpc characters to
|
||||||
iso-8859-1.
|
iso-8859-1.
|
||||||
|
Replaced system() call with execute.
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
Added change character set in English menus and textfiles.
|
Added change character set in English menus and textfiles.
|
||||||
Updated all newfiles macro template to include the magic file-
|
Updated all newfiles macro template to include the magic file-
|
||||||
request macro (English, German, Spanish and Dutch).
|
request macro (English, German, Spanish and Dutch).
|
||||||
|
|
||||||
|
mbuseradd:
|
||||||
|
Uses the execv instead of system to call the systems useradd
|
||||||
|
program.
|
||||||
|
|
||||||
|
mbpasswd:
|
||||||
|
Uses the execv instead of system to call the systems vpassswd
|
||||||
|
program if needed.
|
||||||
|
|
||||||
lang:
|
lang:
|
||||||
Added language prompts 23, 24 and 25.
|
Added language prompts 23, 24 and 25.
|
||||||
|
|
||||||
|
2
TODO
2
TODO
@ -71,6 +71,8 @@ newuser:
|
|||||||
|
|
||||||
N: Add menu setup to set users preffered character set.
|
N: Add menu setup to set users preffered character set.
|
||||||
|
|
||||||
|
U: Fix (kernel 2.6.x ??) problem with creating new users.
|
||||||
|
|
||||||
mbtask:
|
mbtask:
|
||||||
N: Add a thread that keeps track of disk usage of all partitions used
|
N: Add a thread that keeps track of disk usage of all partitions used
|
||||||
by mbse, update partition list after setup changes. Make the info
|
by mbse, update partition list after setup changes. Make the info
|
||||||
|
@ -101,7 +101,7 @@ clean:
|
|||||||
filelist: Makefile
|
filelist: Makefile
|
||||||
BASE=`pwd`; \
|
BASE=`pwd`; \
|
||||||
BASE=`basename $${BASE}`; \
|
BASE=`basename $${BASE}`; \
|
||||||
(for f in ${SRCS} ${HDRS} ${OTHER} ;do echo ${PACKAGE}-${VERSION}/$${BASE}/$$f; done) >filelist
|
(for f in ${SRCS} ${HDRS} ${OTHER} ${MAPS} ;do echo ${PACKAGE}-${VERSION}/$${BASE}/$$f; done) >filelist
|
||||||
|
|
||||||
depend: ftscprod.c
|
depend: ftscprod.c
|
||||||
@rm -f Makefile.bak; \
|
@rm -f Makefile.bak; \
|
||||||
|
105
lib/execute.c
105
lib/execute.c
@ -36,24 +36,21 @@ int e_pid = 0; /* Execute child pid */
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _execute(char *, char *, char *, char *, char *, char *);
|
int _execute(char **, char *, char *, char *);
|
||||||
int _execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
int _execute(char **args, char *in, char *out, char *err)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
char *vector[16];
|
|
||||||
int i, pid, status = 0, rc = 0;
|
int i, pid, status = 0, rc = 0;
|
||||||
|
|
||||||
if (pkt == NULL)
|
memset(&buf, 0, sizeof(buf));
|
||||||
sprintf(buf, "%s %s", cmd, fil);
|
for (i = 0; i < 16; i++) {
|
||||||
else
|
if (args[i])
|
||||||
sprintf(buf, "%s %s %s", cmd, fil, pkt);
|
sprintf(buf, "%s %s", buf, args[i]);
|
||||||
Syslog('+', "Execute: %s",buf);
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Syslog('+', "Execute:%s",buf);
|
||||||
|
|
||||||
memset(vector, 0, sizeof(vector));
|
|
||||||
i = 0;
|
|
||||||
vector[i++] = strtok(buf," \t\n");
|
|
||||||
while ((vector[i++] = strtok(NULL," \t\n")) && (i<16));
|
|
||||||
vector[15] = NULL;
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
@ -86,8 +83,8 @@ int _execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
|||||||
if (rc)
|
if (rc)
|
||||||
WriteError("$execv can't set priority to 15");
|
WriteError("$execv can't set priority to 15");
|
||||||
}
|
}
|
||||||
rc = execv(vector[0],vector);
|
rc = execv(args[0],args);
|
||||||
WriteError("$execv \"%s\" returned %d", MBSE_SS(vector[0]), rc);
|
WriteError("$execv \"%s\" returned %d", MBSE_SS(args[0]), rc);
|
||||||
setpriority(PRIO_PROCESS, 0, 0);
|
setpriority(PRIO_PROCESS, 0, 0);
|
||||||
exit(MBERR_EXEC_FAILED);
|
exit(MBERR_EXEC_FAILED);
|
||||||
}
|
}
|
||||||
@ -104,7 +101,7 @@ int _execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
|||||||
switch (rc) {
|
switch (rc) {
|
||||||
case -1:
|
case -1:
|
||||||
WriteError("$Wait returned %d, status %d,%d", rc,status>>8,status&0xff);
|
WriteError("$Wait returned %d, status %d,%d", rc,status>>8,status&0xff);
|
||||||
return MBERR_EXEC_FAILED;
|
return 0;
|
||||||
case 0:
|
case 0:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
@ -129,7 +126,7 @@ int _execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
int execute(char **args, char *in, char *out, char *err)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -137,7 +134,7 @@ int execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
|||||||
sync();
|
sync();
|
||||||
#endif
|
#endif
|
||||||
msleep(300);
|
msleep(300);
|
||||||
rc = _execute(cmd, fil, pkt, in, out, err);
|
rc = _execute(args, in, out, err);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
sync();
|
sync();
|
||||||
#endif
|
#endif
|
||||||
@ -146,6 +143,76 @@ int execute(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The old behaviour, parse command strings to arguments.
|
||||||
|
*/
|
||||||
|
int execute_str(char *cmd, char *fil, char *pkt, char *in, char *out, char *err)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *args[16], buf[PATH_MAX];
|
||||||
|
|
||||||
|
memset(args, 0, sizeof(args));
|
||||||
|
memset(&buf, 0, sizeof(buf));
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
if ((pkt != NULL) && strlen(pkt))
|
||||||
|
sprintf(buf, "%s %s %s", cmd, fil, pkt);
|
||||||
|
else
|
||||||
|
sprintf(buf, "%s %s", cmd, fil);
|
||||||
|
|
||||||
|
args[i++] = strtok(buf, " \t\0");
|
||||||
|
while ((args[i++] = strtok(NULL," \t\n")) && (i < 15));
|
||||||
|
args[i++] = NULL;
|
||||||
|
|
||||||
|
return execute(args, in, out, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute command in the PATH.
|
||||||
|
*/
|
||||||
|
int execute_pth(char *prog, char *opts, char *in, char *out, char *err)
|
||||||
|
{
|
||||||
|
char *pth;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (strchr(prog, ' ') || strchr(prog, '/')) {
|
||||||
|
WriteError("First parameter of execute_pth() must be a program name");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pth = xstrcpy((char *)"/usr/bin/");
|
||||||
|
pth = xstrcat(pth, prog);
|
||||||
|
if (access(pth, X_OK) == -1) {
|
||||||
|
free(pth);
|
||||||
|
pth = xstrcpy((char *)"/usr/local/bin/");
|
||||||
|
pth = xstrcat(pth, prog);
|
||||||
|
if (access(pth, X_OK) == -1) {
|
||||||
|
free(pth);
|
||||||
|
pth = xstrcpy((char *)"/bin/");
|
||||||
|
pth = xstrcat(pth, prog);
|
||||||
|
if (access(pth, X_OK) == -1) {
|
||||||
|
free(pth);
|
||||||
|
pth = xstrcpy((char *)"/usr/pkg/bin/");
|
||||||
|
pth = xstrcat(pth, prog);
|
||||||
|
if (access(pth, X_OK) == -1) {
|
||||||
|
WriteError("Can't find %s", prog);
|
||||||
|
free(pth);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = execute_str(pth, opts, NULL, in, out, err);
|
||||||
|
free(pth);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SHELL "/bin/sh"
|
#define SHELL "/bin/sh"
|
||||||
|
|
||||||
|
|
||||||
@ -199,7 +266,7 @@ int _execsh(char *cmd, char *in, char *out, char *err)
|
|||||||
while (((rc > 0) && (rc != pid)) || ((rc == -1) && (sverr == EINTR)));
|
while (((rc > 0) && (rc != pid)) || ((rc == -1) && (sverr == EINTR)));
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
WriteError("$Wait returned %d, status %d,%d", rc, status >> 8, status & 0xff);
|
WriteError("$Wait returned %d, status %d,%d", rc, status >> 8, status & 0xff);
|
||||||
return MBERR_EXEC_FAILED;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -2104,7 +2104,9 @@ char *Unix2Dos(char *);
|
|||||||
/*
|
/*
|
||||||
* From execute.c
|
* From execute.c
|
||||||
*/
|
*/
|
||||||
int execute(char *, char *, char *, char *, char *, char *);
|
int execute(char **, char *, char *, char *);
|
||||||
|
int execute_str(char *, char *, char *, char *, char *, char *);
|
||||||
|
int execute_pth(char *, char *, char *, char *, char *);
|
||||||
int execsh(char *, char *, char *, char *);
|
int execsh(char *, char *, char *, char *);
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ int do_req = FALSE; /* Request files from a node */
|
|||||||
int do_stat = FALSE; /* Show outbound status */
|
int do_stat = FALSE; /* Show outbound status */
|
||||||
int do_stop = FALSE; /* Stop polling a node */
|
int do_stop = FALSE; /* Stop polling a node */
|
||||||
int do_reset = FALSE; /* Reset node's try counter */
|
int do_reset = FALSE; /* Reset node's try counter */
|
||||||
int e_pid = 0; /* Pid of child */
|
extern pid_t e_pid; /* Pid of child */
|
||||||
extern int show_log; /* Show logging */
|
extern int show_log; /* Show logging */
|
||||||
time_t t_start; /* Start time */
|
time_t t_start; /* Start time */
|
||||||
time_t t_end; /* End time */
|
time_t t_end; /* End time */
|
||||||
@ -88,7 +88,7 @@ void die(int onsig)
|
|||||||
/*
|
/*
|
||||||
* In case the child had the tty in raw mode...
|
* 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);
|
signal(onsig, SIG_IGN);
|
||||||
|
@ -233,7 +233,7 @@ void Magic_ExecCommand(void)
|
|||||||
opts = strtok(NULL, "\0");
|
opts = strtok(NULL, "\0");
|
||||||
MagicResult((char *)"Exec: \"%s %s\"", cmd, opts);
|
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++;
|
Magics++;
|
||||||
} else
|
} else
|
||||||
Syslog('!', "Mgc Exec: (%s %s) returns %d", cmd, opts, Err);
|
Syslog('!', "Mgc Exec: (%s %s) returns %d", cmd, opts, Err);
|
||||||
@ -287,7 +287,7 @@ void Magic_UnpackFile(void)
|
|||||||
if (getarchiver(unarc)) {
|
if (getarchiver(unarc)) {
|
||||||
cmd = xstrcpy(archiver.munarc);
|
cmd = xstrcpy(archiver.munarc);
|
||||||
if (strlen(cmd)) {
|
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)
|
if (rc)
|
||||||
WriteError("$Magic: unpack in %s, error %d", magic.Path, rc);
|
WriteError("$Magic: unpack in %s, error %d", magic.Path, rc);
|
||||||
else
|
else
|
||||||
|
@ -84,7 +84,7 @@ void die(int onsig)
|
|||||||
/*
|
/*
|
||||||
* In case the child had the tty in raw mode...
|
* 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);
|
signal(onsig, SIG_IGN);
|
||||||
@ -287,11 +287,11 @@ int main(int argc, char **argv)
|
|||||||
die(MBERR_CONFIG_ERROR);
|
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");
|
WriteError("Warning: unpack error, trying again after a sync");
|
||||||
sync();
|
sync();
|
||||||
sleep(1);
|
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;
|
show_log = TRUE;
|
||||||
free(cmd);
|
free(cmd);
|
||||||
free(onl);
|
free(onl);
|
||||||
@ -406,7 +406,7 @@ int main(int argc, char **argv)
|
|||||||
p = xstrcpy(onl);
|
p = xstrcpy(onl);
|
||||||
p = xstrcat(p, (char *)" ");
|
p = xstrcat(p, (char *)" ");
|
||||||
p = xstrcat(p, nn);
|
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);
|
WriteError("Create %s failed", onl);
|
||||||
else {
|
else {
|
||||||
CreateSema((char *)"mailin");
|
CreateSema((char *)"mailin");
|
||||||
|
@ -176,7 +176,7 @@ void die(int onsig)
|
|||||||
/*
|
/*
|
||||||
* In case the child had the tty in raw mode, reset the tty.
|
* 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)
|
if (onsig != MBERR_NO_PROGLOCK)
|
||||||
@ -750,7 +750,7 @@ int TossPkts(void)
|
|||||||
* See if "pktdate" from Tobias Ernst (or another preprocessor) is installed.
|
* See if "pktdate" from Tobias Ernst (or another preprocessor) is installed.
|
||||||
*/
|
*/
|
||||||
if (strlen(CFG.pktdate)) {
|
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)
|
if (rc)
|
||||||
Syslog('+', "%s preprocessing rc=%d", fname, rc);
|
Syslog('+', "%s preprocessing rc=%d", fname, rc);
|
||||||
}
|
}
|
||||||
|
@ -659,7 +659,7 @@ void HtmlIndex(char *Lang)
|
|||||||
sprintf(linebuf, "%s/%s", area.Path, file.Name);
|
sprintf(linebuf, "%s/%s", area.Path, file.Name);
|
||||||
sprintf(outbuf, "%s/.%s", area.Path, file.Name);
|
sprintf(outbuf, "%s/.%s", area.Path, file.Name);
|
||||||
if (file_exist(outbuf, R_OK)) {
|
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"))) {
|
(char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
Syslog('+', "Failed to create thumbnail for %s, rc=% d", file.Name, j);
|
Syslog('+', "Failed to create thumbnail for %s, rc=% d", file.Name, j);
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,7 +77,7 @@ void die(int onsig)
|
|||||||
* In case the child had the tty in raw mode...
|
* In case the child had the tty in raw mode...
|
||||||
*/
|
*/
|
||||||
if (!do_quiet)
|
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);
|
signal(onsig, SIG_IGN);
|
||||||
@ -211,8 +211,8 @@ void DeleteVirusWork()
|
|||||||
|
|
||||||
if (chdir(temp) == 0) {
|
if (chdir(temp) == 0) {
|
||||||
Syslog('f', "DeleteVirusWork %s/arc", temp);
|
Syslog('f', "DeleteVirusWork %s/arc", temp);
|
||||||
system("rm -r -f arc");
|
execute_pth((char *)"rm", (char *)"-r -f arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
system("mkdir arc");
|
execute_pth((char *)"mkdir", (char *)"arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
} else
|
} else
|
||||||
WriteError("$Can't chdir to %s", temp);
|
WriteError("$Can't chdir to %s", temp);
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ int UnpackFile(char *File)
|
|||||||
die(MBERR_GENERAL);
|
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);
|
chdir(pwd);
|
||||||
free(temp);
|
free(temp);
|
||||||
free(pwd);
|
free(pwd);
|
||||||
|
@ -481,7 +481,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
Syslog('!', "No unarc command available");
|
Syslog('!', "No unarc command available");
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
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;
|
UnPacked = TRUE;
|
||||||
} else {
|
} else {
|
||||||
chdir(TIC.Inbound);
|
chdir(TIC.Inbound);
|
||||||
@ -566,11 +566,11 @@ int ProcessTic(fa_list *sbl)
|
|||||||
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
|
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
|
||||||
chdir(temp1);
|
chdir(temp1);
|
||||||
sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.File);
|
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;
|
File_Id = TRUE;
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.TicIn.File);
|
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;
|
File_Id = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
|
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");
|
WriteError("$Changing the banner failed");
|
||||||
} else {
|
} else {
|
||||||
Syslog('+', "New banner %s", tic.Banner);
|
Syslog('+', "New banner %s", tic.Banner);
|
||||||
|
@ -384,13 +384,13 @@ void flush_dir(char *ndir)
|
|||||||
flushed = TRUE;
|
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);
|
unlink(fname);
|
||||||
} else {
|
} else {
|
||||||
WriteError("Create ARCmail failed, trying again after sync()");
|
WriteError("Create ARCmail failed, trying again after sync()");
|
||||||
sync();
|
sync();
|
||||||
sleep(1);
|
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);
|
unlink(fname);
|
||||||
} else {
|
} else {
|
||||||
WriteError("Can't add %s to ARCmail archive", fname);
|
WriteError("Can't add %s to ARCmail archive", fname);
|
||||||
|
@ -90,18 +90,15 @@ int unpack(char *fn)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
|
if ((rc = execute_str(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
|
||||||
// sync();
|
|
||||||
unlink(fn);
|
unlink(fn);
|
||||||
} else {
|
} else {
|
||||||
sync();
|
sync();
|
||||||
sleep(1);
|
sleep(1);
|
||||||
WriteError("Warning: unpack %s failed, trying again after sync()", fn);
|
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) {
|
if ((rc = execute_str(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
|
||||||
// sync();
|
|
||||||
unlink(fn);
|
unlink(fn);
|
||||||
} else {
|
} else {
|
||||||
// sync();
|
|
||||||
strncpy(newname,fn,sizeof(newname)-1);
|
strncpy(newname,fn,sizeof(newname)-1);
|
||||||
strcpy(newname+8,".bad");
|
strcpy(newname+8,".bad");
|
||||||
rename(fn,newname);
|
rename(fn,newname);
|
||||||
|
@ -113,7 +113,7 @@ int Rearc(char *unarc)
|
|||||||
Syslog('f' , "NewFile=\"%s\", NewFullName=\"%s\"", TIC.NewFile, TIC.NewFullName);
|
Syslog('f' , "NewFile=\"%s\", NewFullName=\"%s\"", TIC.NewFile, TIC.NewFullName);
|
||||||
|
|
||||||
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewFile);
|
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);
|
free(cmd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -142,8 +142,8 @@ void DeleteVirusWork()
|
|||||||
|
|
||||||
if (chdir(temp) == 0) {
|
if (chdir(temp) == 0) {
|
||||||
Syslog('f', "DeleteVirusWork %s/arc", temp);
|
Syslog('f', "DeleteVirusWork %s/arc", temp);
|
||||||
system("rm -r -f arc");
|
execute_pth((char *)"rm", (char *)"-r -f arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
system("mkdir arc");
|
execute_pth((char *)"mkdir", (char *)"arc", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
} else
|
} else
|
||||||
WriteError("$Can't chdir to %s", temp);
|
WriteError("$Can't chdir to %s", temp);
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ int VirScan(char *path)
|
|||||||
cmd = xstrcpy(virscan.scanner);
|
cmd = xstrcpy(virscan.scanner);
|
||||||
cmd = xstrcat(cmd, (char *)" ");
|
cmd = xstrcat(cmd, (char *)" ");
|
||||||
cmd = xstrcat(cmd, virscan.options);
|
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) {
|
(char *)"/dev/null" , (char *)"/dev/null") != virscan.error) {
|
||||||
Syslog('!', "Virus found by %s", virscan.comment);
|
Syslog('!', "Virus found by %s", virscan.comment);
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
|
135
mbsebbs/change.c
135
mbsebbs/change.c
@ -142,77 +142,84 @@ int Chg_Language(int NewMode)
|
|||||||
|
|
||||||
void Chg_Password()
|
void Chg_Password()
|
||||||
{
|
{
|
||||||
char *temp1, *temp2;
|
char *temp1, *temp2, *args[16];
|
||||||
|
|
||||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
ReadExitinfo();
|
ReadExitinfo();
|
||||||
DisplayFile((char *)"password");
|
DisplayFile((char *)"password");
|
||||||
|
|
||||||
Enter(1);
|
Enter(1);
|
||||||
/* Old password: */
|
/* Old password: */
|
||||||
language(15, 0, 120);
|
language(15, 0, 120);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
colour(CFG.InputColourF, CFG.InputColourB);
|
colour(CFG.InputColourF, CFG.InputColourB);
|
||||||
Getpass(temp1);
|
Getpass(temp1);
|
||||||
|
|
||||||
if (!strcmp(exitinfo.Password, temp1)) {
|
if (!strcmp(exitinfo.Password, temp1)) {
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
Enter(1);
|
Enter(1);
|
||||||
/* New password: */
|
/* New password: */
|
||||||
language(9, 0, 121);
|
language(9, 0, 121);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
colour(CFG.InputColourF, CFG.InputColourB);
|
colour(CFG.InputColourF, CFG.InputColourB);
|
||||||
Getpass(temp1);
|
Getpass(temp1);
|
||||||
if((strlen(temp1)) >= CFG.password_length) {
|
if((strlen(temp1)) >= CFG.password_length) {
|
||||||
Enter(1);
|
|
||||||
/* Confirm new password: */
|
|
||||||
language(9, 0, 122);
|
|
||||||
colour(CFG.InputColourF, CFG.InputColourB);
|
|
||||||
fflush(stdout);
|
|
||||||
Getpass(temp2);
|
|
||||||
if(( strcmp(temp1,temp2)) != 0) {
|
|
||||||
/* Passwords do not match! */
|
|
||||||
Enter(2);
|
|
||||||
language(12, 0, 123);
|
|
||||||
Enter(1);
|
|
||||||
} else {
|
|
||||||
fflush(stdout);
|
|
||||||
fflush(stdin);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
colour(12, 0);
|
|
||||||
/* Your password must contain at least %d characters! Try again.*/
|
|
||||||
printf("\n%s%d %s\n\n", (char *) Language(42), CFG.password_length, (char *) Language(43));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Syslog('+', "%s/bin/mbpasswd -n %s ******", getenv("MBSE_ROOT"), exitinfo.Name);
|
|
||||||
sprintf(temp1, "%s/bin/mbpasswd -n %s %s", getenv("MBSE_ROOT"), exitinfo.Name, temp2);
|
|
||||||
if (system(temp1) != 0) {
|
|
||||||
WriteError("Failed to set new Unix password");
|
|
||||||
} else {
|
|
||||||
memset(&exitinfo.Password, 0, sizeof(exitinfo.Password));
|
|
||||||
strcpy(exitinfo.Password, temp2);
|
|
||||||
exitinfo.tLastPwdChange = time(NULL);
|
|
||||||
Enter(1);
|
|
||||||
/* Password Change Successful */
|
|
||||||
language(10, 0, 124);
|
|
||||||
Syslog('+', "User changed his password");
|
|
||||||
WriteExitinfo();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Enter(1);
|
Enter(1);
|
||||||
/* Old password incorrect! */
|
/* Confirm new password: */
|
||||||
language(12, 0, 125);
|
language(9, 0, 122);
|
||||||
|
colour(CFG.InputColourF, CFG.InputColourB);
|
||||||
|
fflush(stdout);
|
||||||
|
Getpass(temp2);
|
||||||
|
if(( strcmp(temp1,temp2)) != 0) {
|
||||||
|
/* Passwords do not match! */
|
||||||
|
Enter(2);
|
||||||
|
language(12, 0, 123);
|
||||||
|
Enter(1);
|
||||||
|
} else {
|
||||||
|
fflush(stdout);
|
||||||
|
fflush(stdin);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
colour(12, 0);
|
||||||
|
/* Your password must contain at least %d characters! Try again.*/
|
||||||
|
printf("\n%s%d %s\n\n", (char *) Language(42), CFG.password_length, (char *) Language(43));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(temp1);
|
Syslog('+', "%s/bin/mbpasswd -n %s ******", getenv("MBSE_ROOT"), exitinfo.Name);
|
||||||
free(temp2);
|
sprintf(temp1, "%s/bin/mbpasswd", getenv("MBSE_ROOT"));
|
||||||
Enter(2);
|
memset(args, 0, sizeof(args));
|
||||||
Pause();
|
args[0] = temp1;
|
||||||
|
args[1] = (char *)"-n";
|
||||||
|
args[2] = exitinfo.Name;
|
||||||
|
args[3] = temp2;
|
||||||
|
args[4] = NULL;
|
||||||
|
|
||||||
|
if (execute(args, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") != 0) {
|
||||||
|
WriteError("Failed to set new Unix password");
|
||||||
|
} else {
|
||||||
|
memset(&exitinfo.Password, 0, sizeof(exitinfo.Password));
|
||||||
|
strcpy(exitinfo.Password, temp2);
|
||||||
|
exitinfo.tLastPwdChange = time(NULL);
|
||||||
|
Enter(1);
|
||||||
|
/* Password Change Successful */
|
||||||
|
language(10, 0, 124);
|
||||||
|
Syslog('+', "User changed his password");
|
||||||
|
WriteExitinfo();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Enter(1);
|
||||||
|
/* Old password incorrect! */
|
||||||
|
language(12, 0, 125);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(temp1);
|
||||||
|
free(temp2);
|
||||||
|
Enter(2);
|
||||||
|
Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSu
|
|||||||
if (NoSuid)
|
if (NoSuid)
|
||||||
rc = exec_nosuid(Program);
|
rc = exec_nosuid(Program);
|
||||||
else
|
else
|
||||||
rc = execute((char *)"/bin/sh", (char *)"-c", Program, NULL, NULL, NULL);
|
rc = execute_str((char *)"/bin/sh", (char *)"-c", Program, NULL, NULL, NULL);
|
||||||
|
|
||||||
Altime(0);
|
Altime(0);
|
||||||
alarm_off();
|
alarm_off();
|
||||||
|
@ -181,7 +181,7 @@ void Download(void)
|
|||||||
Enter(2);
|
Enter(2);
|
||||||
OldArea = iAreaNumber;
|
OldArea = iAreaNumber;
|
||||||
WhosDoingWhat(DOWNLOAD, NULL);
|
WhosDoingWhat(DOWNLOAD, NULL);
|
||||||
system("rm -f ./tag/*");
|
execute_pth((char *)"rm", (char *)"-f ./tag/*", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
|
|
||||||
if ((tf = fopen("taglist", "r+")) == NULL) {
|
if ((tf = fopen("taglist", "r+")) == NULL) {
|
||||||
Syslog('+', "Download command but no files marked");
|
Syslog('+', "Download command but no files marked");
|
||||||
@ -382,7 +382,7 @@ void Download(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (temp != NULL) {
|
if (temp != NULL) {
|
||||||
if ((err = execute(sProtDn, temp, NULL, NULL, NULL, NULL))) {
|
if ((err = execute_str(sProtDn, temp, NULL, NULL, NULL, NULL))) {
|
||||||
perror("");
|
perror("");
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
WriteError("Download error %d, prot: %s", err, sProtDn);
|
WriteError("Download error %d, prot: %s", err, sProtDn);
|
||||||
@ -1140,7 +1140,7 @@ int Upload()
|
|||||||
*/
|
*/
|
||||||
Altime(7200);
|
Altime(7200);
|
||||||
alarm_set(7190);
|
alarm_set(7190);
|
||||||
if ((err = execute(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
if ((err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
||||||
/*
|
/*
|
||||||
* Log any errors
|
* Log any errors
|
||||||
*/
|
*/
|
||||||
@ -1309,7 +1309,7 @@ int DownloadDirect(char *Name, int Wait)
|
|||||||
*/
|
*/
|
||||||
alarm_set(((exitinfo.iTimeLeft + 10) * 60) - 10);
|
alarm_set(((exitinfo.iTimeLeft + 10) * 60) - 10);
|
||||||
Altime((exitinfo.iTimeLeft + 10) * 60);
|
Altime((exitinfo.iTimeLeft + 10) * 60);
|
||||||
if ((err = execute(sProtDn, symFrom, NULL, NULL, NULL, NULL))) {
|
if ((err = execute_str(sProtDn, symFrom, NULL, NULL, NULL, NULL))) {
|
||||||
/*
|
/*
|
||||||
* Only log the error, we might have sent some files
|
* Only log the error, we might have sent some files
|
||||||
* instead of nothing.
|
* instead of nothing.
|
||||||
@ -1671,7 +1671,7 @@ int Upload_Home()
|
|||||||
*/
|
*/
|
||||||
Altime(7200);
|
Altime(7200);
|
||||||
alarm_set(7190);
|
alarm_set(7190);
|
||||||
if ((err = execute(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
if ((err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
||||||
/*
|
/*
|
||||||
* Log any errors
|
* Log any errors
|
||||||
*/
|
*/
|
||||||
@ -2342,7 +2342,7 @@ void ViewFile(char *name)
|
|||||||
* display to the user.
|
* display to the user.
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/%s/temptxt", CFG.bbs_usersdir, exitinfo.Name);
|
sprintf(temp, "%s/%s/temptxt", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
rc = execute(archiver.varc, File, NULL, (char *)"/dev/null", temp, (char *)"/dev/null");
|
rc = execute_str(archiver.varc, File, NULL, (char *)"/dev/null", temp, (char *)"/dev/null");
|
||||||
Syslog('+', "Display temp file %s", temp);
|
Syslog('+', "Display temp file %s", temp);
|
||||||
DisplayTextFile(temp);
|
DisplayTextFile(temp);
|
||||||
unlink(temp);
|
unlink(temp);
|
||||||
|
@ -532,7 +532,7 @@ int ScanDirect(char *fn)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
Altime(3600);
|
Altime(3600);
|
||||||
if ((err = execute(virscan.scanner, virscan.options, temp, (char *)"/dev/null",
|
if ((err = execute_str(virscan.scanner, virscan.options, temp, (char *)"/dev/null",
|
||||||
(char *)"/dev/null" , (char *)"/dev/null")) != virscan.error) {
|
(char *)"/dev/null" , (char *)"/dev/null")) != virscan.error) {
|
||||||
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
@ -613,9 +613,9 @@ int ScanArchive(char *fn, char *ftype)
|
|||||||
WriteError("No unarc command available");
|
WriteError("No unarc command available");
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
sprintf(temp, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
||||||
if (execute(archiver.funarc, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
|
if (execute_str(archiver.funarc, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
|
||||||
WriteError("$Failed %s %s", archiver.funarc, temp);
|
WriteError("$Failed %s %s", archiver.funarc, temp);
|
||||||
system("rm -f -r ./*");
|
execute_pth((char *)"rm", (char *)"-r -f ./*", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
chdir(cwd);
|
chdir(cwd);
|
||||||
free(cwd);
|
free(cwd);
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
@ -643,7 +643,7 @@ int ScanArchive(char *fn, char *ftype)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
Altime(3600);
|
Altime(3600);
|
||||||
err = execute(virscan.scanner, virscan.options, (char *)"*", (char *)"/dev/null",
|
err = execute_str(virscan.scanner, virscan.options, (char *)"*", (char *)"/dev/null",
|
||||||
(char *)"/dev/null", (char *)"/dev/null");
|
(char *)"/dev/null", (char *)"/dev/null");
|
||||||
if (err != virscan.error) {
|
if (err != virscan.error) {
|
||||||
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
|
||||||
@ -663,7 +663,7 @@ int ScanArchive(char *fn, char *ftype)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
system("rm -f -r ./*");
|
execute_pth((char *)"rm", (char *)"-r -f ./*", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
chdir(cwd);
|
chdir(cwd);
|
||||||
free(cwd);
|
free(cwd);
|
||||||
free(temp);
|
free(temp);
|
||||||
@ -892,9 +892,9 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
* get the FILE_ID.DIZ if it exists.
|
* get the FILE_ID.DIZ if it exists.
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/%s", area.Path, File);
|
sprintf(temp, "%s/%s", area.Path, File);
|
||||||
if ((err = execute(archiver.iunarc, temp, (char *)"FILE_ID.DIZ", (char *)"/dev/null",
|
if ((err = execute_str(archiver.iunarc, temp, (char *)"FILE_ID.DIZ", (char *)"/dev/null",
|
||||||
(char *)"/dev/null", (char *)"/dev/null"))) {
|
(char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
if ((err = execute(archiver.iunarc, temp, (char *)"file_id.diz", (char *)"/dev/null",
|
if ((err = execute_str(archiver.iunarc, temp, (char *)"file_id.diz", (char *)"/dev/null",
|
||||||
(char *)"/dev/null", (char *)"/dev/null"))) {
|
(char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
Syslog('+', "No FILE_ID.DIZ found in %s", File);
|
Syslog('+', "No FILE_ID.DIZ found in %s", File);
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,7 +77,7 @@ void die(int onsig)
|
|||||||
/*
|
/*
|
||||||
* In case the child had the tty in raw mode...
|
* 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);
|
signal(onsig, SIG_IGN);
|
||||||
@ -491,14 +491,14 @@ void MakeArc()
|
|||||||
Nopper();
|
Nopper();
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
printf("Creating allfiles.zip\n");
|
printf("Creating allfiles.zip\n");
|
||||||
if (!execute(cmd, (char *)"allfiles.zip allfiles.txt", (char *)NULL, (char *)"/dev/null",
|
if (!execute_str(cmd, (char *)"allfiles.zip allfiles.txt", (char *)NULL, (char *)"/dev/null",
|
||||||
(char *)"/dev/null", (char *)"/dev/null") == 0)
|
(char *)"/dev/null", (char *)"/dev/null") == 0)
|
||||||
WriteError("Create allfiles.zip failed");
|
WriteError("Create allfiles.zip failed");
|
||||||
|
|
||||||
Nopper();
|
Nopper();
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
printf("Creating newfiles.zip\n");
|
printf("Creating newfiles.zip\n");
|
||||||
if (!execute(cmd, (char *)"newfiles.zip newfiles.txt", (char *)NULL, (char *)"/dev/null",
|
if (!execute_str(cmd, (char *)"newfiles.zip newfiles.txt", (char *)NULL, (char *)"/dev/null",
|
||||||
(char *)"/dev/null", (char *)"/dev/null") == 0)
|
(char *)"/dev/null", (char *)"/dev/null") == 0)
|
||||||
WriteError("Create newfiles.zip failed");
|
WriteError("Create newfiles.zip failed");
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
@ -178,9 +178,7 @@ void UserPack(int days, int level, int pack)
|
|||||||
long oldsize, curpos;
|
long oldsize, curpos;
|
||||||
int updated, delete = 0, rc, highest = 0, record = 0, sysop = FALSE;
|
int updated, delete = 0, rc, highest = 0, record = 0, sysop = FALSE;
|
||||||
time_t Last;
|
time_t Last;
|
||||||
#ifdef _VPOPMAIL_PATH
|
|
||||||
char *cmd;
|
char *cmd;
|
||||||
#endif
|
|
||||||
|
|
||||||
fnin = calloc(PATH_MAX, sizeof(char));
|
fnin = calloc(PATH_MAX, sizeof(char));
|
||||||
fnout = calloc(PATH_MAX, sizeof(char));
|
fnout = calloc(PATH_MAX, sizeof(char));
|
||||||
@ -323,22 +321,26 @@ void UserPack(int days, int level, int pack)
|
|||||||
WriteError("Cannot delete unix account %s", usr.Name);
|
WriteError("Cannot delete unix account %s", usr.Name);
|
||||||
} else {
|
} else {
|
||||||
#ifndef __FreeBSD__
|
#ifndef __FreeBSD__
|
||||||
rc = execute((char *)"/usr/sbin/userdel ", usr.Name, NULL,
|
rc = execute_str((char *)"/usr/sbin/userdel ", usr.Name, NULL,
|
||||||
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
||||||
#else
|
#else
|
||||||
rc = execute((char *)"/usr/sbin/pw userdel ", usr.Name, NULL,
|
rc = execute_str((char *)"/usr/sbin/pw userdel ", usr.Name, NULL,
|
||||||
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
||||||
#endif
|
#endif
|
||||||
#ifdef _VPOPMAIL_PATH
|
#ifdef _VPOPMAIL_PATH
|
||||||
cmd = xstrcpy((char *)_VPOPMAIL_PATH);
|
cmd = xstrcpy((char *)_VPOPMAIL_PATH);
|
||||||
cmd = xstrcat(cmd, (char *)"/vdeluser ");
|
cmd = xstrcat(cmd, (char *)"/vdeluser ");
|
||||||
rc = execute(cmd, usr.Name, NULL,
|
rc = execute_str(cmd, usr.Name, NULL,
|
||||||
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
||||||
free(cmd);
|
free(cmd);
|
||||||
#endif
|
#endif
|
||||||
if (chdir(CFG.bbs_usersdir) == 0)
|
if (chdir(CFG.bbs_usersdir) == 0) {
|
||||||
rc = execute((char *)"/bin/rm -Rf ", usr.Name, NULL,
|
cmd = xstrcpy((char *)"-Rf ");
|
||||||
|
cmd = xstrcat(cmd, usr.Name);
|
||||||
|
rc = execute_pth((char *)"rm", cmd,
|
||||||
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ void Good_Bye(int onsig)
|
|||||||
*/
|
*/
|
||||||
char *NameGen(char *FidoName)
|
char *NameGen(char *FidoName)
|
||||||
{
|
{
|
||||||
char *sUserName;
|
static char *sUserName;
|
||||||
|
|
||||||
sUserName = calloc(10, sizeof(char));
|
sUserName = calloc(10, sizeof(char));
|
||||||
Syslog('+', "NameGen(%s)", FidoName);
|
Syslog('+', "NameGen(%s)", FidoName);
|
||||||
@ -635,34 +635,47 @@ char *NameGen(char *FidoName)
|
|||||||
*/
|
*/
|
||||||
char *NameCreate(char *Name, char *Comment, char *Password)
|
char *NameCreate(char *Name, char *Comment, char *Password)
|
||||||
{
|
{
|
||||||
char *progname;
|
char *progname, *args[16], *gidstr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
progname = calloc(PATH_MAX, sizeof(char));
|
progname = calloc(PATH_MAX, sizeof(char));
|
||||||
|
gidstr = calloc(10, sizeof(char));
|
||||||
|
memset(args, 0, sizeof(args));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call mbuseradd, this is a special setuid root program to create
|
* Call mbuseradd, this is a special setuid root program to create
|
||||||
* unix acounts and home directories.
|
* unix acounts and home directories.
|
||||||
*/
|
*/
|
||||||
sprintf(progname, "%s/bin/mbuseradd %d %s \"%s\" %s", getenv("MBSE_ROOT"), getgid(), Name, Comment, CFG.bbs_usersdir);
|
sprintf(progname, "%s/bin/mbuseradd", getenv("MBSE_ROOT"));
|
||||||
Syslog('+', "%s", progname);
|
sprintf(gidstr, "%d", getgid());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
|
args[0] = progname;
|
||||||
if ((err = system(progname))) {
|
args[1] = gidstr;
|
||||||
perror("");
|
args[2] = Name;
|
||||||
|
args[3] = Comment;
|
||||||
|
args[4] = CFG.bbs_usersdir;
|
||||||
|
args[5] = NULL;
|
||||||
|
|
||||||
|
if ((err = execute(args, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
WriteError("Failed to create unix account");
|
WriteError("Failed to create unix account");
|
||||||
free(progname);
|
free(progname);
|
||||||
|
free(gidstr);
|
||||||
ExitClient(MBERR_GENERAL);
|
ExitClient(MBERR_GENERAL);
|
||||||
}
|
}
|
||||||
|
free(gidstr);
|
||||||
|
|
||||||
sprintf(progname, "%s/bin/mbpasswd -f %s %s", getenv("MBSE_ROOT"), Name, Password);
|
sprintf(progname, "%s/bin/mbpasswd", getenv("MBSE_ROOT"));
|
||||||
Syslog('+', "%s/bin/mbpasswd -f %s ******", getenv("MBSE_ROOT"), Name);
|
memset(args, 0, sizeof(args));
|
||||||
|
args[0] = progname;
|
||||||
|
args[1] = (char *)"-f";
|
||||||
|
args[2] = Name;
|
||||||
|
args[3] = Password;
|
||||||
|
args[4] = NULL;
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
|
|
||||||
if ((err = system(progname))) {
|
if ((err = execute(args, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
perror("");
|
|
||||||
WriteError("Failed to set unix password");
|
WriteError("Failed to set unix password");
|
||||||
free(progname);
|
free(progname);
|
||||||
ExitClient(MBERR_GENERAL);
|
ExitClient(MBERR_GENERAL);
|
||||||
|
@ -97,7 +97,7 @@ unsigned long ASCII_PackArea(unsigned long, long);
|
|||||||
|
|
||||||
void AddArc(char *Temp, char *Pktname)
|
void AddArc(char *Temp, char *Pktname)
|
||||||
{
|
{
|
||||||
execute((char *)archiver.marc, Pktname, Temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
execute_str((char *)archiver.marc, Pktname, Temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
unlink(Temp);
|
unlink(Temp);
|
||||||
printf(".");
|
printf(".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -1097,7 +1097,7 @@ void OLR_Upload(void)
|
|||||||
*/
|
*/
|
||||||
Altime(7200);
|
Altime(7200);
|
||||||
alarm_set(7190);
|
alarm_set(7190);
|
||||||
if ((err = execute(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
if ((err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
||||||
}
|
}
|
||||||
@ -1184,7 +1184,7 @@ void OLR_Upload(void)
|
|||||||
Syslog('m', "Unarc %s", temp);
|
Syslog('m', "Unarc %s", temp);
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
|
|
||||||
if ((err = execute(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
if ((err = execute_str(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
|
||||||
WriteError("$Failed %s", temp);
|
WriteError("$Failed %s", temp);
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
printf("%s\n", (char *) Language(217));
|
printf("%s\n", (char *) Language(217));
|
||||||
|
@ -62,7 +62,7 @@ void die(int onsig)
|
|||||||
/*
|
/*
|
||||||
* In case the child had the tty in raw mode, reset the tty
|
* 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 (MsgBase.Locked)
|
if (MsgBase.Locked)
|
||||||
|
@ -394,8 +394,8 @@ int EditFileRec(int Area)
|
|||||||
* Erase file in path if path is set and not the default
|
* Erase file in path if path is set and not the default
|
||||||
* FTP base path
|
* FTP base path
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "rm -f %s", area.Path);
|
sprintf(temp, "-f %s", area.Path);
|
||||||
system(temp);
|
execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
rmdir(area.Path);
|
rmdir(area.Path);
|
||||||
}
|
}
|
||||||
memset(&area, 0, sizeof(area));
|
memset(&area, 0, sizeof(area));
|
||||||
|
@ -352,7 +352,7 @@ void Fields2(void)
|
|||||||
int EditUsrRec2(void)
|
int EditUsrRec2(void)
|
||||||
{
|
{
|
||||||
int j = 0, ch;
|
int j = 0, ch;
|
||||||
char temp[PATH_MAX];
|
char temp[PATH_MAX], *args[16];
|
||||||
|
|
||||||
Screen2();
|
Screen2();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -379,8 +379,15 @@ int EditUsrRec2(void)
|
|||||||
strcpy(usrconfig.Password, temp);
|
strcpy(usrconfig.Password, temp);
|
||||||
usrconfig.tLastPwdChange = time(NULL);
|
usrconfig.tLastPwdChange = time(NULL);
|
||||||
Syslog('+', "%s/bin/mbpasswd -f %s ******", getenv("MBSE_ROOT"), usrconfig.Name);
|
Syslog('+', "%s/bin/mbpasswd -f %s ******", getenv("MBSE_ROOT"), usrconfig.Name);
|
||||||
sprintf(temp, "%s/bin/mbpasswd -f %s %s", getenv("MBSE_ROOT"), usrconfig.Name, usrconfig.Password);
|
sprintf(temp, "%s/bin/mbpasswd", getenv("MBSE_ROOT"));
|
||||||
if (system(temp) != 0) {
|
memset(args, 0, sizeof(args));
|
||||||
|
args[0] = temp;
|
||||||
|
args[1] = (char *)"-f";
|
||||||
|
args[2] = usrconfig.Name;
|
||||||
|
args[3] = usrconfig.Password;
|
||||||
|
args[4] = NULL;
|
||||||
|
|
||||||
|
if (execute(args, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")!= 0) {
|
||||||
WriteError("$Failed to set new Unix password");
|
WriteError("$Failed to set new Unix password");
|
||||||
} else {
|
} else {
|
||||||
Syslog('+', "Password changed for %s (%s)", usrconfig.sUserName, usrconfig.Name);
|
Syslog('+', "Password changed for %s (%s)", usrconfig.sUserName, usrconfig.Name);
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <errno.h>
|
||||||
#if defined(SHADOW_PASSWORD)
|
#if defined(SHADOW_PASSWORD)
|
||||||
#include <shadow.h>
|
#include <shadow.h>
|
||||||
#endif
|
#endif
|
||||||
@ -119,6 +122,59 @@ static int force; /* Force update of locked passwords */
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _VPOPMAIL_PATH
|
||||||
|
int execute(char **args, char *in, char *out, char *err)
|
||||||
|
{
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
int i, pid, status = 0, rc = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
if (args[i])
|
||||||
|
sprintf(buf, "%s %s", buf, args[i]);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
syslog(LOG_WARNING, "Execute:%s", buf);
|
||||||
|
fflush(stdout);
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
if ((pid = fork()) == 0) {
|
||||||
|
if (in) {
|
||||||
|
close(0);
|
||||||
|
if (open(in, O_RDONLY) != 0) {
|
||||||
|
syslog(LOG_WARNING, "Reopen of stdin to %s failed", in);
|
||||||
|
_exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out) {
|
||||||
|
close(1);
|
||||||
|
if (open(out, O_WRONLY | O_APPEND | O_CREAT,0600) != 1) {
|
||||||
|
syslog(LOG_WARNING, "Reopen of stdout to %s failed", out);
|
||||||
|
_exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
close(2);
|
||||||
|
if (open(err, O_WRONLY | O_APPEND | O_CREAT,0600) != 2) {
|
||||||
|
syslog(LOG_WARNING, "Reopen of stderr to %s failed", err);
|
||||||
|
_exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rc = execv(args[0],args);
|
||||||
|
syslog(LOG_WARNING, "Exec \"%s\" returned %d", args[0], rc);
|
||||||
|
_exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
rc = wait(&status);
|
||||||
|
} while (((rc > 0) && (rc != pid)) || ((rc == -1) && (errno == EINTR)));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
|
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||||
static void fail_exit(int status)
|
static void fail_exit(int status)
|
||||||
{
|
{
|
||||||
@ -735,6 +791,7 @@ int main(int argc, char *argv[])
|
|||||||
char *cp;
|
char *cp;
|
||||||
#ifdef _VPOPMAIL_PATH
|
#ifdef _VPOPMAIL_PATH
|
||||||
char temp[PATH_MAX];
|
char temp[PATH_MAX];
|
||||||
|
char *args[16];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -926,11 +983,17 @@ int main(int argc, char *argv[])
|
|||||||
#endif /* __FreeBSD__ */
|
#endif /* __FreeBSD__ */
|
||||||
|
|
||||||
#ifdef _VPOPMAIL_PATH
|
#ifdef _VPOPMAIL_PATH
|
||||||
sprintf(temp, "%s/vpasswd %s %s", _VPOPMAIL_PATH, argv[2], argv[3]);
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
|
memset(args, 0, sizeof(args));
|
||||||
|
|
||||||
|
sprintf(temp, "%s/vpasswd", _VPOPMAIL_PATH);
|
||||||
|
args[0] = temp;
|
||||||
|
args[1] = argv[2];
|
||||||
|
args[2] = argv[3];
|
||||||
|
args[3] = NULL;
|
||||||
|
|
||||||
if (system(temp) != 0) {
|
if (execute(args, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty") != 0) {
|
||||||
perror("mbpasswd: Failed to change vpopmail password\n");
|
perror("mbpasswd: Failed to change vpopmail password\n");
|
||||||
syslog(LOG_ERR, "Failed to change vpopmail password");
|
syslog(LOG_ERR, "Failed to change vpopmail password");
|
||||||
}
|
}
|
||||||
|
105
unix/mbuseradd.c
105
unix/mbuseradd.c
@ -48,19 +48,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int execute(char *cmd, char *file, char *in, char *out, char *err)
|
int execute(char **args, char *in, char *out, char *err)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX], *vector[16];
|
char buf[PATH_MAX];
|
||||||
int i, pid, status = 0, rc = 0;
|
int i, pid, status = 0, rc = 0;
|
||||||
|
|
||||||
sprintf(buf, "%s %s", cmd, file);
|
for (i = 0; i < 16; i++) {
|
||||||
syslog(LOG_WARNING, "Execute: %s", buf);
|
if (args[i])
|
||||||
|
sprintf(buf, "%s %s", buf, args[i]);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
syslog(LOG_WARNING, "Execute:%s", buf);
|
||||||
|
|
||||||
memset(vector, 0, sizeof(vector));
|
|
||||||
i = 0;
|
|
||||||
vector[i++] = strtok(buf, " \t\n");
|
|
||||||
while ((vector[i++] = strtok(NULL," \t\n")) && (i < 16)) { syslog(LOG_NOTICE, "%s", vector[i]); } ;
|
|
||||||
vector[15] = NULL;
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
@ -86,8 +86,8 @@ int execute(char *cmd, char *file, char *in, char *out, char *err)
|
|||||||
_exit(-1);
|
_exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc = execv(vector[0],vector);
|
rc = execv(args[0],args);
|
||||||
syslog(LOG_WARNING, "Exec \"%s\" returned %d", vector[0], rc);
|
syslog(LOG_WARNING, "Exec \"%s\" returned %d", args[0], rc);
|
||||||
_exit(-1);
|
_exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,11 +95,6 @@ int execute(char *cmd, char *file, char *in, char *out, char *err)
|
|||||||
rc = wait(&status);
|
rc = wait(&status);
|
||||||
} while (((rc > 0) && (rc != pid)) || ((rc == -1) && (errno == EINTR)));
|
} while (((rc > 0) && (rc != pid)) || ((rc == -1) && (errno == EINTR)));
|
||||||
|
|
||||||
if (rc == -1) {
|
|
||||||
syslog(LOG_WARNING, "Wait returned %d, status %d,%d", rc, status >> 8, status & 0xff);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +120,7 @@ void makedir(char *path, mode_t mode, uid_t owner, gid_t group)
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *PassEnt, *temp, *shell;
|
char *temp, *shell, *homedir, *args[16];
|
||||||
int i;
|
int i;
|
||||||
struct passwd *pwent, *pwuser;
|
struct passwd *pwent, *pwuser;
|
||||||
|
|
||||||
@ -142,9 +137,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PassEnt = calloc(PATH_MAX, sizeof(char));
|
memset(args, 0, sizeof(args));
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
shell = calloc(PATH_MAX, sizeof(char));
|
shell = calloc(PATH_MAX, sizeof(char));
|
||||||
|
homedir = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
|
|
||||||
if (setuid(0) == -1 || setgid(1) == -1) {
|
if (setuid(0) == -1 || setgid(1) == -1) {
|
||||||
perror("");
|
perror("");
|
||||||
@ -168,22 +166,22 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
#if defined(__linux__) || defined(__NetBSD__)
|
#if defined(__linux__) || defined(__NetBSD__)
|
||||||
if ((access("/usr/bin/useradd", R_OK)) == 0)
|
if ((access("/usr/bin/useradd", R_OK)) == 0)
|
||||||
strcpy(temp, "/usr/bin/useradd");
|
args[0] = (char *)"/usr/bin/useradd";
|
||||||
else if ((access("/bin/useradd", R_OK)) == 0)
|
else if ((access("/bin/useradd", R_OK)) == 0)
|
||||||
strcpy(temp, "/bin/useradd");
|
args[0] = (char *)"/bin/useradd";
|
||||||
else if ((access("/usr/sbin/useradd", R_OK)) == 0)
|
else if ((access("/usr/sbin/useradd", R_OK)) == 0)
|
||||||
strcpy(temp, "/usr/sbin/useradd");
|
args[0] = (char *)"/usr/sbin/useradd";
|
||||||
else if ((access("/sbin/useradd", R_OK)) == 0)
|
else if ((access("/sbin/useradd", R_OK)) == 0)
|
||||||
strcpy(temp, "/sbin/useradd");
|
args[0] = (char *)"/sbin/useradd";
|
||||||
else {
|
else {
|
||||||
syslog(LOG_WARNING, "Can't find useradd");
|
syslog(LOG_WARNING, "Can't find useradd");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#elif __FreeBSD__
|
#elif __FreeBSD__
|
||||||
if ((access("/usr/sbin/pw", X_OK)) == 0)
|
if ((access("/usr/sbin/pw", X_OK)) == 0)
|
||||||
strcpy(temp, "/usr/sbin/pw");
|
args[0] = (char *)"/usr/sbin/pw";
|
||||||
else if ((access("/sbin/pw", X_OK)) == 0)
|
else if ((access("/sbin/pw", X_OK)) == 0)
|
||||||
strcpy(temp, "/sbin/pw");
|
args[0] = (char *)"/sbin/pw";
|
||||||
else {
|
else {
|
||||||
syslog(LOG_WARNING, "Can't find pw");
|
syslog(LOG_WARNING, "Can't find pw");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -194,19 +192,39 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
sprintf(shell, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
|
sprintf(shell, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
|
||||||
|
sprintf(homedir, "%s/%s", argv[4], argv[2]);
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__NetBSD__)
|
#if defined(__linux__) || defined(__NetBSD__)
|
||||||
sprintf(PassEnt, "%s -c \"%s\" -d %s/%s -g %s -s %s %s", temp, argv[3], argv[4], argv[2], argv[1], shell, argv[2]);
|
args[1] = (char *)"-c";
|
||||||
|
args[2] = argv[3];
|
||||||
|
args[3] = (char *)"-d";
|
||||||
|
args[4] = homedir;
|
||||||
|
args[5] = (char *)"-g";
|
||||||
|
args[6] = argv[1];
|
||||||
|
args[7] = (char *)"-s";
|
||||||
|
args[8] = shell;
|
||||||
|
args[9] = argv[2];
|
||||||
|
args[10] = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
sprintf(PassEnt, "%s useradd %s -c \"%s\" -d %s/%s -g %s -s %s", temp, argv[2], argv[3], argv[4], argv[2], argv[1], shell);
|
args[1] = (char *)"useradd";
|
||||||
|
args[2] = argv[2];
|
||||||
|
args[3] = (char *)"-c";
|
||||||
|
args[4] = argv[3];
|
||||||
|
args[5] = (char *)"-d";
|
||||||
|
args[6] = homedir;
|
||||||
|
args[7] = (char *)"-g";
|
||||||
|
args[8] = argv[1];
|
||||||
|
args[9] = (char *)"-s";
|
||||||
|
args[10] = shell;
|
||||||
|
args[11] = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
syslog(LOG_WARNING, "system(%s)", PassEnt);
|
if (execute(args, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty") != 0) {
|
||||||
if (system(PassEnt) != 0) {
|
|
||||||
syslog(LOG_WARNING, "Failed to create unix account");
|
syslog(LOG_WARNING, "Failed to create unix account");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
syslog(LOG_WARNING, "Created Unix account");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now create directories and files for this user.
|
* Now create directories and files for this user.
|
||||||
@ -220,26 +238,29 @@ int main(int argc, char *argv[])
|
|||||||
*
|
*
|
||||||
* Check bbs users base home directory
|
* Check bbs users base home directory
|
||||||
*/
|
*/
|
||||||
if ((access(argv[4], R_OK)) != 0)
|
if ((access(argv[4], R_OK)) != 0) {
|
||||||
|
syslog(LOG_WARNING, "No bbs base homedirectory, creating..");
|
||||||
makedir(argv[4], 0770, pwent->pw_uid, pwent->pw_gid);
|
makedir(argv[4], 0770, pwent->pw_uid, pwent->pw_gid);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now create users home directory. Check for an existing directory,
|
* Now create users home directory. Check for an existing directory,
|
||||||
* some systems have already created a home directory. If one is found
|
* some systems have already created a home directory. If one is found
|
||||||
* it is removed to create a fresh one.
|
* it is removed to create a fresh one.
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/%s", argv[4], argv[2]);
|
|
||||||
if ((access(temp, R_OK)) == 0) {
|
if ((access(temp, R_OK)) == 0) {
|
||||||
if ((access("/bin/rm", X_OK)) == 0)
|
if ((access("/bin/rm", X_OK)) == 0)
|
||||||
strcpy(shell, "/bin/rm");
|
args[0] = (char *)"/bin/rm";
|
||||||
else if ((access("/usr/bin/rm", X_OK)) == 0)
|
else if ((access("/usr/bin/rm", X_OK)) == 0)
|
||||||
strcpy(shell, "/usr/bin/rm");
|
args[0] = (char *)"/usr/bin/rm";
|
||||||
else {
|
else {
|
||||||
syslog(LOG_WARNING, "Can't find rm");
|
syslog(LOG_WARNING, "Can't find rm");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
sprintf(PassEnt, " -Rf %s", temp);
|
args[1] = (char *)"-Rf";
|
||||||
i = execute(shell, PassEnt, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty");
|
args[2] = homedir;
|
||||||
|
args[3] = NULL;
|
||||||
|
i = execute(args, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty");
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
syslog(LOG_WARNING, "Unable remove old home directory");
|
syslog(LOG_WARNING, "Unable remove old home directory");
|
||||||
exit(2);
|
exit(2);
|
||||||
@ -253,7 +274,7 @@ int main(int argc, char *argv[])
|
|||||||
syslog(LOG_WARNING, "Can't get passwd entry for %s", argv[2]);
|
syslog(LOG_WARNING, "Can't get passwd entry for %s", argv[2]);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
makedir(temp, 0770, pwuser->pw_uid, pwent->pw_gid);
|
makedir(homedir, 0770, pwuser->pw_uid, pwent->pw_gid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create Maildir and subdirs for Qmail.
|
* Create Maildir and subdirs for Qmail.
|
||||||
@ -268,16 +289,22 @@ int main(int argc, char *argv[])
|
|||||||
makedir(temp, 0700, pwuser->pw_uid, pwent->pw_gid);
|
makedir(temp, 0700, pwuser->pw_uid, pwent->pw_gid);
|
||||||
|
|
||||||
#ifdef _VPOPMAIL_PATH
|
#ifdef _VPOPMAIL_PATH
|
||||||
sprintf(temp, "%s/vadduser %s %s", _VPOPMAIL_PATH, argv[2], argv[2]);
|
sprintf(temp, "%s/vadduser", _VPOPMAIL_PATH);
|
||||||
|
args[0] = temp;
|
||||||
if (system(temp) != 0) {
|
args[1] = argv[2];
|
||||||
|
args[2] = argv[2];
|
||||||
|
args[3] = NULL;
|
||||||
|
|
||||||
|
if (execute(args, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty") != 0) {
|
||||||
syslog(LOG_WARNING, "Failed to create vpopmail account");
|
syslog(LOG_WARNING, "Failed to create vpopmail account");
|
||||||
|
} else {
|
||||||
|
syslog(LOG_WARNING, "Created vpopmail account");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(shell);
|
free(shell);
|
||||||
free(PassEnt);
|
|
||||||
free(temp);
|
free(temp);
|
||||||
|
free(homedir);
|
||||||
syslog(LOG_WARNING, "Added system account for user\"%s\"", argv[2]);
|
syslog(LOG_WARNING, "Added system account for user\"%s\"", argv[2]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define _MBUSERADD_H
|
#define _MBUSERADD_H
|
||||||
|
|
||||||
|
|
||||||
int execute(char *, char *, char *, char *, char *);
|
int execute(char **, char *, char *, char *);
|
||||||
void makedir(char *, mode_t, uid_t, gid_t);
|
void makedir(char *, mode_t, uid_t, gid_t);
|
||||||
void Help(void);
|
void Help(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user