Jump to content

geudrik

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

Posts posted by geudrik

  1. I'm not entirely sure this is the right sub forum, but essentially I'm running to

    ** Pushing [type] [body] [number] [date] to array
    Segmentation fault (core dumped)
    

    I have traced it back to quite literally pushing an array into a parent array. I have no idea where to even begin debugging this...

    Ideas? :S

     

    This is all CLI by the way, no web front end at all. Just a maintenance script I'm writing.  I have E_ALL (for everything), and a -1 memory limit. Shy of that I'm at a loss.

  2. I was thinking that maybe the best way to do it would be to keep track of where the script is in the array, using an index array of numeric values that essentially is just a list.

    eg:

    $counter = array(1,2,3,4);
    

    And on the fly, just reconstruct the string based on Key/Value names when requested by the string output.  This clearly is a very inefficient way to do it, but it's about the best idea I've got, given my knowledge... :-\

    The first issue I foresee though is keeping the array alive/making it available to the child of the function when it spawns itself on each child array...

  3. Fundamentally, I have the parser working. However what isn't working is how it creates the string in the end.  It, for each array, creates a string that is a concatenation of the entire Toplevel parent array. 

     

    Suggestions to circumvent this?  There several elements in the lowest level children arrays.  For each one of those elements, the string portion before the element values needs to remain static.  Once the child array has been exhausted of all values, the process repeats, starting one level higher.

    This is what I'm going after...
    Ford/Mustang/Seats/Leather
    Ford/Mustang/Seats/Cloth
    Ford/Mustang/Trim/Wood
    Ford/Mustang/Trim/Plastic
    Ford/F-150/..
    
    This is what I get...
    Ford/Mustang/Seats/Leather
    Ford/Mustang/Seats/LeatherCloth
    Ford/Mustang/Seats/LeatherClothWood
    ...
    

     

    Setting the string value to null at the end of the loop doesn't work, as then it loses its current path information, and winds up just dumping the element value of the child array it's walking.

     

    Thoughts?  :confused:

     

    PS: Thanks Zane for the usage of the amprisand - I had no idea that it had that functionality!

  4. I have a large multidimensional array that can exist of any number of Children arrays, each having the potential to have any number of their own children (though, realistically not to exceed a few layers deep before actual values being to appear)

     

    For example, my array might look something like this...

    Array
    (
        [Ford] => Array
        (
            [Mustang] => Array
            (
               [seats] => Array
                (
                    [0] => Leather
                    [1] => Cloth
                )
                [Trim] => Array
                (
                    [0] => Plastic
                    [1] => Wood
                )
             )
             [F-150] => Array
             ...
        )
        [Honda] => Array
        ...
    )
    

    What I'm trying to do is traverse the array to the lowest child and work backwards.  For example, I'm trying to create a single string (or series of strings) similar to the following

    Ford/Mustang/Seats/Leather
    Ford/Mustang/Seats/Cloth
    Ford/Mustang/Trim/Wood
    Ford/Mustang/Trim/Plastic
    Ford/F-150/..
    ....
    

     

    What would be the easiest way to go about this?  Making a function, testing if the child is an array and recalling the function from within the function, until it hits a key value that isn't an array, then walking backwards?  That seems the most logical to me, but then I run into the issue of trying to combine Key names to Key values.

     

    Thoughts and/or suggestions?

  5. I'm quite new to bash, but trying to drag my way up the latter one rung at a time here.

     

    I've managed to write the beginnings of a script that's going to help me out with rsync backups (well, it's more an exercise for my sef) but I can't seem to get my statements to work properly...

     

    Here's the code I've written

    #!/bin/sh
    if ( ! getopts "l:r:u:p:df:h" opt); then
    
        echo "Usage: `basename $0` options [-l /path] [-r /path] [-u username] [-p password] [-d] [-f /path] -h for Help";
        exit 1;
    
    elif (getopts "h" opt) then
    
        echo "\nHelp page for `basename $0`"
        echo "The following parameters are accepted"
        echo ""
        echo ""
        echo "[-l]      Specifies a Local path to folder to backup."
        echo "[-r]      Specifies a path on the Remote machine to back up to."
        echo "[-u]      The Username used for our SSH Connection."
        echo "[-p]      The password used for our SSH Connection."
        echo "          * Public Key Authentication will be tried first."
        echo "[-d]      Tells `basename $0` to preform a dry-run. ie: dont transfer data"
        echo "[-f]      The local path for our Filter list."
        echo "          * List of files/folders, one line each, that rsync will ignore"
        echo "\n"
        exit 0; # Script technically completes successfully.
    
    else
    
        # Don't include -h here 
        while getops ":l:r:u:p:df:" opt; do
            case $opt in
                
            l)  
                echo "-l switch thrown. local dir to backup: $OPTARG" >&2
            ;;  
                
                
            r)  
                echo "-r switch thrown. remote dir for backup: $OPTARG" >&2
            ;;  
    
    
            u)  
                echo "-u switch thrown. ssh username: $OPTARG" >&2
            ;;  
    
        
            p)  
                echo "-p switch thrown. ssh password: $OPTARG" >&2
            ;;  
    
    
            d)  
                echo "-d switch thrown. This is a dryrun." >&2
            ;;  
    
    
            f)  
                echo "-f switch thrown. Path to filterlist: $OPTARG" >&2
            ;;  
    
    
            # Invalid Parameter
            \?) 
                echo "Invalid options passed" >&2
                exit 1;
            ;;  
    
            esac
        done
    
    fi
    

     

    When I run

    Fak:backup-script geudrik$ ./BACKUP_MasterScript.sh -f

     

    I get the following error:

    ./BACKUP_MasterScript.sh: option requires an argument -- f
    ./BACKUP_MasterScript.sh: illegal option -- f
    
    Help page for BACKUP_MasterScript.sh
    The following parameters are accepted
    
    
    [-l]		Specifies a Local path to folder to backup.
    [-r]		Specifies a path on the Remote machine to back up to.
    [-u] 		The Username used for our SSH Connection.
    [-p]		The password used for our SSH Connection.
    		* Public Key Authentication will be tried first.
    [-d]		Tells BACKUP_MasterScript.sh to preform a dry-run. ie: dont transfer data
    [-f]		The local path for our Filter list.
    		* List of files/folders, one line each, that rsync will ignore

    Assuming I'm not totally derping here, I feel like I should only be getting my switch thrown string.  Why am I not, but instead getting the help contents?

  6. I thought that it'd be easy to sort the returned array by record_date simply by turning it into a sub query, but I wind up with an error when I do that

    Every derived table must have its own alias

     

    So I give the sub query a name of derrived_table, but it's still not sorting properly. I wind up with all of my calls at the end of the table, not interspersed through the messages based on their datetime. 

     

    Where am I going wrong now? :S

     

    The whole query looks like this:

    SELECT * FROM (
    
    								SELECT 
    										message AS message_message,	message_type,
    										0 AS call_duration,
    										0 AS call_type,
    										message_date AS record_date
    
    								FROM new_messages
    								WHERE thread_number = '$the_thread'
    
    								UNION
    
    								SELECT
    										'' AS message_message,
    										0 AS message_type,
    										duration AS call_duration,
    										type AS call_type,
    										call_date AS record_date
    
    								FROM new_calls
    								WHERE NUMBER = '$the_thread'
    
    								) 
    								AS derrived_table
    								ORDER BY 'record_date' DESC
    

  7. Well, I'm making progress but now it's breaking... I get no messages dumped and my calls are in my message columns...

     

    select * from (
    select
    message as message_message, 
    message_type as message_type, 
    epoch_date as message_date, 
    '' as call_duration, 
    '' as call_datetime,
    '' as call_type
    from messages
    where thread_number='8028816610'
    order by message_date asc
    ) as message_table
    
    union
    
    select * from (
    select
    duration as call_duration,
    datetime as call_datetime,
    type as call_type,
    '' as message_message,
    '' as message_type,
    '' as message_date
    from calls
    where number='8028816610'
    order by call_datetime asc
    ) as call_table
    

     

    Where am I going wrong here :S

     

    Here's a schema for you of both tables.

    CREATE TABLE IF NOT EXISTS `calls` (
      `id` int(10) NOT NULL AUTO_INCREMENT,
      `number` varchar(255) NOT NULL,
      `duration` int( NOT NULL,
      `datetime` varchar(255) NOT NULL,
      `type` int(1) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=178 ;
    
    CREATE TABLE IF NOT EXISTS `messages` (
      `id` int(9) NOT NULL AUTO_INCREMENT COMMENT 'internal id of the message',
      `user_id` int(5) DEFAULT NULL COMMENT 'The UserID within this DB that that the message belongs to ',
      `thread_number` varchar(255) NOT NULL COMMENT 'The phonenumber of the thread that the message is part of',
      `message` text NOT NULL COMMENT 'The Message',
      `message_type` int(1) NOT NULL COMMENT '1: Send BY the other person, 2: Sent by YOU, the user',
      `epoch_date` bigint(255) NOT NULL COMMENT 'The Date/Time in Epoch Format.. much easier for comparison',
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=16650 ;
    

  8. The array posted at the top are real-world records, simply replaced the actual number and message with jibberish.  When dumped out in HTML format, it would show messages with a call showing up between messages where it's datestamp is next in line.  Note that the datestamps are in epoch format (in ms) for ease of comparison.

     

    As for the union.. I've not used a union before, but from everything I'm reading, I'm unsure how I can use it over two different tables that don't have identical fields.. Eg: my calls table doesn't (for obvious reasons) have a message field. 

  9. I'm not entirely sure how to phrase the title, so I hope it's appropriate...

     

    I have an array which looks like the following..

    Array
    (
        [contact] => Array
            (
                [0] => Array
                    (
                        [name] => Someone Cool
                        [number] => 1234567890
                    )
    
            )
    
        [messages] => Array
            (
                [0] => Array
                    (
                        [message] => A message that was recieved
                        [date] => 1234567890
                        [type] => 1
                    )
    
                [1] => Array
                    (
                        [message] => A message which was sent
                        [date] => 1322175702616
                        [type] => 2
                    )
            )
        [calls] => Array
            (
                [0] => Array
                    (
                        [datetime] => 1320674980836
                        [type] => 1
                        [duration] => 7
                        [number] => 1234567890
                    )
    
                [1] => Array
                    (
                        [datetime] => 1320675327541
                        [type] => 2
                        [duration] => 638
                        [number] => 1234567890
                    )
           )
    
    )
    
    

     

    [messages] can have anywhere between 40 and 3000 children

    [calls] can have anywhere from 0 to 200ish children

    ** These are generals, but realistically, either can have any number.

     

    What I'm trying to do is dump all messages and calls.

     

    The catch is this: When dumping a call, a check needs to be run against datestamps and only dump the next call coming out where the datestamp of the call is NEWER than the LAST message dumped, AND OLDER than the message that is to be dump in this cycle of the loop.  What I have so far is the following...

    foreach($vardump['messages'] as $message) {
    
    // So we have a reference point for the first call we're going to dump
    if(!is_numeric($last_message_stamp)) { $last_message_stamp	=	$message['date']; }
    
                if( trim($vardump['calls'][$calls_counter]['datetime']) > trim($last_message_stamp) &&
    		trim($vardump['calls'][$calls_counter]['datetime']) < trim($message['date'])) {
    
    		// Dump the calls row!
    		echo("
    			<div class=\"chatbubble-call\">
                		<div class=\"chatbubble-person\">".$vardump['contact'][0]['name']."</div>
                		<p>".$vardump['calls'][$calls_counter]['number']."</p>
    				<p>".date("h:i:s", $vardump['calls'][$calls_counter]['number'])."</p>
                		<div class=\"chatbubble-datetime\">".date("l, j F, Y -- h:i:s", $vardump['calls'][$calls_counter]['datetime'] / 1000)."</div>
            		</div>
    		");
    
    		// Increase our calls index
    		$calls_counter++;
    
    
    	}
    
    
    	// Begin dumping Texts out 
    	// Let's see which style type we're dumping out...
    	if($message['type'] == 2) { // Message Sent 
    
    		echo("
    			<div class=\"chatbubble-sent\">
    				<div class=\"chatbubble-person\">Pat Litke</div>
    				<p>".$message['message']."</p>
    				<div class=\"chatbubble-datetime\">".date("l, j F, Y -- h:i:s", $message['date'] / 1000)."</div>
    			</div>
    		");
    
    
    	} else { // Message Recieved
    
    		echo("
    			<div class=\"chatbubble-recieved\">
    				<div class=\"chatbubble-person\">".$vardump['contact'][0]['name']."</div>
    				<p>".$message['message']."</p>
    				<div class=\"chatbubble-datetime\">".date("l, j F, Y -- h:i:s", $message['date'] / 1000)."</div>
    			</div>
    		");
    
    	}
    
    	// Reset our $last_messge_stamp variable
    	$last_message_stamp	=	$message['date'];
    
    
    
    
    }
    

     

    I should also add that I am using the following queries to pull this date out of my database...

    $sql_get_messages			=	"SELECT * FROM messages 
    										WHERE thread_number LIKE '%$the_thread%'
    										ORDER BY epoch_date ASC";
    
    $sql_get_calls				=	"SELECT * FROM calls 
    										WHERE number LIKE '%$the_thread%'
    										ORDER BY datetime ASC";								
    
    $sql_get_contact			=	"SELECT * FROM contacts
    										WHERE number LIKE '%$the_thread%'
    										LIMIT 1";
    

     

    But, I feel that this is horribly inefficient, and it doesn't work right... I only ever get a single call dumped.  What am I doing wrong?

     

  10. Edit

     

    [Thu Nov 03 13:51:20 2011] [info] [client 184.171.147.37] Connection to child 0 established (server somesite.com:443)
    [Thu Nov 03 13:51:20 2011] [info] Seeding PRNG with 656 bytes of entropy
    [Thu Nov 03 13:51:20 2011] [info] Initial (No.1) HTTPS request received for child 0 (server somesite.com:443)
    [Thu Nov 03 13:51:20 2011] [info] [client 184.171.147.37] Requesting connection re-negotiation
    [Thu Nov 03 13:51:20 2011] [info] [client 184.171.147.37] Awaiting re-negotiation handshake
    [Thu Nov 03 13:51:21 2011] [error] [client 184.171.147.37] Certificate Verification: Error (20): unable to get local issuer certificate
    [Thu Nov 03 13:51:21 2011] [error] [client 184.171.147.37] Re-negotiation handshake failed: Not accepted by client!?
    [Thu Nov 03 13:51:21 2011] [info] [client 184.171.147.37] Requesting connection re-negotiation
    [Thu Nov 03 13:51:21 2011] [error] [client 184.171.147.37] Re-negotiation request failed
    [Thu Nov 03 13:51:21 2011] [error] SSL Library Error: 67702888 error:04091068:rsa routines:INT_RSA_VERIFY:bad signature
    [Thu Nov 03 13:51:21 2011] [error] SSL Library Error: 336101498 error:1408807A:SSL routines:SSL3_GET_CERT_VERIFY:bad rsa signature
    

     

    [Thu Nov 03 13:51:21 2011] [error] [client 184.171.147.37] Certificate Verification: Error (20): unable to get local issuer certificate

    Is my problem line I suspect...

  11. Alright, so here is what my apache error log has to say about this...

    I am using a cert that I created on my server and then signed using the ssl.key and ssl.crt files. The certificate is installed in FF, and I now get the following error in FF

    An error occurred during a connection to noobitron.com.
    
    Peer does not recognize and trust the CA that issued your certificate.
    
    (Error code: ssl_error_unknown_ca_alert)
    

     

    Below is the tail for a failed handshake... :s  Does anyone have any idea what I'm doing wrong?

    [Thu Nov 03 12:54:28 2011] [error] [client x.x.x.x] Re-negotiation handshake failed: Not accepted by client!?
    [Thu Nov 03 12:54:28 2011] [error] [client x.x.x.x] Re-negotiation request failed
    [Thu Nov 03 12:54:36 2011] [error] [client x.x.x.x] Certificate Verification: Error (20): unable to get local issuer certificate
    [Thu Nov 03 12:54:36 2011] [error] [client x.x.x.x] Re-negotiation handshake failed: Not accepted by client!?
    [Thu Nov 03 12:54:36 2011] [error] [client x.x.x.x] Re-negotiation request failed
    [Thu Nov 03 12:54:36 2011] [error] SSL Library Error: 67702888 error:04091068:rsa routines:INT_RSA_VERIFY:bad signature
    [Thu Nov 03 12:54:36 2011] [error] SSL Library Error: 336101498 error:1408807A:SSL routines:SSL3_GET_CERT_VERIFY:bad rsa signature
    

     

    As a recap for the steps I'm taking...

     

    Creating a new .crt on my server

    Signing the .crt with my ssl.key and ssl.crt files

    Converting the signed crt into a pk12

    Importing the .pk12 into FF

    Trying to access the site

    Fail

     

     

    Am I going wrong somewhere along the way? The only other thing that I can think of, and that I can't really find much info about, is using FF to gen the certificate, having the server sign it, then asking the client to accept it.. But again, I can't find diddly for information about that...

  12. Here is my diagnostic information for normal SSL communication

    Do any of the info atributes need to match the signing certificate, when I create the private keys to be signed?

    ie: do any of these values need to match when I create the client certs?

    depth=1 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Class 1 Primary Intermediate Server CA
    

    $ openssl s_client -connect xxx.com:443
    CONNECTED(00000003)
    depth=1 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Class 1 Primary Intermediate Server CA
    verify error:num=20:unable to get local issuer certificate
    verify return:0
    ---
    Certificate chain
    0 s:/description=503173-XEKhuo5DI0y28uVT/CN=www.xxx.com/emailAddress=xxx.com@email.com
       i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
    1 s:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
       i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority
    ---
    Server certificate
    -----BEGIN CERTIFICATE-----
    cert code here
    -----END CERTIFICATE-----
    subject=/description=503173-XEKhuo5DI0y28uVT/CN=www.xxx.com/emailAddress=xxx.com@email.com
    issuer=/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 1 Primary Intermediate Server CA
    ---
    No client certificate CA names sent
    ---
    SSL handshake has read 4678 bytes and written 369 bytes
    ---
    New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
    Server public key is 4096 bit
    Secure Renegotiation IS supported
    Compression: zlib compression
    Expansion: zlib compression
    SSL-Session:
        Protocol  : SSLv3
        Cipher    : DHE-RSA-AES256-SHA
        Session-ID: 81AAC82B8BE62F1342A265607CB09AC86FB3F655FE7A32192786D437BDA822A3
        Session-ID-ctx:
        Master-Key: CE0B68C1C4BE88F361937A9A9B9E01AC8A6A3D4FF62084201961455544E3D7EF81A2FD1A67E8144C7A067962FAFFAC5A
        Key-Arg   : None
        PSK identity: None
        PSK identity hint: None
        Compression: 1 (zlib compression)
        Start Time: 1319810200
        Timeout   : 7200 (sec)
        Verify return code: 20 (unable to get local issuer certificate)
    ---
    closed
    
    

  13. Using vhosts, by your explanation, seems to be a waste of time.

     

    I would go about this doing the following (assuming that you need server functionality - ie: php parsing)

    Have just your default vhost and move 'other' into your default vhost, just as a folder (eg: http://localhost/other)

    Then, edit your hosts file and add in lines for

     

    Firstly, a hosts file (and DNS) only maps an ip to a domain, not a url. Besides, allot of applications assume they are within the document root.

    In windows 7, you can actually map any string to any location via the hosts file.

    For example: I have "Music" as an entry that points to \\myserver\mymusicshare

    Just my .02

     

    Note/Edit: I specify Win 7 because it's the only OS that I have screwed around with the hosts file. I cannot speak outside of Win 7 in this instance.

  14. Well... using

            <Directory "/var/www/sekrit">
                    # SSLCACertificateFile    /etc/apache2/ssl/ssl.crt
                    SSLCACertificateFile    /etc/apache2/ssl/ca.pem
                    SSLVerifyClient require
                    SSLVerifyDepth  10
                    SSLOptions      +StrictRequire
                    SSLRequire      %{SSL_CIPHER_USEKEYSIZE} >= 128
                    Options +Indexes
            </Directory>
    

     

    I get prompted to identify my self, so I used one of the certs I've created, Then I get a blank page, so I refresh and I get this error...

    An error occurred during a connection to thesite.com.
    
    Peer does not recognize and trust the CA that issued your certificate.
    
    (Error code: ssl_error_unknown_ca_alert)
    

     

    Can anyone shed any light on this?  :wtf:

     

    Edit: I understand what the error is saying / what it means, but it doesn't make any sense... I'm using the crt that startcom gave me (my class 1) to sign the users' keys when I convert them into k12's...  So what am I missing?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.