This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] Use INTERNAL_SYSCALL for setfsuid and setfsgid
- From: GOTO Masanori <gotom at debian dot or dot jp>
- To: Ulrich Drepper <drepper at redhat dot com>
- Cc: GOTO Masanori <gotom at debian dot or dot jp>, libc-alpha at sources dot redhat dot com
- Date: Thu, 27 Mar 2003 12:31:56 +0900
- Subject: Re: [PATCH] Use INTERNAL_SYSCALL for setfsuid and setfsgid
- References: <80n0jii4nz.wl@oris.opensource.jp><3E81F05F.2070400@redhat.com>
At Wed, 26 Mar 2003 10:24:31 -0800,
Ulrich Drepper wrote:
> GOTO Masanori wrote:
>
> > setfsuid(), setfsgid() returns UID or GID, not 0 or -1.
>
> But it might return error values. The fact is that this interface is
> misdesigned. It's returning error values and ID. Somebody will have to
> talk to the kernel people about that.
Definitely. I was not noticed, but security modules which were
introduced in 2.5 might return error value -EINVAL.
> I'm not going to apply the patch as is.
Well, it should not be. Does this patch suit?
Regards,
-- gotom
2003-03-26 GOTO Masanori <gotom at debian dot or dot jp>
* sysdeps/unix/sysv/linux/i386/setfsuid.c: Fix the error
condition check for the return value.
* 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.new2 2003-03-27 08:58:01.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,7 +35,7 @@
# 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 */
@@ -52,7 +52,7 @@
int saved_errno = errno;
result = INLINE_SYSCALL (setfsgid32, 1, gid);
- if (result == 0 || errno != ENOSYS)
+ if (result != -1 || errno != ENOSYS)
return result;
__set_errno (saved_errno);
--- sysdeps/unix/sysv/linux/i386/setfsuid.c 2001-07-06 13:56:16.000000000 +0900
+++ sysdeps/unix/sysv/linux/i386/setfsuid.c.new2 2003-03-27 08:57:12.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,7 +35,7 @@
# 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 */
@@ -52,7 +52,7 @@
int saved_errno = errno;
result = INLINE_SYSCALL (setfsuid32, 1, uid);
- if (result == 0 || errno != ENOSYS)
+ if (result != -1 || errno != ENOSYS)
return result;
__set_errno (saved_errno);