Merge pull request #34638 from YHNdnzj/laccess-error-check

various: correct laccess() error check
This commit is contained in:
Yu Watanabe
2024-10-06 13:50:11 +09:00
committed by GitHub
18 changed files with 66 additions and 60 deletions
+1 -1
View File
@@ -623,7 +623,7 @@ static int controller_is_v1_accessible(const char *root, const char *controller)
* - we can modify the hierarchy. */
cpath = strjoina("/sys/fs/cgroup/", dn, root, root ? "/cgroup.procs" : NULL);
return laccess(cpath, root ? W_OK : F_OK);
return access_nofollow(cpath, root ? W_OK : F_OK);
}
int cg_get_path_and_check(const char *controller, const char *path, const char *suffix, char **ret) {
+1 -1
View File
@@ -49,7 +49,7 @@ int futimens_opath(int fd, const struct timespec ts[2]);
int fd_warn_permissions(const char *path, int fd);
int stat_warn_permissions(const char *path, const struct stat *st);
#define laccess(path, mode) \
#define access_nofollow(path, mode) \
RET_NERRNO(faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW))
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
+3 -2
View File
@@ -97,8 +97,9 @@ int path_is_extension_tree(ImageClass image_class, const char *path, const char
/* Does the path exist at all? If not, generate an error immediately. This is useful so that a missing root dir
* always results in -ENOENT, and we can properly distinguish the case where the whole root doesn't exist from
* the case where just the os-release file is missing. */
if (laccess(path, F_OK) < 0)
return -errno;
r = access_nofollow(path, F_OK);
if (r < 0)
return r;
/* We use /usr/lib/extension-release.d/extension-release[.NAME] as flag for something being a system extension,
* /etc/extension-release.d/extension-release[.NAME] as flag for something being a system configuration, and finally,
+5 -4
View File
@@ -904,6 +904,7 @@ char **env_generator_binary_paths(RuntimeScope runtime_scope) {
int find_portable_profile(const char *name, const char *unit, char **ret_path) {
const char *dot;
int r;
assert(name);
assert(ret_path);
@@ -917,13 +918,13 @@ int find_portable_profile(const char *name, const char *unit, char **ret_path) {
if (!joined)
return -ENOMEM;
if (laccess(joined, F_OK) >= 0) {
r = access_nofollow(joined, F_OK);
if (r >= 0) {
*ret_path = TAKE_PTR(joined);
return 0;
}
if (errno != ENOENT)
return -errno;
if (r != -ENOENT)
return r;
}
return -ENOENT;