diff --git a/libc/Android.mk b/libc/Android.mk index 967399bab..f6e4663be 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -80,14 +80,12 @@ libc_common_src_files := \ bionic/bindresvport.c \ bionic/bionic_clone.c \ bionic/clearenv.c \ - bionic/cpuacct.c \ bionic/daemon.c \ bionic/err.c \ bionic/ether_aton.c \ bionic/ether_ntoa.c \ bionic/fdprintf.c \ bionic/flockfile.c \ - bionic/fork.c \ bionic/ftime.c \ bionic/ftok.c \ bionic/fts.c \ @@ -124,12 +122,7 @@ libc_common_src_files := \ bionic/sched_getcpu.c \ bionic/semaphore.c \ bionic/send.c \ - bionic/setegid.c \ - bionic/seteuid.c \ bionic/setpgrp.c \ - bionic/setresuid.c \ - bionic/setreuid.c \ - bionic/setuid.c \ bionic/sigblock.c \ bionic/siginterrupt.c \ bionic/siglist.c \ @@ -226,6 +219,7 @@ libc_bionic_src_files := \ bionic/__errno.cpp \ bionic/eventfd_read.cpp \ bionic/eventfd_write.cpp \ + bionic/fork.cpp \ bionic/futimens.cpp \ bionic/getauxval.cpp \ bionic/getcwd.cpp \ @@ -248,7 +242,9 @@ libc_bionic_src_files := \ bionic/sbrk.cpp \ bionic/scandir.cpp \ bionic/sched_getaffinity.cpp \ + bionic/setegid.cpp \ bionic/__set_errno.cpp \ + bionic/seteuid.cpp \ bionic/setlocale.cpp \ bionic/signalfd.cpp \ bionic/sigwait.cpp \ diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index f926ad03b..090235712 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -41,8 +41,6 @@ pid_t __sys_clone:clone(int, void*, int*, void*, int*) all int execve(const char*, char* const*, char* const*) all -int __setuid:setuid32(uid_t) arm,x86 -int __setuid:setuid(uid_t) mips,x86_64 uid_t getuid:getuid32() arm,x86 uid_t getuid:getuid() mips,x86_64 gid_t getgid:getgid32() arm,x86 @@ -65,11 +63,13 @@ pid_t getsid(pid_t) all pid_t setsid() all int setgid:setgid32(gid_t) arm,x86 int setgid:setgid(gid_t) mips,x86_64 +int setuid:setuid32(uid_t) arm,x86 +int setuid:setuid(uid_t) mips,x86_64 int seteuid:seteuid32(uid_t) custom -int __setreuid:setreuid32(uid_t, uid_t) arm,x86 -int __setreuid:setreuid(uid_t, uid_t) mips,x86_64 -int __setresuid:setresuid32(uid_t, uid_t, uid_t) arm,x86 -int __setresuid:setresuid(uid_t, uid_t, uid_t) mips,x86_64 +int setreuid:setreuid32(uid_t, uid_t) arm,x86 +int setreuid:setreuid(uid_t, uid_t) mips,x86_64 +int setresuid:setresuid32(uid_t, uid_t, uid_t) arm,x86 +int setresuid:setresuid(uid_t, uid_t, uid_t) mips,x86_64 int setresgid:setresgid32(gid_t, gid_t, gid_t) arm,x86 int setresgid:setresgid(gid_t, gid_t, gid_t) mips,x86_64 void* __brk:brk(void*) all diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index e1d02b3c4..d28c97507 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -7,7 +7,6 @@ syscall_src += arch-arm/syscalls/__waitid.S syscall_src += arch-arm/syscalls/wait4.S syscall_src += arch-arm/syscalls/__sys_clone.S syscall_src += arch-arm/syscalls/execve.S -syscall_src += arch-arm/syscalls/__setuid.S syscall_src += arch-arm/syscalls/getuid.S syscall_src += arch-arm/syscalls/getgid.S syscall_src += arch-arm/syscalls/geteuid.S @@ -22,8 +21,9 @@ syscall_src += arch-arm/syscalls/getppid.S syscall_src += arch-arm/syscalls/getsid.S syscall_src += arch-arm/syscalls/setsid.S syscall_src += arch-arm/syscalls/setgid.S -syscall_src += arch-arm/syscalls/__setreuid.S -syscall_src += arch-arm/syscalls/__setresuid.S +syscall_src += arch-arm/syscalls/setuid.S +syscall_src += arch-arm/syscalls/setreuid.S +syscall_src += arch-arm/syscalls/setresuid.S syscall_src += arch-arm/syscalls/setresgid.S syscall_src += arch-arm/syscalls/__brk.S syscall_src += arch-arm/syscalls/__ptrace.S diff --git a/libc/arch-arm/syscalls/__setresuid.S b/libc/arch-arm/syscalls/setresuid.S similarity index 88% rename from libc/arch-arm/syscalls/__setresuid.S rename to libc/arch-arm/syscalls/setresuid.S index 0fd8ae623..6d640f785 100644 --- a/libc/arch-arm/syscalls/__setresuid.S +++ b/libc/arch-arm/syscalls/setresuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setresuid) +ENTRY(setresuid) mov ip, r7 ldr r7, =__NR_setresuid32 swi #0 @@ -12,4 +12,4 @@ ENTRY(__setresuid) bxls lr neg r0, r0 b __set_errno -END(__setresuid) +END(setresuid) diff --git a/libc/arch-arm/syscalls/__setreuid.S b/libc/arch-arm/syscalls/setreuid.S similarity index 89% rename from libc/arch-arm/syscalls/__setreuid.S rename to libc/arch-arm/syscalls/setreuid.S index bc2fe84ed..fa4a5ddaf 100644 --- a/libc/arch-arm/syscalls/__setreuid.S +++ b/libc/arch-arm/syscalls/setreuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setreuid) +ENTRY(setreuid) mov ip, r7 ldr r7, =__NR_setreuid32 swi #0 @@ -12,4 +12,4 @@ ENTRY(__setreuid) bxls lr neg r0, r0 b __set_errno -END(__setreuid) +END(setreuid) diff --git a/libc/arch-arm/syscalls/__setuid.S b/libc/arch-arm/syscalls/setuid.S similarity index 90% rename from libc/arch-arm/syscalls/__setuid.S rename to libc/arch-arm/syscalls/setuid.S index f7b94da9a..2efe5f259 100644 --- a/libc/arch-arm/syscalls/__setuid.S +++ b/libc/arch-arm/syscalls/setuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setuid) +ENTRY(setuid) mov ip, r7 ldr r7, =__NR_setuid32 swi #0 @@ -12,4 +12,4 @@ ENTRY(__setuid) bxls lr neg r0, r0 b __set_errno -END(__setuid) +END(setuid) diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk index 9a1038c01..4611cd8e9 100644 --- a/libc/arch-mips/syscalls.mk +++ b/libc/arch-mips/syscalls.mk @@ -8,7 +8,6 @@ syscall_src += arch-mips/syscalls/__waitid.S syscall_src += arch-mips/syscalls/wait4.S syscall_src += arch-mips/syscalls/__sys_clone.S syscall_src += arch-mips/syscalls/execve.S -syscall_src += arch-mips/syscalls/__setuid.S syscall_src += arch-mips/syscalls/getuid.S syscall_src += arch-mips/syscalls/getgid.S syscall_src += arch-mips/syscalls/geteuid.S @@ -23,8 +22,9 @@ syscall_src += arch-mips/syscalls/getppid.S syscall_src += arch-mips/syscalls/getsid.S syscall_src += arch-mips/syscalls/setsid.S syscall_src += arch-mips/syscalls/setgid.S -syscall_src += arch-mips/syscalls/__setreuid.S -syscall_src += arch-mips/syscalls/__setresuid.S +syscall_src += arch-mips/syscalls/setuid.S +syscall_src += arch-mips/syscalls/setreuid.S +syscall_src += arch-mips/syscalls/setresuid.S syscall_src += arch-mips/syscalls/setresgid.S syscall_src += arch-mips/syscalls/__brk.S syscall_src += arch-mips/syscalls/kill.S diff --git a/libc/arch-mips/syscalls/__setresuid.S b/libc/arch-mips/syscalls/setresuid.S similarity index 77% rename from libc/arch-mips/syscalls/__setresuid.S rename to libc/arch-mips/syscalls/setresuid.S index e43e12197..a077867c0 100644 --- a/libc/arch-mips/syscalls/__setresuid.S +++ b/libc/arch-mips/syscalls/setresuid.S @@ -1,11 +1,11 @@ /* autogenerated by gensyscalls.py */ #include .text - .globl __setresuid + .globl setresuid .align 4 - .ent __setresuid + .ent setresuid -__setresuid: +setresuid: .set noreorder .cpload $t9 li $v0, __NR_setresuid @@ -19,4 +19,4 @@ __setresuid: j $t9 nop .set reorder - .end __setresuid + .end setresuid diff --git a/libc/arch-mips/syscalls/__setreuid.S b/libc/arch-mips/syscalls/setreuid.S similarity index 78% rename from libc/arch-mips/syscalls/__setreuid.S rename to libc/arch-mips/syscalls/setreuid.S index 72bca1610..934c8db20 100644 --- a/libc/arch-mips/syscalls/__setreuid.S +++ b/libc/arch-mips/syscalls/setreuid.S @@ -1,11 +1,11 @@ /* autogenerated by gensyscalls.py */ #include .text - .globl __setreuid + .globl setreuid .align 4 - .ent __setreuid + .ent setreuid -__setreuid: +setreuid: .set noreorder .cpload $t9 li $v0, __NR_setreuid @@ -19,4 +19,4 @@ __setreuid: j $t9 nop .set reorder - .end __setreuid + .end setreuid diff --git a/libc/arch-mips/syscalls/__setuid.S b/libc/arch-mips/syscalls/setuid.S similarity index 80% rename from libc/arch-mips/syscalls/__setuid.S rename to libc/arch-mips/syscalls/setuid.S index 360552cbf..fedfb1ed6 100644 --- a/libc/arch-mips/syscalls/__setuid.S +++ b/libc/arch-mips/syscalls/setuid.S @@ -1,11 +1,11 @@ /* autogenerated by gensyscalls.py */ #include .text - .globl __setuid + .globl setuid .align 4 - .ent __setuid + .ent setuid -__setuid: +setuid: .set noreorder .cpload $t9 li $v0, __NR_setuid @@ -19,4 +19,4 @@ __setuid: j $t9 nop .set reorder - .end __setuid + .end setuid diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index 424bd1ec0..79b4f2cc3 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -8,7 +8,6 @@ syscall_src += arch-x86/syscalls/__waitid.S syscall_src += arch-x86/syscalls/wait4.S syscall_src += arch-x86/syscalls/__sys_clone.S syscall_src += arch-x86/syscalls/execve.S -syscall_src += arch-x86/syscalls/__setuid.S syscall_src += arch-x86/syscalls/getuid.S syscall_src += arch-x86/syscalls/getgid.S syscall_src += arch-x86/syscalls/geteuid.S @@ -23,8 +22,9 @@ syscall_src += arch-x86/syscalls/getppid.S syscall_src += arch-x86/syscalls/getsid.S syscall_src += arch-x86/syscalls/setsid.S syscall_src += arch-x86/syscalls/setgid.S -syscall_src += arch-x86/syscalls/__setreuid.S -syscall_src += arch-x86/syscalls/__setresuid.S +syscall_src += arch-x86/syscalls/setuid.S +syscall_src += arch-x86/syscalls/setreuid.S +syscall_src += arch-x86/syscalls/setresuid.S syscall_src += arch-x86/syscalls/setresgid.S syscall_src += arch-x86/syscalls/__brk.S syscall_src += arch-x86/syscalls/kill.S diff --git a/libc/arch-x86/syscalls/__setresuid.S b/libc/arch-x86/syscalls/setresuid.S similarity index 93% rename from libc/arch-x86/syscalls/__setresuid.S rename to libc/arch-x86/syscalls/setresuid.S index 537c89770..891d004d2 100644 --- a/libc/arch-x86/syscalls/__setresuid.S +++ b/libc/arch-x86/syscalls/setresuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setresuid) +ENTRY(setresuid) pushl %ebx pushl %ecx pushl %edx @@ -24,4 +24,4 @@ ENTRY(__setresuid) popl %ecx popl %ebx ret -END(__setresuid) +END(setresuid) diff --git a/libc/arch-x86/syscalls/__setreuid.S b/libc/arch-x86/syscalls/setreuid.S similarity index 92% rename from libc/arch-x86/syscalls/__setreuid.S rename to libc/arch-x86/syscalls/setreuid.S index bc6cd25ac..fda43a8fb 100644 --- a/libc/arch-x86/syscalls/__setreuid.S +++ b/libc/arch-x86/syscalls/setreuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setreuid) +ENTRY(setreuid) pushl %ebx pushl %ecx mov 12(%esp), %ebx @@ -21,4 +21,4 @@ ENTRY(__setreuid) popl %ecx popl %ebx ret -END(__setreuid) +END(setreuid) diff --git a/libc/arch-x86/syscalls/__setuid.S b/libc/arch-x86/syscalls/setuid.S similarity index 92% rename from libc/arch-x86/syscalls/__setuid.S rename to libc/arch-x86/syscalls/setuid.S index 5a5ff6df9..ef158caa7 100644 --- a/libc/arch-x86/syscalls/__setuid.S +++ b/libc/arch-x86/syscalls/setuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setuid) +ENTRY(setuid) pushl %ebx mov 8(%esp), %ebx movl $__NR_setuid32, %eax @@ -18,4 +18,4 @@ ENTRY(__setuid) 1: popl %ebx ret -END(__setuid) +END(setuid) diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk index 08fdf3861..51c3646cb 100644 --- a/libc/arch-x86_64/syscalls.mk +++ b/libc/arch-x86_64/syscalls.mk @@ -7,7 +7,6 @@ syscall_src += arch-x86_64/syscalls/__waitid.S syscall_src += arch-x86_64/syscalls/wait4.S syscall_src += arch-x86_64/syscalls/__sys_clone.S syscall_src += arch-x86_64/syscalls/execve.S -syscall_src += arch-x86_64/syscalls/__setuid.S syscall_src += arch-x86_64/syscalls/getuid.S syscall_src += arch-x86_64/syscalls/getgid.S syscall_src += arch-x86_64/syscalls/geteuid.S @@ -22,8 +21,9 @@ syscall_src += arch-x86_64/syscalls/getppid.S syscall_src += arch-x86_64/syscalls/getsid.S syscall_src += arch-x86_64/syscalls/setsid.S syscall_src += arch-x86_64/syscalls/setgid.S -syscall_src += arch-x86_64/syscalls/__setreuid.S -syscall_src += arch-x86_64/syscalls/__setresuid.S +syscall_src += arch-x86_64/syscalls/setuid.S +syscall_src += arch-x86_64/syscalls/setreuid.S +syscall_src += arch-x86_64/syscalls/setresuid.S syscall_src += arch-x86_64/syscalls/setresgid.S syscall_src += arch-x86_64/syscalls/__brk.S syscall_src += arch-x86_64/syscalls/kill.S diff --git a/libc/arch-x86_64/syscalls/__setresuid.S b/libc/arch-x86_64/syscalls/setresuid.S similarity index 89% rename from libc/arch-x86_64/syscalls/__setresuid.S rename to libc/arch-x86_64/syscalls/setresuid.S index e4ca4b83e..fe1f41ca2 100644 --- a/libc/arch-x86_64/syscalls/__setresuid.S +++ b/libc/arch-x86_64/syscalls/setresuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setresuid) +ENTRY(setresuid) movl $__NR_setresuid, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -14,4 +14,4 @@ ENTRY(__setresuid) orq $-1, %rax 1: ret -END(__setresuid) +END(setresuid) diff --git a/libc/arch-x86_64/syscalls/__setreuid.S b/libc/arch-x86_64/syscalls/setreuid.S similarity index 89% rename from libc/arch-x86_64/syscalls/__setreuid.S rename to libc/arch-x86_64/syscalls/setreuid.S index 89d2aad57..e064b553b 100644 --- a/libc/arch-x86_64/syscalls/__setreuid.S +++ b/libc/arch-x86_64/syscalls/setreuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setreuid) +ENTRY(setreuid) movl $__NR_setreuid, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -14,4 +14,4 @@ ENTRY(__setreuid) orq $-1, %rax 1: ret -END(__setreuid) +END(setreuid) diff --git a/libc/arch-x86_64/syscalls/__setuid.S b/libc/arch-x86_64/syscalls/setuid.S similarity index 90% rename from libc/arch-x86_64/syscalls/__setuid.S rename to libc/arch-x86_64/syscalls/setuid.S index 20b508991..c443c79fb 100644 --- a/libc/arch-x86_64/syscalls/__setuid.S +++ b/libc/arch-x86_64/syscalls/setuid.S @@ -3,7 +3,7 @@ #include #include -ENTRY(__setuid) +ENTRY(setuid) movl $__NR_setuid, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -14,4 +14,4 @@ ENTRY(__setuid) orq $-1, %rax 1: ret -END(__setuid) +END(setuid) diff --git a/libc/bionic/cpuacct.c b/libc/bionic/cpuacct.c deleted file mode 100644 index 1321d0eec..000000000 --- a/libc/bionic/cpuacct.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include -#include -#include -#include -#include "cpuacct.h" -#include - -int cpuacct_add(uid_t uid) -{ - int count; - int fd; - char buf[80]; - ssize_t n; - int ret = 0; - - count = snprintf(buf, sizeof(buf), "/acct/uid/%d/tasks", uid); - fd = open(buf, O_RDWR | O_CREAT, 0666); - if (fd == -1) { - /* Note: sizeof("tasks") returns 6, which includes the NULL char */ - buf[count - sizeof("tasks")] = 0; - if (mkdir(buf, 0775) < 0) - return -errno; - - /* Note: sizeof("tasks") returns 6, which includes the NULL char */ - buf[count - sizeof("tasks")] = '/'; - fd = open(buf, O_RDWR | O_CREAT, 0666); - } - if (fd == -1) - return -errno; - - n = TEMP_FAILURE_RETRY(write(fd, "0", 1)); - if (n < 0) - ret = -errno; - else if (n == 0) - ret = -EIO; - - if (TEMP_FAILURE_RETRY(close(fd)) == -1) - return -errno; - - return ret; -} diff --git a/libc/bionic/cpuacct.h b/libc/bionic/cpuacct.h deleted file mode 100644 index 8e24c8cc8..000000000 --- a/libc/bionic/cpuacct.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _BIONIC_CPUACCT_H -#define _BIONIC_CPUACCT_H - -#include -#include - -__BEGIN_DECLS - -extern int cpuacct_add(uid_t uid); - -__END_DECLS - -#endif /* _BIONIC_CPUACCT_H */ diff --git a/libc/bionic/fork.c b/libc/bionic/fork.c deleted file mode 100644 index d30b41b1d..000000000 --- a/libc/bionic/fork.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include -#include "pthread_internal.h" -#include "cpuacct.h" - -#include "private/bionic_pthread.h" - -extern int __fork(void); - -int fork(void) -{ - int ret; - - /* Posix mandates that the timers of a fork child process be - * disarmed, but not destroyed. To avoid a race condition, we're - * going to stop all timers now, and only re-start them in case - * of error, or in the parent process - */ - __timer_table_start_stop(1); - __bionic_atfork_run_prepare(); - - ret = __fork(); - if (ret != 0) { /* not a child process */ - __timer_table_start_stop(0); - __bionic_atfork_run_parent(); - } else { - // Fix the tid in the pthread_internal_t struct after a fork. - __pthread_settid(pthread_self(), gettid()); - - /* - * Newly created process must update cpu accounting. - * Call cpuacct_add passing in our uid, which will take - * the current task id and add it to the uid group passed - * as a parameter. - */ - cpuacct_add(getuid()); - __bionic_atfork_run_child(); - } - return ret; -} diff --git a/libc/bionic/setresuid.c b/libc/bionic/fork.cpp similarity index 63% rename from libc/bionic/setresuid.c rename to libc/bionic/fork.cpp index e62b3e956..a3bea2094 100644 --- a/libc/bionic/setresuid.c +++ b/libc/bionic/fork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2008 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,14 +25,30 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #include -#include "cpuacct.h" +#include "pthread_internal.h" -extern int __setresuid(uid_t ruid, uid_t euid, uid_t suid); +#include "private/bionic_pthread.h" -int setresuid(uid_t ruid, uid_t euid, uid_t suid) -{ - cpuacct_add(euid); - return __setresuid(ruid, euid, suid); +extern "C" int __fork(); +int fork() { + // POSIX mandates that the timers of a fork child process be + // disarmed, but not destroyed. To avoid a race condition, we're + // going to stop all timers now, and only re-start them in case + // of error, or in the parent process + __timer_table_start_stop(1); + __bionic_atfork_run_prepare(); + + int result = __fork(); + if (result != 0) { // Not a child process. + __timer_table_start_stop(0); + __bionic_atfork_run_parent(); + } else { + // Fix the tid in the pthread_internal_t struct after a fork. + __pthread_settid(pthread_self(), gettid()); + __bionic_atfork_run_child(); + } + return result; } diff --git a/libc/bionic/setegid.c b/libc/bionic/setegid.cpp similarity index 95% rename from libc/bionic/setegid.c rename to libc/bionic/setegid.cpp index 9bd697b67..2030ee7a7 100644 --- a/libc/bionic/setegid.c +++ b/libc/bionic/setegid.cpp @@ -25,9 +25,9 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #include -int setegid(gid_t egid) -{ - return setresgid(-1, egid, -1); +int setegid(gid_t egid) { + return setresgid(-1, egid, -1); } diff --git a/libc/bionic/seteuid.c b/libc/bionic/seteuid.cpp similarity index 90% rename from libc/bionic/seteuid.c rename to libc/bionic/seteuid.cpp index b3ea37273..6d2c89c08 100644 --- a/libc/bionic/seteuid.c +++ b/libc/bionic/seteuid.cpp @@ -25,13 +25,9 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #include -#include "cpuacct.h" -extern int __setresuid(uid_t, uid_t, uid_t); - -int seteuid(uid_t euid) -{ - cpuacct_add(euid); - return __setresuid(-1, euid,-1); +int seteuid(uid_t euid) { + return setresuid(-1, euid,-1); } diff --git a/libc/bionic/setreuid.c b/libc/bionic/setreuid.c deleted file mode 100644 index 32e70c8fe..000000000 --- a/libc/bionic/setreuid.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include -#include "cpuacct.h" - -extern int __setreuid(uid_t ruid, uid_t euid); - -int setreuid(uid_t ruid, uid_t euid) -{ - cpuacct_add(euid); - return __setreuid(ruid, euid); -} diff --git a/libc/bionic/setuid.c b/libc/bionic/setuid.c deleted file mode 100644 index 30785d66d..000000000 --- a/libc/bionic/setuid.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include -#include "cpuacct.h" - -extern int __setuid(uid_t); - -int setuid(uid_t uid) -{ - cpuacct_add(uid); - return __setuid(uid); -}