Access control system

User Interface
Sound interface

Download door-0.5

CSIM Logo WelcomeCourses
Faculty, Student, Staff
Projects and reports
Conferences, workshop and seminars
Laboratories and reasearch facilities
Information related to CSIM
Information non-related to CSIM
Address, map, phone, etc.



This library is used to compress the images. It must be installed before you compile door program. I installed jpeg-6b_4 from the ports /usr/ports/graphics/jpeg. The compression subroutine is completely copied from the example program that is shipped with jpeg-6b.
The program uses an embeded Perl interpreter to read the configuration file. I installed perl-5.8.8_1 from the ports /usr/ports/lang/perl5.8 but I think it should also run with any version of Perl greater than 5.1. Information on embeding Perl in a C program can be found in the man pages perlembed(1) and perlapi(1).
A library for editing command lines as they are typed. I am using readline-5.2_1 from the ports /usr/ports/devel/readline.
You can also consider installing Apache and PHP to build an interface to the pictures or video taken by the system.


The program door can be downloaded from CSIM anonymous FTP server. It has been developped specifically on to of FreeBSD, the choice of the operating system depends on personnal preferences.

In the distribution there are 5 files:

the main program
the makefile to compile door.c
a Perl script used by door.c to read the configuration file
a sample of the configuration file, this file needs to be configured
a Perl script to delete the old pictures
a Perl script that is used to do some administrative function when the arlarm is trigered, for example send an email to some administrators, this is only an example, you may want to adapt it to your own needs
same thing but it is attaching some pictures to the email, this is an example too
a mapping of the keyboard used to disable ctrl+alt+del
the directory containing the various sound files used by the sound interface
a Perl script used to reccord video when the door is open, this is only an example, you may want to adapt it to your own needs

There is no GNU autoconfiguration as the program is higly dependent on the hardware and on the operating system.

Gunzip and untar the distribution in the target directory. The only configuration option in door.c is the timezone defined at the very top of the program door.c, the value should be the offset from GMT (Thailand is GMT+7). There maybe some modifications to make for a country with daylight saving time zone.

Then simply make(1).

Try to run the program from the console. The argument -c allows you to check the configuration file, without activating the program.

InstallingThe screen

Once the program is compiled, it can be installed. I choose to do the installation in the directory /usr/local/door.

In the installation directory, you must copy the program door itself, the Perl script used to read the configuration file, the configuration file door.cfg (it can be installed alternatively in /etc), and the Perl script to delete old pictures

You must also create a directory to hold the pictures or videos, I choosed /usr/local/door/pic for pictures and /usr/local/door/video for videos.

There are few system files that need to be modified in order to make the system running.

This file defines the terminals that are started automatically by init(8). You must disactivate all virtual terminals ttyv1 to ttyv8, as well as the dial-up terminals ttyd0 to ttyd3 (they are not used on that machine).
ttyv0 is used to run the door program, through getty(8) with a special terminal type, that I called Door and that does automatic login to qa special used and run only the program door. This way, the program door will automatically restart every time it is stopped.
There is no way to run door directly from /etc/ttys, as it uses a virtual console that would not be initialised.
  ttyv0 "/usr/libexec/getty Door" cons25 on secure # Virtual terminals #ttyv1 "/usr/libexec/getty Pc" cons25 on secure #ttyv2 "/usr/libexec/getty Pc" cons25 on secure #ttyv3 "/usr/libexec/getty Pc" cons25 on secure #ttyv4 "/usr/libexec/getty Pc" cons25 on secure #ttyv5 "/usr/libexec/getty Pc" cons25 on secure #ttyv6 "/usr/libexec/getty Pc" cons25 on secure #ttyv7 "/usr/libexec/getty Pc" cons25 on secure #ttyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secure # Serial terminals # The 'dialup' keyword identifies dialin lines to login, fingerd etc. #ttyd0 "/usr/libexec/getty std.9600" dialup off secure  
This file defines terminal type. I added one definition for the terminal type Door, that is copied from the type Pc, with one more argument al to do automatic login to the user door.
  P|Pc|Pc console:\ :ht:np:sp#115200: Door:\ :ht:np:sp#115200:al=door:  
/etc/passwd & /etc/master.passwd
Use the command vipwd(8) to add a new user door.
  door::0:0::0:0:Run the door program:/usr/local/door:/usr/local/door/door  
The user door should have its home directory set to /usr/local/door and call the program /usr/local/door/door as its shell. It must be set-up without password so it connects automatically and must run under the super-user uid and gid set to 0.
A view of the screenThis file start a number of services at boot-up of the machine. I added the following lines so that it runs as a NIS client and be able to see the user passwords on the network, enable the mouse driver and set the screen to 40x25 characters.
  nis_client_enable="YES" nisdomainname="" moused_enable="YES" allscreens_flags="VGA_40x25" keymap="/usr/local/door/keymap"  
Setting the screen to 40x25 characters makes it all much more readable, especially if the screen is located a bit far from the user.
Note that all strings displayed on the screen have been optimized for that configuration.
Finally I did a couple of modifications to the kernel, to disactivate Ctrl-Alt-Del reboot sequence and to force the video mode of the video capture card to be NTSC.
  device bktr device iicbus device iicbb device smbus options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_NTSC device sound options SC_DISABLE_DDBKEY # disable `debug' key options SC_DISABLE_REBOOT # disable reboot key sequence  
Disabling Ctrl-Alt-Del prevent the users from rebooting the machine, despite they have access to the console keyboard.
The part about the video mode is a problem I have been facing a couple of time with the /dev/bktr0 driver, so I prefer forcing the mode to the known mode of the camera.
The kernel must be rebuilt and installed of course.
Set-up the Perl script that will delete old pictures. The script is run once a day, by crontab.
  0 0 * * * cd /usr/local/door/; ./  
Root crontab
Use the command crontab -e to add such line, the Perl script will run every day at midnight.
Finally I made sure that syslogd(8) will never output anything to the screen and I disabled any line containing /dev/console.
 # *.err;kern.debug;auth.notice;mail.crit /dev/console 
Then the new syslogd(8) configuration has to be applied by sending a signal -1 (HUP) to syslogd(8).

This done, you can reboot your system. From now on, the only access you will have to the system is through remote login (telnet(1), xterm(1), ssh(1)...). The system console will always run the door program.

Whenever you modify the configuration file door.cfg, you can restart the door program by simply killing all door processes that are running. The new access configuration will be taken into account automatically. Do that by issuing a killall door comand.

Configuration file

The configuration file is called door.cfg and is located either in the same directory where the program door is located, or in /etc/door.cfg.

The configuration file is divided into three sections, each section delimited by its name between square brackets [].

A # in a line marks the begining of a comment that extend until the end of the line. Blank lines are ignored. Any space or tabulation character are ignored.

The configuration file is highly case sensitive, for example section names are in lower case.

This section allows to define some options to configure the program.
The syntax is option_name=value.
0 the system is halted, no acontrol access is implemented, the door is unlocked all the time
1 (default) the system is running.
0 (default) means no debuging informatin is logged.
1 means that most of the actions are logged by syslogd(8) SECURITY facility.
-1 means there is no contact switch installed, in that case the alarm will never be activated (not fully tested).
0 means that the contact switch is open when the door is closed, and closed when the door is open.
1 (default) means the contact switch is closed when the door is closed and open when the door is open.
defines the delay in seconds during which the door is unlock for entering the secured room, after the user has entered his password successfuly or pressed the Enter key (default 5).
defines the delay in seconds during which the door is unlock for exiting the secured room, after the user has pressed the door open button (default 5).
Image recorded on May 8, 2003OpenDelayDay
defines the delay in seconds during wich the door can remain open at day time, before the alarm rings. 0 means that the door can remain open indefinitely (default 15).
defines the delay in seconds during wich the door can remain open at night time, before the alarm rings (default 15).
allows to make an intermittent alarm. The alarm will ring 1 second every AlarmDelay seconds. If set to 1, it rings permanently (default 3).
name of a Perscript that will be called at the begining and at the end of an alarm. The script starts with the variable $cause that describe the type of alarm:
0 = end of the alarm
1 = the door stay open for too long (more than OpenDealDay or OpenDelayNight)
2 = the door has been opened without pressing the button or enter or authentication
3 = the door is open when the program starts
The script must have execute permission.
This section allows to define some options to configure the way the program is taking pictures when the door is open. This section cannot coexist with the section [video].
The syntax is option_name=value.
defines the delay in seconds between a user opening the door and taking the first picture. Note that if there is no contact switch, there is no way to know that the door is actually open, so no picture is take (default 1).
defines the delay in seconds between one picture and the next (default 5).
defines the width of the image in pixel, it should be in the range 2 – 640 and have an even value (default 400).
defined the height of the image in pixel, it should be in the range 2 – 480 and have an even value (default 300). Usually, ImageHeigth = 3/4 ImageWidth.
defines the quality factor for JPEG compression of the image, in the range 1 – 100 (default 70).
defines the directory where to keep pictures (default /var/log).
defines the age in days after which the old pictures are automatically deleted (default 10).
This section allows to define some options to configure the way the program is recording videos when the door is open. This section cannot coexist with the section [picture].
The syntax is option_name=value.
defines the directory where to keep videos (default /var/log)
defines the name of the Perl scrip that is run to record a video. The script starts with the variable $file is initialized to the name of the video file. The script ends on a kill signal.
defines the signal to use to kill the video script. The signal may depend on the tool used to do the recording, for example mencoder will crop the end of the video if it receives a SIGKILL (default 2).
defines the maximum amount of space used in the file system before older videos are being deleted (default 90, the file system where videos are stored should not be more than 90% full).
defined the maximum amount of space used in the file system after the older videos have been deleted (default 80, the file system will not be more than 80% full after older videos have been deleted).
This section is used to define some dates that are holiday. During holiday, the access security will always be in night mode, user name and password has to be keyed in every time someone wants to unlock the door.
Holiday can be of two types.
Fixed holiday are such that occurs on the same date every year, like for example new year which is always on January 1st, or Labour day that is always on May 1st. Fixed holiday are in the format dd/mm, one or two digits for the day and one or two digits for the month. So 1/1 is January 1st, while 25/12 is Christmas day.
Fixed holiday can also be represented as a range dd-dd/mm with a beginging and an ending day within one month; such as 25-31/12 would make the period from December 25th, to December 31st, be holiday for every year.
Mobile holiday change date every year, like Easter Monday is April 21st in 2003, but will probably be at another date for the following year. In such case, the date format is dd/mm/yyyy with four digits for the year (and it cannot be truncated to two digits), like 21/4/2003. In the same way as for fixed holiday, range of mobile holiday can be defined with dd-dd/mm/yyyy, for example 14-15/4/2003 will define Songkan festival on April 14th, and April 15th, 2003.
When a day is not an holiday, it can be defined a time of the day when the security acess will be simpler, and the user only has to press the Enter key to unlock the door. Day mode are in the format Day=hh:mm-hh-mm with 3 letters for the abreviated name of the day, and a time range with up to two digits for the hours and up to two digits for the minutes. The first time defines when the day security mode is activated, while the second time defines when the night security mode is resumed. It is possible to define several intervals for one day, for example Mon=8:00-12:00 and Mon=13:00-17:00 will mean that from 8:00 to noon, access is in day mode, it is in night mode from noon to 13:00, then in day mode from 13:00 to 17:00, while after 17:00 it will be in night mode.
Maximum time for one day is 23:59, there is at least one minute every night, from 23:59 to the next day at 00:00 where the system is in night security mode.
There is no limit on the number of intervals that can be defined for one day, it could be set that it is one minute in day mode and one minute in night mode (but you'll write the configuration file, not me), but intervals must not overlap.
Authentication configuration

This part of the configuration file is related to the various authentication systems that can be implemented. When the user has entered his password, all the authentication methods will be checked one after the other, in the order provided in the configuration file. Each authentication system will reply with one of the 3 values:

the password provided for the user is correct and the user is allowed to enter, no futher authentication method is checked, the user is granted access
the password provided for the user was wrong, no other authentication method is checked, the access is denied
the password provided for the user is correct but the user is denied access, or the user name does not exist, check with the next authentication method.
After the last authentication method have been tried, the user will be granted access only if the response is allow.
This section is used to define authentication method with Unix passwords. If NIS is configured it will obey NIS maps. It defines what groups are allowed or denied to use the username and password to open the door.
The syntax is allow=list_of_groups or deny=list_of_groups.
The full systemallow
Defines the groups of users that are allowed to use the username and password.
The list of groups is a comma separated list of numeric value or group name. The list can also contains ranges of groups, 20-25 means all the groups from 20 to 25. A range can also be defined with group names, but combination of numeric groupd ID and group names are not allowed.
The keyword ALL means any group (default ALL).
Defines the groups of users that are allowed to use the username and password.
The list of groups has the same syntax as for allow above (default empty).
If the user's group is listed in allow, the user is allowed the entry
   else if the user's group is listed in deny, the user is denied the entry
   else the user is allowed the entry.
This section defines authentication against an LDAP directory.
Note that LDAP server will make the same response for an invalid password or an unknown user.
Authentication is made with a simple bind to the LDAP server.
The URI of the LDAP server to authenticate with. It can be a list of URIs separated with spaces (default ldap://localhost/).
The base for the bind in the LDAP directory (no default).
The LDAP attribute containing the user name (default uid) used for simple binding to the LDAP server.
The LDAP boolean attribute that allows the access for an authenticated user. Only users where the arttibute has the value TRUE will be given access (default AccessDoor).
Previous: hardware Next: Sound interface

CSIM home pageWMailAccount managementCSIM LibraryNetwork test toolsSearch CSIM directories
Contact us: Olivier Nicole CSIM    SET    AIT Last update: Feb 2008