system.c (8829) | system.c (8837) |
---|---|
1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last program in the `sysinstall' line - the next 5 * generation being essentially a complete rewrite. 6 * | 1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last program in the `sysinstall' line - the next 5 * generation being essentially a complete rewrite. 6 * |
7 * $Id: system.c,v 1.40 1995/05/29 00:50:05 jkh Exp $ | 7 * $Id: system.c,v 1.41 1995/05/29 02:13:31 phk Exp $ |
8 * 9 * Jordan Hubbard 10 * 11 * My contributions are in the public domain. 12 * 13 * Parts of this file are also blatently stolen from Poul-Henning Kamp's 14 * previous version of sysinstall, and as such fall under his "BEERWARE license" 15 * so buy him a beer if you like it! Buy him a beer for me, too! --- 81 unchanged lines hidden (view full) --- 97systemShutdown(void) 98{ 99 if (DialogActive) { 100 end_dialog(); 101 DialogActive = FALSE; 102 } 103 /* REALLY exit! */ 104 if (RunningAsInit) { | 8 * 9 * Jordan Hubbard 10 * 11 * My contributions are in the public domain. 12 * 13 * Parts of this file are also blatently stolen from Poul-Henning Kamp's 14 * previous version of sysinstall, and as such fall under his "BEERWARE license" 15 * so buy him a beer if you like it! Buy him a beer for me, too! --- 81 unchanged lines hidden (view full) --- 97systemShutdown(void) 98{ 99 if (DialogActive) { 100 end_dialog(); 101 DialogActive = FALSE; 102 } 103 /* REALLY exit! */ 104 if (RunningAsInit) { |
105 int fd, on = 1; 106 | |
107 /* Put the console back */ | 105 /* Put the console back */ |
108 ioctl(0, VT_RELDISP, 1); | 106 ioctl(DebugFD, VT_RELDISP, 1); |
109 reboot(RB_HALT); 110 } 111 else 112 exit(1); 113} 114 115/* Run some general command */ 116int --- 65 unchanged lines hidden (view full) --- 182 delwin(w); 183 return 1; 184 } 185 else { 186 use_helpfile(NULL); 187 use_helpline(NULL); 188 w = dupwin(newscr); 189 dialog_textbox(file, fname, LINES, COLS); | 107 reboot(RB_HALT); 108 } 109 else 110 exit(1); 111} 112 113/* Run some general command */ 114int --- 65 unchanged lines hidden (view full) --- 180 delwin(w); 181 return 1; 182 } 183 else { 184 use_helpfile(NULL); 185 use_helpline(NULL); 186 w = dupwin(newscr); 187 dialog_textbox(file, fname, LINES, COLS); |
190 unlink(fname); | |
191 touchwin(w); 192 wrefresh(w); 193 delwin(w); 194 } 195 return 0; 196} 197 198char * 199systemHelpFile(char *file, char *buf) 200{ 201 char *cp; | 188 touchwin(w); 189 wrefresh(w); 190 delwin(w); 191 } 192 return 0; 193} 194 195char * 196systemHelpFile(char *file, char *buf) 197{ 198 char *cp; |
199 static char oldfile[64]; /* Should be FILENAME_MAX but I don't feel like wasting that much space */ |
|
202 203 if (!file) 204 return NULL; 205 206 if ((cp = getenv("LANG")) != NULL) { 207 snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); | 200 201 if (!file) 202 return NULL; 203 204 if ((cp = getenv("LANG")) != NULL) { 205 snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); |
208 vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); | 206 if (oldfile[0]) { 207 if (!strcmp(buf, oldfile)) 208 return oldfile; 209 else { 210 unlink(oldfile); 211 oldfile[0] = '\0'; 212 } 213 } 214 vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); |
209 snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); | 215 snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); |
210 if (file_readable(buf)) | 216 if (file_readable(buf)) { 217 strcpy(oldfile, buf); |
211 return buf; | 218 return buf; |
219 } |
|
212 } 213 /* Fall back to normal imperialistic mode :-) */ 214 cp = "en_US.ISO8859-1"; 215 snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); | 220 } 221 /* Fall back to normal imperialistic mode :-) */ 222 cp = "en_US.ISO8859-1"; 223 snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); |
216 vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); | 224 if (oldfile[0]) { 225 if (!strcmp(buf, oldfile)) 226 return oldfile; 227 else { 228 unlink(oldfile); 229 oldfile[0] = '\0'; 230 } 231 } 232 vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); |
217 snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); | 233 snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); |
218 if (file_readable(buf)) | 234 if (file_readable(buf)) { 235 strcpy(oldfile, buf); |
219 return buf; | 236 return buf; |
237 } |
|
220 return NULL; 221} 222 223void 224systemChangeFont(const u_char font[]) 225{ 226 if (OnVTY && ColorDisplay) { 227 if (ioctl(0, PIO_FONT8x16, font) < 0) --- 57 unchanged lines hidden (view full) --- 285 char *cmd,*p; 286 int i,magic=0; 287 288 cmd = (char *)malloc(FILENAME_MAX); 289 cmd[0] = '\0'; 290 va_start(args, fmt); 291 vsnprintf(cmd, FILENAME_MAX, fmt, args); 292 va_end(args); | 238 return NULL; 239} 240 241void 242systemChangeFont(const u_char font[]) 243{ 244 if (OnVTY && ColorDisplay) { 245 if (ioctl(0, PIO_FONT8x16, font) < 0) --- 57 unchanged lines hidden (view full) --- 303 char *cmd,*p; 304 int i,magic=0; 305 306 cmd = (char *)malloc(FILENAME_MAX); 307 cmd[0] = '\0'; 308 va_start(args, fmt); 309 vsnprintf(cmd, FILENAME_MAX, fmt, args); 310 va_end(args); |
311 |
|
293 /* Find out if this command needs the wizardry of the shell */ 294 for (p="<>|'`=\"()" ; *p; p++) | 312 /* Find out if this command needs the wizardry of the shell */ 313 for (p="<>|'`=\"()" ; *p; p++) |
295 if (strchr(cmd,*p)) magic++; | 314 if (strchr(cmd, *p)) 315 magic++; |
296 omask = sigblock(sigmask(SIGCHLD)); | 316 omask = sigblock(sigmask(SIGCHLD)); |
297 msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); | 317 if (isDebug()) 318 msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); |
298 switch(pid = fork()) { 299 case -1: /* error */ 300 (void)sigsetmask(omask); 301 i = 127; 302 303 case 0: /* child */ 304 (void)sigsetmask(omask); 305 if (DebugFD != -1) { | 319 switch(pid = fork()) { 320 case -1: /* error */ 321 (void)sigsetmask(omask); 322 i = 127; 323 324 case 0: /* child */ 325 (void)sigsetmask(omask); 326 if (DebugFD != -1) { |
306 if (OnVTY) | 327 if (OnVTY && isDebug()) |
307 msgInfo("Command output is on debugging screen - type ALT-F2 to see it"); 308 dup2(DebugFD, 0); 309 dup2(DebugFD, 1); 310 dup2(DebugFD, 2); 311 } 312#ifdef NOT_A_GOOD_IDEA_CRUNCHED_BINARY 313 if (magic) { | 328 msgInfo("Command output is on debugging screen - type ALT-F2 to see it"); 329 dup2(DebugFD, 0); 330 dup2(DebugFD, 1); 331 dup2(DebugFD, 2); 332 } 333#ifdef NOT_A_GOOD_IDEA_CRUNCHED_BINARY 334 if (magic) { |
314 char *argv[100]; 315 i = 0; 316 argv[i++] = "crunch"; 317 argv[i++] = "sh"; 318 argv[i++] = "-c"; 319 argv[i++] = cmd; 320 argv[i] = 0; 321 exit(crunched_main(i,argv)); | 335 char *argv[100]; 336 i = 0; 337 argv[i++] = "crunch"; 338 argv[i++] = "sh"; 339 argv[i++] = "-c"; 340 argv[i++] = cmd; 341 argv[i] = 0; 342 exit(crunched_main(i,argv)); |
322 } else { | 343 } else { |
323 char *argv[100]; 324 i = 0; 325 argv[i++] = "crunch"; 326 while (cmd && *cmd) { 327 argv[i] = strsep(&cmd," \t"); 328 if (*argv[i]) 329 i++; 330 } 331 argv[i] = 0; 332 if (crunched_here(argv[1])) 333 exit(crunched_main(i,argv)); 334 else 335 execvp(argv[1],argv+1); 336 kill(getpid(),9); | 344 char *argv[100]; 345 i = 0; 346 argv[i++] = "crunch"; 347 while (cmd && *cmd) { 348 argv[i] = strsep(&cmd," \t"); 349 if (*argv[i]) 350 i++; 351 } 352 argv[i] = 0; 353 if (crunched_here(argv[1])) 354 exit(crunched_main(i,argv)); 355 else 356 execvp(argv[1],argv+1); 357 kill(getpid(),9); |
337 } 338#else /* !CRUNCHED_BINARY */ 339 execl("/stand/sh", "sh", "-c", cmd, (char *)NULL); 340 kill(getpid(),9); 341#endif /* CRUNCHED_BINARY */ 342 } 343 intsave = signal(SIGINT, SIG_IGN); 344 quitsave = signal(SIGQUIT, SIG_IGN); 345 pid = waitpid(pid, &pstat, 0); 346 (void)sigsetmask(omask); 347 (void)signal(SIGINT, intsave); 348 (void)signal(SIGQUIT, quitsave); 349 i = (pid == -1) ? -1 : WEXITSTATUS(pstat); | 358 } 359#else /* !CRUNCHED_BINARY */ 360 execl("/stand/sh", "sh", "-c", cmd, (char *)NULL); 361 kill(getpid(),9); 362#endif /* CRUNCHED_BINARY */ 363 } 364 intsave = signal(SIGINT, SIG_IGN); 365 quitsave = signal(SIGQUIT, SIG_IGN); 366 pid = waitpid(pid, &pstat, 0); 367 (void)sigsetmask(omask); 368 (void)signal(SIGINT, intsave); 369 (void)signal(SIGQUIT, quitsave); 370 i = (pid == -1) ? -1 : WEXITSTATUS(pstat); |
350 msgDebug("Command `%s' returns status of %d\n", cmd, i); | 371 if (isDebug()) 372 msgDebug("Command `%s' returns status of %d\n", cmd, i); |
351 free(cmd); 352 return i; 353} | 373 free(cmd); 374 return i; 375} |