Showing posts with label Lessons Learned. Show all posts
Showing posts with label Lessons Learned. Show all posts

Wednesday, January 13, 2010

Watching TV and Linux

This all started a couple of weeks ago when I finally got around to putting the tv capture card I had picked up a year or two ago into my computer. Happily like most things in Linux, it just worked, that was a great plus. Sadly the software packages in existence that I ran across were either too much or too little, nothing was just right.

What I wanted was to be able to open up a window, tack it to the desktop in always on top mode, and leave it in the corner taking up some but not all of my screen real estate. I also wanted the ability to pause it, so that I could get up, grab a cup of coffee, hit the head, or what ever. Guess what, this falls into the "good luck with that" category of having had someone scratch that particular coding itch.

For the watching TV in a window, I found several applications, such as tvtime and xawtv. Both are good and configurable. Excellent for what they were designed for which was simply just watching TV, either in a window or fullscreen. Sadly of all of the light weight applications I played with they all lacked the second critical function, the ability to pause. So while I decided to keep tvtime on my system because it is rather a nice piece of software the search must continue.

I decided then to explore mythtv. I had read about it several times over the years and finally had a reason to do more than think about it. I knew that it had the ability to record TV, watch movies, and basically handle being a home theater system. Holy unfriendly overkill batman. By the time I had it compiled (I was doing this on a Funtoo system) I was mildly annoyed at the collection of dependencies that had to be pulled in. That annoyance was nothing compared to trying to configuring it.

Between the documentation, complete and utter lack of editable configuration files, a configuration UI that is among the unfriendliest and unintuitive I have ever seen, and an IRC help channel slightly less friendly than the Spanish Inquisition. I think maybe I would prefer to spend a month at a nudist colony with a porcupine infestation than get near that project again.

OK, enough of a sideline about mythtv, needless to say I did get it up and running. I then decided that while it was not completely unsuited to that task at hand, it was exactly what I did not want. Not to mention it still didn't do exactly what I wanted. Which was simply a window in the corner that I could play/pause.
** It was brought to my attention that mythtv will indeed start in a windowed mode
** thanks for correcting my misstatement Dinotrac. Still it's a level of overkill I do not need.

So I decided to set about doing for myself what I could not find an existing application for. While I had been playing with the capture card and software for it, I found that I could watch TV using mplayer, or record TV using mencoder (part of mplayer). Armed with this dangerous knowledge I figured I could wrap everything up in a script to do what I wanted. I was right too. With one script I can watch TV, play/pause, and as an added bonus, when I close the window I was using to watch TV, it asks me if I want to save the streams I had been watching.

There are only two packages that you need for this script, mplayer and xdialog. Actually xdialog is only if you want it to ask you if you want to save the streams and easy file clean up. Alternately you could just change that portion of the script to : rm $location/$filename.avi to have it clean out all the files when you shut mplayer off.

So here you go:
Click here for the script

UPDATE:
Added file rename when save file is selected. Cleaned up spurious text for those using dialog rather than xdialog. Broke up the mencoder command for easier reading and added deinterlacing to it.

Version 2 of the script

Blogspot mangles code snippets, so its in a pastebin. Personally I dropped the script into /usr/bin/ did chmod 755 on it, and use it as I would any other program. So you could make a desktop shortcut, add it to a menu or do what I did. I mapped it to a spare unused key on my keyboard, so now I have TV at the push of one button.

Thursday, October 11, 2007

Insecure by Default

Guess what, I can walk up to your Ubuntu, PCLinuxOS, Debian, etc desktop installation and take complete control over it without needing a single password. Thats right, root access simply by sitting down at your computer. Why is it nearly every single distro by default leaves this gaping security hole open? Seriously, it is possible to fix the problem during installation, my personal favorite, Sabayon, asks if you want to password GRUB as part of the installation.

What am I talking about? One simple word 'single', thats it. You walk up to nearly every default desktop installation, reboot it then break the boot cycle when GRUB fires up. If GRUB is not passworded, and the default for almost all installations is that it isn't, you now have the option to grant yourself root access.

On single or multi boot systems, select the installation you want and instead of hitting enter to boot, enter 'e' to edit. Select the boot line with all the kernel options, typically the second, and hit 'e' again. Scroll all the way to the end of the line and add the word 'single'. Hit enter and press 'b' for boot.

The system will now start booting up in what appears to be normal fashion. With one exception, instead of dropping you into the GUI it will drop you into CLI with root access automagically granted. From that point on the system is mine. I can change passwords, add users, add background processes such as ftp access or ssh access for myself. Maybe add a hidden user account not so hidden if you know what you are looking for in /etc/passwd, but you have to know to look at it. In other words, anything.

So I ask again, why with security being such an assumed when running Linux is this hole left open? It is possible to close this after the fact, and it is not difficult at all. Directions on how to accomplish this simple security measure can be found:

http://www.cs.wcupa.edu/~rkline/Linux/grub.html
or
http://www.gentoo.org/doc/en/security/security-handbook.xml?part=1&chap=2
(that one includes securing LILO as well)
or
http://www.cyberciti.biz/tips/how-do-i-secure-grub-boot-loader.html

Also if you happen to screw it up and need to recover from locking your GRUB you'll need a LiveCD and the directions here, or a little common sense.

http://www.cyberciti.biz/tips/howto-recovering-grub-boot-loader-password.html

So now, what is your excuse for not securing your bootloader from me? How often do you actually have to go in and mess with it or even look at it? Isn't five minutes of your time worth knowing that no one is going to access your system when your back is turned?

Oh did I mention that Sabayon gives you the option to do this as part of the install routine? I did, but this is a good place for a shameless plug for my distro of choice.

~Az

Sunday, July 8, 2007

Breaking Sabayon

OK, the learning curve is not as steep as I thought it would be, or its my ignorance talking. However I did a "world" update of the install I did from the 3.3 mini LiveCD and then immediately ran into a problem. This update basically brought everything in the system up to "testing" which I guess is a lot more testing than stable then I'm used to coming from Debian.

I wanted to back a few files off to DVD for later use. Namely all the files and updates to install World of Warcraft and Burning Crusade. This was so I could save myself some time later on if I had to reinstall, which I did and am doing as I write this. To do this backup though I fired up k3b, which I nearly always use and the system immediately hard locked and boy do I mean hard.

This is when I discovered that the system had been upgraded to the testing level. OK, can I downgrade my packages? Sure can, you can mix and match so easily its no even funny. you find out the package you want:
emerge -s *package name*

That will spit out available packages plus the one you have installed. The stable one is listed, usually the one thats available with a lower version number. To install that one instead all you have to do is:
emerge =*package name-version number*

Whammo your all fixed up.

OK I may be getting excited over nothing, but fixing and downgrading is something new and different for me. Who said Sabayon/Gentoo were for uber geeks? oh, wait I have, repeatedly. Its so much easier to reconfigure and/or fix screw ups its not even funny.

Anyway, More on the adventures of moving to Sabayon later.

till the have fun
~Az