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

bug in mintlib44's access() function



 Hi!

 It's probably not ok that the access function from mintlib PL44 uses the
`real' user id's to determine access rights, and not the `effective' ones.
If you apply this patch, things look a bit more logical to me... :)

ciao,
TeSche
-- 
Torsten Scherer (TeSche, Schiller...)
Faculty of Technology, University of Bielefeld, Germany, Europe, Earth...
| Use any of "finger itschere@129.70.131.2-15" for adresses and more.|
| Last updated: 14. April 1994.|


--- access.c.origSun Jun 19 13:14:36 1994
+++ access.cSun Jun 19 13:15:48 1994
@@ -13,6 +13,7 @@
 const char *path;
 int mode;
 {
+int euid;
 struct stat sb;
 
 if (stat(path, &sb) < 0)
@@ -20,19 +21,19 @@
 if (mode == F_OK)
 return 0;/* existence test succeeded */
 
-if (getuid() == 0) return 0; /* super user can access anything */
+if ((euid = geteuid()) == 0) return 0; /* super user can access anything */
 
 /* somewhat crufty code -- relies on R_OK, etc. matching the bits in the
    file mode, but what the heck, we can do this
  */
-if (__mint < 9 || ( getuid() == sb.st_uid ) ) {
+if (__mint < 9 || ( euid == sb.st_uid ) ) {
 if ( ((sb.st_mode >> 6) & mode) == mode )
 return 0;
 else
 goto accdn;
 }
 
-if ( getgid() == sb.st_gid ) {
+if ( getegid() == sb.st_gid ) {
 if ( ((sb.st_mode >> 3) & mode) == mode )
 return 0;
 else