[Uludag-commits] r16383 - in branches/comar-dbus/comar: include src
uludag-commits at pardus.org.tr
uludag-commits at pardus.org.tr
18 Ara 2007 Sal 22:08:48 EET
Author: bahadir.kandemir
Date: Tue Dec 18 22:08:47 2007
New Revision: 16383
Modified:
branches/comar-dbus/comar/include/log.h
branches/comar-dbus/comar/src/data.c
branches/comar-dbus/comar/src/log.c
branches/comar-dbus/comar/src/main.c
Log:
Fail if can't write log file, db dir or code dir
Modified: branches/comar-dbus/comar/include/log.h
=================================================================
--- branches/comar-dbus/comar/include/log.h (original)
+++ branches/comar-dbus/comar/include/log.h Tue Dec 18 22:08:47 2007
@@ -12,7 +12,7 @@
#define LOG_PERF 4
#define LOG_FULL 0xffffffff
-void log_start(void);
+int log_start(void);
void log_error(const char *fmt, ...);
void log_info(const char *fmt, ...);
void log_debug(int subsys, const char *fmt, ...);
Modified: branches/comar-dbus/comar/src/data.c
=================================================================
--- branches/comar-dbus/comar/src/data.c (original)
+++ branches/comar-dbus/comar/src/data.c Tue Dec 18 22:08:47 2007
@@ -42,7 +42,10 @@
return -1;
}
} else {
- // FIXME: check perms and owner
+ if (0 != access(cfg_data_dir, W_OK)) {
+ log_error("Cannot write data dir '%s'\n", cfg_data_dir);
+ return -1;
+ }
}
size = strlen(cfg_data_dir) + 6;
@@ -55,6 +58,12 @@
return -1;
}
}
+ else {
+ if (0 != access(code_dir, W_OK)) {
+ log_error("Cannot write code dir '%s'\n", code_dir);
+ return -1;
+ }
+ }
// FIXME: check and recover db files
return 0;
Modified: branches/comar-dbus/comar/src/log.c
=================================================================
--- branches/comar-dbus/comar/src/log.c (original)
+++ branches/comar-dbus/comar/src/log.c Tue Dec 18 22:08:47 2007
@@ -78,14 +78,21 @@
}
//! Log starter. Permissions of log file are set here
-void
+int
log_start(void)
{
+ if (cfg_log_file && 0 != access(cfg_log_file_name, W_OK)) {
+ printf("Cannot write log file '%s'\n", cfg_log_file_name);
+ return -1;
+ }
+
log_info("COMAR v%s\n", VERSION);
if (cfg_log_file) {
// make sure log is not readable by ordinary users
chmod(cfg_log_file_name, S_IRUSR | S_IWUSR);
}
+
+ return 0;
}
//! Error logging
Modified: branches/comar-dbus/comar/src/main.c
=================================================================
--- branches/comar-dbus/comar/src/main.c (original)
+++ branches/comar-dbus/comar/src/main.c Tue Dec 18 22:08:47 2007
@@ -41,24 +41,24 @@
exit(1);
}
+ // Initialize main process
+ proc_init(argc, argv, "Comar");
+
+ // Start logging
+ if (log_start() != 0) {
+ exit(1);
+ }
+
// Load models
if (model_init() != 0) {
- puts(_("Unable to load model.xml."));
exit(1);
}
// Initialize DB
if (db_init() != 0) {
- puts(_("Database is corrupt."));
exit(1);
}
- // Initialize main process
- proc_init(argc, argv, "Comar");
-
- // Start logging
- log_start();
-
// Listen for DBus calls
proc_fork(dbus_listen, "ComarDBus", NULL, NULL);
Uludag-commits mesaj listesiyle ilgili
daha fazla bilgi