mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-18 08:52:42 +01:00
Make newfs options work on rootfs.
Add size argument to new_part, so it can come up with a good default for newfs. Fix (possibly) a dialog botch after label.c's wizard mode. Make vsystem even smarter abour crunched binaries (what a speedup!) (You need to recompile crunchgen !)
This commit is contained in:
parent
7d150b7705
commit
0cee912e58
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8665
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.43 1995/05/20 20:30:08 jkh Exp $
|
||||
* $Id: install.c,v 1.44 1995/05/20 23:33:13 phk Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -204,7 +204,7 @@ make_filesystems(void)
|
||||
|
||||
sprintf(dname, "/dev/r%sa", disk->name);
|
||||
msgNotify("Making a new root filesystem on %s", dname);
|
||||
i = vsystem("newfs %s", dname);
|
||||
i = vsystem("%s %s", p->newfs_cmd,dname);
|
||||
if (i) {
|
||||
msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: label.c,v 1.11 1995/05/20 10:33:04 jkh Exp $
|
||||
* $Id: label.c,v 1.12 1995/05/20 19:22:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -178,13 +178,19 @@ record_label_chunks()
|
||||
|
||||
/* A new partition entry */
|
||||
static PartInfo *
|
||||
new_part(char *mpoint, Boolean newfs)
|
||||
new_part(char *mpoint, Boolean newfs, u_long size)
|
||||
{
|
||||
PartInfo *ret;
|
||||
u_long divisor;
|
||||
|
||||
ret = (PartInfo *)safe_malloc(sizeof(PartInfo));
|
||||
strncpy(ret->mountpoint, mpoint, FILENAME_MAX);
|
||||
strcpy(ret->newfs_cmd, "newfs");
|
||||
for(divisor = 4096 ; divisor > 17*4 ; divisor--) {
|
||||
if (!(size % divisor)) {
|
||||
sprintf(ret->newfs_cmd+strlen(ret->newfs_cmd)," -u %ld",divisor);
|
||||
}
|
||||
}
|
||||
ret->newfs = newfs;
|
||||
return ret;
|
||||
}
|
||||
@ -217,7 +223,7 @@ get_mountpoint(struct chunk *old)
|
||||
else if (old)
|
||||
old->flags &= ~CHUNK_IS_ROOT;
|
||||
safe_free(old ? old->private : NULL);
|
||||
tmp = new_part(val, TRUE);
|
||||
tmp = new_part(val, TRUE, old->size);
|
||||
if (old) {
|
||||
old->private = tmp;
|
||||
old->private_free = safe_free;
|
||||
@ -340,7 +346,8 @@ print_label_chunks(void)
|
||||
* Fill in a fake mountpoint and register it
|
||||
*/
|
||||
sprintf(foo, "/mnt%d", mnt++);
|
||||
label_chunk_info[i].c->private = new_part(foo, FALSE);
|
||||
label_chunk_info[i].c->private =
|
||||
new_part(foo, FALSE,label_chunk_info[i].c->size);
|
||||
label_chunk_info[i].c->private_free = safe_free;
|
||||
}
|
||||
mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint;
|
||||
@ -579,8 +586,8 @@ diskLabelEditor(char *str)
|
||||
if (devs[i]->enabled)
|
||||
slice_wizard(((Disk *)devs[i]->private));
|
||||
}
|
||||
dialog_clear();
|
||||
DialogActive = TRUE;
|
||||
dialog_clear();
|
||||
record_label_chunks();
|
||||
}
|
||||
else
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: system.c,v 1.23 1995/05/20 19:12:13 phk Exp $
|
||||
* $Id: system.c,v 1.25 1995/05/20 23:33:14 phk Exp $
|
||||
*
|
||||
* Jordan Hubbard
|
||||
*
|
||||
@ -279,22 +279,24 @@ systemChangeScreenmap(const u_char newmap[])
|
||||
int
|
||||
vsystem(char *fmt, ...)
|
||||
{
|
||||
#ifdef CRUNCHED_BINARY
|
||||
va_list args;
|
||||
union wait pstat;
|
||||
pid_t pid;
|
||||
int omask;
|
||||
sig_t intsave, quitsave;
|
||||
char *cmd,*argv[100];
|
||||
int i;
|
||||
char *cmd,*p;
|
||||
int i,magic=0;
|
||||
|
||||
cmd = (char *)malloc(FILENAME_MAX);
|
||||
cmd[0] = '\0';
|
||||
va_start(args, fmt);
|
||||
vsnprintf(cmd, FILENAME_MAX, fmt, args);
|
||||
va_end(args);
|
||||
/* Find out if this command needs the wizardry of the shell */
|
||||
for (p="<>|'`=\"()" ; *p; p++)
|
||||
if (strchr(cmd,*p)) magic++;
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
msgDebug("Executing command `%s'\n", cmd);
|
||||
msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic);
|
||||
switch(pid = fork()) {
|
||||
case -1: /* error */
|
||||
(void)sigsetmask(omask);
|
||||
@ -309,56 +311,36 @@ vsystem(char *fmt, ...)
|
||||
dup2(DebugFD, 1);
|
||||
dup2(DebugFD, 2);
|
||||
}
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
argv[i++] = "sh";
|
||||
argv[i++] = "-c";
|
||||
argv[i++] = cmd;
|
||||
argv[i] = 0;
|
||||
exit(crunched_main(i,argv));
|
||||
}
|
||||
intsave = signal(SIGINT, SIG_IGN);
|
||||
quitsave = signal(SIGQUIT, SIG_IGN);
|
||||
pid = waitpid(pid, (int *)&pstat, 0);
|
||||
(void)sigsetmask(omask);
|
||||
(void)signal(SIGINT, intsave);
|
||||
(void)signal(SIGQUIT, quitsave);
|
||||
i = (pid == -1) ? -1 : pstat.w_status;
|
||||
msgDebug("Command `%s' returns status of %d\n", cmd, i);
|
||||
free(cmd);
|
||||
return i;
|
||||
#else /* Not crunched */
|
||||
va_list args;
|
||||
union wait pstat;
|
||||
pid_t pid;
|
||||
int omask;
|
||||
sig_t intsave, quitsave;
|
||||
char *cmd;
|
||||
int i;
|
||||
|
||||
cmd = (char *)malloc(FILENAME_MAX);
|
||||
cmd[0] = '\0';
|
||||
va_start(args, fmt);
|
||||
vsnprintf(cmd, FILENAME_MAX, fmt, args);
|
||||
va_end(args);
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
msgDebug("Executing command `%s'\n", cmd);
|
||||
switch(pid = vfork()) {
|
||||
case -1: /* error */
|
||||
(void)sigsetmask(omask);
|
||||
i = 127;
|
||||
|
||||
case 0: /* child */
|
||||
(void)sigsetmask(omask);
|
||||
if (DebugFD != -1) {
|
||||
if (OnVTY)
|
||||
msgInfo("Command output is on debugging screen - type ALT-F2 to see it");
|
||||
dup2(DebugFD, 0);
|
||||
dup2(DebugFD, 1);
|
||||
dup2(DebugFD, 2);
|
||||
#ifdef CRUNCHED_BINARY
|
||||
if (magic) {
|
||||
char *argv[100];
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
argv[i++] = "sh";
|
||||
argv[i++] = "-c";
|
||||
argv[i++] = cmd;
|
||||
argv[i] = 0;
|
||||
exit(crunched_main(i,argv));
|
||||
} else {
|
||||
char *argv[100];
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
while (cmd && *cmd) {
|
||||
argv[i] = strsep(&cmd," \t");
|
||||
if (*argv[i])
|
||||
i++;
|
||||
}
|
||||
argv[i] = 0;
|
||||
if (crunched_here(argv[1]))
|
||||
exit(crunched_main(i,argv));
|
||||
else
|
||||
execvp(argv[1],argv+1);
|
||||
kill(getpid(),9);
|
||||
}
|
||||
#else /* !CRUNCHED_BINARY */
|
||||
execl("/stand/sh", "sh", "-c", cmd, (char *)NULL);
|
||||
i = 127;
|
||||
kill(getpid(),9);
|
||||
#endif /* CRUNCHED_BINARY */
|
||||
}
|
||||
intsave = signal(SIGINT, SIG_IGN);
|
||||
quitsave = signal(SIGQUIT, SIG_IGN);
|
||||
@ -370,5 +352,4 @@ vsystem(char *fmt, ...)
|
||||
msgDebug("Command `%s' returns status of %d\n", cmd, i);
|
||||
free(cmd);
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.43 1995/05/20 20:30:08 jkh Exp $
|
||||
* $Id: install.c,v 1.44 1995/05/20 23:33:13 phk Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -204,7 +204,7 @@ make_filesystems(void)
|
||||
|
||||
sprintf(dname, "/dev/r%sa", disk->name);
|
||||
msgNotify("Making a new root filesystem on %s", dname);
|
||||
i = vsystem("newfs %s", dname);
|
||||
i = vsystem("%s %s", p->newfs_cmd,dname);
|
||||
if (i) {
|
||||
msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: label.c,v 1.11 1995/05/20 10:33:04 jkh Exp $
|
||||
* $Id: label.c,v 1.12 1995/05/20 19:22:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -178,13 +178,19 @@ record_label_chunks()
|
||||
|
||||
/* A new partition entry */
|
||||
static PartInfo *
|
||||
new_part(char *mpoint, Boolean newfs)
|
||||
new_part(char *mpoint, Boolean newfs, u_long size)
|
||||
{
|
||||
PartInfo *ret;
|
||||
u_long divisor;
|
||||
|
||||
ret = (PartInfo *)safe_malloc(sizeof(PartInfo));
|
||||
strncpy(ret->mountpoint, mpoint, FILENAME_MAX);
|
||||
strcpy(ret->newfs_cmd, "newfs");
|
||||
for(divisor = 4096 ; divisor > 17*4 ; divisor--) {
|
||||
if (!(size % divisor)) {
|
||||
sprintf(ret->newfs_cmd+strlen(ret->newfs_cmd)," -u %ld",divisor);
|
||||
}
|
||||
}
|
||||
ret->newfs = newfs;
|
||||
return ret;
|
||||
}
|
||||
@ -217,7 +223,7 @@ get_mountpoint(struct chunk *old)
|
||||
else if (old)
|
||||
old->flags &= ~CHUNK_IS_ROOT;
|
||||
safe_free(old ? old->private : NULL);
|
||||
tmp = new_part(val, TRUE);
|
||||
tmp = new_part(val, TRUE, old->size);
|
||||
if (old) {
|
||||
old->private = tmp;
|
||||
old->private_free = safe_free;
|
||||
@ -340,7 +346,8 @@ print_label_chunks(void)
|
||||
* Fill in a fake mountpoint and register it
|
||||
*/
|
||||
sprintf(foo, "/mnt%d", mnt++);
|
||||
label_chunk_info[i].c->private = new_part(foo, FALSE);
|
||||
label_chunk_info[i].c->private =
|
||||
new_part(foo, FALSE,label_chunk_info[i].c->size);
|
||||
label_chunk_info[i].c->private_free = safe_free;
|
||||
}
|
||||
mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint;
|
||||
@ -579,8 +586,8 @@ diskLabelEditor(char *str)
|
||||
if (devs[i]->enabled)
|
||||
slice_wizard(((Disk *)devs[i]->private));
|
||||
}
|
||||
dialog_clear();
|
||||
DialogActive = TRUE;
|
||||
dialog_clear();
|
||||
record_label_chunks();
|
||||
}
|
||||
else
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: system.c,v 1.23 1995/05/20 19:12:13 phk Exp $
|
||||
* $Id: system.c,v 1.25 1995/05/20 23:33:14 phk Exp $
|
||||
*
|
||||
* Jordan Hubbard
|
||||
*
|
||||
@ -279,22 +279,24 @@ systemChangeScreenmap(const u_char newmap[])
|
||||
int
|
||||
vsystem(char *fmt, ...)
|
||||
{
|
||||
#ifdef CRUNCHED_BINARY
|
||||
va_list args;
|
||||
union wait pstat;
|
||||
pid_t pid;
|
||||
int omask;
|
||||
sig_t intsave, quitsave;
|
||||
char *cmd,*argv[100];
|
||||
int i;
|
||||
char *cmd,*p;
|
||||
int i,magic=0;
|
||||
|
||||
cmd = (char *)malloc(FILENAME_MAX);
|
||||
cmd[0] = '\0';
|
||||
va_start(args, fmt);
|
||||
vsnprintf(cmd, FILENAME_MAX, fmt, args);
|
||||
va_end(args);
|
||||
/* Find out if this command needs the wizardry of the shell */
|
||||
for (p="<>|'`=\"()" ; *p; p++)
|
||||
if (strchr(cmd,*p)) magic++;
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
msgDebug("Executing command `%s'\n", cmd);
|
||||
msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic);
|
||||
switch(pid = fork()) {
|
||||
case -1: /* error */
|
||||
(void)sigsetmask(omask);
|
||||
@ -309,56 +311,36 @@ vsystem(char *fmt, ...)
|
||||
dup2(DebugFD, 1);
|
||||
dup2(DebugFD, 2);
|
||||
}
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
argv[i++] = "sh";
|
||||
argv[i++] = "-c";
|
||||
argv[i++] = cmd;
|
||||
argv[i] = 0;
|
||||
exit(crunched_main(i,argv));
|
||||
}
|
||||
intsave = signal(SIGINT, SIG_IGN);
|
||||
quitsave = signal(SIGQUIT, SIG_IGN);
|
||||
pid = waitpid(pid, (int *)&pstat, 0);
|
||||
(void)sigsetmask(omask);
|
||||
(void)signal(SIGINT, intsave);
|
||||
(void)signal(SIGQUIT, quitsave);
|
||||
i = (pid == -1) ? -1 : pstat.w_status;
|
||||
msgDebug("Command `%s' returns status of %d\n", cmd, i);
|
||||
free(cmd);
|
||||
return i;
|
||||
#else /* Not crunched */
|
||||
va_list args;
|
||||
union wait pstat;
|
||||
pid_t pid;
|
||||
int omask;
|
||||
sig_t intsave, quitsave;
|
||||
char *cmd;
|
||||
int i;
|
||||
|
||||
cmd = (char *)malloc(FILENAME_MAX);
|
||||
cmd[0] = '\0';
|
||||
va_start(args, fmt);
|
||||
vsnprintf(cmd, FILENAME_MAX, fmt, args);
|
||||
va_end(args);
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
msgDebug("Executing command `%s'\n", cmd);
|
||||
switch(pid = vfork()) {
|
||||
case -1: /* error */
|
||||
(void)sigsetmask(omask);
|
||||
i = 127;
|
||||
|
||||
case 0: /* child */
|
||||
(void)sigsetmask(omask);
|
||||
if (DebugFD != -1) {
|
||||
if (OnVTY)
|
||||
msgInfo("Command output is on debugging screen - type ALT-F2 to see it");
|
||||
dup2(DebugFD, 0);
|
||||
dup2(DebugFD, 1);
|
||||
dup2(DebugFD, 2);
|
||||
#ifdef CRUNCHED_BINARY
|
||||
if (magic) {
|
||||
char *argv[100];
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
argv[i++] = "sh";
|
||||
argv[i++] = "-c";
|
||||
argv[i++] = cmd;
|
||||
argv[i] = 0;
|
||||
exit(crunched_main(i,argv));
|
||||
} else {
|
||||
char *argv[100];
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
while (cmd && *cmd) {
|
||||
argv[i] = strsep(&cmd," \t");
|
||||
if (*argv[i])
|
||||
i++;
|
||||
}
|
||||
argv[i] = 0;
|
||||
if (crunched_here(argv[1]))
|
||||
exit(crunched_main(i,argv));
|
||||
else
|
||||
execvp(argv[1],argv+1);
|
||||
kill(getpid(),9);
|
||||
}
|
||||
#else /* !CRUNCHED_BINARY */
|
||||
execl("/stand/sh", "sh", "-c", cmd, (char *)NULL);
|
||||
i = 127;
|
||||
kill(getpid(),9);
|
||||
#endif /* CRUNCHED_BINARY */
|
||||
}
|
||||
intsave = signal(SIGINT, SIG_IGN);
|
||||
quitsave = signal(SIGQUIT, SIG_IGN);
|
||||
@ -370,5 +352,4 @@ vsystem(char *fmt, ...)
|
||||
msgDebug("Command `%s' returns status of %d\n", cmd, i);
|
||||
free(cmd);
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.43 1995/05/20 20:30:08 jkh Exp $
|
||||
* $Id: install.c,v 1.44 1995/05/20 23:33:13 phk Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -204,7 +204,7 @@ make_filesystems(void)
|
||||
|
||||
sprintf(dname, "/dev/r%sa", disk->name);
|
||||
msgNotify("Making a new root filesystem on %s", dname);
|
||||
i = vsystem("newfs %s", dname);
|
||||
i = vsystem("%s %s", p->newfs_cmd,dname);
|
||||
if (i) {
|
||||
msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: label.c,v 1.11 1995/05/20 10:33:04 jkh Exp $
|
||||
* $Id: label.c,v 1.12 1995/05/20 19:22:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -178,13 +178,19 @@ record_label_chunks()
|
||||
|
||||
/* A new partition entry */
|
||||
static PartInfo *
|
||||
new_part(char *mpoint, Boolean newfs)
|
||||
new_part(char *mpoint, Boolean newfs, u_long size)
|
||||
{
|
||||
PartInfo *ret;
|
||||
u_long divisor;
|
||||
|
||||
ret = (PartInfo *)safe_malloc(sizeof(PartInfo));
|
||||
strncpy(ret->mountpoint, mpoint, FILENAME_MAX);
|
||||
strcpy(ret->newfs_cmd, "newfs");
|
||||
for(divisor = 4096 ; divisor > 17*4 ; divisor--) {
|
||||
if (!(size % divisor)) {
|
||||
sprintf(ret->newfs_cmd+strlen(ret->newfs_cmd)," -u %ld",divisor);
|
||||
}
|
||||
}
|
||||
ret->newfs = newfs;
|
||||
return ret;
|
||||
}
|
||||
@ -217,7 +223,7 @@ get_mountpoint(struct chunk *old)
|
||||
else if (old)
|
||||
old->flags &= ~CHUNK_IS_ROOT;
|
||||
safe_free(old ? old->private : NULL);
|
||||
tmp = new_part(val, TRUE);
|
||||
tmp = new_part(val, TRUE, old->size);
|
||||
if (old) {
|
||||
old->private = tmp;
|
||||
old->private_free = safe_free;
|
||||
@ -340,7 +346,8 @@ print_label_chunks(void)
|
||||
* Fill in a fake mountpoint and register it
|
||||
*/
|
||||
sprintf(foo, "/mnt%d", mnt++);
|
||||
label_chunk_info[i].c->private = new_part(foo, FALSE);
|
||||
label_chunk_info[i].c->private =
|
||||
new_part(foo, FALSE,label_chunk_info[i].c->size);
|
||||
label_chunk_info[i].c->private_free = safe_free;
|
||||
}
|
||||
mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint;
|
||||
@ -579,8 +586,8 @@ diskLabelEditor(char *str)
|
||||
if (devs[i]->enabled)
|
||||
slice_wizard(((Disk *)devs[i]->private));
|
||||
}
|
||||
dialog_clear();
|
||||
DialogActive = TRUE;
|
||||
dialog_clear();
|
||||
record_label_chunks();
|
||||
}
|
||||
else
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: system.c,v 1.23 1995/05/20 19:12:13 phk Exp $
|
||||
* $Id: system.c,v 1.25 1995/05/20 23:33:14 phk Exp $
|
||||
*
|
||||
* Jordan Hubbard
|
||||
*
|
||||
@ -279,22 +279,24 @@ systemChangeScreenmap(const u_char newmap[])
|
||||
int
|
||||
vsystem(char *fmt, ...)
|
||||
{
|
||||
#ifdef CRUNCHED_BINARY
|
||||
va_list args;
|
||||
union wait pstat;
|
||||
pid_t pid;
|
||||
int omask;
|
||||
sig_t intsave, quitsave;
|
||||
char *cmd,*argv[100];
|
||||
int i;
|
||||
char *cmd,*p;
|
||||
int i,magic=0;
|
||||
|
||||
cmd = (char *)malloc(FILENAME_MAX);
|
||||
cmd[0] = '\0';
|
||||
va_start(args, fmt);
|
||||
vsnprintf(cmd, FILENAME_MAX, fmt, args);
|
||||
va_end(args);
|
||||
/* Find out if this command needs the wizardry of the shell */
|
||||
for (p="<>|'`=\"()" ; *p; p++)
|
||||
if (strchr(cmd,*p)) magic++;
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
msgDebug("Executing command `%s'\n", cmd);
|
||||
msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic);
|
||||
switch(pid = fork()) {
|
||||
case -1: /* error */
|
||||
(void)sigsetmask(omask);
|
||||
@ -309,56 +311,36 @@ vsystem(char *fmt, ...)
|
||||
dup2(DebugFD, 1);
|
||||
dup2(DebugFD, 2);
|
||||
}
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
argv[i++] = "sh";
|
||||
argv[i++] = "-c";
|
||||
argv[i++] = cmd;
|
||||
argv[i] = 0;
|
||||
exit(crunched_main(i,argv));
|
||||
}
|
||||
intsave = signal(SIGINT, SIG_IGN);
|
||||
quitsave = signal(SIGQUIT, SIG_IGN);
|
||||
pid = waitpid(pid, (int *)&pstat, 0);
|
||||
(void)sigsetmask(omask);
|
||||
(void)signal(SIGINT, intsave);
|
||||
(void)signal(SIGQUIT, quitsave);
|
||||
i = (pid == -1) ? -1 : pstat.w_status;
|
||||
msgDebug("Command `%s' returns status of %d\n", cmd, i);
|
||||
free(cmd);
|
||||
return i;
|
||||
#else /* Not crunched */
|
||||
va_list args;
|
||||
union wait pstat;
|
||||
pid_t pid;
|
||||
int omask;
|
||||
sig_t intsave, quitsave;
|
||||
char *cmd;
|
||||
int i;
|
||||
|
||||
cmd = (char *)malloc(FILENAME_MAX);
|
||||
cmd[0] = '\0';
|
||||
va_start(args, fmt);
|
||||
vsnprintf(cmd, FILENAME_MAX, fmt, args);
|
||||
va_end(args);
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
msgDebug("Executing command `%s'\n", cmd);
|
||||
switch(pid = vfork()) {
|
||||
case -1: /* error */
|
||||
(void)sigsetmask(omask);
|
||||
i = 127;
|
||||
|
||||
case 0: /* child */
|
||||
(void)sigsetmask(omask);
|
||||
if (DebugFD != -1) {
|
||||
if (OnVTY)
|
||||
msgInfo("Command output is on debugging screen - type ALT-F2 to see it");
|
||||
dup2(DebugFD, 0);
|
||||
dup2(DebugFD, 1);
|
||||
dup2(DebugFD, 2);
|
||||
#ifdef CRUNCHED_BINARY
|
||||
if (magic) {
|
||||
char *argv[100];
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
argv[i++] = "sh";
|
||||
argv[i++] = "-c";
|
||||
argv[i++] = cmd;
|
||||
argv[i] = 0;
|
||||
exit(crunched_main(i,argv));
|
||||
} else {
|
||||
char *argv[100];
|
||||
i = 0;
|
||||
argv[i++] = "crunch";
|
||||
while (cmd && *cmd) {
|
||||
argv[i] = strsep(&cmd," \t");
|
||||
if (*argv[i])
|
||||
i++;
|
||||
}
|
||||
argv[i] = 0;
|
||||
if (crunched_here(argv[1]))
|
||||
exit(crunched_main(i,argv));
|
||||
else
|
||||
execvp(argv[1],argv+1);
|
||||
kill(getpid(),9);
|
||||
}
|
||||
#else /* !CRUNCHED_BINARY */
|
||||
execl("/stand/sh", "sh", "-c", cmd, (char *)NULL);
|
||||
i = 127;
|
||||
kill(getpid(),9);
|
||||
#endif /* CRUNCHED_BINARY */
|
||||
}
|
||||
intsave = signal(SIGINT, SIG_IGN);
|
||||
quitsave = signal(SIGQUIT, SIG_IGN);
|
||||
@ -370,5 +352,4 @@ vsystem(char *fmt, ...)
|
||||
msgDebug("Command `%s' returns status of %d\n", cmd, i);
|
||||
free(cmd);
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user