mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
plugin: simplify plugin dir test a little.
Check if it's a normal file first, then check permissions. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
dc7b76e5e6
commit
b484933b40
1 changed files with 4 additions and 4 deletions
|
@ -725,11 +725,11 @@ static const char *plugin_fullpath(const tal_t *ctx, const char *dir,
|
||||||
fullname = path_join(ctx, dir, basename);
|
fullname = path_join(ctx, dir, basename);
|
||||||
if (stat(fullname, &st) != 0)
|
if (stat(fullname, &st) != 0)
|
||||||
return tal_free(fullname);
|
return tal_free(fullname);
|
||||||
if (!(st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) || st.st_mode & S_IFDIR)
|
/* Only regular files please (or symlinks to such: stat not lstat!) */
|
||||||
|
if ((st.st_mode & S_IFMT) != S_IFREG)
|
||||||
return tal_free(fullname);
|
return tal_free(fullname);
|
||||||
|
/* Must be executable by someone. */
|
||||||
/* Ignore directories, they have exec mode, but aren't executable. */
|
if (!(st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
|
||||||
if (st.st_mode & S_IFDIR)
|
|
||||||
return tal_free(fullname);
|
return tal_free(fullname);
|
||||||
return fullname;
|
return fullname;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue