Operating System - HP-UX
1847587 Members
3529 Online
110265 Solutions
New Discussion

Re: chroot patch for openssh-3.5p1

 
Youlette Etienne_2
Regular Advisor

chroot patch for openssh-3.5p1

I am configuring an ftp server using Openssh and I need to have the chroot functionality. I downloaded the patch openssh-3.5p1-chroot-patch.tmaletic.txt (from another posting in the forums), but when I run the command:
patch session.c openssh-3.5p1-chroot-patch.tmaletic.txt

I get the following results:
Hmm... Looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** session.c.dist Wed Sep 25 20:38:50 2002
|--- session.c Tue Jan 14 14:55:45 2003
--------------------------
Patching file session.c using Plan A...
Hunk #1 failed at 1195.
Hunk #2 failed at 1247.
2 out of 2 hunks failed--saving rejects to session.c.rej
done

session.c.rej contains the following:

***************
*** 1195,1200 ****
void
do_setusercontext(struct passwd *pw)
{
#ifdef HAVE_CYGWIN
if (is_winnt) {
#else /* HAVE_CYGWIN */
--- 1195,1202 ----
void
do_setusercontext(struct passwd *pw)
{
+ char *user_dir;
+ char *new_root;
#ifdef HAVE_CYGWIN
if (is_winnt) {
#else /* HAVE_CYGWIN */
***************
*** 1245,1250 ****
# ifdef _AIX
aix_usrinfo(pw);
# endif /* _AIX */
/* Permanently switch to the desired uid. */
permanently_set_uid(pw);
#endif
--- 1247,1268 ----
# ifdef _AIX
aix_usrinfo(pw);
# endif /* _AIX */
+ user_dir = xstrdup(pw->pw_dir);
+ new_root = user_dir + 1;
+ while((new_root = strchr(new_root, '.')) != NULL) {
+ new_root--;
+ if(strncmp(new_root, "/./", 3) == 0) {
+ *new_root = '\0';
+ new_root += 2;
+ debug("Attempting to chroot to %s", user_dir);
+ if(chroot(user_dir) != 0)
+ fatal("Couldn't chroot to user directory %s: %s", user_dir, strerror(errno));
+ pw->pw_dir = new_root;
+ options.print_lastlog = NULL;
+ break;
+ }
+ new_root += 2;
+ }
/* Permanently switch to the desired uid. */
permanently_set_uid(pw);
#endif


Need much appreciated help on this.

Thanks

--Youlette
If at first you don't succeed, change the rules!
3 REPLIES 3
benoit Bruckert
Honored Contributor

Re: chroot patch for openssh-3.5p1

HI,
You should use gnu patch tool and not the patch tool distributed with HP-UX, On my side it solved many patching !!!
You can downlaod it at
http://hpux.connect.org.uk

I'm not sure it will solve, but may be ?
hth
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
Youlette Etienne_2
Regular Advisor

Re: chroot patch for openssh-3.5p1

Hi Benoit,

Thanks for your reply. I installed the gnu patch tool, but I get the same result.

/usr/local/bin/patch -p1 session.c osshChroot-3.5.diff.txt
patching file session.c
Hunk #1 succeeded at 67 with fuzz 2 (offset 9 lines).
Hunk #2 FAILED at 1207.
Hunk #3 FAILED at 1249.
2 out of 3 hunks FAILED -- saving rejects to file session.c.rej
If at first you don't succeed, change the rules!
Tim Maletic
Valued Contributor

Re: chroot patch for openssh-3.5p1

Are you running this against the 3.5p1 version of the OpenSSH sources? (If you build without the patch, and do a "ssh -V", what output do you get? What is the output of "grep RCSID session.c"?) -Tim