Category: Unix

Chm viewer on Ubuntun

Posted by – September 1, 2010

xchm: Compiled HTML Help (CHM) file viewer for X
To get it:
sudo apt-get install xchm

To search chm relates info:
sudo aptitude search chm

Adding run-time dependency on Ubuntu

Posted by – August 5, 2010

This patch adds a runtime dependency on “dbus-1-utils” to the original source deb.

Refers to:
https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/31458/comments/1
http://launchpadlibrarian.net/1571338/avahi-daemon.debdiff

diff -u avahi-0.5.2/debian/control avahi-0.5.2/debian/control
— avahi-0.5.2/debian/control
+++ avahi-0.5.2/debian/control
@@ -7,7 +7,7 @@

Package: avahi-daemon
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
+Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, dbus-1-utils
Recommends: dbus, libnss-mdns
Suggests: avahi-dnsconfd
Conflicts: mdnsresponder
diff -u avahi-0.5.2/debian/changelog avahi-0.5.2/debian/changelog
— avahi-0.5.2/debian/changelog
+++ avahi-0.5.2/debian/changelog
@@ -1,3 +1,9 @@
+avahi (0.5.2-2) experimental; urgency=low
+
+  * Added dependency on dbus-1-utils, required by postinst
+
+ — Lorenzo J. Lucchini <ljlbox@tiscali.it>  Wed, 15 Feb 2006 02:39:05 +0100
+
avahi (0.5.2-1) experimental; urgency=low

* New upstream release.

design: sign a Debian changes and dsc file pair using GPG/PGP

Posted by – August 1, 2010

On Ubuntu there are at least two methods to sign a debian changes & dsc file pair using PGP:
Enter into source codes dir, and type below each one commands:
1.sudo dpkg-buildpackage -sa -k$GPG_KEY

note: sign the pair during building package.

2. Two steps below:
1). sudo dpkg-buildpackage -sa
2). sudo debsign -k$GPG_KEY *.changes

note: sign the pair AFTER build package.

ssh: 关闭ssh连接时的yes|no提示

Posted by – June 2, 2010

ssh: Disable asking yes/no when first time using ssh to connect a host.

j@ju10:~$ cat > ~/.ssh/config << end
UserKnownHostsFile /dev/null
ConnectTimeout 15
PasswordAuthentication no
StrictHostKeyChecking no
end
j@ju10:~$ more ~/.ssh/config
UserKnownHostsFile /dev/null
ConnectTimeout 15
PasswordAuthentication no
StrictHostKeyChecking no
j@j10:~$

j@ju10:~$ cat > ~/.ssh/config << endUserKnownHostsFile /dev/nullConnectTimeout 15PasswordAuthentication noStrictHostKeyChecking noendjin@jin-u10:~$ more ~/.ssh/config UserKnownHostsFile /dev/nullConnectTimeout 15PasswordAuthentication noStrictHostKeyChecking no

j@ju10:~$

Or:
ssh -o StrictHostKeyChecking=”no” root@ipAddress

Gnome Nanny, a Parental Control System for Linux

Posted by – May 25, 2010

Gnome Nanny, a Parental Control System for Linux

Refers to:
http://linuxers.org/article/gnome-nanny-parental-control-system-linux

nanny logo

I am not in favour of monitored or filtered Internet at all. I love Internet the way it is and I hate if someone tries to censor it. But we have to admit that there is a lot of bad stuff on the Internet that you definitely don’t want little kids to come across. Gnome Nanny is a parental control system build for this purpose. Not just the websites, it can also be used to monitor and control the time spent on web or chatting.

Features

  • You can easily control what the kids/users are doing on the computer.
  • How long a user can be using the compuer, browse the web, email and instant message.
  • You can decide the time of the day you want them to do these things.
  • You can even filter out the web pages seen by each of the user by blocking undesirable websites.
  • Its really easy to understand and configure.

The most recent version of Nanny available is 2.29.2. No stable version has been released yet.

Download and Install the Latest version of Nanny in Ubuntu

In order to install the latest development release in Ubuntu, you will have to install it using the ppa. You can find the PPA archive of Nanny here. Follow the instruction in this howto to install nanny in Ubuntu from the PPA. In case of any trouble, leave a comment.

Other distro users may install the source packages from their download page and give it a try.

After installation you can find it at System -> Administration -> Parental Control.

How to Configure Nanny

Understanding the working of Nanny is really easy. Its developers have worked pretty well to improve its usability. In the first glance, you will easily understand how to use it. You can find it in System -> Administration -> Parental control.

With these bars(click them), you can select which part of the day you want a particular service to be active. Different services are mentioned in separate tabs. Just check the option above to activate any option.

Nanny’s Web Content Filtering System

If you want to control the websites that can be accessed you can easily do that by maintaining lists of allowed and blocked sites. Check the enable web filtering box in the web browser tab and click configure.

You can even download the list of blacklisted websites from internet and ofcouse manual addition is available.

Limitations of Nanny

Nanny is a pretty good software and probably the only Parental control system for Linux I know. But it connects the tasks with the respective applicaitons e.g. pidgin with chatting, thunderbird with emails and browser with web surfing. This seems logical but now a days each of these activities are possible on the browser. You can’t expect a 10-12 year old kid to use a mail client . There are tons of social networking sites out there that can keep him “busy”. Although my point seems a little vague here because you can manage and control websites the user can access using Nanny’s web content filtering system.

Another thing I noticed was the applists mentioned in /etc/nanny/applists. It is probably the list of applicaitons supported by Nanny. As of now, or as mentioned in my list, it supports only 3 browsers epiphany, firefox and konqueror. Since, browsing is the most important thing to be censored and monitored here, Nanny should add support for more browsers.

Xwindow的工作原理

Posted by – May 18, 2010

Refers to:
http://blog.chinaunix.net/u/28814/showart_685151.html

Calling Qt Functions From Unix Signal Handlers

Posted by – May 18, 2010

Home · All Classes · All Functions · Overviews

Calling Qt Functions From Unix Signal Handlers

Refers to:
http://doc.qt.nokia.com/4.6/unix-signals.html
http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_04.html#tag_02_04_01
http://doc.qt.nokia.com/4.6/qsocketnotifier.html
http://doc.qt.nokia.com/4.6/platform-specific.html
You can’t call Qt functions from Unix signal handlers. The standard POSIX rule applies: You can only call async-signal-safe functions from signal handlers. See Signal Actions for the complete list of functions you can call from Unix signal handlers.

But don’t despair, there is a way to use Unix signal handlers with Qt. The strategy is to have your Unix signal handler do something that will eventually cause a Qt signal to be emitted, and then you simply return from your Unix signal handler. Back in your Qt program, that Qt signal gets emitted and then received by your Qt slot function, where you can safely do whatever Qt stuff you weren’t allowed to do in the Unix signal handler.

One simple way to make this happen is to declare a socket pair in your class for each Unix signal you want to handle. The socket pairs are declared as static data members. You also create a QSocketNotifier to monitor the read end of each socket pair, declare your Unix signal handlers to be static class methods, and declare a slot function corresponding to each of your Unix signal handlers. In this example, we intend to handle both the SIGHUP and SIGTERM signals. Note: You should read the socketpair(2) and the sigaction(2) man pages before plowing through the following code snippets.

[cpp]
class MyDaemon : public QObject
{
Q_OBJECT

public:
MyDaemon(QObject *parent = 0, const char *name = 0);
~MyDaemon();

// Unix signal handlers.
static void hupSignalHandler(int unused);
static void termSignalHandler(int unused);

public slots:
// Qt signal handlers.
void handleSigHup();
void handleSigTerm();

private:
static int sighupFd[2];
static int sigtermFd[2];

QSocketNotifier *snHup;
QSocketNotifier *snTerm;
};
[/cpp]

In the MyDaemon constructor, use the socketpair(2) function to initialize each file descriptor pair, and then create the QSocketNotifier to monitor the read end of each pair. The activated() signal of each QSocketNotifier is connected to the appropriate slot function, which effectively converts the Unix signal to the QSocketNotifier::activated() signal.

[cpp]
MyDaemon::MyDaemon(QObject *parent, const char *name)
: QObject(parent,name)
{
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighupFd))
qFatal("Couldn’t create HUP socketpair");

if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd))
qFatal("Couldn’t create TERM socketpair");
snHup = new QSocketNotifier(sighupFd[1], QSocketNotifier::Read, this);
connect(snHup, SIGNAL(activated(int)), this, SLOT(handleSigHup()));
snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
connect(snTerm, SIGNAL(activated(int)), this, SLOT(handleSigTerm()));


}
[/cpp]

Somewhere else in your startup code, you install your Unix signal handlers with sigaction(2)

[cpp]
static int setup_unix_signal_handlers()
{
struct sigaction hup, term;

hup.sa_handler = MyDaemon::hupSignalHandler;
sigemptyset(&hup.sa_mask);
hup.sa_flags = 0;
hup.sa_flags |= SA_RESTART;

if (sigaction(SIGHUP, &hup, 0) > 0)
return 1;

term.sa_handler = MyDaemon::termSignalHandler;
sigemptyset(&term.sa_mask);
term.sa_flags |= SA_RESTART;

if (sigaction(SIGTERM, &term, 0) > 0)
return 2;

return 0;
}
[/cpp]

In your Unix signal handlers, you write a byte to the write end of a socket pair and return. This will cause the corresponding QSocketNotifier to emit its activated() signal, which will in turn cause the appropriate Qt slot function to run.

[cpp]
void MyDaemon::hupSignalHandler(int)
{
char a = 1;
::write(sighupFd[0], &a, sizeof(a));
}

void MyDaemon::termSignalHandler(int)
{
char a = 1;
::write(sigtermFd[0], &a, sizeof(a));
}
[/cpp]

In the slot functions connected to the QSocketNotifier::activated() signals, you read the byte. Now you are safely back in Qt with your signal, and you can do all the Qt stuff you weren’tr allowed to do in the Unix signal handler.

[cpp]
void MyDaemon::handleSigTerm()
{
snTerm->setEnabled(false);
char tmp;
::read(sigtermFd[1], &tmp, sizeof(tmp));

// do Qt stuff

snTerm->setEnabled(true);
}

void MyDaemon::handleSigHup()
{
snHup->setEnabled(false);
char tmp;
::read(sighupFd[1], &tmp, sizeof(tmp));

// do Qt stuff

snHup->setEnabled(true);
}
[/cpp]

Diagram Editor

Posted by – May 13, 2010

Ubuntu Diagram Editor:

Refers to:
http://www.gliffy.com/

Diagram Software for the rest of us!

With Gliffy online diagram software, you can easily create professional-quality flowcharts, diagrams, floor plans, technical drawings, and more.

Our online diagram editor makes it easier than ever to create great looking drawings.

1). Can edit diagram files suffixs with .dia
2). Can export dia file as a png file
3). Can draw UML diagram.

To install:
sudo apt-get install dia

Video for Linux Two API Specification

Posted by – May 12, 2010

Refers to:
http://linux.bytesex.org/
http://v4l2spec.bytesex.org/spec/
http://v4l2spec.bytesex.org/
http://linuxtv.org/downloads/video4linux/API/V4L1_API.html

V4L2 API Specification (Revision 0.24)

V4L2 Mini-FAQ

Q: That’s the V4L2 spec, what about V4L?
A: /usr/src/linux/Documentation/video4linux/API.html
and http://linuxtv.org/downloads/video4linux/API/V4L1_API.html

Q: Are there any examples?
A: Yes, in the spec. Also a complete video capture example, source is capture.c.

Q: I have more questions.
A: Try the V4L Wiki or the Video4Linux mailing list.

IBM Mainframe

Posted by – May 6, 2010

Refers to:

http://www-03.ibm.com/systems/z/
http://en.wikipedia.org/wiki/IBM_mainframe
http://www.ibmmainframeforum.com/