Blog

Notes from the field in Seattle: technology, the water, the kitchen, and the kids.

Korean BBQ - Galbi

IMG_0042.jpg

Ingredients


1 pound rib eye, sliced through the bone
2 tablespoons brown sugar
2 tablespoons soy sauce
1 tablespoon saki
2 teaspoons sesame oil
5 cloves crushed garlic
fresh ground black pepper


Place ingredients in large mixing bowl and mix well. Add Rib Eye and coat evenly. Marinate for at least 2 hours, overnight is better! Cook on hot a charcoal grill, gas is for the weak!

Special Modes

The 'chmod' command is short for change mode. It allows the administrator to set the permissions and special modes for directories and files.

The 'chmod' command accepts up to four digits to represent an octal number. This allows you to set the setuid, setgid, and sticky modes via the first digit.

Most of us are familiar with the following command.


chmod 755 file


Since the setuid, setgid, and sticky bits are not set, this is equivalent to the following.


chmod 0755 file


The setuid mode sets the user id, which is used on executable files to allow the executable file to be run as the file owner of the executable rather than as the user logged into the system. It can also be used on a directory to change the ownership of files created in or moved to that directory to be owned by the directory owner rather than the user who created it.

The setgid mode sets the group id, which functions similar to that of the setuid mode yet applies to groups instead.

The sticky mode is used for shared directories to prevent users from renaming or deleting each other's files. The only users who can rename or delete files in directories with the sticky bit set are the file owner, the directory owner, or the super-user (root). The sticky bit is represented by the letter t in the last position of the other permissions display.

Here are a few examples.


mkdir test
chmod 777 test
chmod t test
ls -l

drwxrwxrwt 2 admin photography 4096 Apr 01 12:00 test


This is equivalent to the following.


mkdir test
chmod 1777 test
ls -l

drwxrwxrwt 2 admin photography 4096 Apr 01 12:00 test


Lets take this one step further. Lets say we needed a directory which other users could create or move files into. We also wanted those files to default to a specific username and group. This is where the setuid and setgid options come in.


mkdir test
chmod 777 test
chmod u s,g s test
ls -l

drwsrwsrwx 2 admin photography 4096 Apr 01 12:00 test


This is equivalent to the following.


mkdir test
chmod 6777 test
ls -l

drwsrwsrwx 2 admin photography 4096 Apr 01 12:00 test


Now anyone may create or move files into this directory and they will become owned by adrian and the group photography.

MediaWiki LDAP Authentication

MediaWiki is a free web-based application that allows you to run your own Wikipedia styled site. A wiki is usually open to all so groups may collaborate within a project freely. Sometimes an enterprise needs it's wiki locked down to authenticated users only hence the need for an authentication mechanism such as LDAP.

LDAP is the Lightweight Directory Access Protocol and in this example we will be using Windows Server's Active Directory Database to authenticate valid users. The scope of this post only covers how to implement LDAP into an already installed and running MediaWiki with Ubuntu Server 10.10.

First we'll navigate to the MediaWiki directory. The actual location may vary so please keep that in mind.


cd /var/lib/mediawiki


Next we'll edit LocalSettings.php with your favorite text editor.


sudo vi LocalSettings.php


Add the following lines adjusted to fit your domain.


require_once( "$IP/extensions/LdapAuthentication/LdapAuthentication.php" );

$wgAuth = new LdapAuthenticationPlugin();
#### Uncomment this line to see debug messages:
#$wgLDAPDebug = 10;
$wgDebugLogGroups["ldap"] = "/tmp/ldap.log" ;
$wgLDAPDomainNames = array('your_domain.com' );
$wgLDAPServerNames = array('your_domain.com' => 'hostname.your_domain.com' );
$wgLDAPEncryptionType = array('your_domain.com' => 'ssl' );
$wgLDAPUseSSL = array('your_domain.com' => true );
$wgLDAPBaseDNs = array('your_domain.com' => 'dc=your_domain,dc=com' );
$wgLDAPSearchAttributes = array('your_domain.com' => 'sAMAccountName' );
$wgLDAPUseLocal = true;
$wgMinimalPasswordLength = 1;
$wgLDAPProxyAgent = array("your_domain.com" => "CN=LDAP Lookup,CN=Users,DC=your_domain,DC=com" );
$wgLDAPProxyAgentPassword = array("your_domain.com" => "supersecretpassword" );
$wgLDAPUpdateLDAP = array("your_domain.com" => false );
$wgLDAPAddLDAPUsers = array("your_domain.com" => false );
#$wgLDAPRetrievePrefs = array("your_domain.com" => true );
$wgLDAPPPreferences = array("your_domain.com" => true );

$wgLDAPGroupUseFullDN = array("your_domain.com" => true );
$wgLDAPGroupObjectclass = array( "your_domain.com" => "group" );
$wgLDAPGroupAttribute = array( "your_domain.com" => "member" );
$wgLDAPGroupMemberOfAttribute = array( "your_domain.com" => "memberof" );
$wgLDAPGroupSearchNestedGroups = array( "your_domain.com" => true );
$wgLDAPGroupNameAttribute = array( "your_domain.com" => "cn" );
$wgLDAPUseLDAPGroups = array( "your_domain.com" => true );
#$wgLDAPGroupsUseMemberOf = array( "your_domain.com" => true );

#### restrict to logged in users only
#$wgGroupPermissions['*']['edit'] = false;
#$wgGroupPermissions['user']['edit'] = false;
#$wgGroupPermissions['Domain users']['edit'] = true;
#$wgGroupPermissions['*']['read'] = false;
#$wgGroupPermissions['user']['read'] = true;
#$wgGroupPermissions['Domain users']['read'] = true;
#$wgGroupPermissions['*']['createaccount'] = false;

$wgWhitelistRead = array( "Special:Userlogout", "Special:Userlogin" );

# This section defines permissions which allow only logged-in users to edit
#
# Deny access to Anonymous
#
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['*']['createtalk'] = false;
#
# Allow logged in users to do these things
#
$wgGroupPermissions['user']['move'] = true;
$wgGroupPermissions['user']['read'] = true;
$wgGroupPermissions['user']['edit'] = true;
$wgGroupPermissions['user']['createpage'] = true;
$wgGroupPermissions['user']['createtalk'] = true;
$wgGroupPermissions['user']['upload'] = true;
$wgGroupPermissions['user']['reupload'] = true;
$wgGroupPermissions['user']['reupload-shared'] = true;
$wgGroupPermissions['user']['minoredit'] = true;
#
# Allow automated accounts to do these things
#
$wgGroupPermissions['autoconfirmed']['autoconfirmed'] = true;
$wgGroupPermissions['bot']['bot'] = true;
$wgGroupPermissions['bot']['autoconfirmed'] = true;
#
# Allow logged in sysops to do these things
#
$wgGroupPermissions['sysop']['block'] = true;
$wgGroupPermissions['sysop']['createaccount'] = true;
$wgGroupPermissions['sysop']['delete'] = true;
$wgGroupPermissions['sysop']['deletedhistory'] = true;
$wgGroupPermissions['sysop']['editinterface'] = true;
$wgGroupPermissions['sysop']['import'] = true;
$wgGroupPermissions['sysop']['importupload'] = true;
$wgGroupPermissions['sysop']['move'] = true;
$wgGroupPermissions['sysop']['patrol'] = true;
$wgGroupPermissions['sysop']['protect'] = true;
$wgGroupPermissions['sysop']['rollback'] = true;
$wgGroupPermissions['sysop']['upload'] = true;
$wgGroupPermissions['sysop']['reupload'] = true;
$wgGroupPermissions['sysop']['reupload-shared'] = true;
$wgGroupPermissions['sysop']['unwatchedpages'] = true;
$wgGroupPermissions['sysop']['autoconfirmed'] = true;
$wgGroupPermissions['bureaucrat']['userrights'] = true;

require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );


Next we'll navigate to the extensions directory and install the necessary extensions.


cd /var/lib/mediawiki/extensions


We'll create two folders.


sudo mkdir LdapAuthentication
sudo mkdir ParserFunctions


Now we'll download the extensions.


cd LdapAuthentication
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/LdapAuthentication/LdapAuthentication.php
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/LdapAuthentication/LdapAutoAuthentication.php


Change directories and finish downloading the extensions.


cd ../ParserFunctions
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/Expr.php
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/ParserFunctions.i18n.magic.php
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/ParserFunctions.i18n.php
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/ParserFunctions.php
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/SprintfDateCompat.php
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/exprTests.txt
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/funcsParserTests.txt
wget http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/extensions/ParserFunctions/testExpr.php


Now we edit the 'ldap.conf'

.

cd /etc/ldap
sudo vi ldap.conf


Add the following line.


TLS_REQCERT never


Now we add the LDAPProxyAgent user in Active Directory. In this case we named the user 'LDAP Lookup' and gave it the password of 'supersecretpassword'. 'LDAP Lookup' should be a member of the Domain Users. Browse to your wiki install and you should be prompted to login. Enter a valid domain user account and now you are logged in.

Mi Bo Kho

IMG_0039.jpg
Vietnamese Beef Stew Egg Noodle Soup
Beef, Carrot


Hungering for Korean cuisine while running an errand, we went to the nearest restaurant according to Google Maps. Apparently the place went out of business and was instead replaced by a Vietnamese restaurant called Mekong Village. With our stomaches beginning to self devour themselves we decided to give it a go and found ourselves pleasantly surprised.

I usually order Steak Pho with rice noodles. The elderly Vietnamese woman patiently waiting to take our order suggested I try their version of Mi Bo Kho which is similar to Pho in that it's a soup based noodle dish but entirely different. Open to trying new things we gave her the go ahead along with a few sides.

Proudly presented with the bowl of stew I was amazed by the richness of the broth and the generous portions of perfectly prepared beef shank and tendon. The Bo Kho seasoning along with the Vietnamese fish sauce gave it a pleasant aroma like no other. Upon adding the fresh basil and jalapeno I knew this was going to be amazing.

Compared to other Vietnamese restaurant's the decor was above average and if you're looking for atmosphere you may as well go elsewhere. If you want fresh, authentic dishes prepared by people that know what they are doing when it comes to Vietnamese cuisine then look no further. For me this is simply the best I've ever had and from where I live it's definitely out of the way, almost a 50 minute drive! I'm definitely going back to try out the rest of the menu and I'm bringing all of my friends.

Mekong Village
12020 Aurora Ave N.
Seattle, WA 98133

SQL Injection

SQL Injections are the act of injecting arbitrary SQL code into a query tricking the application into doing something unintended. This means an attacker could gain administrator privileges without a password or even delete records.

To prevent SQL Injection's you must check and sanitize any user input. If a text field is supposed to contain numbers make sure the user data is actually a number.


if(!is_numeric($_POST['number'])) die('Please choose a number.');


Sanitizing data before inserting it into a database means escaping any characters that may trick the query. Using addslashes() is helpful but might not be enough. For MYSQL using the mysql_real_escape_string() function makes user data safe.


$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$sql="SELECT * FROM users WHERE username='$username' AND password='$password'";