Tuesday, December 9, 2008

Samba, vfs_extd_audit module and syslog



Did you ever wanted to monitor samba shares? To know, who's opening what and when, who's deleting what?
That's a good thing to know. Every sysadmin should know which user deleted some public file - by accident of course ;-)
By default SAMBA offers extended logging system, setting "log level = 5" in smb.conf allows us to see what's happening to our files. But! It logs ALOT of crap that we don't need!

Samba comes with some default modules that we can use some of them are responsible for logging, ie, vfs_audit which logs opening, renaming, deleting creating, etc to syslog, vfs_extd_audit which do exacltly the same thing but to BOTH syslog, AND samba log file and third module - vfs_full_audit which is richer and more configurable version of vfs_audit. We can choose what to log and what to not (to syslog only tho :(), very nice thing. However in this case we just need to log file access. Logging should go to separate samba log files, not to syslog.
According to SAMBA documentation, we can turn syslog off by setting "syslog = 0" variable in smb.conf file. However it doesn't work for vfs_extd_audit module. This module also offers us the log level, documentation says that setting "log level = 0 vfs:X" where X=vfs_extd_audit log level, we can seperate the global log level, and module log level. However it doesn't work either! So basicly we are stuck with logging to both syslog and samba log files which waste our disk spacem and we don't want that.
I wrote a simple patch for latest version of Samba (3.2.5) which resolves those issues.
It can be downloaded at https://bugzilla.samba.org/show_bug.cgi?id=5956
To patch your Samba go to samba_src/source/modules and type patch -p0 < vfs_extd_audit.c.patch
Then recompile and enjoy! :)

Friday, April 11, 2008

Playing with Hibernate.

So recently I'm in love in JAVA (at least my girlfriend says that). I'm developing simple project for my company (because I'm bored). Swing based thing with Hibernate and mssql.
I've used annotations to map classes to db, very cool thingy. Gotta love that. Everything in one file, class and database mapping. Some genius invented this :D But lets get to the point.

Following the manual on hibernate page good thing to do is to create a HibernateUtil (or call it whatever) class to help us menage hibernate session. (http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html#tutorial-firstapp) So I've created it. But I don't wanna use mapping files in xml's, I wanna use Annotations, so what I need to change is

sessionFactory = new Configuration().configure().buildSessionFactory();
to
sessionFactory = new AnnotationConfiguration().buildSessionFactory();

Hibernate has couple of configuration methods.
- You can configure thru the code, eg.
sessionFactory = new AnnotationConfiguration()
.addPackage("test.animals") //the fully qualified package name
.addAnnotatedClass(Flight.class)
.buildSessionFactory()

- Configure thru hibernate.properties file. Altrought that method (as far as i know) cannot directly add/configure annotated classes.

- And the last but best method thru hibernate.cfg.xml file. It is the common way of using hibernate.cfg.xml for Hibernate configuration.
File is very flexible, and understandable.

All tutorials and manuals on hibernate.org tell that hibernate.cfg.xml is the best way of configuring hibernate.
But, they don't tell that if you'll be using AnnotationConfiguration that file ISN'T searched in classpath!

That gave me smth. to think about when i was wondering why my configuration file isn't parsed. I've tryied adding in do different folders, debugging my app and nothing.
Then I've came up with simple idea. I simply put path to my config file in creation of sessionFactory. So it looks like this.

sessionFactory =
new AnnotationConfiguration()
.configure("/hibernate.cfg.xml")
.buildSessionFactory();

And boom~! Everything works fine ;-)

Wednesday, February 13, 2008

Windows 2008 Enterprise RTM

So, yesterday I've installed win2k8 enterprise. First thing was that my DVD drive LG GMA 4082 don't read the MediaStore dvds, ouc! I went to my friend and copied it to "normal" disc.
Installation went smooth. It's Vista based isntall so you can partition your hdd, merge, resize etc. Very cool thingy. You have 60 days for activating the product. Enterprise full takes 10gb of hard disk space and alot of RAM! I've installed vista extensions, drivers for my ati card and nothing else (sound drivers installed automagically - WOW!) and i have 200mb ram free of my 1gb. I think i need to expand my ram, lol! I'll write more about this system when i get more into it. Hmm... how do you run aero? xD Does it even have aero? xD Looks cool, goes fast, we'll see in a year or so xD

Tuesday, February 5, 2008

Sony Ericsson P1i and internet via PC.

So I've recently bought brand new Sony Ericsson P1i. Fascinating mobile phone. I got the version w/o GPS but what the hell. I don't need it... now.

The phone is fine, allright. I don't wanna write how many functions it has.
First thing i wanted to do was internet in my phone. So I've took USB cable and plug it in.
I've synchronized my phone with... No wait! I did't synchronized it with Outlook 2007. It didn't worked! I did synchro it with Outlook 2003 in work but that's not that i want to do.
Outlook is ewwwwww so i used http://mobical.net. It work with most phones, works like a charm but... You need internet to access it. This could sound stupid but is there a point in storing contacts on Your hard drive? Yea I know. Service can go down, someone can hack it, you can loose ALL of your contacts and notes but telling the truth your hard drive can break too.

So the point is P1i needs internet access to store data on mobical. As i don't have my personal USB bluetooth (why? the one in my laptop broke) I used USB cable.
So SE PC Suite come with application called mRouter. What is it? Hard to tell... It's SUPPOSED to do NAT and give my phone internet access but... it just don't work. Ok. No, i didn't missconfigured it. I've tryied EVERYTHING and it just won't work. Blue light is on, state is connected but creating every type of connection on my P1i and configuring tons of serial ports in mRouter just don't work. If ANYONE knows a way how to connect this piece of crap with my lovely phone please let me know! And yes, i've read allmost everything on google.

I took my mom's USB bluetooth device, pluged in and installed BlueSoleil v1.5 or smth. Provied on a mini disc. I've connected my phone to it, paired and it works like a charm. OK now i want internet via bluetooth.
In BlueSoleil i choose My Services -> Properites -> Personal Area networking (PAN) and what i see? That i cannot click on "Access LAN Network"!! Why? I dunno... It's just gray... So I've tried to do MS ICS (Internet connection sharing) between my network and bluetooth network.
I've noticed that my P1i doesn't send any DHCP requests! OMG WHY!? I still don't know... but. I've configured a static IP, gateway, netmask DNS server and... it didn't worked. WTH!? When I tried to connect to internet on mobile PC asked if i agree i agreed ofcourse and... nothing. For no reason no packets where IN on PC bluetooth interface. I've fighted with it for another hour and ... lost.
Next thing to do was to download newer version of BlueSoleil and i got v.3.2.2.8. I installed it and.. OMG, I could click on "Access LAN Network"! YAY! So I did, restarted BS, my PC PAN adapter got IP address from my ethernet NIC. I set correct IP on P1i and IT WORKS! WOOOOOOHOOOOO! After couple minutes of internet surfing my PC got BSOD. I was like WTF!? I didn't saw BSOD for like 2 years (win xp pro). So I restarted my PC. After 2 more BSODs and couple of cigaretes I've uninstalled BlueSoleil (you cannot do this from emergency mode because the stupid windows installer won't start!). So my PC was back to normal and still no internet on P1i. I watched a movie, installed BlueSoleil 5.0.5 and there was no option "Access LAN Network" so I've unisntalled it and went to sleep.
At work I was goign to try again. And the chooise was BlueSoleil 3.2.2.8 witch crashes my home laptop. So at my desktop in work it works fine. Internet works fine, and everything works fine. I need to find the BSOD reason. Hmmm... Interesting.
I've just download UIQ3 SDK. I'd rather write in MIDP2.0 beacause i want to learn more JAVA but i don't offers so many, many cool things like UIQ3. We'll see. I'll for sure write something in JME.
BTW, Java iphonelock runs soooo slooooooow for me. gDesk isn't really that at all!
TWUIK is a thing that require a closer look but they don't want to give it to meh! Absurd! ;)
What i need is application like mouse gestures. Hmm... Maybe I'll write one? ;)