[PATCH 40/63] policycoreutils: make use of the new

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


   This patch looks good to me. acked.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6wTXEACgkQrlYvE4MpobPrkACggN6TN2K75r1ni431U9ux4T8H
k30An1aHieieg1zju4ZrnVg3lKZUiAuw
=RVbr
-----END PGP SIGNATURE-----
>From 271db4fe3f1fd08df4261e52f6420369cac2627e Mon Sep 17 00:00:00 2001
From: Eric Paris <eparis@xxxxxxxxxx>
Date: Fri, 23 Sep 2011 17:39:43 -0400
Subject: [PATCH 40/63] policycoreutils: make use of the new
 realpath_not_final function

Instead of coding the exact same thing and calling it symlink_realpath
use the function exported by libselinux.

Signed-off-by: Eric Paris <eparis@xxxxxxxxxx>
---
 policycoreutils/setfiles/restore.c |   42 +-----------------------------------
 1 files changed, 1 insertions(+), 41 deletions(-)

diff --git a/policycoreutils/setfiles/restore.c b/policycoreutils/setfiles/restore.c
index fc5eaa0..00c0b51 100644
--- a/policycoreutils/setfiles/restore.c
+++ b/policycoreutils/setfiles/restore.c
@@ -285,46 +285,6 @@ static int apply_spec(FTSENT *ftsent)
 	return rc;
 }
 
-static int symlink_realpath(char *name, char *path)
-{
-	char *p = NULL, *file_sep;
-	char *tmp_path = strdupa(name);
-	size_t len = 0;
-
-	if (!tmp_path) {
-		fprintf(stderr, "strdupa on %s failed:  %s\n", name,
-			strerror(errno));
-		return -1;
-	}
-	file_sep = strrchr(tmp_path, '/');
-	if (file_sep == tmp_path) {
-		file_sep++;
-		p = strcpy(path, "");
-	} else if (file_sep) {
-		*file_sep = 0;
-		file_sep++;
-		p = realpath(tmp_path, path);
-	} else {
-		file_sep = tmp_path;
-		p = realpath("./", path);
-	}
-	if (p)
-		len = strlen(p);
-	if (!p || len + strlen(file_sep) + 2 > PATH_MAX) {
-		fprintf(stderr, "symlink_realpath(%s) failed %s\n", name,
-			strerror(errno));
-		return -1;
-	}
-	p += len;
-	/* ensure trailing slash of directory name */
-	if (len == 0 || *(p - 1) != '/') {
-		*p = '/';
-		p++;
-	}
-	strcpy(p, file_sep);
-	return 0;
-}
-
 static int process_one(char *name, int recurse_this_path)
 {
 	int rc = 0;
@@ -449,7 +409,7 @@ int process_one_realpath(char *name, int recurse)
 		if (S_ISLNK(sb.st_mode)) {
 			char path[PATH_MAX + 1];
 
-			rc = symlink_realpath(name, path);
+			rc = realpath_not_final(name, path);
 			if (rc < 0)
 				return rc;
 			rc = process_one(path, 0);
-- 
1.7.7


[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux