Friday, May 13, 2011

i like to see what others type + syslog-ng

Once you've gone through the trouble of patching bash to send output to local5, you might find that you're not using syslog, as assumed in a previous post. Instead, you're using syslog-ng. That's cool.

In your syslog-ng.conf file, you'll need to edit some stanzas, filters and destinations.

Set local5 (bash output) destination, if you want it to go to a file.
# bash destination 
destination d_local5 { file("/var/log/local5"); }; 

# bash filters 
filter f_local5 { facility(local5); }; 

and in messages filter, add local5
filter f_messages {
        level(info,notice,warn)
            and not facility(auth,authpriv,cron,daemon,mail,news,local5);
};
and finally, set the log destination:
# local5
log {
        source(s_all); 
        filter(f_local5);
        destination(d_bash);
};

If you have a remote syslog daemon or logger such as loggly or splunk set up, drop their destination definitions in the log stanza for "local5". e.g.:

# loggy
#
destination d_loggly { tcp("logs.loggly.com" port(XXXXXX)); };

# local5
log {
        source(s_all); 
        filter(f_local5);
        destination(d_local5);
        destination(d_loggly); 
};

On loggly (if you've allowed the destination in your remote device list) or splunk, you should see something akin to:
2011 May 13 16:09:19.000 s_all@host1 bash-ub610: history: [pid:5379 uid:0] exit
2011 May 13 16:09:50.000 s_all@host1 bash-ub610: history: [pid:5584 uid:0] ls -la
2011 May 13 16:09:52.000 s_all@host1 bash-ub610: history: [pid:5584 uid:0] cd /opt/
In your old /etc/syslog.conf or /etc/rsyslog.d/50-default.conf add the following:
auth,authpriv.*;local5.*        @syslogserver
auth,authpriv.*;local5.*        @logs.loggly.com:yourportno

Thursday, May 12, 2011

microsoft dhcp and me

I like to use dhcpd on a Linux box because I can set all kinds of options, like giving search suffixes to my DHCP clients. Microsoft Windows Server iterations have no such option - or so you're told. By default, yes, this isn't an option, but at least in Server 2008, you can add new DHCP options to include the DHCP-supplied option. To do as such:

1.  Open the DHCP mmc
2.  Expand DHCP, select DHCP server name.
3.  Right Click IPv4
4.  Select "Set Predefined Options"
5.  Click Add.

A new window appears

6.  Enter the following:
Name: "Domain suffix search order" (without quotation marks)
Data Type: String
Code: "135" (without the quotation marks)
Description: "List of domain suffixes in order" (without the quotation marks)
String: Enter search suffixes separated by comma with no spaces
 
7.  Click OK.
8.  Close DHCP MMC and restart DHCP Server Service.

Now, re-open the DHCP mmc, scroll to the end of the DHCP options, and the newly created option will appear.

Monday, March 7, 2011

apache & openldap group authentication

For Apache 2.2, check your mod-enabled and mods-available directory. Make certain your ls in mods-available have the following symlinked from mods-enabled; e.g.:

 alias.load -> ../mods-available/alias.load
 auth_basic.load -> ../mods-available/auth_basic.load
 authnz_ldap.load -> /etc/apache2/mods-available/authnz_ldap.load
 authz_default.load -> ../mods-available/authz_default.load
 authz_user.load -> ../mods-available/authz_user.load
 ldap.load -> ../mods-available/ldap.load

In your site-available file, load these two loaded mods, with the following:

 LoadModule ldap_module           /usr/lib/apache2/modules/mod_ldap.so
 LoadModule authnz_ldap_module    /usr/lib/apache2/modules/mod_authnz_ldap.so

In the directory structure where you'd like to have LDAP authentication to take place, add the following stanza:

 AuthBasicProvider ldap
 AuthType Basic
 AuthzLDAPAuthoritative on
 AuthName "restricted site access"
 AuthLDAPURL ldap://www.xxx.yyy.zzz/ou=users,dc=your,dc=com?uid
 AuthLDAPGroupAttribute memberUid
 AuthLDAPGroupAttributeIsDN off
 Require ldap-group cn=agroup,ou=groups,dc=your,dc=com
 Require ldap-user adude anotherdude
 Satisfy any

If you have a round-robin LDAP setup, place the FQDN of your OpenLDAP server in the AuthLDAPURL section. The uid condition means that your authentication control is via uid. AuthLDAPGroupAttribute and its allied Require ldap-group, states that you're checking for membership in a specific group "agroup", and those members have the attribute "memberUid". You can tack on an individual user (or users on the same line), by specifying "Require ldap-user". And, To allow for both groups and users, have the "Satisfy any" directive set; otherwise no one will be able to log on and use your web-resource.

Monday, January 24, 2011

a bind slave configuration on ubuntu is sometimes vexing

while installing a slave dns server with bind on an ubuntu box, i found that the slave zone would not synchronize. logs are your friends. in /var/log/daemon.log , I saw the following:
named[4402]: dumping master file: /etc/bind/tmp-xxxxxxx: open: permission denied
named[4402]: transfer of 'www.xxx.yyy.zzz/IN' from master#53: failed while receiving responses: permission denied
it appears that named was unable to write to /etc/bind/ .
after some digging and using strace, i discovered that ubuntu is shipped with slave zone files residing here:
/var/cache/bind/
in /etc/bind/named.conf the zone definition ought to have the following format:
zone "mydomain.com" IN {
        type slave;
        file "/var/cache/bind/db.mydomain.com";
        masters { www.xxx.yyy.zzz; };
};
(or no path to the file)

and have the correct permissions:
# chown -R bind:bind /var/cache/bind/
# chmod -R g+w /var/cache/bind/
bind also needs permissions to write to various zone files, in:
/etc/default/bind9
add:  ENABLE_ZONE_WRITE=yes
however, my slave zone would still not synchronize. this was due to apparmor (sure, i knew that); edit:
/etc/apparmor.d/usr.sbin.named 

change: /etc/bind/** r,
to: /etc/bind/** rw,
some other excitement is to actually resolve things on the localhost.
/etc/network/interfaces

add:
dns-nameservers 127.0.0.1

and in /etc/bind/named.conf.options include the following stanza:
        forwarders {
                8.8.8.8; <- our friend google for ext lookups
                8.8.8.4; <- our friend google for ext lookups
                10.6.6.6; <- an internal server for internal lookups
        };

Monday, January 17, 2011

ubuntu host, let's rename you, shall we?

easy peasy.

to change an ubuntu system's hostname, do the following:
# /bin/hostname new.name
# vi /etc/hosts
# grep -r old.name /etc
# /etc/init.d/cron restart
on a debian system, do the following:
# /bin/hostname new.name
# vi /etc/hostname
# vi /etc/hosts
# grep -r old.name /etc
# sysctl kernel.hostname=new.name
# /etc/init.d/cron restart

Wednesday, December 22, 2010

resetting windows local security policy is annoying

sometimes you just need to remove a system from one ad domain and add it to another. a problem is that the other domain's registry settings get tattooed. yuck.

well, i like to just reset everything, because i'm lazy that way. as administrator at the command prompt...

for xp & server 2003:
secedit /configure /cfg %windir%\repair\secsetup.inf /db secsetup.sdb /verbose

for vista:
secedit /configure /cfg %windir%\inf\defltbase.inf /db defltbase.sdb /verbose

Friday, December 17, 2010

solaris 10, mount those automounts, please?

Solaris and failing mounts get me depressed sometimes. After you've rebooted a machine your nice UDP NFS mounts just don't go or you've made a change in one of your auto defs and your brain is addled because you work with so many variants of Solaris it just isn't funny anymore.

Solaris 8 and 9 were pretty easy. To restart the service (which wasn't one) after you've mucked about in /etc/auto_master &c.:
# /etc/init.d/autofs stop; /etc/init.d/autofs start

Solaris 10 is different. The init script is no longer there, and autofs has become a service. To figure out if is running and to (re)start it after doing what you need to do, follow this sequence:
# svcs | grep auto
legacy_run     14:14:53 lrc:/etc/rc2_d/S72autoinstall
online          9:51:27 svc:/system/filesystem/autofs:default
# svcadm -v restart svc:/system/filesystem/autofs:default
Action restart set for svc:/system/filesystem/autofs:default.
cd to your newly mounted dirs and away you go.