... represents a match. (See the 253, and 267 in the fifth and sixth columns, respectively? Column five is the "major number", and column six is the "minor number". Together, those uniquely identify the block device as it is known to the Linux kernel on a particular system.)

As an anecdotal example, on a system where DM-Multipath is enabled, one will see differently named block devices (with identical major and minor numbers) in the /dev and /dev/mapper directories. (The reason for this is beyond the scope of this essay.)

-------

Problem solution

Anyway, back to my task. I've got two different directories, and I want to match major and minor numbers between block devices in them. And I want a pretty report that tells me block device filenames when matches are located.

Simple problem to solve with just a few device files, but each directory contained hundreds of devices in my case. Enter my old friend Perl:

So I am sharing my own contrived steps here. There's nothing wrong with logrotate(8), in particular, but I wanted an alternative approach.

----------

The approach is simple. But, first, my caveats: do not use this example script if you don't understand what it's doing. Do not use this script in a production environment without properly testing and ensuring proper backups in advance. The script is here as a convenience, not as a tool to blindly copy and paste.

Also, read the MySQL documentation on FLUSH LOGS. You may not want to follow the approach I propose here if you've enabled binary logging. If you maintain several different types of log files, you'll need to build in logic for those.

Without further ado, here's what the script does:

It uses mv(1) to rename the MySQL log file to a .prev suffix. As you may already know, this operation (on the same filesystem) does not change the file's inode. As a result, MySQL server continues writing to the .prev log.

It creates a new log file (which must match the 'log=' name specified in my.cnf, of course).

It sets proper ownership and permissions on the new log file. (Will likely differ on your system.)

It fires up the MySQL client as the root user (replace as appropriate for your environment), and issues the FLUSH LOGS command. This commits any outstanding logging to the .prev log file, and then forces MySQL server to begin writing to the new log file.

]]>anomiehttp://www.linuxquestions.org/questions/blog/anomie-152469/rotating-mysql-server-log-files-34565/OpenLDAP and Perlhttp://www.linuxquestions.org/questions/blog/anomie-152469/openldap-and-perl-34367/
Thu, 12 Jan 2012 23:15:46 GMTI recently deployed a slapd(8) instance, and immediately recognized the need for a robust directory entry management utility. After doing some...I recently deployed a slapd(8) instance, and immediately recognized the need for a robust directory entry management utility. After doing some reading and experimentation, I discovered that Perl - and a few accompanying modules - handle the job nicely. What I'm sharing here is a brief, rather disjointed synopsis and some code samples.

In order to understand and use the samples, you should be comfortable with Perl and the installation of modules. And you'll certainly want a good fundamental understanding of LDAPv3 itself. (Both are outside the scope of this post.)

Before we get started, there are some acronyms and other terminology that you should become familiar with. This list is very limited, and is no substitute for a strong understanding of the object class you will be working with (e.g. inetOrgPerson).

Some points to note about the code above: The Beverly Xin cn is a child of ou=users, so we use the "one" scope. We are able to unbind() after $ldap_conn->search(), because the results (if any) are stored in the $search object.

Adding a new entry using Perl

This example provides a way to add users without using LDIF entries. Note the error checking via Net::LDAP->code.

This approach is not the only (or necessarily the best) way to modify entries. The Net::LDAP module also provides an excellent interface through Net::LDAP::Entry.
]]>anomiehttp://www.linuxquestions.org/questions/blog/anomie-152469/openldap-and-perl-34367/Quick-and-dirty symmetric encryptionhttp://www.linuxquestions.org/questions/blog/anomie-152469/quick-and-dirty-symmetric-encryption-3535/
Fri, 28 Jan 2011 04:53:17 GMTNothing earth shattering here. Just a quick automation utility I put together using the venerable openssl.
The wrapper script does a couple...Nothing earth shattering here. Just a quick automation utility I put together using the venerable openssl.

The wrapper script does a couple sanity checks, and saves you from having to remember command options for enc(1). You can change _cipher to suit your tastes / baked-in support.