mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
feat: stdpath('run'), /tmp/nvim.user/ #18993
Problem:
- Since c57f6b28d7
#8519, sockets are created in ~/.local/… but XDG
spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).
Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().
closes #3517
closes #17093
This commit is contained in:
@@ -126,7 +126,7 @@ bool os_isrealdir(const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the given path is a directory or not.
|
||||
/// Check if the given path exists and is a directory.
|
||||
///
|
||||
/// @return `true` if `name` is a directory.
|
||||
bool os_isdir(const char_u *name)
|
||||
@@ -791,6 +791,27 @@ int os_setperm(const char *const name, int perm)
|
||||
return (r == kLibuvSuccess ? OK : FAIL);
|
||||
}
|
||||
|
||||
#ifdef UNIX
|
||||
/// Checks if the current user owns a file.
|
||||
///
|
||||
/// Uses both uv_fs_stat() and uv_fs_lstat() via os_fileinfo() and
|
||||
/// os_fileinfo_link() respectively for extra security.
|
||||
bool os_file_owned(const char *fname)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
uid_t uid = getuid();
|
||||
FileInfo finfo;
|
||||
bool file_owned = os_fileinfo(fname, &finfo) && finfo.stat.st_uid == uid;
|
||||
bool link_owned = os_fileinfo_link(fname, &finfo) && finfo.stat.st_uid == uid;
|
||||
return file_owned && link_owned;
|
||||
}
|
||||
#else
|
||||
bool os_file_owned(const char *fname)
|
||||
{
|
||||
return true; // TODO(justinmk): Windows. #8244
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Changes the owner and group of a file, like chown(2).
|
||||
///
|
||||
/// @return 0 on success, or libuv error code on failure.
|
||||
|
Reference in New Issue
Block a user