summaryrefslogtreecommitdiffhomepage
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-04-15 06:41:55 +0000
committermidipix <writeonce@midipix.org>2021-04-15 09:44:27 +0000
commitd385653e04a9455a5c9e34cc9a63c7de375981d7 (patch)
tree826766dbed097a65054d22a509cdeeb5d2af4328 /src/logic
parente524bdc940fa8826a9d076a9b9cb250d1bad71c4 (diff)
downloadslibtool-d385653e04a9455a5c9e34cc9a63c7de375981d7.tar.bz2
slibtool-d385653e04a9455a5c9e34cc9a63c7de375981d7.tar.xz
library: replace all uses of unlink() with unlinkat().
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_compile.c7
-rw-r--r--src/logic/slbt_exec_link.c7
-rw-r--r--src/logic/slbt_exec_uninstall.c2
3 files changed, 13 insertions, 3 deletions
diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c
index 7a934ab..2a407da 100644
--- a/src/logic/slbt_exec_compile.c
+++ b/src/logic/slbt_exec_compile.c
@@ -21,10 +21,15 @@ static int slbt_exec_compile_remove_file(
struct slbt_exec_ctx * ectx,
const char * target)
{
+ int fdcwd;
+
(void)ectx;
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* remove target (if any) */
- if (!(unlink(target)) || (errno == ENOENT))
+ if (!unlinkat(fdcwd,target,0) || (errno == ENOENT))
return 0;
return SLBT_SYSTEM_ERROR(dctx,0);
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index d83935c..0bc474d 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -867,10 +867,15 @@ static int slbt_exec_link_remove_file(
struct slbt_exec_ctx * ectx,
const char * target)
{
+ int fdcwd;
+
(void)ectx;
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* remove target (if any) */
- if (!(unlink(target)) || (errno == ENOENT))
+ if (!unlinkat(fdcwd,target,0) || (errno == ENOENT))
return 0;
return SLBT_SYSTEM_ERROR(dctx,0);
diff --git a/src/logic/slbt_exec_uninstall.c b/src/logic/slbt_exec_uninstall.c
index b904ef7..7e1d37a 100644
--- a/src/logic/slbt_exec_uninstall.c
+++ b/src/logic/slbt_exec_uninstall.c
@@ -101,7 +101,7 @@ static int slbt_exec_uninstall_fs_entry(
}
/* remove file or symlink entry */
- if (unlink(path))
+ if (unlinkat(fdcwd,path,0))
return SLBT_SYSTEM_ERROR(dctx,path);
/* remove empty containing directory? */