Merged PR 685368: Remove libc functions obsolete after glibc 2.33

- Removes obsolete Unix style xstat functions and replaces them with modern stat equivalents when glibc version >= 2.33

Related work items: #1989552
This commit is contained in:
Pasindu Gunasekara 🍣 2022-10-27 17:56:34 +00:00
Родитель 82474f7e47
Коммит f4fad1ae6d
4 изменённых файлов: 61 добавлений и 1 удалений

Просмотреть файл

@ -114,7 +114,8 @@ namespace Sandbox {
dependsOnCurrentHostOSDirectories: true,
prepareTempDirectory: true,
untrackedDirectoryScopes: [ d`/lib` ],
untrackedFiles: []
untrackedFiles: [],
runtimeDependencies: [f`/usr/lib64/ld-linux-x86-64.so.2`]
};
}
}

Просмотреть файл

@ -336,7 +336,11 @@ public:
{
int old = errno;
struct stat buf;
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 33)
mode_t result = real___lxstat(1, path, &buf) == 0
#else
mode_t result = real_lstat(path, &buf) == 0
#endif
? buf.st_mode
: 0;
errno = old;
@ -381,6 +385,7 @@ public:
GEN_FN_DEF(int, execve, const char *, char *const[], char *const[]);
GEN_FN_DEF(int, execvp, const char *, char *const[]);
GEN_FN_DEF(int, execvpe, const char *, char *const[], char *const[]);
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 33)
GEN_FN_DEF(int, __lxstat, int, const char *, struct stat *);
GEN_FN_DEF(int, __lxstat64, int, const char*, struct stat64*);
GEN_FN_DEF(int, __xstat, int, const char *, struct stat *);
@ -389,6 +394,14 @@ public:
GEN_FN_DEF(int, __fxstatat, int, int, const char*, struct stat*, int);;
GEN_FN_DEF(int, __fxstat64, int, int, struct stat64*);
GEN_FN_DEF(int, __fxstatat64, int, int, const char*, struct stat64*, int);
#else
GEN_FN_DEF(int, stat, const char *, struct stat *);
GEN_FN_DEF(int, stat64, const char *, struct stat64 *);
GEN_FN_DEF(int, lstat, const char *, struct stat *);
GEN_FN_DEF(int, lstat64, const char *, struct stat64 *);
GEN_FN_DEF(int, fstat, int, struct stat *);
GEN_FN_DEF(int, fstat64, int, struct stat64 *);
#endif
GEN_FN_DEF(FILE*, fdopen, int, const char *);
GEN_FN_DEF(FILE*, fopen, const char *, const char *);
GEN_FN_DEF(FILE*, fopen64, const char *, const char *);

Просмотреть файл

@ -96,6 +96,7 @@ INTERPOSE(int, execvpe, const char *file, char *const argv[], char *const envp[]
return bxl->fwd_execvpe(file, argv, bxl->ensureEnvs(envp)).restore();
})
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 33)
INTERPOSE(int, __fxstat, int __ver, int fd, struct stat *__stat_buf)({
result_t<int> result = bxl->fwd___fxstat(__ver, fd, __stat_buf);
bxl->report_access_fd(__func__, ES_EVENT_TYPE_NOTIFY_STAT, fd);
@ -143,6 +144,43 @@ INTERPOSE(int, __lxstat64, int __ver, const char *pathname, struct stat64 *buf)(
bxl->report_access(__func__, ES_EVENT_TYPE_NOTIFY_STAT, pathname, O_NOFOLLOW);
return result.restore();
})
#else
INTERPOSE(int, stat, const char *pathname, struct stat *statbuf)({
result_t<int> result = bxl->fwd_stat(pathname, statbuf);
bxl->report_access(__func__, ES_EVENT_TYPE_NOTIFY_STAT, pathname, O_NOFOLLOW);
return result.restore();
})
INTERPOSE(int, stat64, const char *pathname, struct stat64 *statbuf)({
result_t<int> result = bxl->fwd_stat64(pathname, statbuf);
bxl->report_access(__func__, ES_EVENT_TYPE_NOTIFY_STAT, pathname, O_NOFOLLOW);
return result.restore();
})
INTERPOSE(int, lstat, const char *pathname, struct stat *statbuf)({
result_t<int> result = bxl->fwd_lstat(pathname, statbuf);
bxl->report_access(__func__, ES_EVENT_TYPE_NOTIFY_STAT, pathname, O_NOFOLLOW);
return result.restore();
})
INTERPOSE(int, lstat64, const char *pathname, struct stat64 *statbuf)({
result_t<int> result = bxl->fwd_lstat64(pathname, statbuf);
bxl->report_access(__func__, ES_EVENT_TYPE_NOTIFY_STAT, pathname, O_NOFOLLOW);
return result.restore();
})
INTERPOSE(int, fstat, int fd, struct stat *statbuf)({
result_t<int> result = bxl->fwd_fstat(fd, statbuf);
bxl->report_access_fd(__func__, ES_EVENT_TYPE_NOTIFY_STAT, fd);
return result.restore();
})
INTERPOSE(int, fstat64, int fd, struct stat64 *statbuf)({
result_t<int> result = bxl->fwd_fstat64(fd, statbuf);
bxl->report_access_fd(__func__, ES_EVENT_TYPE_NOTIFY_STAT, fd);
return result.restore();
})
#endif
static es_event_type_t get_event_from_open_mode(const char *mode) {
const char *pMode = mode;

Просмотреть файл

@ -34,6 +34,14 @@ export const mounts = Context.getCurrentHost().os !== "win" ? [
isReadable: true,
isScrubbable: false,
},
{
name: a`usrlib64`,
path: p`/usr/lib64`,
trackSourceFileChanges: true,
isWritable: false,
isReadable: true,
isScrubbable: false,
},
{
name: a`usrinclude`,
path: p`/usr/include`,