Troy – Adams Bros Blog http://blog.adamsbros.org Wed, 15 May 2019 01:45:31 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.2 Making New Linux Disk Visible Without a Reboot http://blog.adamsbros.org/2015/11/16/making-new-linux-disk-visible-without-a-reboot/ http://blog.adamsbros.org/2015/11/16/making-new-linux-disk-visible-without-a-reboot/#respond Mon, 16 Nov 2015 19:28:56 +0000 http://blog.adamsbros.org/?p=574 I was having trouble today getting Linux to see my new partition space that I added in vSphere without rebooting the host. The new disk space was made visible by re-scanning the SCSI bus (below) and then the new partition was made visible by using the partprobe command (below).

 

I asked VMWare to provision my disk to be larger and then asked Linux to refresh the kernel info:

 $ echo 1 > /sys/class/scsi_device/0\:0\:3\:0/device/rescan 
 $ dmesg
 sdd: Write Protect is off 
 sdd: Mode Sense: 61 00 00 00 
 sdd: cache data unavailable 
 sdd: assuming drive cache: write through 
 sdd: detected capacity change from 171798691840 to 343597383680

 

I added another partition and then tried to get LVM to use it:

$ fdisk /dev/sdd
 Command (m for help): n
 Command action
 e extended
 p primary partition (1-4)
 p
 Partition number (1-4): 3

But LVM couldn’t see it:

 $ pvcreate /dev/sdd3
 Device /dev/sdd3 not found (or ignored by filtering).
 $ pvcreate -vvvv /dev/sdd3
 #device/dev-cache.c:578 /dev/sdd3: stat failed: No such file or directory
 #metadata/metadata.c:3546 
 #device/dev-cache.c:578 /dev/sdd3: stat failed: No such file or directory

The solution was to use partprobe to inform the OS of partition table changes:

 $ partprobe /dev/sdd
 $ pvcreate /dev/sdd3
 dev_is_mpath: failed to get device for 8:51
 Writing physical volume data to disk "/dev/sdd3"
 Physical volume "/dev/sdd3" successfully created
]]>
http://blog.adamsbros.org/2015/11/16/making-new-linux-disk-visible-without-a-reboot/feed/ 0
OpenLDAP SSHA Salted Hashes By Hand http://blog.adamsbros.org/2015/06/09/openldap-ssha-salted-hashes-by-hand/ http://blog.adamsbros.org/2015/06/09/openldap-ssha-salted-hashes-by-hand/#respond Tue, 09 Jun 2015 20:07:40 +0000 http://blog.adamsbros.org/?p=575 I needed a way to verify that the OpenLDAP server had the correct hash recorded.  That is, a SSHA Hash Generator that I could run off the command line was in order.  After fiddling through it, I thought it would be worth documenting in a blog post.

We need to find the salt (the last four bytes of the hash), and then concatenate PASSWORD+SALT, take the SHA hash, convert to base64, prepend {SSHA}, and then finally base64 encode that whole string again.

Here is what ldapsearch says is the password hash:

userPassword:: e1NTSEF9OWZ1MHZick15Tmt6MnE3UGh6eW94SDMrNmhWb3llajU=

The first step is to retrieve the (binary) salt which is stored at the end of a double base64 encoded hash.  I wrote a perl SSHA Salt Extractor for that:

$ cat getSalt.pl
#!/usr/bin/perl -w

my $hash=$ARGV[0];
# The hash is encoded as base64 twice:
use MIME::Base64;
$hash = decode_base64($hash);
$hash=~s/{SSHA}//;
$hash = decode_base64($hash);

# The salt length is four (the last four bytes).
$salt = substr($hash, -4);

# Split the salt into an array.
my @bytes = split(//,$salt);

# Convert each byte from binary to a human readable hexadecimal number.
foreach my $byte (@bytes) {
$byte = uc(unpack "H*", $byte);
print "$byte";
}
$ ./getSalt.pl e1NTSEF9OWZ1MHZick15Tmt6MnE3UGh6eW94SDMrNmhWb3llajU=
68C9E8F9

See, that is four ASCII characters represented by human readable hexadecimal. Another way to do this is like this:

echo "e1NTSEF9OWZ1MHZick15Tmt6MnE3UGh6eW94SDMrNmhWb3llajU=" | base64 -d | sed 's/^{SSHA}//' | base64 -d | tail -c4 | od -tx1

Now that we have extracted the salt, we can regenerate the salted hash with what we think the password should be.

$ cat openldap-sha.pl
#!/usr/bin/perl

use Digest::SHA1;
use MIME::Base64;

my $p=$ARGV[0];
my $s=$ARGV[1];

# Convert from hex to binary.
$s_bin=pack 'H*', $s;

# Hash the password with the salt.
$digest = Digest::SHA1->new;
$digest->add("$p");
$digest->add("$s_bin");

# Encode PASSWORD+SALT as Base64.
$hashedPasswd = '{SSHA}' . encode_base64($digest->digest . "$s_bin" ,'');

# Encode as Base64 again:
print 'userPassword:: ' . encode_base64($hashedPasswd) . "\n";

$ ./openldap-sha.pl correcthorsebatterystaple 68C9E8F9
userPassword:: e1NTSEF9OWZ1MHZick15Tmt6MnE3UGh6eW94SDMrNmhWb3llajU=

And there you have it.

]]>
http://blog.adamsbros.org/2015/06/09/openldap-ssha-salted-hashes-by-hand/feed/ 0
arduino interfacing with the HD44780 LCD http://blog.adamsbros.org/2009/06/15/arduino-interfacing-with-the-hd44780-lcd/ http://blog.adamsbros.org/2009/06/15/arduino-interfacing-with-the-hd44780-lcd/#comments Tue, 16 Jun 2009 04:54:18 +0000 http://blog.adamsbros.org/?p=60 It became time for me to interface an LCD with my Arduino.  I need to generate a handy report of what my various sensors are picking up.  The following is an account of my notes on twisting up my HD44780 compatible LCD on the Arduino. Please enjoy.

I’m staring at my LCD module.  I can hear it saying, “hook me up!”, but I’ll have to read a bit first.

#1: Identification

ArduinoLCD_back

On the back of the unit, it says:
AMC2004A-B-B6NTDW-SP LOT#000542

A little Googling for “AMC2004A-B” and I find that it’s an HD44780 compatible LCD.  I find a PDF spec sheet and even an Arduino library:

http://www.shopeio.com/inventory/pdf/AMC2004A.pdf
http://arduino.cc/en/Reference/LiquidCrystal

#2: Figuring

The only figuring I need is for the backlight.  The spec says that for the white backlight, I should use 4.0V at 30mA.  I have a 5V supply so, with Ohm’s Law in mind, the math goes:
R   =   V/I   =   Rdrop/series_current   =   (5V-4V)/30mA   =   33Ω

#3: Wiring
A little skimming of the spec sheet helps me understand how to wire this up so here we go:

Pin No. Symbol   Destination   Description
——  ——   ———–   ————————
1          VSS Ground        Ground
2          VDD 5V            Supply Voltage for logic
3           V0 Pot Leg 2     Variable Operating voltage for LCD
4           RS → Arduino 12 Register Selector (H: DATA, L: Instruction code)
5          R/W Ground (Low)  Read/Write Selector (H: Read(MPU→Module) L: Write(MPU→Module))
6            E Arduino 11    Chip enable signal
7          DB0 → No Connection Data bit 0
8          DB1 No Connection Data bit 1
9          DB2 No Connection Data bit 2
10         DB3 No Connection Data bit 3
11         DB4 Arduino  7 Data bit 4
12         DB5 Arduino  8 Data bit 5
13         DB6 Arduino  9 Data bit 6
14         DB7 Arduino 10 Data bit 7
15      LED(+) R2            Anode of LED Backlight
16      LED(-) Ground        Cathode of LED Backlight

ArduinoLCD_finished

#4: Programming

The LiquidCrystal Library came with my Arduino 0012 Alpha software package (IDE).   A couple of modifications to the Hello World Example:

#include <LiquidCrystal.h>

/* LiquidCrystal display with:
LCD 4 (RS) to arduino pin 12
LCD 5 (R/W) to ground (non-existent pin 14 okay?)
LCD 6 (E) to arduino pin 11
d4, d5, d6, d7 on arduino pins 7, 8, 9, 10
*/
LiquidCrystal lcd(12, 14, 11, 7, 8, 9, 10);

void setup()
{
// position cursor on line x=4,y=3
lcd.setCursor(3,2);
// Print a message to the LCD.
lcd.print(“hello, world!”);
}

void loop()
{
}
]]>
http://blog.adamsbros.org/2009/06/15/arduino-interfacing-with-the-hd44780-lcd/feed/ 5