Admin Life Errors, Fixes, and Encounters

4Feb/150

Send a test mail using Telnet

Telnet into the smtp server (postfix)

# telnet localhost 25

The server should reply with:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mytestmail.com ESMTP Postfix

Great. Postfix is listening and wants us to speak SMTP:

ehlo example.com

Postfix appreciates the EHLO and tells us which features it provides:

250-my-new-mailserver
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Hey, Postfix, we have a mail from joe@example.com:

mail from:<joe@example.com>

Looks like Postfix is happy with that because return codes that start with a '2' are good news:

250 2.1.0 Ok

Tell Postfix who the recipient of the mail is:

rcpt to:<john@example.com>

Postfix accepts that:

250 2.1.5 Ok

Then we are ready to send the actual mail:

data

Postfix agrees and tells us we can send the actual mail now and end our input with a dot on an empty line:

354 End data with <CR><LF>.<CR><LF>

Okay, type in the mail:

Hi John,

just wanted to drop you a note.
.

Postfix tells us it has received the mail and queued under a queue ID:

250 2.0.0 Ok: queued as AK782JKD4

Thanks, Postfix, we are done:

quit
Filed under: Errors No Comments
4Feb/150

ezjail / jail setup on freebsd 9.3

# cd /usr/ports/sysutils/ezjail
# make install clean

create a base jail

# ezjail-admin install -sp

update the basejail with freebsd-update
# ezjail-admin update -u

update the base jail's ports tree

# ezjail-admin update -P

rc.conf entry ensures our jail will be started at boot and gets the IP it needs.
# ifconfig em0 alias 192.168.1.13 netmask 0xffffff00 broadcast 192.168.1.255
# echo 'ifconfig_em0_alias0="inet 192.168.1.13 netmask 0xffffff00 broadcast 192.168.1.255"' >> /etc/rc.conf
# echo 'ezjail_enable="YES"' >> /etc/rc.conf

Create the jail
# ezjail-admin create myjail.com 192.168.1.13
# cp /etc/resolv.conf /usr/jails/myjail.com/etc/
# service ezjail start
to see running jail
# jls

to get console access to the jail
# ezjail-admin console myjail.com
to stop a jail
# ezjail-admin stop myjail.com

to archive for you to copy a jail
# ezjail-admin archive myjail.com

The archived file should appear in /usr/jails/ezjail_archives. you can then duplicate it as many times as you want. If you install ports, don't bother copying the jail to another machine, there will be missing libraries...
# ezjail-admin create -a /usr/jails/ezjail_archives/myjail.com.tar.gz myjail.com 192.168.1.13
# ezjail-admin start myjail.com
 
Filed under: Errors No Comments
4Feb/150

freebsd 9.3 error warning: smtputf8_enable is true, but EAI support is not compiled in

if you are getting this error "warning: smtputf8_enable is true, but EAI support is not compiled in" on freebsd 9.3 (maybe freebsd 10) it's a bug in the port config. EASY way to fix it (well best way to fix it) is to compile postfix with EAI support.

# cd /usr/ports/mail/postfix-current/
# make config

Make sure you select EAI from the list

# make install clean
or
# make reinstall clean

Filed under: Errors No Comments
30Jan/150

How to build php5 module into apache22 with freebsd

The Apache module is no longer inside ports/lang/php5. there is no option to build php with apache.

The fix:

use www/mod_php5 to get apache to run php

Also note that

The Apache PHP module has been separated from the main PHP port. If you had the APACHE OPTION selected, you have to perform the following steps:

1) update your lang/php* options (i.e. 'make config')

2) rebuild lang/php* port

3) install www/mod_php* port

It is mandatory to build both ports with the same DEBUG and ZTS options, so if you have a threaded Apache (i.e. worker or event MPM) you have to select the ZTS option in lang/php* port.

 

if you have this error

===>  mod_php55-5.5.17_1 is marked as broken: : Error from bsd.apache.mk. apache22 is installed (or APACHE_PORT is defined) and port requires apache.
*** [install] Error code 1

then make sure you add this line to /etc/make.conf
DEFAULT_VERSIONS=apache=2.2

Filed under: Errors No Comments
30Aug/120

5 Thrifty Tips for Driving Sales with Online Video

If a picture is worth a thousand words, a moving picture adds to that figure exponentially. As a dynamic and immediate marketing tool, video is the next best thing to greeting potential customers face-to-face. Plus, not only can videos help deliver traffic from search engines like Google, but video thumbnails tend to catch the eye in search results better than linked text.

But if a slick, professionally produced clip isn’t within your budget, that’s ok – today’s affordable web and phone cams make it inexpensive to create do-it-yourself videos that look and sound clean enough to get your message across in a professional way.

Online video powerhouse YouTube is the world’s second-largest search engine, reaching 4 billion views per day in January. And as a free service, you don’t need budget to upload videos. That means, all you need to start connecting with your audience is a camera, a story and a plan.

Don’t know where to start? Here are five tips for messaging and presentation of your video:

Tip 1 – Make it unique:  Because the chances are there are already countless videos out there related to your field, it’s important to make your message as unique as possible. Offer hard-to-find information that satisfies a real customer need. Don’t discuss what you want to. Focus on what they want to learn about.
Tip 2 – Make it friendly:  Keep your tone light and conversational. Try to make a personal connection. Present a real-life situation, and address it with a demo of your product. Entertain if you can.
Tip 3 – Make it quick:  Bear in mind the attention span of the viewer. Deliver the message as succinctly as possible – 5 minutes or less for best results. For in-depth or supplemental info, link to a blog post. (You have a blog, right? No? No worries – you can easily start one with the free WordPress blog capability we include in our discounted hosting packages.)
Tip 4 – Make a deal:  Share a video coupon, a special code for a discount or deal for those who watch the video to its end.
Tip 5 – Make it viral:  Upload it to YouTube; post it on Twitter and Facebook. Do whatever you can to make it spread. Craft your message with this in mind: Be funny, be poignant, be memorable.

For other tips, see our blog – http://blog.domainpeople.com/

Filed under: Errors No Comments
27Mar/120

eAccelerator freebsd error shmmax

Freebsd has an issue with eAccelerator right now where when you try to start it it gives you an error "eAccelerator: shmmax should be at least 2MBPHP Warning"

To fix this we're going to remove eAccelerator then reinstall it:

# cd /usr/ports/www/eaccelerator

# make deinstall

# vi MakeFile

The "CONFIGURE_ARGS=" line needs to be changed so it looks like this
CONFIGURE_ARGS= --with-eaccelerator-shared-memory \
--with-eaccelerator-userid=80 \
--without-eaccelerator-use-inode

save the file and exit

then
# make install clean

restart apache

Filed under: Errors, FreeBSD No Comments
9Mar/120

How To Design Your Site Like a Pro

Think of the websites you visit the most — chances are they are clean, professional, and easy to navigate. This is no coincidence: the human mind takes just a millisecond to make a definitive decision as to a site's credibility, and this initial judgment is based entirely on aesthetics which means a good web design is critical for retaining visitors.

This month we consulted with Netfirms's very own Director of Web and UI, he shared with us the best tips and tricks for designing the most visually appealing website:

1) Plan Your Site

    : Before turning on your computer, consider the layout, page structure and how users will move from one page to another (navigation). Then, sketch out your site on paper.

2) Understand Your Audience

    : Knowing your audience will help set the tone for your content and layout, as you identify what visitors will be looking for on your site. It's also important to consider popular web browsers and your visitor's screen resolution size so that they see your site the way you intended; you can find this data in most site analytics tools. If you're not sure how wide to make your site, 960px is a great place to start.

3) Allow for Easy Navigation

    : Since people often read from left to right and top to bottom, the upper left-hand corner of your site is the first place your visitors will look. Place your navigation buttons here and keep them consistent, along with font and color choices, for easy reading and fluid movement from page to page.

4) Choose a Color Scheme

      : If you're designing your site around an image, try uploading it to a color palette tool, like

DeGraeve.com

    's, for example, for complementary color suggestions. Be sure to remain consistent with your design patterns, and stick to no more than three font types and colors.

5) Use High Quality Photos

      : In order to give your site a more professional appearance, all images should be clear, focused, and of high resolution. An alternative to taking your own photos is buying them from

istockphoto.com

    ; at about five-dollars an image it's an inexpensive way to visually take your website to the next level.

6) Test Your Site, Then Test Again

    : When you've created or redesigned your site, ask friends and family to test it for you. They may find things you've missed, or point out areas of confusion.

When paired with quality content, executing these tips appropriately will help retain first-time visitors and transform them into yourdomain.com regulars.

 

Thanks for netfirms for the great tips

Filed under: Errors No Comments
27Sep/110

Apache freebsd munin not working together

I came across an issue with Apache 2.2 on freebsd 8.2 where munin wasn't graphing the Apache data. (apache_accesses, apache_processes and apache_volume )

When I tailed the munin error log I found this error.

tail /var/log/munin/munin-node.log
munin UserAgent not found at apache_volume line 86.
With some researching on google I found this nice munin command to tell me more about how to setup munin. IE what we can install on freebsd.

/usr/local/sbin/munin-node-configure --suggest
The output gave us "LWP::UserAgent not found". which means, install Perl's libwww.

To fix this error we install p5-libwww

cd /usr/ports/www/p5-libwww/
make install clean

Restart munin and everything should now work.

# ./usr/local/etc/rc.d/munin-node restart

ref: http://articles.slicehost.com/2010/4/9/enabling-munin-node-plug-ins-on-ubuntu

8Jun/110

PHP MySQL injection

Here is an example of how an SQL injection that was found, monitored, and fixed!

When dealing with a large website with legacy code sometimes it's not possible to check every query after one starts.

One day while reviewing a new clients slow quries via MySQL. I started to notice these types of quries showing up.

# User@Host: test_db[test_db] @ db.domain.com [12.13.14.15]
# Query_time: 0 Lock_time: 0 Rows_sent: 1 Rows_examined: 48648
select * from serv_main where id = 71261 and 3=8 union select 1,2,3,concat(0x232425,ifnull(`idClient`,0x4E554C4C),char(9),ifnull(`username`,0x4E554C4C),char(9),ifnull(`pass`,0x4E554C4C),char(9),0x252423),5,6,7,8,9,10,11,12,13,14,15,16 from `test_db`.`private` where idClient>2119021 limit 16215,1 --;

# User@Host: test_db[test_db] @ db.domain.com [12.13.14.15]
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 48654
select * from serv_main where id = 71261 and 3=8 union select 1,2,3,concat(0x232425,ifnull(`idClient`,0x4E554C4C),char(9),ifnull(`username`,0x4E554C4C),char(9),ifnull(`pass`,0x4E554C4C),char(9),0x252423),5,6,7,8,9,10,11,12,13,14,15,16 from `test_db`.`private` where idClient>2119021 limit 16217,1 --;

Knowing the table serv_main I knew the developer that wrote that code did not use a UNION.
After a few moments of thinking what was going on I tailed Apaches access log and confirmed what I thought.

120.2.194.136 - - [1/Jan/2010:10:08:40 -0500] "GET /viewAd.php?id=71261%20and%203%3D8%20union%20select%201,2,3,concat%280x232425,ifnull%28%60idClient%60,0x4E554C4C%29,char%289%29,ifnull%28%60username%60,0x4E554C4C%29,char%289%29,ifnull%28%60pass%60,0x4E554C4C%29,char%289%29,0x252423%29,5,6,7,8,9,10,11,12,13,14,15,16%20from%20%60test_db%60.%60private%60%20where%20idClient%3E2119021%20limit%2034642,1%20-- HTTP/1.1" 200 1093 "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)"

It was an SQL Injection attack. so I did the next logical step (to me at least). Block the offender.

I did this by adding his IP to the .htaccess file along with a bigger subnet block.
Order allow,deny
deny from 120.2.194.136
deny from 120.2.194.
allow from all

Now that the Injections had stopped, the next step was to figure out where it was done, how it was done, and how to fix it.

WHERE was it done)
That was easy to find, it's right there in the access log viewAd.php

How was it done)
$sql = "select * from serv_main where id = " . $_GET['id'];
$result = mysql_query($sql);

Fix)
That was the easy part, and the hard part.

The EASY part was just to just use mysql_real_escape_string.

we have 2 quick options here.

Option 1.

$_GET['id'] = (int) $_GET['id']; //cat whatever is passed into id as an integer.

Option 2.

$sql = "select * from serv_main where id = " . mysql_real_escape_string($_GET['id']); //escape user input
$result = mysql_query($sql);

The HARD part, fix the whole site...
Not having time to check 1000's of quries, here was what I did in a 30 mintue span.

1) include a function somewhere in a global include that can clean all input (or cast all input)
a good place was in our db_include.php file.

function sanitize_user_input(&$input) {

$int_keys = array ('id', 'item', 'item_id' );

foreach ( $int_keys as $key ) {
if ( isset($input[$key]) ) {
if ( !empty($input[$key]) && !is_numeric($input[$key]) )
$input[$key] = (int) $input[$key];
}
}
}

if (isset($_GET)) sanitize_user_input($_GET);

The hard part was easier than I thought.

But the truly hard part started, going though the 1000's of queries to fix them.

Some interesting points and notes.

#http://www.asciitable.com/
# 0x232425 = #$%
# 0x252423 = %$#
# 0x4E554C4C = NULL
# 0x4E554C4C = NULL
# CHAR(9) = Tab
# CHAR(10) = Line feed
# CHAR(13) = Carriage return
select concat(0x232425,
ifnull(`idClient`,0x4E554C4C),
char(9),
ifnull(`username`,0x4E554C4C),
char(9),
ifnull(`pass`,0x4E554C4C),
char(9),
0x252423)

Filed under: Errors, MySQL, PHP No Comments
4Sep/100

I've updated the Wedding guest section with some more user friendly UI. Hope bride's & Grooms like it. It should help them greatly with wedding planning and making sure everything gets done on the wedding check list.

Filed under: Errors No Comments