Categories
Unix Websites

Running root commands in PHP via Apache

I have a web application that needs to perform shells commands as root within a PHP function, and you would think that would be pretty straight forward… but it did take my a few googles to get all the details, so here are my handy notes on it. This is on a Linux system running Apache, and we’ll be using “sudo” within “shell_exec” to run the commands.

The main thing is to edit the /etc/sudoers file, and typically you can (as root) use the ”visudo” command to do so.

Make sure apache can run commands, AND not require a password:

apache  ALL=(ALL)       NOPASSWD: ALL

Then you need to comment out this line:

#Defaults    requiretty

If you don’t, then you will see these errors in /var/log/secure: “sorry, you must have a tty to run sudo”. Now you are ready to go, and the PHP code is simple:

$results = shell_exec(‘sudo date’);

Categories
Photos

Borders without Books

It is sad to see all these bookstores closing these days, and even the large bookstores are suffering. Perhaps some karma at play, seeing how they forced the little bookstores to close in the past!

But nonetheless, I am sad to see this particular Borders shut down, since they had an AWESOME selection of tech books! And I was just there a few days ago to see ALL the bookshelves empty of knowledge.

They were selling everything in the store, even those big-ass bookshelves. I thought briefly of putting in a 12 foot high bookshelf in my home office but decided against it.

Categories
Unix

SquirrelMail working with change_sqlpass

I installed SquirrelMail 1.4.21 the other day, and I wanted to add the plugin for password changes. I chose the one that works with MySQL, since I use Dovecot with the MySQL option for users/passwords.

I downloaded the change_sqlpass plugin, and ran into an issue where once the user changed the password, it gave an error “Your session has expired, but will be resumed after logging in again.”

I had to dig around to find some patches people recommended to use, but that plugin download is over 5 years old and has not been updated with it! You basically need to update one file, “functions.php”, so I have done so and you can just grab it here.

Categories
Websites

Changing to PHP5 in Yahoo Web Hosting

I was updating some code on a Yahoo hosted site, and it wasn’t working because Yahoo will default you to PHP4 on their hosting. My code of course requires PHP5.

I spent a fair amount of time searching around for an answer and finally found it at http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-38.html

I was surprised at how difficult it was to find this switch option! After I made this post, Yahoo support replied to give me the proper link and some more information, which I must compliment Yahoo support for doing.

Categories
Unix

Pure-FTPd is good

I sure do like pure-ftpd, it chroots user logins so they can’t chdir all over the place, and is easy to configure and use.

I did have one case lately where I would connect in and it would hang while “entering passive mode”. It turns out I needed to add some extra stuff into iptables. This did the trick:

-A RH-Firewall-1-INPUT -p udp -m udp –dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp –dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp –dport 21 -m recent –set –name FTP –rdest -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp –dport 1024:65535 -m recent –rcheck –seconds 9800 –name FTP –rdest -j ACCEPT

-A RH-Firewall-1-INPUT -p udp -m udp –dport 20 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp –dport 20 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp –dport 21 -m recent –set –name FTP –rdest -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp –dport 1024:65535 -m recent –rcheck –seconds 9800 –name FTP –rdest -j ACCEPT

Categories
Cellphone

Android phone contacts all kafloobered

A few days ago, my nice Android Motorola X phone went all wonky and kafloobered up my contacts!

Yes, that’s right — kafloobered.

It mixed up names and phone numbers so that when I got a call and it said “John Smith calling” it was really someone else. So I’d answer the phone and say “Hey John,” and it would be the guy you’ve been avoiding for the past few weeks because he wants you to introduce him to your wife’s friend who really doesn’t like him… anyway, I digress.

What I had to do was to drop my sync settings in the phone, and re-sync to my exchange server and gmail account again. That fixed it!

Categories
Coding Websites

http AJAX fails in Internet Explorer

I ran across an interesting bug recently where I had an AJAX routine failing when I viewed the page in IE8. When you clicked the little warning icon in the lower left, it gave a message of “Object doesn’t support this property or method”!

It was failing around code that looks like:

function parseCalcResponse() {
if (http.readyState == 4 && http.status == 200) {
results = http.responseText;
results = results.split(“|||”);
document.getElementById(‘test’).innerHTML = results;
}
}

It turns out, the fix was to declare “results” at the top of the function code with:

var results=”;

And that fixed it!

Categories
Unix

SVN in chroot says you don’t exist

You may one day set up a chroot environment and find you get this message when you try to ssh or use svn (using ssh):

You don’t exist, go away!
svn: Connection closed unexpectedly

In addition to my assurance that you do indeed exist in the universe, let me tell you how I fixed it.

Check your chroot /etc to make sure passwd and shadow exist for your user and the IDs are correct.

Then, note that when svn does a repository connection it uses libnss_files.so which can require proper DNS resolution. In my case, I had to add the repository domain name into the chroot /etc/hosts file.

Then I existed in more ways than one.

Categories
Hardware Unix

Fedora13 kernel update breaks video

I did my usual old “yum update” the other day and it hosed up my video upon reboot!

Never fear, it is a known problem, and has probably already been fixed by the time you read this.

But one thing I learned is that you should have akmod installed so the system will be smart and use a previous video driver if it fails. To do this, all I needed to do was:

yum install akmod-nvidia

then, on reboot, it was all working again.

[Update]

One thing to note is that when you do a yum update, make sure if there is a new kernel that there is a corresponding nvidia update for it! If not, then DO NOT yum update, and try again in a day or so. Eventually there will be a matching nvidia update and you are safe to update. Example:

Installing:

kernel x86_64 2.6.34.9-69.fc13 updates 22 M

kernel-devel x86_64 2.6.34.9-69.fc13 updates 6.4 M

Removing:

kernel x86_64 2.6.34.7-63.fc13 @updates 102 M

kernel-devel x86_64 2.6.34.7-63.fc13 @updates 23 M

Installing for dependencies:

kmod-nvidia-2.6.34.9-69.fc13.x86_64 x86_64 1:260.19.36-1.fc13.3 rpmfusion-nonfree-updates 2.8 M

Removing for dependencies:

kmod-nvidia-2.6.34.7-63.fc13.x86_64 x86_64 1:260.19.29-1.fc13 @rpmfusion-nonfree-updates 12 M

Categories
Travel

Hawaii 2010 – the good and the bad

OK, I’m going to depart from my usual tech blogging to give my reviews on some businesses on my 2010 trip to Hawaii. My family and I head to Hawaii typically every two years, and we’ve been to a number of the islands, but this year was our first trip to Maui. Plus, it was our 10 year wedding anniversary, so we wanted a special trip.

We decided on booking the Westin Maui Resort & Spa, because it looked like a top level accommodation plus it had the best pool setup on the island which would be great for the kids.

Well, unfortunately we had more bad than good experiences with this hotel!

Now let me preface my comments with the statement that, in my opinion, one of Hawaii’s main attributes is its hospitality and friendly greetings. Where else is one greeted by friendly smiles, dancing, and neck wear? You sure as heck aren’t greeted like that when visiting France! But that’s a review for another time.

In addition, when I booked the trip, I did so direct with the hotel, and I told the booking person that it was our 10 year anniversary. I also inquired about a meal plan and they said I could either do it on the phone or at the hotel once there.

Here’s the BAD:

  • Upon arrival at the hotel, an attendant greeted us and asked if we were checking in. We said yes, and he took our bags away. We entered the hotel on our own, and there was no greeting. No smiling faces, no leis, no music. We checked in, told the person it was our 10th anniversary, and they did not know it — apparently the booking person on the phone did not make a note in the system. Did this person note anything special at this point? No, just checked us in.
  • We got to the room, and it was not in good shape. The beds were made poorly, there was dust and grime on both phones in the room and on a table, and when we walked out onto the balcony, my daughter asked, “Why do the other balconies have tables and we only have a chair?”
  • Once we called the front desk about this, we went out and 5 hours later nothing had changed. We had to go to the front desk, mention it again, and then people said they would call someone.
  • That night we needed an extra blanket, and called room service. The brought up a blanket that seriously looked 20 years old, was fraying on the edges, and looked like something you would pad your dogs bed with it.
  • The next day we were at the pool near the activities desk, and asked the guy working the desk there if we could use his phone to call housekeeping so they would know our room was empty and could clean while we were out. The guy, who was doing nothing and had no customers, said we can’t use the phone because it was for activities. Of course, it is the same phone as the one in our room (not as grimy though), and hooked into the hotel system. We asked him what phone we could use, and he said a house phone. We asked him where one was, and he said he didn’t know. That was it. He didn’t allow us to make a quick call to housekeeping (hotel call, not local or long distance), and didn’t offer to make the call for us, and did nothing to help us.
  • I let the day manager know that we were not having a good experience, and she was apologetic. I mentioned our 10 year anniversary again, and she congratulated us (more on this below in the GOOD experiences). I asked about meal plans, since we were using the breakfast buffet which is a bit expensive and we wanted to get a week or multi-day plan. She said it was a tricky thing to do, and I may have to cancel my entire reservation and re-book with a special meal plan. I told her the booking agent said I could just get on once on-site, and she said she would call up the chain and see what she could do. She got back to us and said they said nothing could be done and she couldn’t help us. Seriously? Nothing can be done? It’s a meal plan, for crying out loud.

Now, the GOOD:

  • The day manager I interacted with did her best to try and help us, but when we tried to get a breakfast buffet plan, she said the corporate people above her could not help her. Now, this doesn’t make much sense to me, why would they not allow her to provide a meal package I’m not sure. But she tried, and gave us meal passes for one morning. That was nice, but I’m wondering — if she has the ability to give us some free passes, how can she not have the ability to give us discounted passes, or ones for every other day or something like that?
  • The day manager sent us up a bottle of champagne and milk & cookies platter for the kids for our anniversary which was appreciated.
  • The bartenders were ALWAYS helpful.
  • We were at Longhi’s restaurant later that week and told the waitress of our experiences. She was shocked, and told us she used to bartend for the hotel company and apologized for them. Now, she was excellent with customer service, and frankly the hotel should hire her back in that sort of role.

Now, on the rest of the island, here are some excellent experiences we had with restaurants and activities:

Lahaina Pizza Company: This place, first of all, has the best deep dish pizza we’ve had in years! And their management is top notch. When we had an order get confused and the wrong pizza was delivered, the manager personally came over and apologized and offered us a desert on the house. And, he even officated our kids’ drawing contest and diplomatically declared both winners!

Zip-Line Adventure:  Well, the ziplines themselves were pretty short, around 30 seconds each on average. This pales in comparison to some Ziplines you’ll find in places like Costa Rica that can go for 3 minutes! But, they did a great job on the tour — our guide, David, was excellent and told us detailed stories about the island that we above the call of duty.

The Lahaina Grill:  This restaurant was constantly mentioned to us as a consistent award winner on the island, and sometimes when you hear that, it can be a tourist trap. But this place was fantastic. The food was amazing, the service was impressive, and when they knew it was our anniversary they took our picture and provided a nice desert. All in all, one of the best dining experiences we’ve had at any restaurant in the world.

So, what was our final opinion of Maui? Unfortunately, somewhat neutral. We’ve had more fun and better treatment on other islands, frankly, but we probably will go back one more time to see what we may have missed.