b8d3bb library: replace all uses of symlink() with symlinkat().

Authored and Committed by midipix 4 years ago
    library: replace all uses of symlink() with symlinkat().
    
        
src/helper/slbt_archive_import.c CHANGED
@@ -4,6 +4,7 @@
4
4
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
5
5
/*******************************************************************/
6
6
7
+ #include <fcntl.h>
7
8
#include <stdio.h>
8
9
#include <limits.h>
9
10
#include <unistd.h>
@@ -21,6 +22,7 @@
21
22
#include "slibtool_errinfo_impl.h"
22
23
23
24
static char * slbt_mri_argument(
25
+ int fdat,
24
26
char * arg,
25
27
char * buf)
26
28
{
@@ -50,7 +52,7 @@ static char * slbt_mri_argument(
50
52
if (!(tmpnam(buf)))
51
53
return 0;
52
54
53
- if (!(symlink(target,buf)))
55
+ if (!(symlinkat(target,fdat,buf)))
54
56
lnk = buf;
55
57
}
56
58
@@ -127,8 +129,8 @@ int slbt_archive_import(
127
129
128
130
ectx->pid = pid;
129
131
130
- dst = slbt_mri_argument(dstarchive,mridst);
131
- src = slbt_mri_argument(srcarchive,mrisrc);
132
+ dst = slbt_mri_argument(fdcwd,dstarchive,mridst);
133
+ src = slbt_mri_argument(fdcwd,srcarchive,mrisrc);
132
134
fmt = "OPEN %s\n"
133
135
"ADDLIB %s\n"
134
136
"SAVE\n"
src/internal/slibtool_symlink_impl.c CHANGED
@@ -9,6 +9,7 @@
9
9
#include <stdbool.h>
10
10
#include <unistd.h>
11
11
12
+ #include "slibtool_driver_impl.h"
12
13
#include "slibtool_errinfo_impl.h"
13
14
#include "slibtool_symlink_impl.h"
14
15
#include "slibtool_readlink_impl.h"
@@ -24,6 +25,7 @@ int slbt_create_symlink(
24
25
const char * lnkname,
25
26
bool flawrapper)
26
27
{
28
+ int fdcwd;
27
29
char ** oargv;
28
30
const char * slash;
29
31
char * ln[5];
@@ -99,8 +101,11 @@ int slbt_create_symlink(
99
101
/* restore execution context */
100
102
ectx->argv = oargv;
101
103
104
+ /* fdcwd */
105
+ fdcwd = slbt_driver_fdcwd(dctx);
106
+
102
107
/* create symlink */
103
- if (symlink(atarget,tmplnk))
108
+ if (symlinkat(atarget,fdcwd,tmplnk))
104
109
return SLBT_SYSTEM_ERROR(dctx,tmplnk);
105
110
106
111
return rename(tmplnk,lnkname)
file modified
+8 -4
src/logic/slbt_exec_link.c CHANGED
@@ -1357,8 +1357,8 @@ static int slbt_exec_link_create_archive(
1357
1357
if (slbt_exec_link_remove_file(dctx,ectx,arlink))
1358
1358
return SLBT_NESTED_ERROR(dctx);
1359
1359
1360
- if (symlink(arfile,arlink))
1361
- return SLBT_SYSTEM_ERROR(dctx,arlink);
1360
+ if (slbt_create_symlink(dctx,ectx,arfile,arlink,0))
1361
+ return SLBT_NESTED_ERROR(dctx);
1362
1362
}
1363
1363
1364
1364
return 0;
@@ -1535,8 +1535,12 @@ static int slbt_exec_link_create_library(
1535
1535
if (slbt_exec_link_remove_file(dctx,ectx,ectx->rpathfilename))
1536
1536
return SLBT_NESTED_ERROR(dctx);
1537
1537
1538
- if (symlink(dctx->cctx->host.ldrpath,ectx->rpathfilename))
1539
- return SLBT_SYSTEM_ERROR(dctx,ectx->rpathfilename);
1538
+ if (slbt_create_symlink(
1539
+ dctx,ectx,
1540
+ dctx->cctx->host.ldrpath,
1541
+ ectx->rpathfilename,
1542
+ 0))
1543
+ return SLBT_NESTED_ERROR(dctx);
1540
1544
}
1541
1545
1542
1546
/* cwd */