diff options
author | John Denker <jsd@av8n.com> | 2012-07-31 15:00:19 -0700 |
---|---|---|
committer | John Denker <jsd@av8n.com> | 2012-07-31 17:48:52 -0700 |
commit | 4ed0a7a5212d83029d52ef4104b13cb48e9dd41f (patch) | |
tree | ecc73855dffa21c1fb511c88c70365e2d8c8f9d3 /tools | |
parent | efb6301f794cc272173fa09ad83293ad3aa79ad4 (diff) |
ltgrey will attempt to create its working directories
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libltgrey.c | 20 | ||||
-rw-r--r-- | tools/ltgrey.c | 12 |
2 files changed, 25 insertions, 7 deletions
diff --git a/tools/libltgrey.c b/tools/libltgrey.c index 7104c69..9b02642 100644 --- a/tools/libltgrey.c +++ b/tools/libltgrey.c @@ -126,28 +126,36 @@ void whatsit::update(const string msg, const timeval new_mod, } #endif -int whatsit::maybe_mkdir(const string somedir, const string msg){ +int whatsit::maybe_mkdir(const string subdir, const string msg){ // see if our directory exists: + string mydir = parent_dir; + if (subdir != ".") { + mydir += "/" + subdir; + } struct stat dirstat; - int rslt = stat(somedir.c_str(), &dirstat); + int rslt = stat(mydir.c_str(), &dirstat); if (rslt != 0){ if (errno != ENOENT) { cerr << progid << " stat failed for " << msg - << " '" << somedir << "' : "; + << " '" << mydir << "' : "; perror(0); + return(ex_syserr); } - rslt = mkdir(somedir.c_str(), 0755); + /* else it simply does not exist */ + rslt = mkdir(mydir.c_str(), 0755); if (rslt != 0) { cerr << progid - << "uid " << getuid() + << " uid " << getuid() + << " euid " << geteuid() << " mkdir failed for " << msg - << "' " << somedir << "' : "; + << " '" << mydir << "' : "; perror(0); return(ex_syserr); } } + // here if stat succeeded return 0; } diff --git a/tools/ltgrey.c b/tools/ltgrey.c index bc41a99..ee6b4e5 100644 --- a/tools/ltgrey.c +++ b/tools/ltgrey.c @@ -18,6 +18,17 @@ int main(int _argc, char** _argv){ char** argv(_argv); const string parent_dir("/var/qmail/ltgrey"); whatsit foo(argv[0], parent_dir); argc--; argv++; + + if (foo.setup()) return ex_syserr; + + int rslt; + rslt = foo.maybe_mkdir(".", "parent dir"); + if (rslt) return rslt; + rslt = foo.maybe_mkdir(box_40.dir, "quarantine dir"); + if (rslt) return rslt; + rslt = foo.maybe_mkdir(box_rep.dir, "reputation dir"); + if (rslt) return rslt; + int scan40mode(0); int scanrepmode(0); int copies(1); @@ -89,7 +100,6 @@ int main(int _argc, char** _argv){ exeunt(ex_syserr); } } - if (foo.setup()) return ex_syserr; // dns_mode mode ... // Probably it would be better to make more thorough DNS checks. |