<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joe's Linux Blog</title>
	<atom:link href="http://joseph.freivald.com/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://joseph.freivald.com/linux</link>
	<description>Linux Admin tips and tricks</description>
	<lastBuildDate>Thu, 25 Feb 2010 21:26:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Qt 4.6.2 packages for Centos 5.4</title>
		<link>http://joseph.freivald.com/linux/2010/02/25/qt-4-6-2-packages-for-centos-5-4/</link>
		<comments>http://joseph.freivald.com/linux/2010/02/25/qt-4-6-2-packages-for-centos-5-4/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:25:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=83</guid>
		<description><![CDATA[The Qt4 packages for Centos are updated to 4.6.2 and Qt Creator is updated to 1.3.1.
To install:
rpm -ivh http://software.freivald.com/centos/software.freivald.com-1.0.0-1.noarch.rpm
yum update fontconfig fontconfig-devel qt4 qt4-devel qt4-doc qt4-postgresql qt4-odbc qt4-sqlite qt-creator
Verify that the versions are coming from software.freivald.com and enjoy.   
]]></description>
			<content:encoded><![CDATA[<p>The Qt4 packages for Centos are updated to 4.6.2 and Qt Creator is updated to 1.3.1.</p>
<p>To install:</p>
<pre>rpm -ivh http://software.freivald.com/centos/software.freivald.com-1.0.0-1.noarch.rpm</pre>
<pre>yum update fontconfig fontconfig-devel qt4 qt4-devel qt4-doc qt4-postgresql qt4-odbc qt4-sqlite qt-creator</pre>
<p>Verify that the versions are coming from software.freivald.com and enjoy.  <img src='http://joseph.freivald.com/linux/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2010/02/25/qt-4-6-2-packages-for-centos-5-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Managing an openssl certificate authority with perl</title>
		<link>http://joseph.freivald.com/linux/2009/11/02/managing-an-openssl-certificate-authority-with-perl/</link>
		<comments>http://joseph.freivald.com/linux/2009/11/02/managing-an-openssl-certificate-authority-with-perl/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 19:04:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=72</guid>
		<description><![CDATA[There are several good tutorials on how to set up a certificate authority with openssl, but once you have one in place, what is a good way to manage it?  Sure there are some tools out there that can help, but I&#8217;ve found them all to be a bit of a pain, especially when it [...]]]></description>
			<content:encoded><![CDATA[<p>There are several good tutorials on how to set up a certificate authority with openssl, but once you have one in place, what is a good way to manage it?  Sure there are some tools out there that can help, but I&#8217;ve found them all to be a bit of a pain, especially when it comes time to renew a bunch of user certificates.  For this purpose, a home-grown script is almost always better than a generic tool.  Scripting allows you to customize each and every step of the process according to your specific organization&#8217;s needs.  In this article I&#8217;ll give an example of how I use simple scripts to make key generation and regeneration easy.</p>
<p>It&#8217;s worth noting that lots of people probably don&#8217;t need their own CA.  Generally, using a self-signed key or getting a key signed by a recognized authority will be simpler and easier, but in some cases this isn&#8217;t true.  For example, at my office we have a server that is accessible via the Internet and contains proprietary information.  It&#8217;s behind a solid firewall and is pretty well protected.  The server is restricted to SSL only, but if username/password systems are used, they constantly get hammered by idiots looking to log in.  By restricting the server to sessions authorized with an SSL key signed by our local CA only, we can limit the users that connect.  Note that if we used a recognized authority (Versign et. al.) instead of our own, then we would still have the same problem.  By using our own CA, no other keys will make it past the SSL authentication stage.  We noticed a 86% drop in hack attempts two weeks after we went to this setup on this particular server. YMMV.  Note that by doing this we also gain the advantage of users not having to enter their passwords every time they access the server, and the system admin (me) doesn&#8217;t have to worry about whether or not users are circumventing the strong password requirements (see my previous post: <a href="http://joseph.freivald.com/linux/2009/05/14/subversion-ssl-and-apache-for-secure-passwordless-user-based-repository-access-controls/">Subversion, SSL and Apache for Secure, Passwordless, User-based repository access controls</a>.)</p>
<p>Our CA directory structure looks like this:</p>
<pre>CA
  - certs
    - ca
    - user
    - server
  - private
    - ca
    - user
    - server
  - csr
    - ca
    - user
    - server
  - userp12</pre>
<p>It&#8217;s a bit convoluted, but it works for our needs.  As I said, that&#8217;s the beauty of scripting.<br />
I use an openssl.cnf file to maintain all of the defaults and file locations.  Here it is:</p>
<pre>#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#

# This definition stops the following lines choking if HOME isn't
# defined.
HOME                    = .
RANDFILE                = $ENV::HOME/.rnd

# Extra OBJECT IDENTIFIER info:
#oid_file               = $ENV::HOME/.oid
oid_section             = new_oids

# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
# extensions            =
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)

[ new_oids ]

# We can add new OIDs in here for use by 'ca' and 'req'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6

####################################################################
[ ca ]
default_ca      = CA_default            # The default ca section

####################################################################
[ CA_default ]

dir             = .                     # Where everything is kept
certs           = $dir/certs            # Where the issued certs are kept
crl_dir         = $dir/crl              # Where the issued crl are kept
database        = $dir/index.txt        # database index file.
#unique_subject = no                    # Set to 'no' to allow creation of
 # several ctificates with same subject.
new_certs_dir   = $dir/newcerts         # default place for new certs.

certificate     = $dir/certs/ca/myca.crt         # The CA certificate
serial          = $dir/serial           # The current serial number
crlnumber       = $dir/crlnumber        # the current crl number
 # must be commented out to leave a V1 CRL
crl             = $dir/crl.pem          # The current CRL
private_key     = $dir/private/ca/myca.key       # The private key
RANDFILE        = $dir/private/.rand    # private random number file

x509_extensions = usr_cert              # The extentions to add to the cert

# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt        = ca_default            # Subject Name options
cert_opt        = ca_default            # Certificate field options

# Extension copying option: use with caution.
# copy_extensions = copy

# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions        = crl_ext

default_days    = 365                   # how long to certify for
default_crl_days= 30                    # how long before next CRL
default_md      = sha1                  # which md to use.
preserve        = no                    # keep passed DN ordering

# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that <img src='http://joseph.freivald.com/linux/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
policy          = policy_match

# For the CA policy
[ policy_match ]
countryName             = match
stateOrProvinceName     = match
organizationName        = match
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName             = optional
stateOrProvinceName     = optional
localityName            = optional
organizationName        = optional
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = supplied

####################################################################
[ req ]
default_bits            = 1024
default_md              = sha1
default_keyfile         = privkey.pem
distinguished_name      = req_distinguished_name
attributes              = req_attributes
x509_extensions = v3_ca # The extentions to add to the self signed cert

# Passwords for private keys if not present they will be prompted for
# input_password = secret
# output_password = secret

# This sets a mask for permitted string types. There are several options.
# default: PrintableString, T61String, BMPString.
# pkix   : PrintableString, BMPString.
# utf8only: only UTF8Strings.
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
# MASK:XXXX a literal mask value.
# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
# so use this option with caution!
# we use PrintableString+UTF8String mask so if pure ASCII texts are used
# the resulting certificates are compatible with Netscape
string_mask = MASK:0x2002

# req_extensions = v3_req # The extensions to add to a certificate request

[ req_distinguished_name ]
countryName                     = Country Name (2 letter code)
countryName_default             = US
countryName_min                 = 2
countryName_max                 = 2

stateOrProvinceName             = State or Province Name (full name)
stateOrProvinceName_default     = YourState

localityName                    = Locality Name (eg, city)
localityName_default            = YourCity

0.organizationName              = Organization Name (eg, company/unit)
0.organizationName_default      = YourOrganization

# we can do this but it is not needed normally <img src='http://joseph.freivald.com/linux/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
1.organizationName              = Division
1.organizationName_default      = YouCanSkipThisOneIfYouWantTo

organizationalUnitName          = Organizational Unit Name (eg, section)
organizationalUnitName_default  = ThisOneCanBeSkippedToo

commonName                      = Common Name (eg, your name or your server\'s hostname)
commonName_max                  = 64

emailAddress                    = Email Address
emailAddress_max                = 64

# SET-ex3                       = SET extension number 3

[ req_attributes ]
#challengePassword              = A challenge password
#challengePassword_min          = 4
#challengePassword_max          = 20

#unstructuredName               = An optional company name

[ usr_cert ]

# These extensions are added when 'ca' signs a request.

# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.

basicConstraints=CA:FALSE

# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.

# This is OK for an SSL server.
# nsCertType                    = server

# For an object signing certificate this would be used.
# nsCertType = objsign

# For normal client use this is typical
# nsCertType = client, email

# and for everything including object signing:
# nsCertType = client, email, objsign

# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment

# This will be displayed in Netscape's comment listbox.
nsComment                       = "Signed by my private Certificate Authority"

# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer

# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move

# Copy subject details
# issuerAltName=issuer:copy

#nsCaRevocationUrl              = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName

[ v3_req ]

# Extensions to add to a certificate request

basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment

[ v3_ca ]

# Extensions for a typical CA

# PKIX recommendation.

subjectKeyIdentifier=hash

authorityKeyIdentifier=keyid:always,issuer:always

# This is what PKIX recommends but some broken software chokes on critical
# extensions.
#basicConstraints = critical,CA:true
# So we do this instead.
basicConstraints = CA:true

# Key usage: this is typical for a CA certificate. However since it will
# prevent it being used as an test self-signed certificate it is best
# left out by default.
# keyUsage = cRLSign, keyCertSign

# Some might want this also
# nsCertType = sslCA, emailCA

# Include email address in subject alt name: another PKIX recommendation
# subjectAltName=email:copy
# Copy issuer details
# issuerAltName=issuer:copy

# DER hex encoding of an extension: beware experts only!
# obj=DER:02:03
# Where 'obj' is a standard or added object
# You can even override a supported extension:
# basicConstraints= critical, DER:30:03:01:01:FF

[ crl_ext ]

# CRL extensions.
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.

# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always,issuer:always

[ proxy_cert_ext ]
# These extensions should be added when creating a proxy certificate

# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.

basicConstraints=CA:FALSE

# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.

# This is OK for an SSL server.
# nsCertType                    = server

# For an object signing certificate this would be used.
# nsCertType = objsign

# For normal client use this is typical
# nsCertType = client, email

# and for everything including object signing:
# nsCertType = client, email, objsign

# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment

# This will be displayed in Netscape's comment listbox.
nsComment                       = "My CA Signed Certificate"

# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always

# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move

# Copy subject details
# issuerAltName=issuer:copy

#nsCaRevocationUrl              = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName

# This really needs to be in place for it to be a proxy certificate.
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo</pre>
<p>For generating a single user certificate, which we only do when someone new gets hired, we have a simple shell script.  All information is entered by hand.<br />
Here is generate-user-key:</p>
<pre>#!/bin/bash

[ "$1" == "" ] &amp;&amp; echo "Usage: generate-user-key &lt;username&gt;" &amp;&amp; exit -1;

openssl req -config openssl.cnf -new -sha1 -newkey rsa:1024 -nodes -keyout private/user/$1.key -out csr/user/$1.pem
openssl ca -config openssl.cnf -policy policy_anything -extensions usr_cert -out certs/user/$1.pem -infiles csr/user/$1.pem
openssl pkcs12 -export -clcerts -in certs/user/$1.pem -inkey private/user/$1.key -out userp12/$1.p12</pre>
<p>It checks to make sure a username is present, and then runs through the three openssl commands necessary for generating the certificates.</p>
<p>Now, as you can see in the openssl.cnf file, the user keys only last for 365 days.  So every year we have to regenerate all the keys, most of them on the same day.  To do that, we use a perl script: regenerate-all-user-keys</p>
<pre>#!/usr/bin/perl</pre>
<p>We check to make sure the CA password is provided:</p>
<pre>$ARGV[0] =~ /.+/ or die "usage: regenerate-user-keys &lt;ca-password&gt;";

$password = $ARGV[0];
chomp($password);</pre>
<p>And grab all the user keys by checking the private/user directory and stripping off the extra characters.</p>
<pre>@keys=`ls private/user/*.key`;
chomp for(@keys);
s/\.key//g for(@keys);
s/.*\/(.*$)/\1/g for(@keys);</pre>
<p>Now for each key we&#8217;ll go through the regeneration process.</p>
<pre>for $key(@keys) {</pre>
<p>Grab the existing subject line from the existing certificate and re-format it for the command line.</p>
<pre> $subjects=`openssl x509 -in certs/user/$key.pem -noout -text | grep Subject:`;
 chomp ($subjects);
 $subjects =~ s/, /\//g;
 $subjects =~ s/\s+Subject: (.*)/\/\1/;</pre>
<p>Make a copy of all of the keys and certificates in case we have a failure and need to roll back.</p>
<pre> system "cp private/user/$key.key private/user/$key.key.last";
 system "cp csr/user/$key.pem csr/user/$key.pem.last";
 system "cp certs/user/$key.pem certs/user/$key.pem.last";
 system "cp userp12/$key.p12 userp12/$key.p12.last";</pre>
<p>Regenerate the key and signing request</p>
<pre> print "\n\nopenssl req -config openssl.cnf -new -sha1 -newkey rsa:1024 -nodes -keyout private/user/$key.key -out csr/user/$key.pem -multivalue-rdn -subj '$subjects'\n";
 system "openssl req -config openssl.cnf -new -sha1 -newkey rsa:1024 -nodes -keyout private/user/$key.key -out csr/user/$key.pem -multivalue-rdn -subj '$subjects'";</pre>
<p>Check to be certain that the process ended correctly.  If it didn&#8217;t then roll back the keys.</p>
<pre> if ($? == -1) {
 print "failed to execute: $!\n";
 } if ($? &amp; 127) {
 printf "child died with signal %d, %s coredump\n", ($? &amp; 127), ($? &amp; 128) ? 'with' : 'without';
 } else {
 $exitval = $? &gt;&gt; 8;
 if ($exitval != 0) {
 printf "child exited with value %d\n", $exitval;
 print "$key failed to regenerate.  Restoring old keys.\n";
 system "cp private/user/$key.key.last private/user/$key.key";
 system "cp csr/user/$key.pem.last csr/user/$key.pem";
 system "cp certs/user/$key.pem.last certs/user/$key.pem";
 system "cp userp12/$key.p12.last userp12/$key.p12";
 push(@errored_out, $key);
 next;
 }
 }</pre>
<p>Sign the key using the password supplied on the command line.</p>
<pre> print "\n\nopenssl ca -config openssl.cnf -policy policy_anything -extensions usr_cert -out certs/user/$key.pem -in csr/user/$key.pem -multivalue-rdn -subj '$subjects' -batch -key '$password'\n";
 system "openssl ca -config openssl.cnf -policy policy_anything -extensions usr_cert -out certs/user/$key.pem -in csr/user/$key.pem -multivalue-rdn -subj '$subjects' -batch -key '$password'";
 if ($? == -1) {
 print "failed to execute: $!\n";
 } elsif ($? &amp; 127) {
 printf "child died with signal %d, %s coredump\n", ($? &amp; 127), ($? &amp; 128) ? 'with' : 'without';
 } else {
 $exitval = $? &gt;&gt; 8;
 if ($exitval != 0) {
 printf "child exited with value %d\n", $exitval;
 print "$key failed to regenerate.  Restoring old keys.\n";
 system "cp private/user/$key.key.last private/user/$key.key";
 system "cp csr/user/$key.pem.last csr/user/$key.pem";
 system "cp certs/user/$key.pem.last certs/user/$key.pem";
 system "cp userp12/$key.p12.last userp12/$key.p12";
 push(@errored_out, $key);
 next;
 }
 }</pre>
<p>And finally, output the pcks12 formatted certificate to send to the users.  Note that the output is encrypted with a passcode postpended with the username.  This is sufficient for our needs, but probably not everyones.  To make it so that each user gets a unique password, remove the -passout parameter and the sytem will prompt each time it goes to export a pkcs12 certificate.</p>
<pre> print "\n\nopenssl pkcs12 -export -clcerts -in certs/user/$key.pem -inkey private/user/$key.key -out userp12/$key.p12 -des3 -passout 'pass:ourcode$key'\n";
 system "openssl pkcs12 -export -clcerts -in certs/user/$key.pem -inkey private/user/$key.key -out userp12/$key.p12 -des3 -passout 'pass:ourcode$key'";
 if ($? == -1) {
 print "failed to execute: $!\n";
 } elsif ($? &amp; 127) {
 printf "child died with signal %d, %s coredump\n", ($? &amp; 127), ($? &amp; 128) ? 'with' : 'without';
 } else {
 $exitval = $? &gt;&gt; 8;
 if ($exitval != 0) {
 printf "child exited with value %d\n", $exitval;
 print "$key failed to regenerate.  Restoring old keys.\n";
 system "cp private/user/$key.key.last private/user/$key.key";
 system "cp csr/user/$key.pem.last csr/user/$key.pem";
 system "cp certs/user/$key.pem.last certs/user/$key.pem";
 system "cp userp12/$key.p12.last userp12/$key.p12";
 push(@errored_out, $key);
 next;
 }
 }

}</pre>
<p>Output each of the certificates that failed for one reason or another so that they can be addressed manually.</p>
<pre>for $fail(@errored_out) {
 print "WARNING: $fail did not regenerate.\n";
}</pre>
<p>And remove any remaining backup files.</p>
<pre>system "rm -f private/user/*.last";
system "rm -f csr/user/*.last";
system "rm -f certs/user/*.last";
system "rm -f userp12/*.last";</pre>
<p>Pretty straight forward, and makes regenerating hundreds of keys on a single day much less of a problem.  A task left to the reader is to have the script email the user their new key based on the e-mail address captured in the subject line.  Our doesn&#8217;t do that because we have to get VP level approval to send automated e-mails.</p>
<p>Cheers.</p>
<p>&#8211;JATF</p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/11/02/managing-an-openssl-certificate-authority-with-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Register before post</title>
		<link>http://joseph.freivald.com/linux/2009/09/08/register-before-post/</link>
		<comments>http://joseph.freivald.com/linux/2009/09/08/register-before-post/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 15:26:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=69</guid>
		<description><![CDATA[I had to change the settings to allow only registered users to post because I&#8217;m getting hammered by spam for the past week.  Sorry about that.  Life would be a lot nicer if people weren&#8217;t assholes.
]]></description>
			<content:encoded><![CDATA[<p>I had to change the settings to allow only registered users to post because I&#8217;m getting hammered by spam for the past week.  Sorry about that.  Life would be a lot nicer if people weren&#8217;t assholes.</p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/09/08/register-before-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copying Nikon RAW pictures to JPEG</title>
		<link>http://joseph.freivald.com/linux/2009/08/24/copying-nikon-raw-pictures-to-jpeg/</link>
		<comments>http://joseph.freivald.com/linux/2009/08/24/copying-nikon-raw-pictures-to-jpeg/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 21:19:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[batch convert]]></category>
		<category><![CDATA[JPEG]]></category>
		<category><![CDATA[JPG]]></category>
		<category><![CDATA[NEF]]></category>
		<category><![CDATA[NIKON]]></category>
		<category><![CDATA[RAW]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=63</guid>
		<description><![CDATA[My wife loves her Nikon camera.  She also loves Photoshop.  The two go together really well.  She takes pictures in the raw &#8220;NEF&#8221; format, and photoshop works miracles on them.  Unfortunately, for sharing snapshots it&#8217;s always a pain in the butt to get each and every picture that we want to share converted to JPEG [...]]]></description>
			<content:encoded><![CDATA[<p>My wife loves her Nikon camera.  She also loves Photoshop.  The two go together really well.  She takes pictures in the raw &#8220;NEF&#8221; format, and photoshop works miracles on them.  Unfortunately, for sharing snapshots it&#8217;s always a pain in the butt to get each and every picture that we want to share converted to JPEG so that everyone who doesn&#8217;t have photoshop can use them.  Not to mention that even as JPEGs, a 10 megapixel photo is too big to go e-mailing to Aunt Laura on her Dial-Up.</p>
<p>The dichotomy is clear: Quality vs. Portability.</p>
<p>So like everything else that takes for ever and is tedious, I wrote a script.  This one looks in the underlying tree and checks to see if each NEF file has a corresponding JPEG file.  If it doesn&#8217;t, then it creates one using ImageMagick.  If there is one, it ignores the file and moves on to the next one. Now she can have the super-high quality RAW pictures, and I can e-mail them to grandma.  Once again, everyone is happy in Joeland.</p>
<p>In this case we also convert the size of the image to two megapixels, which is plenty for sharing photos, but not great for printing blow-ups.  But that&#8217;s okay, because we still have the original NEF to manipulate if we want to!</p>
<p>On Centos I had to do a &#8216;cpan install autodie&#8217; and &#8216;cpan install IPC::System::Simple&#8217; to get this to compile right.  Autodie is nice because if you hit Ctrl-C to stop the script then it will actually stop instead of continuing on to the next picture.</p>
<p>Here is the script:</p>
<pre>#!/usr/bin/perl

use autodie qw(:all);

@FILES = split(/\n/, `find . | grep "\.NEF\$"`);
foreach $file(@FILES) {
    $rawfile = $file;
    $file =~ s/NEF$/small.JPG/;
    if (-d $file) {
        print "Entering directory $file.\n";
    } elsif (! -f $file) {
        print "\t$rawfile -&gt; $file\n";
        system("convert \"$rawfile\" -normalize -resize \"\@2000000\" \"$file\"");
    } else {
        print "\t$rawfile skipped.  $file already exists.\n";
    }
}

Enjoy!

--JATF</pre>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/08/24/copying-nikon-raw-pictures-to-jpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delay . . .</title>
		<link>http://joseph.freivald.com/linux/2009/08/02/delay/</link>
		<comments>http://joseph.freivald.com/linux/2009/08/02/delay/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 02:38:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=60</guid>
		<description><![CDATA[Sorry that I haven&#8217;t put another post up.  The one I was working on was long enough that I&#8221;ve submitted it to the Linux Journal, so they get first crack at it.  If they don&#8217;t want it, then I&#8217;ll post it here, otherwise I&#8217;ll work up something else new and interesting soon.
]]></description>
			<content:encoded><![CDATA[<p>Sorry that I haven&#8217;t put another post up.  The one I was working on was long enough that I&#8221;ve submitted it to the Linux Journal, so they get first crack at it.  If they don&#8217;t want it, then I&#8217;ll post it here, otherwise I&#8217;ll work up something else new and interesting soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/08/02/delay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using rsync to update a website on hostmonster.com</title>
		<link>http://joseph.freivald.com/linux/2009/06/05/using-rsync-to-update-a-website-on-hostmonstercom/</link>
		<comments>http://joseph.freivald.com/linux/2009/06/05/using-rsync-to-update-a-website-on-hostmonstercom/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 03:32:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Web Publishing]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=29</guid>
		<description><![CDATA[I was working on a website with a software repository that had hard links in it.  Linking reduces disk space on the server, and when mirroring with rsync, reduces the time needed to sync the entire mirror.  If you are using scp or ftp to push to the server it causes problems because those [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a website with a software repository that had hard links in it.  Linking reduces disk space on the server, and when mirroring with rsync, reduces the time needed to sync the entire mirror.  If you are using scp or ftp to push to the server it causes problems because those programs copy each link as a new file, meaning more bandwidth consumed, more time in transfer, and more disk space used on the server side.  Just what we wanted to avoid by using rsync in the first place.</p>
<p>So how do we use rsync to push our web site to the server when we don&#8217;t have access to any of the rsyncd configuration files and can&#8217;t work with anything higher in the file tree than our home directory?  Sure we could pay more for a dedicated server, but why?  Lets use the tools we have as a simple user to accomplish what we need cheaply and easily.</p>
<p>First, get ssh access for your host server.  Hostmonster requires a faxed copy of a picture ID and some other confirmation.  Whatever your host requires, follow their procedures.</p>
<p>Test your ssh connection by opening a terminal and typing:</p>
<pre>ssh <em>username</em>@<em>hostname</em></pre>
<p>It will ask you if you want to remember the host key and you should respond with a yes.</p>
<p>If you are able to enter your password and log in, you should be at your home directory on the host server. You should be able to see the files for your website with</p>
<pre>ls ~/public_html</pre>
<p>Type the following commands:</p>
<pre>mkdir ~/.ssh
chmod 700 ~/.ssh</pre>
<p>Log out and return to your local computer&#8217;s prompt and enter the following commands:</p>
<pre>ssh-keygen -t dsa -C <em>youremailaddress</em></pre>
<p>ssh-keygen will ask you some questions.  Using the default file name (/home/<em>username</em>/.ssh/id_dsa) is fine.  It will also prompt you for a password.  This will guard your ssh key, and you only have to type it once per session, so make it a good one.</p>
<p>Once complete, you should have two new files in ~/.ssh: id_dsa and id_dsa.pub.    Create a configuration shortcut:</p>
<pre>echo -e "host <em>shortname</em>\n\tHostName <em>hostname</em>\n\tUser <em>username</em>" &gt;&gt; ~/.ssh/config</pre>
<p>Where <em>shortname</em> is any name that you want to use to represent your website, <em>hostname</em> is the host that you are uploading to, and <em>username</em> is your login name on that server.</p>
<p>Now, send the public key to the server with:</p>
<pre>scp ~/.ssh/id_dsa.pub <em>username</em>@<em>hostname</em>:~/.ssh/authorized_keys2</pre>
<p>Now, to prevent yourself from having to type your password every time you want to copy files or log in, type:</p>
<pre>ssh-add</pre>
<p>and type your password.  This will put your ssh key into an &#8216;agent&#8217;, which will authorize you without a password for the rest of the time you are logged in.  After you log out you&#8217;ll have to do ssh-add again, but as long as you stay logged in you should be able to log into the hosting server with a simple:</p>
<pre>ssh <em>shortname</em></pre>
<p>No password, no nothing, and all encrypted, too.  Log out of the server and get back to a local prompt.</p>
<p>Change to your directory that has the local copy of your web site, such as:</p>
<pre>cd ~/public_html</pre>
<p>To push the update your web site, type the command is:</p>
<pre>rsync -e ssh -vramlHP --exclude '*.log' --numeric-ids --delete --delete-excluded --delete-after --delay-updates . <em>shortname</em>:~/public_html/</pre>
<p>To pull the webserver down to your local directory, the command is:</p>
<pre>rsync -e ssh -vralmHP --exclude '*.log' --numeric-ids --delete --delete-excluded --delete-after --delay-updates <em>shortname</em>:~/public_html/ .</pre>
<p>It will transmit only the changed data, saving you time, and will properly handle hard and soft links, which will save you space on the server.</p>
<p>Just to finish the job I put them into shell scripts by:</p>
<pre>mkdir ~/bin
echo -e '#!/bin/bash\n\nrsync -e ssh -vralHP --numeric-ids --delete --delete-excluded --delete-after --delay-updates <em>localdirectory</em> <em>shortname</em>:~/public_html/\n' &gt;&gt; ~/bin/pushsite
echo -e '#!/bin/bash\n\nrsync -e ssh -vralHP --numeric-ids --delete --delete-excluded --delete-after --delay-updates <em>shortname</em>:~/public_html/ <em>localdirectory</em>\n' &gt;&gt; ~/bin/pullsite
chmod +x ~/bin/pushsite ~/bin/pullsite</pre>
<p>Where <em>localdirectory</em> is where you want the site stored locally.</p>
<p>Now typing &#8216;pushsite&#8217; at a terminal prompt will push the update, and &#8216;pullsite&#8217; will pull it down from the server (assuming your local bin dir is in your path, which it is on most systems).  Assuming you have previously done an &#8217;ssh-add&#8217;, you won&#8217;t even need to use a password.</p>
<p>Of course, this doesn&#8217;t backup databases, just static files.  But if you are dealing with static files, rsync can&#8217;t be beat.  It will push and pull only the changes, and will properly handle hard and soft links without duplicating the files.</p>
<p>Happy publishing.</p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/06/05/using-rsync-to-update-a-website-on-hostmonstercom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Qt4 RPMs for Centos 5</title>
		<link>http://joseph.freivald.com/linux/2009/05/24/qtsdk-on-centos-53/</link>
		<comments>http://joseph.freivald.com/linux/2009/05/24/qtsdk-on-centos-53/#comments</comments>
		<pubDate>Sun, 24 May 2009 18:03:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[qt]]></category>
		<category><![CDATA[Linux Centos Qt QtSDK]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=11</guid>
		<description><![CDATA[UPDATE: Nokia released Qt 4.6.0 and qt-creator 1.3.0 today.  The new RPMs are compiled and stored in the repository.  &#8216;yum update&#8217; should be sufficient to grab the new ones.  I also changed the directory to reflect Centos 5.4 instead of 5.3.  Let me know of any issues.
&#8211;JATF
Want to get the Qt SDK working on Centos [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: Nokia released Qt 4.6.0 and qt-creator 1.3.0 today.  The new RPMs are compiled and stored in the repository.  &#8216;yum update&#8217; should be sufficient to grab the new ones.  I also changed the directory to reflect Centos 5.4 instead of 5.3.  Let me know of any issues.</p>
<p>&#8211;JATF</p>
<p>Want to get the Qt SDK working on Centos 5.3?</p>
<p>Quick instructions:</p>
<pre>rpm -ivh http://software.freivald.com/centos/software.freivald.com-1.0.0-1.noarch.rpm</pre>
<pre>yum update fontconfig fontconfig-devel qt4 qt4-devel qt4-doc qt4-postgresql qt4-odbc qt4-sqlite qt-creator</pre>
<p>Verify that the versions are coming from software.freivald.com and install.  <img src='http://joseph.freivald.com/linux/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Longer story:</p>
<p>All of the RPM&#8217;s described in this post are in a yum repository that you can access by installing <a href="http://software.freivald.com/centos/software.freivald.com-1.0.0-1.noarch.rpm">this RPM</a>.  It includes both x86_64 and i386 repositories that are automatically selected based on your architecture.</p>
<p>The first problem: the FcFreeTypeQueryFace problem that is very well described <a href="http://theitdepartment.wordpress.com/2009/03/15/centos-qt-fcfreetypequeryface/">here</a>, with a manual compile and upgrade way around it.  I thought I would go one step further and create an RPM.  Here is what I did:</p>
<p>I started with <a href="http://fontconfig.org/release/fontconfig-2.5.93.tar.gz">this</a> source file from fontconfig.org and <a href="ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/fontconfig-2.4.1-7.el5.src.rpm">this</a> SRPM from redhat.com, modified the spec file from the SRPM because of a changed config file location, and created <a href="http://software.freivald.com/centos/5.3/"> these </a> RPM files for you to install.</p>
<p>The second problem:  the QtSDK is built against several other libraries that are newer than provided with CentOS 5.3.  Rather than update those libraries, I&#8217;ve opted to compile RPMs for qt4 and qt-creator for CentOS 5.3.  There are all new packages for them in the repository.  They upgrade the shipped version (4.2.1) to the new version.  They should be binary compatible, since theoretically Qt only breaks binary backwards compatibility on a major revision number change, but I don&#8217;t have any real way to test this.  Feel free to post any problems you encounter.</p>
<p>The third problem: qt-creator isn&#8217;t included with the qt4 source.  I created it as its own package.  &#8216;yum install qt-creator&#8217; to install it by itself.</p>
<p>Hopefully after installing the repository package, a</p>
<pre>yum update</pre>
<p>and everything should &#8216;just work&#8217;.</p>
<p>Oh, and feel free to use the &#8216;joewidgets&#8217; and &#8216;joewidgets-devel&#8217; packages.  They include some widgets that I use for other projects, primarily a back-port of the KLed widget to QLed that removed KDE dependancies, and a multi-state button with configurable colors for each state.  The &#8216;devel&#8217; package includes designer plugins that also work in qt-creator.  Source for those are published in the srpms directory.</p>
<p>&#8211;JATF</p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/05/24/qtsdk-on-centos-53/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Subversion, SSL and Apache for Secure, Passwordless, User-based repository access controls</title>
		<link>http://joseph.freivald.com/linux/2009/05/14/subversion-ssl-and-apache-for-secure-passwordless-user-based-repository-access-controls/</link>
		<comments>http://joseph.freivald.com/linux/2009/05/14/subversion-ssl-and-apache-for-secure-passwordless-user-based-repository-access-controls/#comments</comments>
		<pubDate>Thu, 14 May 2009 16:54:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://joseph.freivald.com/linux/?p=3</guid>
		<description><![CDATA[I get tired of passwords.  Password here, password there, everywhere a password.
I am a systems designer who does a lot of admin out of necessity.  When I get tired enough of a task, I eliminate it.
I use subversion on several projects to track documentation, source, configurations and more.  All of my servers are SSL only, [...]]]></description>
			<content:encoded><![CDATA[<p>I get tired of passwords.  Password here, password there, everywhere a password.</p>
<p>I am a systems designer who does a lot of admin out of necessity.  When I get tired enough of a task, I eliminate it.</p>
<p>I use subversion on several projects to track documentation, source, configurations and more.  All of my servers are SSL only, and use user certificates for identity verification.  Here&#8217;s what I did to make passwordless, user-based restrictions on Subversion:</p>
<p>First, make sure that SSL is working on your apache server (if you get a server error when you do an https request, but http://yourserver.com:443 works then SSL is not set up right).</p>
<p>Put the following in /etc/httpd/conf.d/subversion.conf:</p>
<pre>&lt;Location /<em>yourSubversionWebLocation</em>&gt;
   DAV svn
   SVNParentPath <em>pathToYourSubversionFolder</em>

   AuthzSVNAccessFile /etc/httpd/<em>yourSubversionAccessFile</em>

   SSLRequireSSL
   SSLVerifyClient require
   SSLUserName SSL_CLIENT_S_DN_Email
   SetOutputFilter DEFLATE
&lt;/Location&gt;</pre>
<p>Some people might want to use SSL_CLIENT_S_DN_CN as the user name instead of the email, but in my case I use the CN to put the person&#8217;s real full name in the certificate, so the email worked out better.  Also, this way I can have jsmith@company1.com and jsmith@company2.com without a collision.  Use whichever works for your situation.</p>
<p>Put your repository access information into your SVN access file like this:</p>
<pre>[shared:/]
user1@yourplace.com = rw
user2@yourplace.com = rw
user3@yourplace.com = rw
readonlyuser@yourplace.com = r

[user1:/]
user1@yourplace.com = rw

[user2:/]
user2@yourplace.com = rw

[user3:/]
user3@yourplace.com = rw</pre>
<p>Generate your User SSL keys.  I do it with a script (lots of stuff on the web on how to set up your own CA, so I&#8217;m not re-hashing it here):</p>
<pre>#!/bin/bash

[ "$1" == "" ] &amp;&amp; exit -1;

openssl req -config openssl.myconf.cnf -new -sha1 -newkey rsa:1024 -nodes -keyout private/$1.key -out csr/$1.pem
openssl ca -config openssl.myconf.cnf -policy policy_anything -extensions usr_cert -out certs/$1.pem -infiles csr/$1.pem
openssl pkcs12 -export -clcerts -in certs/$1.pem -inkey private/$1.key -out userp12/$1.p12</pre>
<p>Be sure to use the same email addresses that you use in the SVN authorization file.</p>
<p>To access subversion from the command line, put the following into your .subverions/servers file.  Be certain that the file has strict permissions (chmod -R 0600 ~user1/.subversion; chmod -R 0600 ~user1/certs):</p>
<pre>[groups]
myrepositories = &lt;your server address&gt;</pre>
<pre>[myrepositories]</pre>
<pre>ssl-authority-files = /home/user1/certs/&lt;your CA file&gt;.crt</pre>
<pre>ssl-client-cert-file = /home/user1/certs/user1.p12</pre>
<pre>ssl-client-cert-password = &lt;user's certificate password&gt;</pre>
<p>To access it with a browser, import the CA and user certificates into the browser of your choice.  Users should then be able to select your web page and auto-magically get the right repositories with the right permissions.  No passwords needed.</p>
<p>If you want a pretty web interface for your repository, try out websvn.  Use the same SSL configuration information for your websvn.conf as you did for your subversion.conf, follow the install information for websvn, put your repositories into your config.php and you&#8217;re done.</p>
]]></content:encoded>
			<wfw:commentRss>http://joseph.freivald.com/linux/2009/05/14/subversion-ssl-and-apache-for-secure-passwordless-user-based-repository-access-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
