diff -r c85643dd7164 -r 45ea57d83f28 librazor/rpm.c --- a/librazor/rpm.c Thu Jan 08 13:51:07 2009 +0000 +++ b/librazor/rpm.c Thu Jan 08 14:35:18 2009 +0000 @@ -567,7 +567,11 @@ run_script(struct installer *installer, unsigned int program_tag, unsigned int script_tag) { +#if HAVE_CHROOT int pid, status, fd[2]; +#else + FILE *fp; +#endif const char *script = NULL, *program = NULL; program = razor_rpm_get_indirect(installer->rpm, program_tag, NULL); @@ -575,9 +579,21 @@ if (program == NULL && script == NULL) { return 0; } else if (program == NULL) { +#if MSWIN_API + program = getenv("COMSPEC"); + if (program) { + program = strchr(program, '='); + if (program) + program++; + } + if (!program) + program = "c:\\windows\\system32\\cmd.exe"; +#else program = "/bin/sh"; +#endif } +#if HAVE_CHROOT if (pipe(fd) < 0) { fprintf(stderr, "failed to create pipe\n"); return -1; @@ -621,6 +637,14 @@ if (status) printf("script exited with status %d\n", status); } +#else + fp = popen(program, "w"); + if (fwrite(script, strlen(script), 1, fp) != 1) { + fprintf(stderr, "failed to pipe script, %m\n"); + return -1; + } + pclose(fp); +#endif return 0; }