Tuesday, January 29, 2013

exim4 db corruption

i often grep through my logs looking for a clue. i saw this:
/var/spool/exim4/db/*: unexpected file type or format
in other words:
tis corrupted milady.
[root@badbox ~]#/etc/init.d/exim4 stop
[root@badbox ~]#cd /var/spool/exim4
[root@badbox exim4]# cp -R db/ db.bak
[root@badbox exim4]# cd db/
[root@badbox db]#  rm -rf *
[root@badbox ~]# /etc/init.d/exim4 start

Monday, January 28, 2013

Friday, January 18, 2013

i like to see what others type: bash 4.2



root@happybox:~# apt-cache policy bash
bash:
  Installed: 4.2-2ubuntu2
  Candidate: 4.2-2ubuntu2
  Version table:
 *** 4.2-2ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status

root@happybox:~# apt-get source bash

Reading package lists... Done
Building dependency tree       
Reading state information... Done
NOTICE: 'bash' packaging is maintained in the 'Bzr' version control system at:
http://bazaar.launchpad.net/~doko/+junk/pkg-bash-debian
Please use:
bzr branch http://bazaar.launchpad.net/~doko/+junk/pkg-bash-debian
to retrieve the latest (possibly unreleased) updates to the package.
Skipping already downloaded file 'bash_4.2-2ubuntu2.dsc'
Skipping already downloaded file 'bash_4.2.orig.tar.gz'
Skipping already downloaded file 'bash_4.2-2ubuntu2.diff.gz'
Need to get 0 B of source archives.
gpgv: Signature made Tue 03 Apr 2012 11:46:28 AM EDT using DSA key ID 0F932C9C
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./bash_4.2-2ubuntu2.dsc
dpkg-source: info: extracting bash in bash-4.2
dpkg-source: info: unpacking bash_4.2.orig.tar.gz
dpkg-source: info: applying bash_4.2-2ubuntu2.diff.gz
root@na-nyc-lovetron:~# cd /usr/local/src/
root@na-nyc-lovetron:/usr/local/src# ls
root@na-nyc-lovetron:/usr/local/src# cd

root@happybox:~# ls
bash-4.2  bash_4.2-2ubuntu2.diff.gz  bash_4.2-2ubuntu2.dsc  bash_4.2.orig.tar.gz

root@happybox:~# cd bash-4.2/

root@happybox:/usr/local/src/bash-4.2# ls
bash-4.2.tar.xz  debian

root@happybox:/usr/local/src/bash-4.2# tar xf bash-4.2.tar.xz 

root@happybox:/usr/local/src/bash-4.2# cd bash-4.2

a nice diff

diff -uNr ./bashhist.c ../bash-4.2-patched/bashhist.c
--- ./bashhist.c        2010-08-14 04:09:08.000000000 +0300
+++ ../bash-4.2-patched/bashhist.c      2013-01-18 00:00:00.000000000 +0500
@@ -40,6 +40,8 @@
 
 #if defined (SYSLOG_HISTORY)
 #  include 
+#  include 
+#  include 
 #endif
 
 #include "shell.h"
@@ -707,16 +709,34 @@
      const char *line;
 {
   char trunc[SYSLOG_MAXLEN];
+  struct passwd *pwd;
+
+/* has the user has run sudo. use orig name
+ *    will be in SUDO_USER variable. */
+  const char *sudo_user = getenv("SUDO_USER");
+    if (sudo_user == NULL) { /* No he's not running sudo. Let's find out
+                                who he is */
+        if ((pwd = getpwuid(getuid())) != NULL)
+                sudo_user = pwd->pw_name;
+        else /* We couldn't find his username by asking passwd. We'll have
+                to trust LOGNAME */
+                sudo_user = getenv("LOGNAME");
+    }
 
   if (strlen(line) < SYSLOG_MAXLEN)
-    syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line);
+    syslog (SYSLOG_FACILITY|SYSLOG_LEVEL,
+        "HISTORY: PID=%d user %s as %s(%d) run: %s",
+        getpid(), sudo_user, current_user.user_name, current_user.uid, line);
   else
     {
       strncpy (trunc, line, SYSLOG_MAXLEN);
       trunc[SYSLOG_MAXLEN - 1] = '\0';
-      syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s", getpid(), current_user.uid, trunc);
+      syslog (SYSLOG_FACILITY|SYSLOG_LEVEL,
+        "HISTORY (TRUNCATED): PID=%d user %s as %s(%d) run: %s",
+        getpid(), sudo_user, current_user.user_name, current_user.uid, trunc);
     }
 }

 #endif
      
 /* Add a line to the history list.
diff -uNr ./config-top.h ../bash-4.2-patched/config-top.h
--- ./config-top.h      2009-12-22 22:29:39.000000000 +0200
+++ ../bash-4.2-patched/config-top.h    2012-02-15 15:40:06.000000000 +0200
@@ -101,9 +101,9 @@
 
 /* Define if you want each line saved to the history list in bashhist.c:
    bash_add_history() to be sent to syslog(). */
-/* #define SYSLOG_HISTORY */
+#define SYSLOG_HISTORY
 #if defined (SYSLOG_HISTORY)
-#  define SYSLOG_FACILITY LOG_USER
+#  define SYSLOG_FACILITY LOG_LOCAL5
 #  define SYSLOG_LEVEL LOG_INFO
 #endif


root@happybox:/usr/local/src/bash-4.2/bash-4.2# ./configure —-prefix=/usr/local/bash41 ; make ; make install

Done.

in /etc/rsyslog:

/etc/rsyslog.d/50-default.conf

add:
auth,authpriv.*;local5.*        @syslogserver

root@happybox:~# cd /bin
root@happybox:~# cp bash bash.orig ; rm bash ; cp /usr/local/bash41/bin/bash .

my mind aix or adventures with ibm aix 6.1 XLcc++

# cc -V
cc:  1501-273 A mismatch exists between the OS level and the configuration file. The configuration file /etc/vac.cfg is intended for AIX 5.3. Use vac.cfg.61 to correct the problem.
What?
# ls -la /etc/ |grep vac

lrwxrwxrwx    1 root     system           10 Jan 18 08:51 vac.cfg -> vac.cfg.53
-rw-r--r--    1 bin      bin           32781 Jan 16 10:23 vac.cfg.50
-rw-r--r--    1 bin      bin           32876 Jan 16 10:23 vac.cfg.51
-rw-r--r--    1 bin      bin           37043 Jan 16 10:23 vac.cfg.52
-rw-r--r--    1 bin      bin           37045 Jan 16 10:23 vac.cfg.53
Not there. Okay...
# cp vac.cfg.53 vac.cfg.61
# vi vac.cfg.61
Remove the last lines:
oslevel   = 5.3
os_major  = 5
os_minor  = 3
Done.
# ln -s vac.cfg.61 vac.cfg
# chown bin.bin vac.cfg.61 
# cc -V
blah blah
I win.

Friday, January 11, 2013

solaris 10 re-ip notes

these are for me.

uname -a

sol10?  yeah...

vi /etc/hosts
vi /etc/inet/ipnodes
vi /etc/nodename 
vi /etc/hostname.e1000g0 
vi /etc/defaultrouter 
vi /etc/netmasks 
vi /etc/resolv.conf
reboot -- -r

hosts
10.10.10.101   sunbox   loghost

nodename
sunbox

hostname.e1000g0
10.10.10.101 netmask 255.255.240.0

defaultrouter
10.10.10.1

netmasks
10.10.10.0 255.255.240.0

other things to check:
/etc/vfstab
/etc/ldap.conf
/var/ldap/ldap_client_file 

Tuesday, January 8, 2013

solaris 10 zone ip change

note to self:
zonecfg -z zonename
select net address=x.x.x.x (current address)
set address=y.y.y.y (new address)
end
verify
commit
exit

good times with system inventories

i heart lists. i really do.

i have lots and lots of lists. sometimes people send me lists asking me to do things with things on lists. one of my favorite sorts of lists is an inventory list. i like to know what i have.

one day, say today, someone asked me to turn off a scad of systems that were on a list. it was a long list. but some things on the to-be-turned-off list were not on my list. how do i figure out what is mine or not?

sort and awk are my friends.
sort mysystems.txt maybemysytstems.txt | awk 'seen[$0]++ == 1' > systemsonbothlists.txt
and there you go.

Monday, January 7, 2013

samba wins flags

because it is fun making linux machines pretend they're nt4 boxes.
edit /var/lib/samba/wins.dat for fun and profit:
wins flags for NetBIOS

On the WINS server, there is a NetBIOS name for each service a NetBIOS computer offers. This uses the 16th hidden character of the NetBIOS names.  The same flags are used in lmhosts entries.

The characters and their meanings are:

 00 - Workstation service (Domain name) or (Workgroup name) or (Computer name)
 03 - Messenger service (Computer name) or (User name)
 06 - RAS server service (Computer name)
 1B - Primary domain controller (Domain name)
 1C - Domain controller or PDC or BDC (Domain name)
 1D - Master browser (Domain name)
 1E - servers only; indicates the computer would become a browser if requested.. (Domain name) or (Workgroup name)
 1F - NetDDE service (Computer name)
 20 - Server service (Computer name)
 21 - RAS client (Computer name)
 BE - Network Monitoring Agent service (Computer name)
 BF - Network monitor utility service (Computer name)
here's a nice snippet of wins.dat for a domain. the zilch means permanent record.
"AWESOME#1d" 0 192.128.80.22 e4R
"AWESOME#1e" 0 255.255.255.255 e4R
"AWESOME#1b" 0 192.128.80.22 e4R
"AWESOME#1c" 0 192.128.80.22 e4R
"AWESOME#00" 0 255.255.255.255 e4R
1d is very important if you want other systems that are using wins to not preempt the domain master browser if their os is "higher."