icd-main.cpp File Reference

inotify cron daemon main file More...

#include <map>
#include <signal.h>
#include <wait.h>
#include <fcntl.h>
#include <pwd.h>
#include <dirent.h>
#include <syslog.h>
#include <errno.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include "inotify-cxx.h"
#include "incron.h"
#include "incrontab.h"
#include "usertable.h"

Defines

#define DAEMON   true
 Daemon yes/no.
#define INCRON_LOG_OPTS   (LOG_CONS | LOG_PID)
 Logging options (console as fallback, log PID).
#define INCRON_LOG_FACIL   LOG_CRON
 Logging facility (use CRON).
#define CHILD_PIPE_BUF_LEN   32

Typedefs

typedef std::map< std::string,
UserTable * > 
SUT_MAP
 User name to user table mapping definition.

Functions

void on_signal (int signo)
 Handles a signal.
bool check_user (const char *user)
 Checks whether an user exists and has permission to use incron.
void load_tables (Inotify *pIn, EventDispatcher *pEd) throw (InotifyException)
 Attempts to load all user incron tables.
void prepare_pipe ()
 Prepares a 'dead/done child' notification pipe.
int main (int argc, char **argv)
 Main application function.

Variables

SUT_MAP g_ut
 User name to user table mapping table.
volatile bool g_fFinish = false
 Finish program yes/no.
int g_cldPipe [2]
 Pipe for notifying about dead children.
char g_cldPipeBuf [CHILD_PIPE_BUF_LEN]


Detailed Description

inotify cron daemon main file

inotify cron system

Copyright (C) 2006, 2007 Lukas Jelinek, <lukas@aiken.cz>

This program is free software; you can use it, redistribute it and/or modify it under the terms of the GNU General Public License, version 2 (see LICENSE-GPL).


Define Documentation

#define CHILD_PIPE_BUF_LEN   32

#define DAEMON   true

Daemon yes/no.

#define INCRON_LOG_FACIL   LOG_CRON

Logging facility (use CRON).

#define INCRON_LOG_OPTS   (LOG_CONS | LOG_PID)

Logging options (console as fallback, log PID).


Typedef Documentation

typedef std::map<std::string, UserTable*> SUT_MAP

User name to user table mapping definition.


Function Documentation

bool check_user ( const char *  user  ) 

Checks whether an user exists and has permission to use incron.

It searches for the given user name in the user database. If it failes it returns 'false'. Otherwise it checks permission files for this user (see InCronTab::CheckUser()).

Parameters:
[in] user user name
Returns:
true = user has permission to use incron, false = otherwise
See also:
InCronTab::CheckUser()

void load_tables ( Inotify pIn,
EventDispatcher pEd 
) throw (InotifyException)

Attempts to load all user incron tables.

Loaded tables are registered for processing events.

Parameters:
[in] pIn inotify object
[in] pEd inotify event dispatcher
Exceptions:
InotifyException thrown if base table directory cannot be read

int main ( int  argc,
char **  argv 
)

Main application function.

Parameters:
[in] argc argument count
[in] argv argument array
Returns:
0 on success, 1 on error
Attention:
In daemon mode, it finishes immediately.

void on_signal ( int  signo  ) 

Handles a signal.

For SIGTERM and SIGINT it sets the program finish variable. For SIGCHLD it writes a character into the notification pipe (this is a workaround made due to disability to reliably wait for dead children).

Parameters:
[in] signo signal number

void prepare_pipe (  ) 

Prepares a 'dead/done child' notification pipe.

This function returns no value at all and on error it throws an exception.


Variable Documentation

int g_cldPipe[2]

Pipe for notifying about dead children.

char g_cldPipeBuf[CHILD_PIPE_BUF_LEN]

volatile bool g_fFinish = false

Finish program yes/no.

SUT_MAP g_ut

User name to user table mapping table.


Generated on Sat Jan 6 23:06:32 2007 for incron by  doxygen 1.5.1