aboutsummaryrefslogtreecommitdiff
path: root/src/directive.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-13 21:50:15 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-13 22:32:40 +0300
commit2f3ec2402f827066cb55ae562154106433d29ac2 (patch)
tree87e650e32e90da305478c17e1e9730932e4e3c50 /src/directive.c
parenta9d38e5de5cceb667bec3db15fed68f7e8d96a8b (diff)
downloadwydawca-2f3ec2402f827066cb55ae562154106433d29ac2.tar.gz
wydawca-2f3ec2402f827066cb55ae562154106433d29ac2.tar.bz2
Rewrite diskio function so as not to assume any particular cwd
* src/backup.c (get_backup_suffix) (find_backup_file_name): Get directory descriptor as first argument. * src/diskio.c: Rewrite using *at() functions. * src/gpg.c (rmdir_r): Silently skip ENOENT. (verify_detached_signature): push_dir/pop_dir. * src/triplet.c: Don't change to spool->source_dir. Underlying functions don't assume any specific cwd. * src/wydawca.h (find_backup_file_name) (create_hierarchy): Change signatures. All uses changed. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Likewise. (AT_WYDAWCA_DAEMON): Take additional argument. * tests/inotify-rmsymlink.at: New test. * tests/inotify-symlink.at: New test. * tests/rmsymlink00.at: New test. * tests/symlink00.at: New test. * tests/symlink01.at: New test. * tests/dist/rmsymlink.directive.asc: New directive file. * tests/dist/symlink.directive.asc: New directive file.
Diffstat (limited to 'src/directive.c')
-rw-r--r--src/directive.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/directive.c b/src/directive.c
index 2aac9dc..2261158 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -308,7 +308,7 @@ save_script(const char *script)
int fd;
size_t length;
- file_name = concat_dir(temp_homedir, "chkXXXXXX", NULL);
+ file_name = concat_file(temp_homedir, "chkXXXXXX", NULL);
old_mask = umask(0077);
fd = mkstemp(file_name);
umask(old_mask);
@@ -538,14 +538,16 @@ external_check(struct wy_triplet *trp)
if (!spool->check_script && !default_check_script)
return 0;
- file = concat_dir(temp_homedir, trp->file[file_dist].name, NULL);
- if (copy_file(trp->file[file_dist].name, file)) {
+ file = concat_file(temp_homedir, trp->file[file_dist].name, NULL);
+ if (copy_file(trp->spool->source_fd, trp->file[file_dist].name,
+ AT_FDCWD, file)) {
free(file);
return 1;
}
rc = 0;
if (spool->check_script)
+ //FIXME: Ensure correct CWD
rc |= run_check_script(spool->check_script, trp,
_("spool check script"));
@@ -660,7 +662,8 @@ process_directives(struct wy_triplet *trp)
}
}
- if (!wy_dry_run && unlink(trp->file[file_directive].name)) {
+ if (!wy_dry_run
+ && unlinkat(trp->spool->source_fd, trp->file[file_directive].name, 0)) {
wy_log(LOG_CRIT, _("%s: cannot unlink directive file: %s"),
trp->file[file_directive].name, strerror(errno));
}

Return to:

Send suggestions and report system problems to the System administrator.