diff options
author | midipix <writeonce@midipix.org> | 2021-04-15 06:22:36 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-04-15 08:03:32 +0000 |
commit | b8d3bb8ec89cc703b939bd7097f931ce4ddc2200 (patch) | |
tree | 9e47196099e98780f3eccf1462536b3c2fab5f2e | |
parent | c81d169af088b6b90d850d7c0f5c5daae6cfc4ba (diff) | |
download | slibtool-b8d3bb8ec89cc703b939bd7097f931ce4ddc2200.tar.bz2 slibtool-b8d3bb8ec89cc703b939bd7097f931ce4ddc2200.tar.xz |
library: replace all uses of symlink() with symlinkat().
-rw-r--r-- | src/helper/slbt_archive_import.c | 8 | ||||
-rw-r--r-- | src/internal/slibtool_symlink_impl.c | 7 | ||||
-rw-r--r-- | src/logic/slbt_exec_link.c | 12 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c index b3b1cec..444c48d 100644 --- a/src/helper/slbt_archive_import.c +++ b/src/helper/slbt_archive_import.c @@ -4,6 +4,7 @@ /* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ /*******************************************************************/ +#include <fcntl.h> #include <stdio.h> #include <limits.h> #include <unistd.h> @@ -21,6 +22,7 @@ #include "slibtool_errinfo_impl.h" static char * slbt_mri_argument( + int fdat, char * arg, char * buf) { @@ -50,7 +52,7 @@ static char * slbt_mri_argument( if (!(tmpnam(buf))) return 0; - if (!(symlink(target,buf))) + if (!(symlinkat(target,fdat,buf))) lnk = buf; } @@ -127,8 +129,8 @@ int slbt_archive_import( ectx->pid = pid; - dst = slbt_mri_argument(dstarchive,mridst); - src = slbt_mri_argument(srcarchive,mrisrc); + dst = slbt_mri_argument(fdcwd,dstarchive,mridst); + src = slbt_mri_argument(fdcwd,srcarchive,mrisrc); fmt = "OPEN %s\n" "ADDLIB %s\n" "SAVE\n" diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c index cc09a32..8f1244d 100644 --- a/src/internal/slibtool_symlink_impl.c +++ b/src/internal/slibtool_symlink_impl.c @@ -9,6 +9,7 @@ #include <stdbool.h> #include <unistd.h> +#include "slibtool_driver_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_symlink_impl.h" #include "slibtool_readlink_impl.h" @@ -24,6 +25,7 @@ int slbt_create_symlink( const char * lnkname, bool flawrapper) { + int fdcwd; char ** oargv; const char * slash; char * ln[5]; @@ -99,8 +101,11 @@ int slbt_create_symlink( /* restore execution context */ ectx->argv = oargv; + /* fdcwd */ + fdcwd = slbt_driver_fdcwd(dctx); + /* create symlink */ - if (symlink(atarget,tmplnk)) + if (symlinkat(atarget,fdcwd,tmplnk)) return SLBT_SYSTEM_ERROR(dctx,tmplnk); return rename(tmplnk,lnkname) diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 01a46bb..94f1f19 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -1357,8 +1357,8 @@ static int slbt_exec_link_create_archive( if (slbt_exec_link_remove_file(dctx,ectx,arlink)) return SLBT_NESTED_ERROR(dctx); - if (symlink(arfile,arlink)) - return SLBT_SYSTEM_ERROR(dctx,arlink); + if (slbt_create_symlink(dctx,ectx,arfile,arlink,0)) + return SLBT_NESTED_ERROR(dctx); } return 0; @@ -1535,8 +1535,12 @@ static int slbt_exec_link_create_library( if (slbt_exec_link_remove_file(dctx,ectx,ectx->rpathfilename)) return SLBT_NESTED_ERROR(dctx); - if (symlink(dctx->cctx->host.ldrpath,ectx->rpathfilename)) - return SLBT_SYSTEM_ERROR(dctx,ectx->rpathfilename); + if (slbt_create_symlink( + dctx,ectx, + dctx->cctx->host.ldrpath, + ectx->rpathfilename, + 0)) + return SLBT_NESTED_ERROR(dctx); } /* cwd */ |