Showing posts with label opensolaris. Show all posts
Showing posts with label opensolaris. Show all posts

Wednesday, May 02, 2007

SSH Tunnels

SSH allows us to play some tricks with the local ports and enable ssh tunnels for port forwarding. This allows for some nifty tricks in restricted corporate environments, to access the real world wide web and nothing else ofcourse.

There is small nuance while configuring ssh tunnels. The tunnels are bound to the localhost:portnum. Now trying to access localhost_ip:portnum doesnt resolve to the same port (remember a port is always referred to as a combination of ip+portnum).

127.0.0.1:605 = localhost:605 != localhost_ip:605

This is because [ man ssh(1) ] while doing port forwarding

-L port:host:hostport
Specifies that the given port on the local (client) host
is to be forwarded to the given host and port on the
remote side. This works by allocating a socket to listen
to the port on the local side. Then, whenever a connec-
tion is made to this port, the connection is forwarded
over the secure channel and a connection is made to host
port hostport from the remote machine. Port forwardings
can also be specified in the configuration file...


Now what if you want to use the localhost_ip:port instead then [ man ssh(1) ]

-g
Allows remote hosts to connect to local forwarded ports.


Chillax... Have fun

Thursday, April 26, 2007

Some OpenSolaris Annoyances

1) There is no -R option in most of the basic shell utilities. Yeah I know I can always download the gnu equivalent too.
2) 64 bit libraries are placed in /lib/am64. This is crappy especially when you are compiling from source and most configures would expect the libpath to end at /lib
3) Too man locations for libs and binaries. We have /usr/[bin,lib] /usr/local/[bin,lib] /opt/csw/[bin,lib] /usr/sfw/[bin,lib]. Worse most of them are not included in the path by default, we need to set them up.
4) Compilations on 64 bit systems dont generate 64bit binaries by default
5) Even the Sun Studio compilers use dumb options for default... remember stlport. Comeon guys.

Maybe we are sacrificing a lot for ensuring backward compatibility. At the end of the day we need to assure that we have a easily usable system.

Note: Binary compatility rocks but maintaining everything just doesnt seem to make sense. After all how many people use Solaris 7 binaries on Solaris 10.

Tuesday, April 03, 2007

OpenSolaris Custom Search Engine

Sitting idle I just went ahead and created a custom search engine for OpenSolaris on the Google Co-op website

OpenSolaris Custom Search

I've just added some 17 sites that I find useful for my solaris problems. Will add more as I go along and if I get some inputs from anyone.

Cheers

Wednesday, March 28, 2007

Opensolaris installed. What next?

Done with the solaris installation and want to play around now. Here are some of the sites that I use to learn more about my favourite OS.
http://developers.sun.com/sunstudio/articles/amd64_migration.html - tips on migrating code from x86 to x64 and some tips on moving from gcc to sunstudio
http://blogs.sun.com/rie/date/20061219 - on why ld cant exactly locate _init and _fini
http://blogs.sun.com/sga/ - tips and tricks for getting boost c++ libs going
http://forum.java.sun.com/thread.jspa?threadID=5075258&messageID=9274275 - getting started with dtrace on available binaries
http://prefetch.net/articles/dtracecookbook.html - collection mechanisms/tools and what do they exactly display
http://blogs.sun.com/brendan/ - brendan gregg's cool dtrace toolbox and all his other gyan on zones, zfs and more
http://solaris.reys.net/english/categories/3-DTrace/P4.html - cool dtrace guy with some nift tricks other than those from Brendan Gregg


Thursday, February 08, 2007

Adding a second SATA disk

Here is the sundocs link that tells you what all is needed to be done for adding a new disk on your machine.

Step-by-Step:
- Connect your disk on your motherboard
- open a terminal and login as superuser
% format
(choose the new disk)
format> fdisk
(create your partitions here and save before exiting ie choose 5)
format> parition
partition> print
partition> modify
(modify your partitions and note down the serial numbers)
partition> quit
format> quit

Now you have the serial numbers of the disk that you just worked on
% newfs
% mount

Hope this helps... Now to playing with zfs

Wednesday, February 07, 2007

OpenCV on OpenSolaris

I had some problems getting OpenCV working on OpenSolaris.

Finally found a solution. Just do a
./configure AR=ar
else
./configure && make AR=ar

Couldn't find any link for OpenCV on OpenSolaris/Solaris so hope this helps people who are trying this out.

Technorati Tags: , ,

Saturday, September 23, 2006

Google testing OpenSolaris

There are rumors running all over the place that Google is Testing Sun's OpenSolaris. In fact even digg featured the article and the comments are quite interesting. Now leaving out the Linux fanatics who seem to be blindfolded in their love for their OS the reasonable amongst them can argue about the benefits about it. Now that would be a really fruitful discussion, which unfortunately never happens. Most threads of this nature are dominated by the "I am good and all else is bad" comments.

But taking a look at this from an unbiased perspective (I am really trying to be unbiased here) Google can seriously benefit from a lot of what OpenSolaris has to offer.

OpenSolaris is a BSD variant
All Unix and Linux faithful can't deny the fact that the BSD variants are for some reason the more sturdier class of *nixes. Be if FreeBSD, NetBSD, OpenBSD, Solaris of Apple's Darwin all of these have been very successful on high end systems. And high end today does not mean high cost but its more in terms of their scale. The up times shown by Solaris servers are legendary in their own right. And ofcourse now OpenSolaris is Trusted by default.

OpenSolaris has the bells and whistles
Dtrace, Zones, Zfs, FMA, x64 support and a lot more. Sun has gone all out while developing Solaris and has gone ahead and released all of this as OpenSolaris. Yes they are currently using the same code base for both, Solaris and OpenSolaris. So someone like Google can benefit by using zfs and scaling their mhamoth data centers even further while running dtrace to figure out the real time patterns in usage and code segments. So catch those algorithms while they are lazing around or eating more resources and improve them.

OpenSolaris provides for binary compatibility
Now I am sure Linux guys dint know what that means but it has been an assurance given by Sun on all Solaris systems for nearly 2 decades or more now. And hey its not just OpenSolaris that will let you maintain binary compatibility but because of the way the code is structured there should be no reason why this guarantee shouldn't be maintained between OpenSolaris variants as well.

OpenSolaris is Open
Ignore GPL devotees. If you don't like CDDL tough luck. But even with CDDL in place Google can go ahead and create a custom version of OpenSolaris for themselves and deploy it all over and heck even redistribute it if they like. Golaris sounds kiddish but well you never know:)

Suggestion to Google: Use Niagara ie USIV+ processors
The Niagara family of processors are targetted at customers such as Google that need a higher throughput on their front ends. With 8 cores and 4 threads per core in the Niagara1 family these processors can go ahead and eat up web queries on the Google website while the back end servers churn up the results. And NO the cost of the Niagara based systems is not prohibitive at all. In fact you could compare them with many desktop processors while comparing the cost/GHz and well the beat all of them in the cost/watt category. Am sure Google will be thinking about energy costs in the huge facility that they are supposedly coming up with in collaboration with the US government.

Well Netcraft shows gmail running some servers on Solaris 8 already. So I guess in a couple of months we should know if these rumors have any meat in them at all. And yeah being realistic even if Google adopts OpenSolaris it will be for very specific reasons. Their deployment of Linux is humongously distributed and very customized, from what I have heard. So we wont see them going on OpenSolaris 100% in the near future. And of course they too will have to douse off the in house Linux flame throwers too right. That may be the toughest challenge!

Well moving to OpenSolaris will simply mean that Google is definitely not resting on its laurels and is in constant search of whatever will let it improve further.


Technorati Tags:

Tuesday, September 19, 2006

Nevada on VMWare

It's really exciting to see OpenSolaris build 46 ie Nevada running smoothly on my laptop inside a VMWare workstation environment. I have dedicated 8GB and 512Mb RAM to its running instance and hopefully it will suffice. The main idea here is to keep up to speed with the new features being constantly integrated into Nevada while still doing my routine job. It was so much more fun while doing all this on the 7th floor of Divyasree chambers (Sun Microsystems IEC Bangalore)

Anyways the setup procedure in VMWare turned out to be pretty straightforward. The only hiccup was when selecting the disk for the installation. You actually need to uncheck and recheck the box again and only then things go on smoothly.

I have used VMWare a couple of times before and it seems to work alright most of the times. However there is a new kid on the block called Parallels and there were these rave reviews about it some time ago. Hope I can check that out sometime soon too.

For VMWare there is this wonderful set of slides on how to go about doing this right here. So there is no reason not to be running OpenSolaris even if you can't dedicate a complete box for it. Get onto the train now!

Technorati Tags:

Tuesday, August 08, 2006

DTrace on OSX

Well I haven't formatted my previous post correctly as yet but this news is just too good to keep out.

MacOSX Leopard will have inbuilt support for DTrace and that too within XCode.

Now for those of you who haven't used OSX, guys you haven't seen a true and complete OS yet, ah if only it used OpenSolaris as its choice of BSD platform it would be a marriage made in heaven, with Solaris powering the hardware while Aqua playing the sweet enchantress for the common user and ofcourse having the luxury of running the best and advanced version of Microsoft Office. And all that on the new and improved low-power Intel beasts. Come in VMWare and Parallels to create such sweet harmony that could make the tech gods dance.

But for now congrats to Team DTrace and the guys at Apple for recognising the beauty of the beast that is DTrace.

Tehcnorati Tags: , ,, , , , ,

Monday, August 07, 2006

Stack Overflows in SPARC

Causing and Thereby Avoiding Sparc stack overflows
--------------------------------------------------

Have been hitting my head against the screen to get an
understanding of the overflow problem on a sparc machine.
Ran into some pretty good examples but it took me some
time to get a good grip on the way to do this.

for the 32bit version of things
===============================
sample program from http://blogs.sun.com/peteh

main()
call x();
x()
call y();
y()
int a[1];
a[20]=0


now why would this corrupt the stack and

which stack and
what part of the stack?


Let me try to answer these questions the best I can

PSEUDO-CODE ASSEMBLY
main() save %sp,... %fp=%sp
call x(); call x %o7=pc
x() save %sp,... %fp=%sp
call y(); call y %o7=pc
y() save %sp,... %fp=%sp
int a[1];
a[20]=0


definition int a[1];
What makes this offset 20 special?
Look at the .s file it should show you an offset of the a[] array
in mine it was showing these two lines for a[20]=0

add %fp,-20,%l0
st %g0,[%l0+80]


Thus it shows that a is pointing to fp-20


HigherAddr

fp of x() ----------------------
fr_argx[1] _____________________________
fr_argd[6] |nothing else coz there are no|
fr_stret |local variables etc in x() |
frame.h fr_savpc -----------------------------
from fr_savfp this is the registerw of main()
fr_arg[6]
fr_local[8]
fp of y() ----------------------
fp-20 a <---array a
register window of x
is saved here
current sp ----------------------

LowerAddr

so at fp you have fr_local %l0-%l7
at fp+8 you have fr_arg %i0-i5
at fp+14 you have fr_savfp %i6
at fp+15 you have fr_savpc %i7 <-----return addr

so the return address offset from a[] is
= +(20B+(15*4B))
= +60B
= +(20*4B)

so offset a[20] messes up the i7 for main and thereby the fault


now for the 64bit version of things
===================================
definition long a[1];
the assembly code shows

or %g0,1,%l3
add %fp,1991,%l1
stx %l3,[%l1+176]

so the array a is at fp+1991. Note the v9 arch specifies a 0x7ff stack bias
so this is within the stack even though you are adding to fp.

So where exactly is %o7 ?
Well 2047-1995 = 52B from the fp

fp+2047 -------------------

fp+1995 a


fp -------------------

the return address offset from a[] is

= +(52B+(15*8B))
= +172B
= +(22*8B)

so offset a[22] should corrupt i7 for main and cause a fault


So here we have managed to overwrite the %i7 register which stores
the return address. We have corrupted the stack of the x() function
so it cannot return correctly.




Sidenote: save instruction
Notice that most of the save instructions put in 96 bytes for the
stack. Why is that?

current sp ---------------------------------
%i0-%i7 and %l0-%l7

(input and local vars)


sp+64 --------------------------------- <- why 64? *A
hidden parameter
---------------------------------
%o0-%o5

(store first 6 params just in
case the params are passed by
addr and not by value)
sp+92 ---------------------------------
padding to be aligned
sp+96 --------------------------------- <- why pad? *B


*A - why 64? - 8*2 registers = 8*2*(8bytes ie 4 locations) = 64
*B - why pad> - this is SPARC land
refer this link http://www.cs.unm.edu/%7Emaccabe/classes/341/labman/node12.html
thats all!

Technorati Tags: , ,