libselinux: rename and export symlink_realpath

symlink_realpath is used by both libselinux and policycoreutils.
Instead of coding it twice, export the libselinux version under a new
name that makes it sound more generic.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Eric Paris 2011-09-23 17:38:09 -04:00
parent 74a9a52966
commit 2b06f47400
2 changed files with 7 additions and 2 deletions

View File

@ -413,6 +413,11 @@ extern int matchpathcon_init_prefix(const char *path, const char *prefix);
/* Free the memory allocated by matchpathcon_init. */
extern void matchpathcon_fini(void);
/* Resolve all of the symlinks and relative portions of a pathname, but NOT
* the final component (same a realpath() unless the final component is a
* symlink. Resolved path must be a path of size PATH_MAX + 1 */
extern int realpath_not_final(const char *name, char *resolved_path);
/* Match the specified pathname and mode against the file contexts
configuration and set *con to refer to the resulting context.
'mode' can be 0 to disable mode matching.

View File

@ -344,7 +344,7 @@ void matchpathcon_fini(void)
* determine a real path component of the first portion. We then have to
* copy the last part back on to get the final real path. Wheww.
*/
static int symlink_realpath(const char *name, char *resolved_path)
int realpath_not_final(const char *name, char *resolved_path)
{
char *last_component;
char *tmp_path, *p;
@ -406,7 +406,7 @@ int matchpathcon(const char *path, mode_t mode, security_context_t * con)
return -1;
if (S_ISLNK(mode)) {
if (!symlink_realpath(path, stackpath))
if (!realpath_not_final(path, stackpath))
path = stackpath;
} else {
p = realpath(path, stackpath);