• HEADS UP, Linux 02-24-2011 Comments Off

    The script will need to run thru a wrapper, or the OS will ignore the setuid bit altoghether. Compile the following C program and make it setuid, and it will work:

    #include 
    #include 
    
    int main(int argc, char *argv[])
    {
    argv[0] = "some_script_path";
    
    setreuid(geteuid(), -1);
    execv(argv[0], argv);
    exit(1);
    }
    
  • HEADS UP, Solaris 02-22-2011 Comments Off

    connecting to sun blades

    start /CH/blade/SP/cli
    start SP/console

  • HEADS UP 02-22-2011 Comments Off

    ‘xauth list’ will give the current tokens for the first login user
    SOANDSO/unix:10 MIT-MAGIC-COOKIE-1 498e25150e75b1c319278813d853b1ca

    you can add some or alll of them to a second login user:

    xauth add SOANDSO/unix:10 MIT-MAGIC-COOKIE-1 498e25150e75b1c319278813d853b1ca

  • HEADS UP, Linux, iptables 02-16-2011 Comments Off

    #!/usr/bin/perl -w
    # server.pl
    #--------------------

    use strict;
    use Socket;

    # use port 7890 as default
    my $port = shift || 7890;
    my $proto = getprotobyname('tcp');

    # create a socket, make it reusable
    socket(SOCKET, PF_INET, SOCK_STREAM, $proto)
    or die "Can't open socket $!\n";
    setsockopt(SOCKET, SOL_SOCKET, SO_REUSEADDR, 1)
    or die "Can't set socket option to SO_REUSEADDR $!\n";

    # bind to a port, then listen
    bind( SOCKET, pack( 'Sn4x8', AF_INET, $port, "\0\0\0\0" ))
    or die "Can't bind to port $port! \n";
    listen(SOCKET, 5) or die "listen: $!";
    print "SERVER started on port $port\n";

    # accepting a connection
    my $client_addr;
    while ($client_addr = accept(NET_SOCKET, SOCKET)) {
    # send them a message, close connection
    print NEW_SOCKET "Smile from the server";
    close NEW_SOCKET;
    }

  • HEADS UP, Solaris 02-16-2011 Comments Off
    for i in `ndd -get /dev/${DEV} \? | awk '{print $1}'| grep ^[a-z]`;
    do
    echo -n "$i:"; ndd -get /dev/${DEV} $i;
    done
    
  • Enterprise Manager, HEADS UP, Linux 02-14-2011 Comments Off

    mv /etc/localtime /etc/localtime-old

    ln -sf /usr/share/zoneinfo/GMT /etc/localtime

    hwclock –systohc (or –utc)

  • HEADS UP, SQL & PL/SQL, SQLPLUS 02-11-2011 Comments Off
    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    
  • VMWare 02-07-2011 Comments Off

    vmware-cmd -l
    shows the vhosts on the server

    vmware-cmd start
    will start a vhost.

  • HEADS UP, Linux, Solaris 02-05-2011 Comments Off

    The problem is that the ssh session will wait for the command to complete and the ‘&’ to background the task does not seem to work. The net result is that the script running the nohup ssh command hangs.

    This is because by default ssh does not allocate a TTY to run a command. You can force TTY allocation by using the ‘-t’ option to ssh, which will permit backgrounding, and the ssh command will return immediately.

    In order to demonstrate, create a file /tmp/sleepy like so:

    #!/bin/bash
    while ( true ); do
    echo `date` “sleep”
    sleep 1
    done

    This command will invoke the script over ssh using nohup and &:

    ssh -t localhost ‘nohup /tmp/sleepy &’

    Tags: , ,

  • HEADS UP, Solaris 02-02-2011 Comments Off

    passwd -f <login>