summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/helper/slbt_archive_import.c7
-rw-r--r--src/helper/slbt_copy_file.c7
-rw-r--r--src/helper/slbt_realpath.c3
-rw-r--r--src/internal/slibtool_readlink_impl.h5
-rw-r--r--src/internal/slibtool_symlink_impl.c4
-rw-r--r--src/internal/slibtool_symlink_impl.h2
-rw-r--r--src/logic/slbt_exec_install.c14
-rw-r--r--src/logic/slbt_exec_link.c7
-rw-r--r--src/logic/slbt_exec_uninstall.c10
9 files changed, 40 insertions, 19 deletions
diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c
index ae8821b..b3b1cec 100644
--- a/src/helper/slbt_archive_import.c
+++ b/src/helper/slbt_archive_import.c
@@ -13,6 +13,7 @@
#include <sys/wait.h>
#include <slibtool/slibtool.h>
+#include "slibtool_driver_impl.h"
#include "slibtool_spawn_impl.h"
#include "slibtool_dprintf_impl.h"
#include "slibtool_symlink_impl.h"
@@ -80,6 +81,7 @@ int slbt_archive_import(
char * dstarchive,
char * srcarchive)
{
+ int fdcwd;
pid_t pid;
pid_t rpid;
int fd[2];
@@ -90,8 +92,11 @@ int slbt_archive_import(
char mrisrc [L_tmpnam];
char program[PATH_MAX];
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* not needed? */
- if (slbt_symlink_is_a_placeholder(srcarchive))
+ if (slbt_symlink_is_a_placeholder(fdcwd,srcarchive))
return 0;
/* program */
diff --git a/src/helper/slbt_copy_file.c b/src/helper/slbt_copy_file.c
index e9abee5..7e549d9 100644
--- a/src/helper/slbt_copy_file.c
+++ b/src/helper/slbt_copy_file.c
@@ -6,6 +6,7 @@
/*******************************************************************/
#include <slibtool/slibtool.h>
+#include "slibtool_driver_impl.h"
#include "slibtool_spawn_impl.h"
#include "slibtool_symlink_impl.h"
#include "slibtool_errinfo_impl.h"
@@ -16,13 +17,17 @@ int slbt_copy_file(
char * src,
char * dst)
{
+ int fdcwd;
char ** oargv;
char * oprogram;
char * cp[4];
int ret;
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* placeholder? */
- if (slbt_symlink_is_a_placeholder(src))
+ if (slbt_symlink_is_a_placeholder(fdcwd,src))
return 0;
/* cp argv */
diff --git a/src/helper/slbt_realpath.c b/src/helper/slbt_realpath.c
index 4c7446e..bae41ec 100644
--- a/src/helper/slbt_realpath.c
+++ b/src/helper/slbt_realpath.c
@@ -12,6 +12,7 @@
#include <sys/stat.h>
#include <slibtool/slibtool.h>
+#include "slibtool_driver_impl.h"
#include "slibtool_readlink_impl.h"
#ifdef _MIDIPIX_ABI
@@ -64,7 +65,7 @@ int slbt_realpath(
sprintf(procfspath,"/proc/self/fd/%d",fd);
- if (slbt_readlink(procfspath,buf,buflen)) {
+ if (slbt_readlinkat(fdat,procfspath,buf,buflen)) {
close(fd);
return -1;
}
diff --git a/src/internal/slibtool_readlink_impl.h b/src/internal/slibtool_readlink_impl.h
index 644a638..3730b1e 100644
--- a/src/internal/slibtool_readlink_impl.h
+++ b/src/internal/slibtool_readlink_impl.h
@@ -10,14 +10,15 @@
#include <unistd.h>
#include <errno.h>
-static inline int slbt_readlink(
+static inline int slbt_readlinkat(
+ int fdcwd,
const char * restrict path,
char * restrict buf,
ssize_t bufsize)
{
ssize_t ret;
- if ((ret = readlink(path,buf,bufsize)) <= 0) {
+ if ((ret = readlinkat(fdcwd,path,buf,bufsize)) <= 0) {
return -1;
} else if (ret == bufsize) {
errno = ENOBUFS;
diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c
index dd91d5e..cc09a32 100644
--- a/src/internal/slibtool_symlink_impl.c
+++ b/src/internal/slibtool_symlink_impl.c
@@ -108,7 +108,7 @@ int slbt_create_symlink(
: 0;
}
-int slbt_symlink_is_a_placeholder(char * lnkpath)
+int slbt_symlink_is_a_placeholder(int fdcwd, char * lnkpath)
{
size_t len;
char slink [PATH_MAX];
@@ -121,6 +121,6 @@ int slbt_symlink_is_a_placeholder(char * lnkpath)
memcpy(slink,lnkpath,len);
memcpy(&slink[len],suffix,sizeof(suffix));
- return (!slbt_readlink(slink,target,sizeof(target)))
+ return (!slbt_readlinkat(fdcwd,slink,target,sizeof(target)))
&& (!strcmp(target,"/dev/null"));
}
diff --git a/src/internal/slibtool_symlink_impl.h b/src/internal/slibtool_symlink_impl.h
index 9393a17..402208c 100644
--- a/src/internal/slibtool_symlink_impl.h
+++ b/src/internal/slibtool_symlink_impl.h
@@ -11,6 +11,6 @@ int slbt_create_symlink(
const char * lnkname,
bool flawrapper);
-int slbt_symlink_is_a_placeholder(char * lnkpath);
+int slbt_symlink_is_a_placeholder(int fdcwd, char * lnkpath);
#endif
diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c
index 5adfd34..3429d91 100644
--- a/src/logic/slbt_exec_install.c
+++ b/src/logic/slbt_exec_install.c
@@ -115,6 +115,7 @@ static int slbt_exec_install_import_libraries(
char * srcdso,
char * dstdir)
{
+ int fdcwd;
char * host;
char * slash;
char * dot;
@@ -127,6 +128,9 @@ static int slbt_exec_install_import_libraries(
char minor [128];
char rev [128];
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* .libs/libfoo.so.x.y.z */
if ((size_t)snprintf(srcbuf,sizeof(srcbuf),"%s",
srcdso) >= sizeof(srcbuf))
@@ -184,7 +188,7 @@ static int slbt_exec_install_import_libraries(
return SLBT_BUFFER_ERROR(dctx);
/* libfoo.so.def.{flavor} */
- if (slbt_readlink(hostlnk,hosttag,sizeof(hosttag)))
+ if (slbt_readlinkat(fdcwd,hostlnk,hosttag,sizeof(hosttag)))
return SLBT_SYSTEM_ERROR(dctx,hostlnk);
/* host/flabor */
@@ -399,7 +403,7 @@ static int slbt_exec_install_entry(
return SLBT_BUFFER_ERROR(dctx);
if (!fstatat(fdcwd,slnkname,&st,0)) {
- if (slbt_readlink(slnkname,target,sizeof(target)) < 0)
+ if (slbt_readlinkat(fdcwd,slnkname,target,sizeof(target)) < 0)
return SLBT_SYSTEM_ERROR(dctx,slnkname);
if (strncmp(lasource,target,(slen = strlen(lasource))))
@@ -453,7 +457,7 @@ static int slbt_exec_install_entry(
/* libfoo.a installation */
if (!(dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_STATIC))
farchive = true;
- else if (slbt_symlink_is_a_placeholder(slnkname))
+ else if (slbt_symlink_is_a_placeholder(fdcwd,slnkname))
farchive = true;
else
farchive = false;
@@ -478,9 +482,9 @@ static int slbt_exec_install_entry(
base = slnkname;
/* source (build) symlink target */
- if (slbt_readlink(slnkname,target,sizeof(target)) < 0) {
+ if (slbt_readlinkat(fdcwd,slnkname,target,sizeof(target)) < 0) {
/* -all-static? */
- if (slbt_symlink_is_a_placeholder(slnkname))
+ if (slbt_symlink_is_a_placeholder(fdcwd,slnkname))
return 0;
/* -avoid-version? */
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index e5376b3..01a46bb 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -304,7 +304,7 @@ static int slbt_adjust_linker_argument(
if (fpic) {
sprintf(dot,"%s",dsosuffix);
- if (slbt_symlink_is_a_placeholder(arg))
+ if (slbt_symlink_is_a_placeholder(fdcwd,arg))
sprintf(dot,"%s",arsuffix);
else if ((fdlib = openat(fdcwd,arg,O_RDONLY)) >= 0)
close(fdlib);
@@ -536,8 +536,9 @@ static int slbt_exec_link_adjust_argument_vector(
sprintf(rpathlnk,"%s.slibtool.rpath",*carg);
if (!fstatat(fdcwd,rpathlnk,&st,AT_SYMLINK_NOFOLLOW)) {
- if (slbt_readlink(
- rpathlnk,\
+ if (slbt_readlinkat(
+ fdcwd,
+ rpathlnk,
rpathdir,
sizeof(rpathdir)))
return slbt_exec_link_exit(
diff --git a/src/logic/slbt_exec_uninstall.c b/src/logic/slbt_exec_uninstall.c
index 9f2521c..2930c26 100644
--- a/src/logic/slbt_exec_uninstall.c
+++ b/src/logic/slbt_exec_uninstall.c
@@ -166,6 +166,7 @@ static int slbt_exec_uninstall_entry(
char ** parg,
uint32_t flags)
{
+ int fdcwd;
const char * dsosuffix;
char * dot;
char path [PATH_MAX];
@@ -177,6 +178,9 @@ static int slbt_exec_uninstall_entry(
*parg = (char *)entry->arg;
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
/* remove explicit argument */
if (slbt_exec_uninstall_fs_entry(dctx,ectx,parg,path,flags))
return SLBT_NESTED_ERROR(dctx);
@@ -200,7 +204,7 @@ static int slbt_exec_uninstall_entry(
/* .so symlink? */
strcpy(dot,dsosuffix);
- if (!(slbt_readlink(path,lpath,sizeof(lpath))))
+ if (!(slbt_readlinkat(fdcwd,path,lpath,sizeof(lpath))))
if (slbt_exec_uninstall_versioned_library(
dctx,ectx,parg,
path,lpath,
@@ -210,7 +214,7 @@ static int slbt_exec_uninstall_entry(
/* .lib.a symlink? */
strcpy(dot,".lib.a");
- if (!(slbt_readlink(path,lpath,sizeof(lpath))))
+ if (!(slbt_readlinkat(fdcwd,path,lpath,sizeof(lpath))))
if (slbt_exec_uninstall_versioned_library(
dctx,ectx,parg,
path,lpath,
@@ -220,7 +224,7 @@ static int slbt_exec_uninstall_entry(
/* .dll symlink? */
strcpy(dot,".dll");
- if (!(slbt_readlink(path,lpath,sizeof(lpath))))
+ if (!(slbt_readlinkat(fdcwd,path,lpath,sizeof(lpath))))
if (slbt_exec_uninstall_versioned_library(
dctx,ectx,parg,
path,lpath,