aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-10 23:25:11 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-10 23:26:52 +0200
commit39a97e438dde837ada9a99cceea93a1cf97db19e (patch)
treeefc492dcfcdc2c21bfdec5c31692b348601cd94a /src
parent87602f5492b842f734dffe22f4e2f85dbc6ce713 (diff)
downloadwydawca-39a97e438dde837ada9a99cceea93a1cf97db19e.tar.gz
wydawca-39a97e438dde837ada9a99cceea93a1cf97db19e.tar.bz2
Provide a convenient debugging macro.
Rename logmsg to wy_log.
Diffstat (limited to 'src')
-rw-r--r--src/builtin.c4
-rw-r--r--src/dictionary.c26
-rw-r--r--src/directive.c88
-rw-r--r--src/diskio.c107
-rw-r--r--src/exec.c34
-rw-r--r--src/gpg.c62
-rw-r--r--src/job.c53
-rw-r--r--src/lock.c10
-rw-r--r--src/module.c18
-rw-r--r--src/net.c24
-rw-r--r--src/null.c22
-rw-r--r--src/pidfile.c12
-rw-r--r--src/process.c36
-rw-r--r--src/sql.c18
-rw-r--r--src/triplet.c58
-rw-r--r--src/userprivs.c22
-rw-r--r--src/verify.c42
-rw-r--r--src/watcher.c60
-rw-r--r--src/wydawca.c41
-rw-r--r--src/wydawca.h12
20 files changed, 350 insertions, 399 deletions
diff --git a/src/builtin.c b/src/builtin.c
index 72b73cd..b812236 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -80,7 +80,7 @@ cmp_regex(const char *pat, const char *str, int flags)
char errbuf[512];
regerror(rc, &regex, errbuf, sizeof(errbuf));
- logmsg(LOG_ERR, _("%s: cannot compile regexp: %s"), pat,
+ wy_log(LOG_ERR, _("%s: cannot compile regexp: %s"), pat,
errbuf);
return 0;
}
@@ -119,7 +119,7 @@ parse_cmp_type(const char *pat, strcmp_fn * cmpfn, int *rf)
break;
default:
- logmsg(LOG_NOTICE,
+ wy_log(LOG_NOTICE,
_("unrecognized comparison flag: %c"),
*pat);
}
diff --git a/src/dictionary.c b/src/dictionary.c
index f46dd81..4f18267 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -65,10 +65,10 @@ dictionary_init(struct dictionary *dict)
return 0;
if (wy_debug_level > 1) {
int i;
- logmsg(LOG_DEBUG, _("initializing dictionary: %s \"%s\""),
+ wy_log(LOG_DEBUG, _("initializing dictionary: %s \"%s\""),
mp->name, SP(dict->query));
for (i = 0; i < dict->parmc; i++)
- logmsg(LOG_DEBUG, " parmv[%d]=%s", i, dict->parmv[i]);
+ wy_log(LOG_DEBUG, " parmv[%d]=%s", i, dict->parmv[i]);
}
if (mp->init)
rc = mp->init(dict);
@@ -110,10 +110,10 @@ dictionary_done(struct dictionary *dict)
return 0;
if (wy_debug_level > 1) {
int i;
- logmsg(LOG_DEBUG, _("closing dictionary: %s \"%s\""),
+ wy_log(LOG_DEBUG, _("closing dictionary: %s \"%s\""),
mp->name, SP(dict->query));
for (i = 0; i < dict->parmc; i++)
- logmsg(LOG_DEBUG, " parmv[%d]=%s", i, dict->parmv[i]);
+ wy_log(LOG_DEBUG, " parmv[%d]=%s", i, dict->parmv[i]);
}
if (mp->done)
rc = mp->done(dict);
@@ -128,24 +128,22 @@ dictionary_lookup(struct dictionary *dict, void *handle, const char *cmd)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
- if (wy_debug_level > 1) {
- if (cmd)
- logmsg(LOG_DEBUG, _("dictionary lookup: %s \"%s\""),
- mp->name, cmd);
- else
- logmsg(LOG_DEBUG, _("dictionary lookup: %s"),
- mp->name);
- }
+ if (cmd)
+ wy_debug(1, (_("dictionary lookup: %s \"%s\""),
+ mp->name, cmd));
+ else
+ wy_debug(1, (_("dictionary lookup: %s"),
+ mp->name));
if (!dict->init_passed) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
_("INTERNAL ERROR: "
"dictionary %s \"%s\" not initialized"),
mp->name, SP(dict->query));
return 1;
}
if (!mp->lookup) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
_("INTERNAL ERROR: "
"no lookup function for dictionary %s \"%s\""),
mp->name, SP(dict->query));
diff --git a/src/directive.c b/src/directive.c
index cc43c16..481e267 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -25,9 +25,8 @@ directive_parse(struct file_triplet *trp)
size_t dcount, i, j;
char *p;
- if (wy_debug_level > 2)
- logmsg(LOG_DEBUG, _("%s: parsing directive blurb: %s"),
- trp->file[file_directive].name, trp->blurb);
+ wy_debug(3, (_("%s: parsing directive blurb: %s"),
+ trp->file[file_directive].name, trp->blurb));
dcount = 0;
for (p = trp->blurb; *p; p++)
@@ -44,7 +43,7 @@ directive_parse(struct file_triplet *trp)
if (trim(trp->directive[j]) == 0) /* ignore empty lines */
continue;
if (strchr(trp->directive[j], ':') == NULL) {
- logmsg(LOG_ERR, _("%s: invalid line: %s"),
+ wy_log(LOG_ERR, _("%s: invalid line: %s"),
trp->file[file_directive].name,
trp->directive[j]);
free(trp->directive);
@@ -174,17 +173,17 @@ directive_version_in_range_p(struct file_triplet *trp,
unsigned version;
if (directive_get_value(trp, "version", &val)) {
- logmsg(LOG_ERR, _("%s: missing `version' directive"),
+ wy_log(LOG_ERR, _("%s: missing `version' directive"),
trp->file[file_directive].name);
return 0;
}
if (directive_pack_version(val, &version)) {
- logmsg(LOG_ERR, _("%s: unparsable version: %s"),
+ wy_log(LOG_ERR, _("%s: unparsable version: %s"),
trp->file[file_directive].name, val);
return 0;
}
- logmsg(LOG_NOTICE, _("%s: VERSION: %s"),
+ wy_log(LOG_NOTICE, _("%s: VERSION: %s"),
trp->file[file_directive].name, val);
trp->version = version;
@@ -192,7 +191,7 @@ directive_version_in_range_p(struct file_triplet *trp,
if (from <= version && version <= to)
return 1;
- logmsg(LOG_ERR, _("%s: version %s is not in the allowed range"),
+ wy_log(LOG_ERR, _("%s: version %s is not in the allowed range"),
trp->file[file_directive].name, val);
return 0;
}
@@ -257,7 +256,7 @@ verify_directive_format(struct file_triplet *trp)
switch (dnum) {
case 1:
if (strcmp(key, "version")) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("%s:%d: expected `%s' but found `%s'"),
trp->file[file_directive].name, n,
"version", key);
@@ -267,7 +266,7 @@ verify_directive_format(struct file_triplet *trp)
case 2:
if (strcmp(key, "directory")) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("%s:%d: expected `%s' but found `%s'"),
trp->file[file_directive].name, n,
"directory", key);
@@ -277,7 +276,7 @@ verify_directive_format(struct file_triplet *trp)
default:
if (find_directive(key) == unknown_dir) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("%s:%d: unknown directive `%s'"),
trp->file[file_directive].name, n, key);
return 1;
@@ -288,12 +287,12 @@ verify_directive_format(struct file_triplet *trp)
if (trp->file[file_dist].name && trp->file[file_signature].name) {
const char *filename;
if (directive_get_value(trp, "filename", &filename)) {
- logmsg(LOG_ERR, _("%s: missing `filename' directive"),
+ wy_log(LOG_ERR, _("%s: missing `filename' directive"),
trp->file[file_directive].name);
return 1;
}
if (strcmp(filename, trp->file[file_dist].name)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("%s: filename %s does not match actual name"),
trp->file[file_dist].name, filename);
return 1;
@@ -315,7 +314,7 @@ save_script(const char *script)
fd = mkstemp(file_name);
umask(old_mask);
if (fd == -1) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
_("cannot create temporary script file %s: %s"),
file_name, strerror(errno));
free(file_name);
@@ -326,14 +325,14 @@ save_script(const char *script)
while (length) {
ssize_t wrb = write(fd, script, length);
if (wrb == -1) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
_("error writing to temporary script "
"file %s: %s"),
file_name, strerror(errno));
break;
}
if (wrb == 0) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
_("short write to temporary script file %s"),
file_name);
break;
@@ -357,13 +356,13 @@ stderr_redirector(const char *tag)
pid_t pid;
if (pipe(p)) {
- logmsg(LOG_CRIT, "redirector pipe: %s", strerror(errno));
+ wy_log(LOG_CRIT, "redirector pipe: %s", strerror(errno));
return -1;
}
pid = fork();
if (pid == -1) {
- logmsg(LOG_CRIT, "redirector fork: %s", strerror(errno));
+ wy_log(LOG_CRIT, "redirector fork: %s", strerror(errno));
return -1;
}
@@ -378,7 +377,7 @@ stderr_redirector(const char *tag)
_exit(127);
while (grecs_getline(&buf, &size, fp) >= 0) {
trim_crlf(buf);
- logmsg(LOG_NOTICE, "%s: %s", tag, buf);
+ wy_log(LOG_NOTICE, "%s: %s", tag, buf);
}
_exit(0);
}
@@ -400,23 +399,21 @@ run_check_script(const char *script, struct file_triplet *trp,
char *buf;
size_t size, total;
- if (wy_debug_level > 1)
- logmsg(LOG_DEBUG, _("prep script: %20.20s%s"),
- script, strlen(script) > 20 ? "..." : "");
+ wy_debug(2, (_("prep script: %20.20s%s"),
+ script, strlen(script) > 20 ? "..." : ""));
script_file = save_script(script);
if (!script_file)
return 1;
- if (wy_debug_level > 1)
- logmsg(LOG_DEBUG, _("script file: %s"), script_file);
+ wy_debug(2, (_("script file: %s"), script_file));
if (pipe(p)) {
- logmsg(LOG_CRIT, "pipe: %s", strerror(errno));
+ wy_log(LOG_CRIT, "pipe: %s", strerror(errno));
return 1;
}
oldsig = signal(SIGCHLD, SIG_DFL);
pid = fork();
if (pid == -1) {
- logmsg(LOG_CRIT, "fork: %s", strerror(errno));
+ wy_log(LOG_CRIT, "fork: %s", strerror(errno));
free(script_file);
close(p[0]);
close(p[1]);
@@ -446,14 +443,14 @@ run_check_script(const char *script, struct file_triplet *trp,
}
if (p[1] != 1 && dup2(p[1], 1) != 1) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
"cannot duplicate script's stdout: %s",
strerror(errno));
_exit(127);
}
if (efd != 2 && dup2(efd, 2) != 2) {
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
"cannot duplicate script's stderr: %s",
strerror(errno));
_exit(127);
@@ -467,7 +464,7 @@ run_check_script(const char *script, struct file_triplet *trp,
setenv("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1);
if (chdir(temp_homedir)) {
- logmsg(LOG_CRIT, "cannot change to %s: %s",
+ wy_log(LOG_CRIT, "cannot change to %s: %s",
temp_homedir, strerror(errno));
_exit(127);
}
@@ -486,18 +483,15 @@ run_check_script(const char *script, struct file_triplet *trp,
fp = fdopen(p[0], "r");
buf = NULL;
size = total = 0;
- if (wy_debug_level > 2)
- logmsg(LOG_DEBUG, _("reading script output..."));
+ wy_debug(3, (_("reading script output...")));
while (grecs_getline(&buf, &size, fp) > 0) {
size_t len = strlen(buf);
- if (wy_debug_level > 2)
- logmsg(LOG_DEBUG, _("read: %s"), buf);
+ wy_debug(3, (_("read: %s"), buf));
txtacc_grow(trp->acc, buf, len);
total += size;
}
txtacc_1grow(trp->acc, 0);
- if (wy_debug_level > 2)
- logmsg(LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total);
+ wy_debug(3, (_("bytes read: %lu"), (unsigned long)total));
fclose(fp);
@@ -511,20 +505,20 @@ run_check_script(const char *script, struct file_triplet *trp,
if (WIFEXITED(status)) {
status = WEXITSTATUS(status);
if (status) {
- logmsg(LOG_ERR, "%s for %s@%s returned %d",
+ wy_log(LOG_ERR, "%s for %s@%s returned %d",
descr, trp->name, trp->spool->tag, status);
return 1;
- } else if (wy_debug_level > 2)
- logmsg(LOG_DEBUG, "%s for %s@%s returned %d",
- descr, trp->name, trp->spool->tag, status);
+ } else
+ wy_debug(3, ("%s for %s@%s returned %d",
+ descr, trp->name, trp->spool->tag, status));
} else if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status);
- logmsg(LOG_NOTICE,
+ wy_log(LOG_NOTICE,
"%s for %s@%s terminated on signal %d",
descr, trp->name, trp->spool->tag, sig);
return 1;
} else {
- logmsg(LOG_NOTICE,
+ wy_log(LOG_NOTICE,
"%s for %s@%s terminated with unhandled status",
descr, trp->name, trp->spool->tag);
return 1;
@@ -576,14 +570,14 @@ symlink_filelist(struct file_triplet *trp, const char *key, const char *val)
struct wordsplit ws;
if (wordsplit(val, &ws, WRDSF_DEFFLAGS)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot parse symlink value `%s'"), val);
return 1;
}
if (ws.ws_wordc != 2) {
rc = 1;
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("wrong number of arguments to %s directive: `%s'"),
key, val);
} else
@@ -614,7 +608,7 @@ process_directives(struct file_triplet *trp)
abort();
case comment_dir:
- logmsg(LOG_NOTICE, _("%s: COMMENT: %s"),
+ wy_log(LOG_NOTICE, _("%s: COMMENT: %s"),
trp->file[file_directive].name, val);
break;
@@ -632,7 +626,7 @@ process_directives(struct file_triplet *trp)
move_file(trp, file_signature))
return 1;
} else {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("invalid detached signature for %s"),
trp->name);
return 1;
@@ -661,7 +655,7 @@ process_directives(struct file_triplet *trp)
case replace_dir:
if (trp->version < 102) {
rc = 1;
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("\"replace\" directive is invalid "
"for version %d"),
trp->version);
@@ -670,7 +664,7 @@ process_directives(struct file_triplet *trp)
}
if (!dry_run_mode && unlink(trp->file[file_directive].name)) {
- logmsg(LOG_CRIT, _("%s: cannot unlink directive file: %s"),
+ wy_log(LOG_CRIT, _("%s: cannot unlink directive file: %s"),
trp->file[file_directive].name, strerror(errno));
}
diff --git a/src/diskio.c b/src/diskio.c
index 9574014..99d3b54 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -66,13 +66,13 @@ create_hierarchy(char *dir, size_t baselen)
if (stat(dir, &st) == 0) {
if (!S_ISDIR(st.st_mode)) {
- logmsg(LOG_ERR, _("component %s is not a directory"),
+ wy_log(LOG_ERR, _("component %s is not a directory"),
dir);
return 1;
}
return 0;
} else if (errno != ENOENT) {
- logmsg(LOG_ERR, _("cannot stat file %s: %s"), dir,
+ wy_log(LOG_ERR, _("cannot stat file %s: %s"), dir,
strerror(errno));
return 1;
}
@@ -80,7 +80,7 @@ create_hierarchy(char *dir, size_t baselen)
p = strrchr(dir, '/');
if (p) {
if (p - dir + 1 < baselen) {
- logmsg(LOG_ERR, _("base directory %s does not exist"),
+ wy_log(LOG_ERR, _("base directory %s does not exist"),
dir);
return 1;
}
@@ -92,7 +92,7 @@ create_hierarchy(char *dir, size_t baselen)
if (p)
*p = '/';
if (mkdir(dir, MKDIR_PERMISSIONS)) {
- logmsg(LOG_ERR, _("cannot create directory %s: %s"),
+ wy_log(LOG_ERR, _("cannot create directory %s: %s"),
dir, strerror(errno));
rc = 1;
}
@@ -132,14 +132,14 @@ copy_file(const char *file, const char *dst_file)
in_fd = open(file, O_RDONLY);
if (in_fd == -1) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot open source file %s for reading: %s"),
file, strerror(errno));
return 1;
}
if (fstat(in_fd, &st)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot stat source file %s: %s"),
file, strerror(errno));
close(in_fd);
@@ -148,7 +148,7 @@ copy_file(const char *file, const char *dst_file)
out_fd = creat(dst_file, CREAT_PERMISSIONS);
if (out_fd == -1) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot create destination file %s: %s"),
dst_file, strerror(errno));
close(in_fd);
@@ -171,20 +171,20 @@ copy_file(const char *file, const char *dst_file)
rest = fsize > bufsize ? bufsize : fsize;
rdbytes = read(in_fd, buf, rest);
if (rdbytes == -1) {
- logmsg(LOG_ERR, _("unexpected error reading %s: %s"),
+ wy_log(LOG_ERR, _("unexpected error reading %s: %s"),
file, strerror(errno));
rc = 1;
break;
}
rest = write(out_fd, buf, rdbytes);
if (rest == -1) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("unexpected error writing to %s: %s"),
dst_file, strerror(errno));
rc = 1;
break;
} else if (rest != rdbytes) {
- logmsg(LOG_ERR, _("short write on %s"), dst_file);
+ wy_log(LOG_ERR, _("short write on %s"), dst_file);
rc = 1;
}
fsize -= rdbytes;
@@ -208,15 +208,15 @@ do_move_file(const char *file, const char *dst_file)
if (rename(file, dst_file)) {
if (errno == EXDEV) {
if (copy_file(file, dst_file)) {
- logmsg(LOG_CRIT, _("cannot copy %s to %s: %s"),
+ wy_log(LOG_CRIT, _("cannot copy %s to %s: %s"),
file, dst_file, strerror(errno));
rc = 1;
} else if (unlink(file)) {
- logmsg(LOG_ERR, _("cannot unlink %s: %s"),
+ wy_log(LOG_ERR, _("cannot unlink %s: %s"),
file, strerror(errno));
}
} else {
- logmsg(LOG_CRIT, _("cannot move %s to %s: %s"),
+ wy_log(LOG_CRIT, _("cannot move %s to %s: %s"),
file, dst_file, strerror(errno));
rc = 1;
}
@@ -231,8 +231,7 @@ tar_append_file(const char *archive, const char *file)
{
const char *argv[6];
- if (wy_debug_level)
- logmsg(LOG_DEBUG, _("tarring %s to %s"), file, archive);
+ wy_debug(1, (_("tarring %s to %s"), file, archive));
if (dry_run_mode) {
UPDATE_STATS(STAT_ARCHIVES);
return 0;
@@ -252,7 +251,7 @@ tar_append_file(const char *archive, const char *file)
case exec_fail:
case exec_error:
- logmsg(LOG_ERR, _("cannot archive %s"), file);
+ wy_log(LOG_ERR, _("cannot archive %s"), file);
break;
}
@@ -286,13 +285,11 @@ backup_file(const char *dst_file, const char *dst_dir, const char *file,
file_name = concat_dir(adir, file, NULL);
if (access(file_name, F_OK) == 0) {
if (archive->backup_type == no_backups) {
- if (wy_debug_level)
- logmsg(LOG_DEBUG,
- _("removing previous archive "
- "file `%s'"),
- file_name);
+ wy_debug(1, (_("removing previous archive "
+ "file `%s'"),
+ file_name));
if (!dry_run_mode && unlink(file_name)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot unlink previous archive "
"file `%s': %s"),
file_name, strerror(errno));
@@ -304,16 +301,14 @@ backup_file(const char *dst_file, const char *dst_dir, const char *file,
char *archive_file_name =
find_backup_file_name(file_name,
archive->backup_type);
- if (wy_debug_level)
- logmsg(LOG_DEBUG,
- _("backing up previous archive "
- "file `%s' to `%s'"),
- file_name, archive_file_name);
+ wy_debug(1, (_("backing up previous archive "
+ "file `%s' to `%s'"),
+ file_name, archive_file_name));
if (!dry_run_mode) {
rc = do_move_file(file_name,
archive_file_name);
if (rc) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("backing `%s' up as `%s' failed: %s"),
file_name, archive_file_name,
strerror(errno));
@@ -327,13 +322,11 @@ backup_file(const char *dst_file, const char *dst_dir, const char *file,
}
}
- if (wy_debug_level)
- logmsg(LOG_DEBUG, _("archiving `%s' to `%s'"), dst_file,
- file_name);
+ wy_debug(1, (_("archiving `%s' to `%s'"), dst_file, file_name));
if (!dry_run_mode) {
rc = do_move_file(dst_file, file_name);
if (rc)
- logmsg(LOG_ERR, _("archiving `%s' as `%s' failed: %s"),
+ wy_log(LOG_ERR, _("archiving `%s' as `%s' failed: %s"),
dst_file, file_name, strerror(errno));
}
free(file_name);
@@ -365,7 +358,7 @@ do_archive_file(const char *dst_file, const char *dst_dir, const char *file,
}
if (!dry_run_mode && unlink(dst_file) && errno != ENOENT) {
- logmsg(LOG_ERR, _("canot unlink file `%s': %s"),
+ wy_log(LOG_ERR, _("canot unlink file `%s': %s"),
dst_file, strerror(errno));
return 1;
}
@@ -408,9 +401,8 @@ dir_move_file(struct file_triplet *trp, enum file_type file_id)
return 1;
dst_file = concat_dir(dst_dir, trp->file[file_id].name, NULL);
- if (wy_debug_level)
- logmsg(LOG_DEBUG, _("installing %s to %s"),
- trp->file[file_id].name, dst_dir);
+ wy_debug(1, (_("installing %s to %s"),
+ trp->file[file_id].name, dst_dir));
if (access(dst_file, F_OK) == 0) {
if (replace_allowed_p(trp))
@@ -419,7 +411,7 @@ dir_move_file(struct file_triplet *trp, enum file_type file_id)
&spool->archive,
trp->relative_dir);
else {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("refusing to upload %s because it already "
"exists and replace is not allowed"),
trp->file[file_id].name);
@@ -457,7 +449,7 @@ archive_single_file(struct file_triplet *trp, const char *file_name,
dst_file = safe_file_name(concat_dir(dst_dir, file_name, NULL));
if (!sub_dir_p(dst_file, spool->dest_dir)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("file to be archived `%s' does not lie under `%s'"),
dst_file, spool->dest_dir);
free(dst_file);
@@ -466,18 +458,17 @@ archive_single_file(struct file_triplet *trp, const char *file_name,
}
if (access(dst_file, F_OK) == 0) {
- if (wy_debug_level)
- logmsg(LOG_DEBUG, _("archiving file `%s'"), dst_file);
+ wy_debug(1, (_("archiving file `%s'"), dst_file));
rc = do_archive_file(dst_file, dst_dir, file_name,
&spool->archive, trp->relative_dir);
} else if (errno == ENOENT) {
if (!noentok)
- logmsg(LOG_NOTICE,
+ wy_log(LOG_NOTICE,
_("nothing to archive: "
"file `%s' does not exist"),
dst_file);
} else {
- logmsg(LOG_ERR, _("canot access file `%s': %s"),
+ wy_log(LOG_ERR, _("canot access file `%s': %s"),
dst_file, strerror(errno));
rc = 1;
}
@@ -539,7 +530,7 @@ dir_symlink_file(struct file_triplet *trp,
src = safe_file_name_alloc(wanted_src);
if (!src || src[0] == '/') {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("symlink source `%s' does not lie under `%s'"),
wanted_src, spool->dest_dir);
free(src);
@@ -548,7 +539,7 @@ dir_symlink_file(struct file_triplet *trp,
dst = safe_file_name_alloc(wanted_dst);
if (!dst || dst[0] == '/') {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("symlink destination `%s' does not lie under `%s'"),
wanted_dst, spool->dest_dir);
free(src);
@@ -556,9 +547,8 @@ dir_symlink_file(struct file_triplet *trp,
return 1;
}
- if (wy_debug_level)
- logmsg(LOG_DEBUG, _("symlinking %s to %s in directory %s"),
- src, dst, dst_dir);
+ wy_debug(1, (_("symlinking %s to %s in directory %s"),
+ src, dst, dst_dir));
if (!dry_run_mode) {
char *p = strrchr(dst, '/');
@@ -576,25 +566,25 @@ dir_symlink_file(struct file_triplet *trp,
if (rc == 0) {
if (push_dir(dst_dir))
- logmsg(LOG_ERR, _("cannot change to %s: %s"),
+ wy_log(LOG_ERR, _("cannot change to %s: %s"),
dst_dir, strerror(errno));
else {
struct stat st;
if (lstat(dst, &st) == 0) {
if (!S_ISLNK(st.st_mode)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("file %s exists and is not a symbolic link"),
dst);
rc = 1;
} else if (unlink(dst)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot unlink %s: %s"),
dst, strerror(errno));
rc = 1;
}
} else if (errno != ENOENT) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("cannot stat file %s: %s"),
dst, strerror(errno));
rc = 1;
@@ -603,13 +593,13 @@ dir_symlink_file(struct file_triplet *trp,
if (rc == 0) {
rc = symlink(src, dst);
if (rc)
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("symlinking %s to %s in directory %s failed: %s"),
src, dst, dst_dir,
strerror(errno));
}
if (pop_dir()) {
- logmsg(LOG_EMERG,
+ wy_log(LOG_EMERG,
_("cannot restore current directory: %s"),
strerror(errno));
exit(EX_SOFTWARE);
@@ -632,26 +622,25 @@ do_rmsymlink_file(const char *dst_file, int noentok)
{
struct stat st;
- if (wy_debug_level)
- logmsg(LOG_DEBUG, _("removing symbolic link %s"), dst_file);
+ wy_debug(1, (_("removing symbolic link %s"), dst_file));
if (stat(dst_file, &st)) {
if (errno == ENOENT) {
if (!noentok)
- logmsg(LOG_NOTICE,
+ wy_log(LOG_NOTICE,
_("symlink `%s' does not exist"),
dst_file);
return 0;
}
if (!S_ISLNK(st.st_mode)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("refusing to unlink %s: is not a symlink"),
dst_file);
return 1;
}
}
if (!dry_run_mode && unlink(dst_file)) {
- logmsg(LOG_ERR, _("cannot unlink %s: %s"), dst_file,
+ wy_log(LOG_ERR, _("cannot unlink %s: %s"), dst_file,
strerror(errno));
return 1;
}
@@ -676,7 +665,7 @@ dir_rmsymlink_file(struct file_triplet *trp, const char *file_name)
dst_file = safe_file_name(concat_dir(dst_dir, file_name, NULL));
if (!sub_dir_p(dst_file, spool->dest_dir)) {
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("refusing to remove a symlink `%s' that is not "
"located under `%s'"), dst_file, spool->dest_dir);
free(dst_file);
diff --git a/src/exec.c b/src/exec.c
index c41d48c..5b75f77 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -31,7 +31,7 @@ start_prog(int argc, const char **argv, pid_t * ppid)
int i;
if (pipe(p)) {
- logmsg(LOG_CRIT, "pipe: %s", strerror(errno));
+ wy_log(LOG_CRIT, "pipe: %s", strerror(errno));
return NULL;
}
@@ -40,12 +40,12 @@ start_prog(int argc, const char **argv, pid_t * ppid)
/* Child process */
if (p[1] != 1 && dup2(p[1], 1) == -1) {
- logmsg(LOG_CRIT, "dup2: %s", strerror(errno));
+ wy_log(LOG_CRIT, "dup2: %s", strerror(errno));
_exit(EX_UNAVAILABLE);
}
if (p[1] != 1 && dup2(p[1], 2) == -1) {
- logmsg(LOG_CRIT, "dup2: %s", strerror(errno));
+ wy_log(LOG_CRIT, "dup2: %s", strerror(errno));
_exit(EX_UNAVAILABLE);
}
@@ -56,12 +56,12 @@ start_prog(int argc, const char **argv, pid_t * ppid)
close(i);
execvp(argv[0], (char **)argv);
- logmsg(LOG_CRIT, _("cannot run %s: %s"), argv[0],
+ wy_log(LOG_CRIT, _("cannot run %s: %s"), argv[0],
strerror(errno));
exit(EX_UNAVAILABLE);
case -1:
- logmsg(LOG_CRIT, _("cannot run `%s': fork failed: %s"),
+ wy_log(LOG_CRIT, _("cannot run `%s': fork failed: %s"),
argv[0], strerror(errno));
return NULL;
@@ -70,7 +70,7 @@ start_prog(int argc, const char **argv, pid_t * ppid)
close(p[1]);
fp = fdopen(p[0], "r");
if (!fp)
- logmsg(LOG_ERR, _("cannot fdopen: %s"),
+ wy_log(LOG_ERR, _("cannot fdopen: %s"),
strerror(errno));
*ppid = pid;
}
@@ -80,15 +80,15 @@ start_prog(int argc, const char **argv, pid_t * ppid)
/* Log everything read from FP as the output from the program PROG, using
syslog priority PRIO. */
void
-log_output(int prio, const char *prog, FILE * fp)
+log_output(int prio, const char *prog, FILE *fp)
{
size_t size = 0;
char *buf = NULL;
- logmsg(prio, _("%s output follows:"), prog);
+ wy_log(prio, _("%s output follows:"), prog);
while (grecs_getline(&buf, &size, fp) > 0)
- logmsg(prio, "%s", buf);
- logmsg(prio, _("end of %s output"), prog);
+ wy_log(prio, "%s", buf);
+ wy_log(prio, _("end of %s output"), prog);
free(buf);
}
@@ -104,7 +104,7 @@ wydawca_exec(int argc, const char **argv, int *retcode)
fp = start_prog(5, argv, &pid);
if (!fp) {
- logmsg(LOG_CRIT, _("cannot start %s"), argv[0]);
+ wy_log(LOG_CRIT, _("cannot start %s"), argv[0]);
return exec_error;
}
@@ -113,13 +113,13 @@ wydawca_exec(int argc, const char **argv, int *retcode)
switch (npid) {
case -1:
- logmsg(LOG_CRIT, _("cannot execute %s: waitpid failed: %s"),
+ wy_log(LOG_CRIT, _("cannot execute %s: waitpid failed: %s"),
argv[0], strerror(errno));
fclose(fp);
return exec_error;
case 0:
- logmsg(LOG_CRIT,
+ wy_log(LOG_CRIT,
_("cannot execute %s: the process did not respond "
"within 5 seconds: %s"), argv[0], strerror(errno));
kill(pid, SIGKILL);
@@ -134,7 +134,7 @@ wydawca_exec(int argc, const char **argv, int *retcode)
int rc = WEXITSTATUS(status);
if (rc) {
res = exec_fail;
- logmsg(LOG_ERR, _("command %s returned %d"), argv[0],
+ wy_log(LOG_ERR, _("command %s returned %d"), argv[0],
rc);
log_output(LOG_ERR, argv[0], fp);
} else {
@@ -147,13 +147,13 @@ wydawca_exec(int argc, const char **argv, int *retcode)
} else {
res = exec_error;
if (WIFSIGNALED(status))
- logmsg(LOG_ERR, _("%s terminated on signal %d"),
+ wy_log(LOG_ERR, _("%s terminated on signal %d"),
argv[0], WTERMSIG(status));
else if (WIFSTOPPED(status))
- logmsg(LOG_ERR, _("%s stopped on signal %d"),
+ wy_log(LOG_ERR, _("%s stopped on signal %d"),
argv[0], WTERMSIG(status));
else
- logmsg(LOG_ERR,
+ wy_log(LOG_ERR,
_("%s terminated with unrecognized status"),
argv[0]);
}
diff --git a/src/gpg.c b/src/gpg.c
index 1eb1db8..7b5146e 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -22,7 +22,7 @@
#define fail_if_err(expr) do { \
int a = expr; \
if (a) { \
- logmsg(LOG_ERR, _("%s: GPGME error: %s"), #expr, \
+ wy_log(LOG_ERR, _("%s: GPGME error: %s"), #expr, \
gpgme_strerror(a)); \
return 1; \
} \
@@ -42,14 +42,14 @@ recursive_rmdir(const char *name)
struct dirent *ent;
if (chdir(name)) {
- logmsg(LOG_ERR, _("cannot change to directory %s: %s"),
+ wy_log(LOG_ERR, _("cannot change to directory %s: %s"),
name, strerror(errno));
return 1;
}
dir = opendir(".");
if (!dir) {
- logmsg(LOG_ERR, _("cannot open directory %s: %s"),
+ wy_log(LOG_ERR, _("cannot open directory %s: %s"),
name, strerror(errno));
return 1;
}
@@ -62,13 +62,13 @@ recursive_rmdir(const char *name)
continue;
if (stat(ent->d_name, &st) && errno != ENOENT) {
- logmsg(LOG_ERR, _("cannot stat file `%s': %s"),
+ wy_log(LOG_ERR, _("cannot stat file `%s': %s"),
name, strerror(errno));
rc = 1;
} else if (S_ISDIR(st.st_mode))
rc = rmdir_r(ent->d_name);
else if ((rc = unlink(ent->d_name)) != 0 && errno != ENOENT)
- logmsg(LOG_ERR, _("cannot unlink %s: %s"),
+ wy_log(LOG_ERR, _("cannot unlink %s: %s"),
ent->d_name, strerror(errno));
}
closedir(dir);
@@ -83,19 +83,19 @@ rmdir_r(const char *name)
int rc;
if (push_dir(NULL)) {
- logmsg(LOG_ERR, _("cannot save current directory: %s"),
+ wy_log(LOG_ERR, _("cannot save current directory: %s"),
strerror(errno));
return 1;
}
rc = recursive_rmdir(name);
if (pop_dir()) {
- logmsg(LOG_ERR, _("cannot restore current directory: %s"),
+ wy_log(LOG_ERR, _("cannot restore current directory: %s"),
strerror(errno));
rc = 1;
}
if (rc == 0 && rmdir(name)) {
- logmsg(LOG_ERR, _("cannot remove directory %s: %s"),
+ wy_log(LOG_ERR, _("cannot remove directory %s: %s"),
name, strerror(errno));