Skip to contentSkip to conversation

Patch matchpathcon to eliminate file "/"

PATCH Daniel J Walsh 3 participants 3 messages Mar 4, 2009 – May 18, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

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

So

matchpathcon /etc/
Will work the same as
matchpathcon /etc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkmu5wMACgkQrlYvE4MpobNK4gCgiVeXXEZcCMsJKXM7jqh6r1u3 OScAoLcmXBIR63gpvA8RS3g07pcPC6IF
=e+Re
-----END PGP SIGNATURE-----

utils/matchpathcon.c +5 -0
@@ -101,6 +101,11 @@
 	for (i = optind; i < argc; i++) {
 		int mode = 0;
 		struct stat buf;
+		int len = strlen(argv[i]);
+		if (len > 1  && argv[i][len - 1 ] == '/') {
+			argv[i][len - 1 ] = '\0';
+		}
+
 		if (lstat(argv[i], &buf) == 0)
 			mode = buf.st_mode;
 
Acked-by
#1 lore raw
Quoted 20 lines · Daniel J Walsh

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

So

matchpathcon /etc/
Will work the same as
matchpathcon /etc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkmu5wMACgkQrlYvE4MpobNK4gCgiVeXXEZcCMsJKXM7jqh6r1u3 OScAoLcmXBIR63gpvA8RS3g07pcPC6IF
=e+Re
-----END PGP SIGNATURE-----

utils/matchpathcon.c 2009-03-04 15:23:52.000000000 -0500 renamed from utils/matchpathcon.c 2008-10-28 10:06:51.000000000 -0400 +0 -0
@@ -101,6 +101,11 @@
 for (i = optind; i < argc; i++) {

utils/matchpathcon.c 2009-03-04 15:23:52.000000000 -0500 line 111

Quoted 10 lines
utils/matchpathcon.c 2009-03-04 15:23:52.000000000 -0500 renamed from utils/matchpathcon.c 2008-10-28 10:06:51.000000000 -0400 +5 -0
 int mode = 0;
 struct stat buf;
+  int len = strlen(argv[i]);
+  if (len > 1  && argv[i][len - 1 ] == '/') {
+   argv[i][len - 1 ] = '\0';
+  }
+
 if (lstat(argv[i], &buf) == 0)
 mode = buf.st_mode;
 

Looks fine to me.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw
Quoted 35 lines · Chad Sellers
Quoted 20 lines · Daniel J Walsh

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

So

matchpathcon /etc/
Will work the same as
matchpathcon /etc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkmu5wMACgkQrlYvE4MpobNK4gCgiVeXXEZcCMsJKXM7jqh6r1u3 OScAoLcmXBIR63gpvA8RS3g07pcPC6IF
=e+Re
-----END PGP SIGNATURE-----

utils/matchpathcon.c 2009-03-04 15:23:52.000000000 -0500 renamed from utils/matchpathcon.c 2008-10-28 10:06:51.000000000 -0400 +0 -0
@@ -101,6 +101,11 @@
 for (i = optind; i < argc; i++) {

utils/matchpathcon.c 2009-03-04 15:23:52.000000000 -0500 line 111

Quoted 10 lines
utils/matchpathcon.c 2009-03-04 15:23:52.000000000 -0500 renamed from utils/matchpathcon.c 2008-10-28 10:06:51.000000000 -0400 +5 -0
 int mode = 0;
 struct stat buf;
+  int len = strlen(argv[i]);
+  if (len > 1  && argv[i][len - 1 ] == '/') {
+   argv[i][len - 1 ] = '\0';
+  }
+
 if (lstat(argv[i], &buf) == 0)
 mode = buf.st_mode;
 

Looks fine to me.

Quoted 2 lines

Merged in libselinux-2.0.81

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.