diff options
author | midipix <writeonce@midipix.org> | 2021-04-13 18:15:38 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-04-15 08:03:32 +0000 |
commit | c81d169af088b6b90d850d7c0f5c5daae6cfc4ba (patch) | |
tree | 4f9a8dbaff4ebae2ec685e8755fb1449644ee744 /src/logic | |
parent | 7ae5c14d2b4cc2dce023dac9bdf6020962c7bcec (diff) | |
download | slibtool-c81d169af088b6b90d850d7c0f5c5daae6cfc4ba.tar.bz2 slibtool-c81d169af088b6b90d850d7c0f5c5daae6cfc4ba.tar.xz |
library: replace all uses of [slbt_]readlink() with [slbt_]readlinkat().
Diffstat (limited to 'src/logic')
-rw-r--r-- | src/logic/slbt_exec_install.c | 14 | ||||
-rw-r--r-- | src/logic/slbt_exec_link.c | 7 | ||||
-rw-r--r-- | src/logic/slbt_exec_uninstall.c | 10 |
3 files changed, 20 insertions, 11 deletions
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, |