From 89ff899810b06bf0cc502dbe311765d85d0c8eed Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 13 Apr 2011 02:01:50 +0000 Subject: [PATCH] 2011-04-13 04:01 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbunix/chroot.c ! following suit with the others functions, on error, errno should be saved. + further, in about 101% of the cases, chroot() is to be followed by a chdir("/"), so i think it would be right to include this right here. ; [Tamas Tevesz] --- harbour/ChangeLog | 8 ++++++++ harbour/contrib/hbunix/chroot.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b0c6d42796..71a8019a3a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2011-04-13 04:01 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbunix/chroot.c + ! following suit with the others functions, on error, errno should be + saved. + + further, in about 101% of the cases, chroot() is to be followed by a + chdir("/"), so i think it would be right to include this right here. + ; [Tamas Tevesz] + 2011-04-13 02:09 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + contrib/hbunix/chroot.c * contrib/hbunix/hbunix.hbp diff --git a/harbour/contrib/hbunix/chroot.c b/harbour/contrib/hbunix/chroot.c index b2f94782bb..fc82bd2987 100644 --- a/harbour/contrib/hbunix/chroot.c +++ b/harbour/contrib/hbunix/chroot.c @@ -54,5 +54,16 @@ HB_FUNC( UNIX_CHROOT ) { - hb_retni( chroot( hb_parcx( 1 ) ) ); + if( chroot( hb_parcx( 1 ) ) == -1 ) + { + hb_posix_save_errno(); + hb_retni( -1 ); + } + else if( chdir( "/" ) == -1 ) + { + hb_posix_save_errno(); + hb_retni( -1 ); + } + else + hb_retni( 0 ); }