00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 #pragma ident "@(#) libf/pxf/pxfsetuid.c 92.1 06/29/99 11:36:06" 00038 00039 #include <errno.h> 00040 #include <liberrno.h> 00041 #include <fortran.h> 00042 #include <sys/types.h> 00043 #include <unistd.h> 00044 00045 /* PXFSETUID -- set user ID 00046 * (section 4.2.2 of Posix 1003.9-1992) 00047 * 00048 * Call from Fortran: 00049 * 00050 * SUBROUTINE PXFSETUID(IUID, IERROR) 00051 * INTEGER IUID, IERROR 00052 * 00053 * Where: 00054 * 00055 * IUID is an input integer variable used to replace the 00056 * current user ID for the calling process. 00057 * 00058 * IERROR is an output integer variable that will contain 00059 * the status: 00060 * 00061 * zero - PXFLOCALTIME was successful. 00062 * 00063 * nonzero - PXFLOCALTIME was unsuccessful. 00064 * 00065 * PXFSETUID may return any of the following 00066 * 00067 * EINVAL If the value of the IUID argument is out of range. 00068 * 00069 * EPERM If the process does not have the appropriate 00070 * privileges and IUID does not match the real 00071 * user ID. 00072 * 00073 * 00074 */ 00075 00076 #ifdef _UNICOS 00077 void 00078 PXFSETUID( 00079 #else 00080 void 00081 _PXFSETUID( 00082 #endif 00083 _f_int *IUID, 00084 _f_int *IERROR 00085 ) 00086 { 00087 uid_t ciuid = *IUID; 00088 00089 if (setuid(ciuid) == -1) { 00090 *IERROR = errno; 00091 return; 00092 } 00093 00094 *IERROR = 0; 00095 } 00096 00097 #ifndef _UNICOS 00098 void 00099 pxfsetuid_( 00100 _f_int *IUID, 00101 _f_int *IERROR 00102 ) 00103 { 00104 _PXFSETUID(IUID, IERROR); 00105 } 00106 #endif
1.5.6