This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use INTERNAL_SYSCALL for setfsuid and setfsgid


Hi,

setfsuid(), setfsgid() returns UID or GID, not 0 or -1.  But the
current implementation looks the return value 0 of INLINE_SYSCALL as
the system call sucess.  So it can't check the return value correctly
if the return value of setfs[ug]id32 is not 0 and only if errno was
set as ENOSYS before calling these functions.  This failure invites
__libc_missing_32bit_uids = 1, so the next time setfs[ug]id32 is not
called.

This patch fixes this problem for sysdeps/unix/sysv/linux/i386/
{setfsgid.c, setfsuid.c}, like sysdeps/unix/sysv/linux/i386/getgid.c
which uses INTERNAL_SYSCALL.

Regards,
-- gotom

2003-03-26  GOTO Masanori  <gotom at debian dot or dot jp>

	* sysdeps/unix/sysv/linux/i386/setfsuid.c: Use INTERNAL_SYSCALL and
	do not check for errors (unless testing for 32bit variant).
	* sysdeps/unix/sysv/linux/i386/setfsgid.c: likewise.


--- sysdeps/unix/sysv/linux/i386/setfsgid.c	2001-07-06 13:56:16.000000000 +0900
+++ sysdeps/unix/sysv/linux/i386/setfsgid.c.new	2003-03-25 23:20:21.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,27 +35,28 @@
 #  if __ASSUME_32BITUIDS == 0
 /* This variable is shared with all files that need to check for 32bit
    uids.  */
-extern int __libc_missing_32bit_uids;
+extern int __libc_missing_32bit_uids attribute_hidden;
 #  endif
 # endif /* __NR_setfsgid32 */
 
 int
 setfsgid (gid_t gid)
 {
+  INTERNAL_SYSCALL_DECL (err);
 # if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setfsgid32, 1, gid);
+  /* No error checking. */
+  return INTERNAL_SYSCALL (setfsgid32, err, 1, gid);
 # else
 #  ifdef __NR_setfsgid32
   if (__libc_missing_32bit_uids <= 0)
     {
       int result;
-      int saved_errno = errno;
 
-      result = INLINE_SYSCALL (setfsgid32, 1, gid);
-      if (result == 0 || errno != ENOSYS)
+      result = INTERNAL_SYSCALL (setfsgid32, err, 1, gid);
+      if (! INTERNAL_SYSCALL_ERROR_P (result, err)
+	  || INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
 	return result;
 
-      __set_errno (saved_errno);
       __libc_missing_32bit_uids = 1;
     }
 #  endif /* __NR_setfsgid32 */
@@ -65,7 +66,8 @@
       return -1;
     }
 
-  return INLINE_SYSCALL (setfsgid, 1, gid);
+  /* No error checking. */
+  return INTERNAL_SYSCALL (setfsgid, err, 1, gid);
 # endif
 }
 #endif
--- sysdeps/unix/sysv/linux/i386/setfsuid.c	2001-07-06 13:56:16.000000000 +0900
+++ sysdeps/unix/sysv/linux/i386/setfsuid.c.new	2003-03-25 23:19:44.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,27 +35,28 @@
 #  if __ASSUME_32BITUIDS == 0
 /* This variable is shared with all files that need to check for 32bit
    uids.  */
-extern int __libc_missing_32bit_uids;
+extern int __libc_missing_32bit_uids attribute_hidden;
 #  endif
 # endif /* __NR_setfsuid32 */
 
 int
 setfsuid (uid_t uid)
 {
+  INTERNAL_SYSCALL_DECL (err);
 # if  __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setfsuid32, 1, uid);
+  /* No error checking. */
+  return INTERNAL_SYSCALL (setfsuid32, err, 1, uid);
 # else  
 #  ifdef __NR_setfsuid32
   if (__libc_missing_32bit_uids <= 0)
     {
       int result;
-      int saved_errno = errno;
 
-      result = INLINE_SYSCALL (setfsuid32, 1, uid);
-      if (result == 0 || errno != ENOSYS)
+      result = INTERNAL_SYSCALL (setfsuid32, err, 1, uid);
+      if (! INTERNAL_SYSCALL_ERROR_P (result, err)
+	  || INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
 	return result;
 
-      __set_errno (saved_errno);
       __libc_missing_32bit_uids = 1;
     }
 #  endif /* __NR_setfsuid32 */
@@ -66,7 +67,8 @@
       return -1;
     }
 
-  return INLINE_SYSCALL (setfsuid, 1, uid);
+  /* No error checking. */
+  return INTERNAL_SYSCALL (setfsuid, err, 1, uid);
 # endif
 }
 #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]