Ubuntu, Webmin and Samba for Windows and linux clients

Samba can be one of those things that causes a ton of headaches. It always feels like a huge slowdown when I get to the Samba portion of my media server install. This time I decided to check out using Webmin for my samba configuration and I was pleasantly surprised with how easy it made some of the configurations.

I will hit on the major things to be noted here, firstly the idea of separate samba and system users. You can set up synchronization between these so that when a user is created it gets added to the smbpasswd file also. I created my system users earlier and converted them to samba users, so the synchronization didn’t do me any good for my original user set. New users will be created in the smbpasswd file correctly. In any case, the current users I had did not have the password hash information in the smbpasswd file. An example looks like this: Read the rest of this entry »

Fuzz Testing for Reliability

In a course on writing secure software here at University we looked into the practice of fuzz testing. That is, generating arbitrary information to be used as inputs for software. Apparently this is a very high cost:benifit practice in secure software development and testing.

Around 1990 the National Science Foundation provided grants for research regarding operating systems reliability testing, one culmination of efforts was presented in a paper written by Barton P. Miller, Lars Fredriksen and Brian So; (Paper). In this work the claim was made that many of the assumed reliable operating system utilities could be broken using the basic technique of fuzzing:

Operating system facilities, such as the kernel and utility programs, are typically assumed to be reliable. In our recent experiments, we have been able to crash 25-33% of the utility programs on any version of UNIX that was tested. This report describes these tests and an analysis of the program bugs that caused the crashes.

For our purposes we created a quick program in C, and used a simple bash scripting test bench to perform many iterations of each test:

fuzz — Source for the fuzzer, used by the following script. Very limited functionality, by no means is this a product for use in any setting other than academic investigation.

Read the rest of this entry »

Fitting and AOC-USAS-L8i in a PCIe slot (UIO to PCIe)

One of the recent server upgrades called for the purchase of raid controller cards. I use software raid in Linux for its versatility and the L8i controllers can perform in hba (Host Bus Adapter) mode. These cards ship with Supermicro’s IT mode firmware which essentially lets all of the drives show up independently in linux.

Before I could see all that, I needed to get these cards into my case. Don’t be too upset when you first try to slide this card into your case and mobo (I have a Norco 4220 and Gigabyte EP45-UD3P) they will not fit at all. It appears as if the bracket is off on the Y axis by about a quarter inch, this is because these cards are UIO form factor.

Establishing my frame of reference

Establishing my frame of reference

This can easily be resolved with some longer screws and nylon spacers. Be sure to use the original brackets as buying new brackets was really hard to figure out (If anyone knows the exact bracket for this then please let me know).

Using quarter inch nylon spacers for number ten machine screws (need to verify)

Using quarter inch nylon spacers for number ten machine screws (need to verify)

We used two spacers on each of the ‘posts’, it appeared that this resolved the issue as we got a good solid fit for both of the cards.

Power Monitoring with APCUPSD, Email using SSMTP and Google Apps

Recently I performed a large upgrade to my raid file-server, the information being stored is much more critical at this point in time and I have chosen to step up the game in four ways:

  1. Move from on-board Intel controller to dual LSI L8i 8channel hba controllers
  2. Move from raid5 to raid6
  3. Install an APC UPS and monitor it with apcupsd
  4. System monitoring with email alerts via mdadm and Google SMTP

(Sorry for re-iteration if you are following the feed, trying to establish context)

The apcupsd tool lets you connect to your UPS and control when the machine shuts itself down during a scenario where you loose power. Another really nice thing this will do is allow you to send yourself an email through whatever MTA you set up.

The difficult part of getting email setup is configuring a MTA (Mail Transfer Agent). I searched for quite a while on how to get this setup. My initial impression was that I would have to host my own via postfix or some other alternative. I was happy to find that I could use a much more lightweight solution with ssmtp and an email I created from my google apps account.

Install ssmtp

sudo apt-get install ssmtp

Configure ssmtp via its config file /etc/ssmtp/ssmtp.conf

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=serveremailaddress@yourgoogleappsdomain.tld

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=servername.yourgoogleappsdomain.tld

# Are users allowed to set their own From: address?
# YES – Allow the user to specify their own From: address
# NO – Use the system generated From: address
#FromLineOverride=YES

UseSTARTTLS=YES
UseTLS=YES
AuthUser=serveremailaddress@yourgoogleappsdomain.tld
AuthPass=password

Now for a test of ssmtp, create a test file with some text in it. My test file was called ‘test’:

ssmtp youremail@yourgoogleappsdomain.tld < test

For apcupsd we need to modify two files to set our email address up for alerts. They are both located in the /etc/apcupsd directory and are called ‘onbattery’ and ‘offbattery’. I would suggest to leave these as they are because if you set up ssmtp like I have, when an email comes in for root it will be sent on to the ssmtp root address.

Now unplug your UPS and wait for the emails to come!

RAID Monitoring with MDADM, Email using SSMTP and Google Apps

Recently I performed a large upgrade to my raid file-server, the information being stored is much more critical at this point in time and I have chosen to step up the game in four ways:

  1. Move from on-board Intel controller to dual LSI L8i 8channel hba controllers
  2. Move from raid5 to raid6
  3. Install an APC UPS and monitor it with apcupsd
  4. System monitoring with email alerts via mdadm and Google SMTP

Software raid tool mdadm has monitoring functionality that is easily configured through the /etc/mdadm/mdadm.conf file. You simply need to specify an email address under the MAILADDR property. I would suggest to leave this as root, because with ssmtp you are going to set the email address for everything routed to root.

The difficult part of getting email setup is configuring a MTA (Mail Transfer Agent). I searched for quite a while on how to get this setup. My initial impression was that I would have to host my own via postfix or some other alternative. I was happy to find that I could use a much more lightweight solution with ssmtp and an email I created from my google apps account.

Install ssmtp

sudo apt-get install ssmtp

Configure ssmtp via its config file /etc/ssmtp/ssmtp.conf

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=serveremailaddress@yourgoogleappsdomain.tld

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=servername.yourgoogleappsdomain.tld

# Are users allowed to set their own From: address?
# YES – Allow the user to specify their own From: address
# NO – Use the system generated From: address
#FromLineOverride=YES

UseSTARTTLS=YES
UseTLS=YES
AuthUser=serveremailaddress@yourgoogleappsdomain.tld
AuthPass=password

Now for a test of ssmtp, create a test file with some text in it. My test file was called ‘test’:

ssmtp youremail@yourgoogleappsdomain.tld < test

Test mdadm

sudo mdadm –monitor –scan –test

Everything should be set to go now, hopefully you wont ever need to be notified of a failure.

Known Issue

Using ssmtp with Google’s smtp is great, however if you use special characters in your email password ssmtp will not be able to authenticate. I ran into this and saw the following error:

ssmtp: Authorization failed (454 4.7.0 Cannot authenticate due to temporary system problem. Try again later. 14sm88672bwz.5)

This was promptly resolved by my choosing a password without special characters.

Creating a Custom EditForm for a SharePoint List

There is a saying that goes “when you have a hammer, everything looks like a nail”. In the case of SharePoint lists sometimes they get carried away fromĀ  their designed nature and used to store massive data sets. The more columns loaded into a list, the slower it typically performs. This is especially the case for ‘lookup’ columns which may query lists other lists (or even itself) and return a massive data set that needs to be rendered as user controls.

Once traveled down this road the only preventative maintenance you can do is clean up and move your data to another location (relational database) or create some custom forms for your users to access. These forms can display a subset of the lists fields so that a user may be access something more performant for their purposes. This is a very simple task when you realize how to do it, screen shots will explain this quite quickly: Read the rest of this entry »

Customizing the SharePoint List Menu Bar

Microsoft’s SharePoint services are very good at meeting some generalized needs for information storage and organization. I won’t go down the rabbit hole of discussing how SharePoint lists should never be used to represent data that is inherently relational. Given that you can get a site up and running in a matter of seconds it is very difficult to customize and extend the out of box functionality. One particular need people might have when using SharePoint lists is to modify the default menu buttons. In particular we created several new display and edit forms for a monolithic list we were using, we needed a way to let users navigate to these customized pages.

In this article I will explain how to take the standard menu bar like this:

StandardMenuBar

Standard menubar might not provide enough functionality.

Through post-processing DOM Manipulation accomplish something like this:

CustomizedMenuBar

Added new buttons, removed one, and created a second row.

I tried to write these customization scripts in a manner that would allow for them to re-usable by someone else for the same purposes. They are separated into two files, one is a toolkit containing common functions used through this hack and the other is the actual ‘main’ which contains all page specific information.

Firstly lets look at where to put the code in at; every list creates a DispForm.aspx which is filled with bunches of <asp:content> tags. We need to put a link to the javascript customization files in between on of these <asp:content> tags to make sure it gets executed on the users page. For my purposes I put the calls inside the the “PlaceHolderTitleAreaClass” like this:

<asp:Content ContentPlaceHolderId=”PlaceHolderTitleAreaClass” runat=”server”>
<script id=”onetidPageTitleAreaFrameScript”>
document.getElementById(“onetidPageTitleAreaFrame”).className=”ms-areaseparator”;
</script>
!– Call to the Customization Script –>
<script src=”http://prod.servername.intranet.local/resources/script/toolkit/toolkit.js”>
<script src=”http://prod.servername.intranet.local/resources/script/sharepoint/customization.js”>
!– End Call to Customization Script –>
</asp:Content>

You can see here I am linking to my javascript toolkit, which has many of the common functions I use, and the particular pages customization script. First lets look at the customization script. This will help you to see what I am doing on the page, I caution you however that this will appear as an extreme hack… mainly because it is.

customization.js — Download this file and I will explain what I am doing as you read through.

iD is a variable that we are storing to represent aspx pages overall ID.

source is a variable that we are going to store the return address for any of the links that we are building.

tableID variable is the specific html id of the table that we will be manipulating, this has to be hard coded in the customization file. Basically you need to find the parent table of the control we are modifying, I will leave you to figure this out.

We are going to get the html element table and start modifying the dom. From here on you should be able to see how iterated through using two worker functions; addButton and addSeperator.

toolkit.js — Download this file and I will explain what I am doing as you read through.

The functions and their comments should be most likely self explanatory except for addButton which might look quite daunting. This is because I tried to follow the convention of how they have created the container for buttons. I nested the concatenation like the html should appear for readability, but to me it still looks like junk and I wrote it.

So, in recap we essentially are hacking up the menu item on each client after the page loads. This is a nasty hack in my opinion and I would much rather have modified the actual control, however the way that SharePoint was designed makes it very difficult for a developer who doesn’t have access to the whole production environment. Over a period of about a year we didn’t see any data corruption from building out the aspx links in this manner, I would consider this hack safe for the data in your list and unobtrusive enough that someone with limited access (ex. SharePoint Desginer) can get it in place.

Install (Set up) Aptana Studio on Ubuntu x64 Revisited

Aptana Studio just updated to version 1.5, this means great things for the native linux users! Now all you need to do is simply extract the tar some place and run the AptanaStudio script. For my purposes I extracted the tar to my desktop then:

sudo mv ~/Desktop/Aptana\ Studio\ 1.5/ /usr/local/aptana
sudo ln -sf /usr/local/aptana/AptanaStudio /usr/local/bin/aptana

Now you can run Aptana Studio by typing ‘aptana’ in your terminal or create a nice menu icon for the program. Happy developing!

O/R Mapping with the iBATIS Framework and iBATOR (iBator, MySQL, Spring)

When working on a software system that is backed by a persistence layer such as a database the developers need to mitigate that connection through some means. Object-relational mapping gives developers the ability to interact with an object instead of sql queries, stored procedures or something else.

The iBATIS framework provides data mapping in a simple and flexible manner and mitigates the transfer of data between your objects and relational database. You can use the full power of SQL without writing a single line of JDBC code. With iBATIS data access objects you can abstract the persistence implementation of your application. Coding to the DAO’s provided by iBATIS will enable your project to be dynamically configured to use different persistence mechanisms through one common interface.

iBator is a code generator for iBATIS. It will introspect a database schema and generate iBATIS artifacts. iBator can be run as a plugin for eclipse, once configured to the database any changes in tables can be quickly enveloped in the iBATIS layer by simply running the iBator generator over the changed database (can also be run as an ant task or a stand alone JAR).

For this project we will be working with Eclipse, iBator, MySQL and Spring. I will be using an example project that I am working on with some friends codenamed ‘chapplet’.

Read the rest of this entry »

Disable PC Speaker on Ubuntu

Recently did an install on my girlfriends laptop of Ubuntu 9.04 (E1705) . Everything went really well excpet for the obnoxious PC Speaker beeping all time. So to disable this guy you need to edit the blacklist file:

sudo nano /etc/modprobe.d/blacklist.conf

Now you need to add this at the bottom so that your computer wont load the pcspkr module next time it boots:

# Damn PC Speaker is annoying
blacklist pcspkr

Restart the machine and you wont hear that obnoxious beeping anymore!

OR Remove the Module

You can also remove the module as was pointed out below. This may be a better solution because you do not have to restart and it takes immediate effect.

sudo rmmod pcspkr