Ownership Permissions of /var in Debian Squeeze

Suppose you happen to accidentally do sudo chown -R www-data:www-data * whilst the current directory is /var. Now that’s a fairly daft thing to do! but we all make mistakes. There doesn’t seem to be an easy way to correct this other than restore a backup or look at another machine with a similar setup. Rather than having to restore a backup I looked at a machine with a similar setup, the machine has lighttpd, mysql, and sendmail installed on it so I built the following script based on the permissions with those packages installed on a fresh install of Debian Squeeze

#!/bin/bash

echo "Setting Directory ownership" &&
chown -R root:root /var &&
chown -R man:root /var/cache/man &&
chown -R www-data:www-data /var/cache/lighttpd &&
chown -R libuuid:libuuid /var/lib/libuuid &&
chown -R smmta:smmsp /var/lib/sendmail &&
chown -R mysql:mysql /var/lib/mysql &&
chown -R www-data:www-data /var/log/lighttpd &&
chown -R mysql:adm /var/log/mysql &&
chown -R www-data:www-data /var/run/lighttpd &&
chown -R mysql:root /var/run/mysqld &&
chown -R smmsp:smmsp /var/run/sendmail/msp &&
chown -R smmta:smmsp /var/run/sendmail/mta &&
chown -R smmta:smmsp /var/spool/mqueue &&
chown -R smmsp:smmsp /var/spool/mqueue-client &&
chown -R root:staff /var/local &&
chown -R root:mail /var/mail &&
chown -R root:smmta /var/run/sendmail &&
chown -R root:smmsp /var/run/sendmail/stampdir &&
chown -R root:crontab /var/spool/cron/crontabs &&
chown -R www-data:www-data /var/www &&
echo "Setting File ownership" &&
chown root:smmsp /var/lib/sendmail/dead.letter &&
chown root:adm 
 /var/log/auth.log 
 /var/log/boot 
 /var/log/daemon.log 
 /var/log/debug 
 /var/log/dmesg* 
 /var/log/fsck/checkfs 
 /var/log/fsck/checkroot 
 /var/log/kern.log 
 /var/log/lpr.log 
 /var/log/mail.err 
 /var/log/mail.info 
 /var/log/mail.log 
 /var/log/mail.warn 
 /var/log/messages 
 /var/log/news/news.crit 
 /var/log/news/news.err 
 /var/log/news/news.notice 
 /var/log/syslog 
 /var/log/user.log &&
chown root:utmp 
 /var/log/lastlog 
 /var/log/btmp 
 /var/log/wtmp 
 /var/run/utmp &&
chown root:smmsp 
 /var/run/sendmail/mta/smsocket 
 /var/run/sendmail/stampdir/reload &&
chown -f root:smmsp /var/run/sendmail/mta/sendmail.pid &&
chown mysql:adm 
 /var/log/mysql.err 
 /var/log/musql.log &&
chown -f mysql:adm /var/run/mysqld.pid &&
echo "Done."

In addition you will need to set the ownership permissions of /var/spool/cron/crontabs/<user> and /var/mail/<user> depending on the users on the system.

Advertisement

OpenSCAD

I have been hacking around with OpenSCAD. First I added an exponent operator to the language because I felt that writing pow(x,2) was a bit more cumbersome than x^2 . Then I added a few more operators like a component-wise multiply and component-wise divide I wanted these to make it easier to translate points so I could use them as datums. I even implemented an experimental rotation operator. Then I decided to get a little bit more adventureous. What I wanted to do was make the OpenSCAD editor have syntax highlighting. Investigating doing this using qcodeedit is on the OpenSCAD todo list, so I thought I would give it a try

I was quite pleased with the results and it wasn’t to complex to implement, QCodeEdit’s QEditor is almost a drop in replacement for QTextEdit. I created a wrapper which allows somone compiling the source to choose which editor they want to use with compile time flags. In fact, to disable QCodeEdit support all one has to do is uncomment out the line with

CONFIG += qcodeedit

in openscad.pro

EDIT: All the changes have been merged into the main github repository which can be checked out using

git clone https://github.com/openscad/openscad.git

Music Player Daemon on the MusicPal

Some time ago I recived a MusicPal as a gift. Out of the box the device is great fun, and made a very good present. The device is designed to work as an internet radio, It can connect to a wireless network and stream radio from various internet radio stations. However the device does have a few limitations when you want to play your own music. The device can connect to Media servers that use the UPnP Media Devices Protocol and the device is operated using two rotary knobs. For me the combination of these two features is the major design flaw in the product.  I don’t want to walk over to the device, twiddle some knobs and play a tune that is on my laptop, instead I want to select songs from my laptop and queue them up for playing on the device. There are two remote control applications for the MusicPal, one which is accessible through a web interface, and another which is Windows™ software. However both of the remote control applications are useless, all one can do is pause music, you can’t select a new song to be played, change the position of playback or even fast-forward and rewind!

Well a while ago,  I found a blog from someone who goes by the name of Nerdy Toad who was trying to run Music Player Deamon on his MusicPal.  At the time he had only managed to make a test sinewave come out of the devices internal speaker, and we worked together to see if we could get output from the line-out of the device. We were somewhat unsuccessful. However, about half a year later, someone called Maz took our research further. He was able not only to get sound fully working on the device, he was also able to patch Music Player Deamon to work on the device aswell.

For anyone else who has a MusicPal and wants to use it in conjunction with Linux you will need to do the following. First you have to enable the telnet interface for the device. You can enable it via a hidden web interface page:
http://musicpal/admin/cgi-bin/debug

You can then telnet to the device, login as root, and issue the following command.
wget http://musicpal.v3v.de/cifs/cifs.ko

This will get you a kernel module will will allow you to access a samba share on the device. This is important because the device has very limited disk space, and so its preferable to put mpd, config files, etc. In a samba share. Of course you will probably have your mp3 files in a samba share aswell. You will need to create an smb.conf on the machine that you will be sharing files from, (not the MusicPal). This is my smb.conf

[global]
server string = masala
security = SHARE
guest account = giles
[mpd]
comment = mpd
path = /home/giles/mpd
guest ok = Yes
read only = No
[music]
comment = Music
path = /home/giles/Music
guest ok = Yes

In my setup I have mpd on the machine sharing music, this is because of the limited space on the MusicPal, so still on this machine download the mpd binary

wget http://musicpal.v3v.de/mpd-testing/mpd.tar.gz

Then expand the gzip into the mpd directory. You will have to modify the mpd.conf file so that the directories are correct. Once you have done all this, you can mount the shares from the MusicPal telnet session

mount -t cifs //192.168.2.4/mpd /tmp/mnt/mpd
mount -t cifs //192.168.2.4/music /tmp/mnt/mpd/music

Finally from the telnet session you can launch mpd. Back on the client you should now be able to connect to mpd via your favorite mpd client program.

Webcam in Linux on Sony VGN-BX61MN

For anyone interested in using linux on this laptop, the following should be of help. The camera is labeled as Motion Eye but lsusb reports the device as:

05ca:1839 Ricoh Co., Ltd Visual Communication Camera VGP-VCC6 [R5U870]

After alot of messing around and installing defunct kernel modules, that seem to work, but actually include the wrong firmware versions. I found that the work being done by Alex Hixon on a generic R5U87x driver to be the most up to date. Previously the project rolled its own kernel module to support the camera, However the current version works by providing userspace tools to upload firmware to the device so that the standard uvcvideo driver in the kernel can communicate with the camera.

Unfortunately there wasn’t much around in the way of a howto to explain how to use the code. So I had to figure out the following for myself.

First of all install mercurial and some other project dependencies

sudo apt-get install git-core libglib2.0-dev libusb-dev

Now you can download the source

git clone https://github.com/p6/R5U87X.git

Change into the source directory and issue the following three commands.

cd R5U87X
make clean
make
make rules
sudo make install

If your user isn’t part of the video group you will probably have to modify /etc/group and make yourself a member of that group otherwise you might experience Permission Denied errors.

After you have rebooted you can test using mplayer

mplayer tv:// -tv driver=v4l2

Also make sure you can record because uploading the wrong firmware will in some cases allow you to see output but not record it.

mencoder tv:// -tv driver=v4l2:device=/dev/video0 -nosound -ovc lavc -o test.avi

If you want to clean things up afterwards you can run the following commands
sudo apt-get --purge remove mercurial libglib2.0-dev libusb-dev
sudo apt-get --purge autoremove
rm -r R5U87X

You may find the above steps also work for the following devices:

05ca:1830 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
05ca:1832 Ricoh Co., Ltd Visual Communication Camera VGP-VCC3 [R5U870]
05ca:1833 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
05ca:1834 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
05ca:1835 Ricoh Co., Ltd Visual Communication Camera VGP-VCC5 [R5U870]
05ca:1836 Ricoh Co., Ltd Visual Communication Camera VGP-VCC4 [R5U870]
05ca:1837 Ricoh Co., Ltd Visual Communication Camera VGP-VCC4 [R5U870]
05ca:1839 Ricoh Co., Ltd Visual Communication Camera VGP-VCC6 [R5U870]
05ca:183a Ricoh Co., Ltd Visual Communication Camera VGP-VCC7 [R5U870]
05ca:183b Ricoh Co., Ltd Visual Communication Camera VGP-VCC8 [R5U870]
05ca:183e Ricoh Co., Ltd Visual Communication Camera VGP-VCC9 [R5U870]