summaryrefslogtreecommitdiffhomepage
path: root/src
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
parente524bdc940fa8826a9d076a9b9cb250d1bad71c4 (diff)
downloadslibtool-d385653e04a9455a5c9e34cc9a63c7de375981d7.tar.bz2
slibtool-d385653e04a9455a5c9e34cc9a63c7de375981d7.tar.xz
library: replace all uses of unlink() with unlinkat().
Diffstat (limited to 'src')
-rw-r--r--src/driver/slbt_driver_ctx.c6
-rw-r--r--src/helper/slbt_archive_import.c4
-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
5 files changed, 20 insertions, 6 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index be70ad5..13efa37 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -658,6 +658,7 @@ static int slbt_init_host_params(
struct slbt_host_params * host,
struct slbt_host_params * cfgmeta)
{
+ int fdcwd;
int arprobe;
int arfd;
int ecode;
@@ -873,9 +874,12 @@ static int slbt_init_host_params(
cfgmeta->ar = cfgnative;
}
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* clean up */
if (arfd >= 0) {
- unlink(archivename);
+ unlinkat(fdcwd,archivename,0);
close(arfd);
}
}
diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c
index 444c48d..071654f 100644
--- a/src/helper/slbt_archive_import.c
+++ b/src/helper/slbt_archive_import.c
@@ -149,10 +149,10 @@ int slbt_archive_import(
0);
if (dst == mridst)
- unlink(dst);
+ unlinkat(fdcwd,dst,0);
if (src == mrisrc)
- unlink(src);
+ unlinkat(fdcwd,src,0);
return (rpid == pid) && (ectx->exitcode == 0)
? 0 : SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_ARCHIVE_IMPORT);
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? */