{"id":446,"date":"2011-01-28T00:30:38","date_gmt":"2011-11-17T13:51:50","guid":{"rendered":"http:\/\/kraftek.com\/blog\/build-openssh-with-chroot-jail-patch-on-solaris-10\/"},"modified":"2011-01-28T00:30:38","modified_gmt":"2011-11-17T13:51:50","slug":"build-openssh-with-chroot-jail-patch-on-solaris-10","status":"publish","type":"post","link":"\/blog\/index.php\/build-openssh-with-chroot-jail-patch-on-solaris-10\/","title":{"rendered":"Build openssh with chroot jail patch on Solaris 10"},"content":{"rendered":"<p>The compiler is gcc version 3.4.5, from blastwave.<br \/>\nGot the sources for:<br \/>\nzlib-1.2.3<br \/>\nopenssl-0.9.8d<br \/>\nopenssh-4.5.1<br \/>\nUntar them all and apply the chroot patch &#8220;openssh-4.5p1-sshjail.patch&#8221; to openssh-4.5.1<br \/>\nBuild them in that order.<br \/>\nTo build zlib do:<br \/>\n# .\/configure &#8211;prefix=\/opt\/acsssh &#8211;shared<br \/>\n# make &amp;&amp; make install<br \/>\nTo build openssl:<br \/>\n# .\/config shared &#8211;prefix=\/opt\/acsssh<br \/>\n# make &amp;&amp; make install<br \/>\nTo build openssh<br \/>\n#.\/configure &#8211;with-pam &#8211;prefix=\/opt\/acsssh &#8211;with-ssl-dir=\/opt\/acsssh &#8211;with-zlib=\/opt\/acsssh<br \/>\n# make &amp;&amp; make install<br \/>\nTo build the chrooted jail i modded a script, jail.ksh, with contents:<br \/>\n#!\/usr\/bin\/ksh<br \/>\nJAILUSER=juser<br \/>\nJAILGROUP=jgroup<br \/>\necho &#8220;deleting previous structures&#8221;<br \/>\nuserdel -r $JAILUSER<br \/>\ngroupdel $JAILGROUP<br \/>\nrm -fR \/export\/home\/jail<br \/>\necho &#8221; deleted&#8221;<br \/>\nSDIR=opt\/acsssh<br \/>\n\/usr\/sbin\/groupadd $JAILGROUP<br \/>\nmkdir -p \/export\/home\/jail<br \/>\nchown root:$JAILGROUP \/export\/home\/jail<br \/>\nchmod 750 \/export\/home\/jail<br \/>\n\/usr\/sbin\/useradd -g $JAILGROUP -c &#8220;Jail user $JAILUSER&#8221; -d \/export\/home\/jail\/$JAILUSER\/export\/home\/$JAILUSER -s \/bin\/sh $JAILUSER<br \/>\nmkdir -p \/export\/home\/jail\/$JAILUSER<br \/>\n202\/433<br \/>\nchown $JAILUSER:$JAILGROUP \/export\/home\/jail\/$JAILUSER<br \/>\ncd \/export\/home\/jail\/$JAILUSER<br \/>\nmkdir etc<br \/>\nmkdir bin<br \/>\nmkdir usr<br \/>\nmkdir usr\/bin<br \/>\nmkdir -p $SDIR\/bin<br \/>\nmkdir -p $SDIR\/lib<br \/>\nmkdir -p $SDIR\/sbin<br \/>\nmkdir -p $SDIR\/etc<br \/>\nmkdir -p $SDIR\/ssl\/lib<br \/>\nmkdir -p $SDIR\/libexec<br \/>\nmkdir usr\/lib<br \/>\nmkdir usr\/platform<br \/>\nmkdir usr\/platform\/`uname -i`<br \/>\nmkdir usr\/platform\/`uname -i`\/lib<br \/>\nmkdir -p usr\/platform\/sun4u\/lib\/sparcv9<br \/>\nmkdir -p platform\/sun4u\/lib\/sparcv9<br \/>\nmkdir lib<br \/>\nmkdir dev<br \/>\nmkdir devices<br \/>\nmkdir devices\/pseudo<br \/>\ncd \/export\/home\/jail\/$JAILUSER<br \/>\nAPPS=&#8217;bin\/cp bin\/ls bin\/mkdir bin\/mv bin\/pwd bin\/rm bin\/rmdir bin\/sh&#8217;<br \/>\nfor i in $APPS; do<br \/>\ncp \/$i .\/$i<br \/>\nLIBS=`ldd .\/$i | awk &#8216;{print $3}&#8217;`<br \/>\nfor l in $LIBS; do<br \/>\nif [[ ! -d .\/`dirname $l` ]]; then<br \/>\nmkdir .\/`dirname $l` &gt; \/dev\/null<br \/>\nfi<br \/>\ncp $l .$l<br \/>\ndone<br \/>\ndone<br \/>\ncd \/export\/home\/jail\/$JAILUSER\/devices\/pseudo<br \/>\nmknod mm@0:zero c 13 12<br \/>\nmknod mm@0:null c 13 2<br \/>\ncd \/export\/home\/jail\/$JAILUSER\/dev<br \/>\nln -s ..\/devices\/psuedo\/mm@0:zero zero<br \/>\nln -s ..\/devices\/pseudo\/mm@0:null null<br \/>\ncd \/export\/home\/jail\/$JAILUSER<br \/>\nBINS=&#8221;lib\/ld.so. 1 $SDIR\/bin\/ssh $SDIR\/libexec\/sftp-server $SDIR\/sbin\/sshd $SDIR\/lib\/libz.so<br \/>\n$SDIR\/lib\/libcrypto.so.0.9.8 usr\/lib\/ld.so.1 usr\/lib\/nss_files.so.1 platform\/sun4u\/lib\/libc_psr.so.1<br \/>\nplatform\/sun4u\/lib\/sparcv9\/libc_psr.so.1&#8243;<br \/>\nfor i in $BINS; do<br \/>\ncp \/$i .\/$i<br \/>\ndone<br \/>\nmkdir -p \/export\/home\/jail\/$JAILUSER\/export\/home\/$JAILUSER<br \/>\nchown $JAILUSER:$JAILGROUP \/export\/home\/jail\/$JAILUSER\/export\/home\/$JAILUSER<br \/>\ntouch \/export\/home\/jail\/$JAILUSER\/etc\/passwd<br \/>\ntouch \/export\/home\/jail\/$JAILUSER\/etc\/group<br \/>\necho &#8220;$JAILUSER:x:`\/usr\/xpg4\/bin\/id -u $JAILUSER`:`\/usr\/xpg4\/bin\/id -g<br \/>\n$JAILUSER`::\/export\/home\/$JAILUSER:\/bin\/sh&#8221; &gt; \/export\/home\/jail\/$JAILUSER\/etc\/passwd<br \/>\n203\/433<br \/>\necho &#8220;$JAILGROUP::`\/usr\/xpg4\/bin\/id -g $JAILUSER`:$JAILUSER&#8221; &gt; \/export\/home\/jail\/$JAILUSER\/etc\/group<br \/>\necho &#8220;done!&#8221;<br \/>\nhere<br \/>\n!<br \/>\n204\/433<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The compiler is gcc version 3.4.5, from blastwave. Got the sources for: zlib-1.2.3 openssl-0.9.8d openssh-4.5.1 Untar them all and apply the chroot patch &#8220;openssh-4.5p1-sshjail.patch&#8221; to openssh-4.5.1 Build them in that order. To build zlib do: # .\/configure &#8211;prefix=\/opt\/acsssh &#8211;shared # make &amp;&amp; make install To build openssl: # .\/config shared &#8211;prefix=\/opt\/acsssh # make &amp;&amp; make [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-446","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=446"}],"version-history":[{"count":0,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/446\/revisions"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=446"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}