From 22489c69719c30f105503de899bbcdf1483fff84 Mon Sep 17 00:00:00 2001 From: hjp Date: Thu, 24 Jan 2002 11:00:02 +0000 Subject: [PATCH] chdir to / before execing program. --- obwrap/obwrap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/obwrap/obwrap.c b/obwrap/obwrap.c index 2bac387..3bb23ec 100644 --- a/obwrap/obwrap.c +++ b/obwrap/obwrap.c @@ -7,7 +7,8 @@ char obwrap_c_rcsid[] = * from such a script (e.g., oracle) will have open file descriptors * on /var/opt/omni, which is a bad thing. * This program closes all file descriptors except stdin and stdout, - * changes uid (if -u is given) and executes the specified program. + * changes uid (if -u is given), chdirs to the root directory and + * executes the specified program. */ #include #include @@ -84,6 +85,8 @@ int main(int argc, char **argv) { dup2(1, 2); + chdir("/"); + execv(argv[optind], argv + optind + 1); fprintf(nonstderr, "%s: could not exec %s: %s\n", cmnd, argv[optind], strerror(errno));