]> git.saurik.com Git - apple/system_cmds.git/blobdiff - at.tproj/privs.h
system_cmds-790.30.1.tar.gz
[apple/system_cmds.git] / at.tproj / privs.h
index 9c5e39d88279e867707e45ee14eb755b91465198..4a43b6cc98c18934663c075e71ee7f9c7589aee7 100644 (file)
@@ -1,5 +1,5 @@
-/* 
- *  privs.h - header for privileged operations 
+/*
+ *  privs.h - header for privileged operations
  *  Copyright (C) 1993  Thomas Koenig
  *
  * Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.bin/at/privs.h,v 1.8 2001/09/04 16:15:51 ru Exp $
+ * $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/usr.bin/at/privs.h,v 1.10 2011/11/06 20:30:21 ed Exp $
  */
 
 #ifndef _PRIVS_H
@@ -64,7 +64,7 @@ extern
 #endif
 uid_t real_uid, effective_uid;
 
-#ifndef MAIN 
+#ifndef MAIN
 extern
 #endif
 gid_t real_gid, effective_gid;
@@ -74,8 +74,8 @@ gid_t real_gid, effective_gid;
        effective_uid = geteuid(); \
        real_gid = getgid(); \
        effective_gid = getegid(); \
-       setegid(real_gid); \
-       seteuid(real_uid); \
+       if (setegid(real_gid)<0) perr("cannot setegid"); \
+       if (seteuid(real_uid)<0) perr("cannot seteuid"); \
 }
 
 #define RELINQUISH_PRIVS_ROOT(a, b) { \
@@ -83,8 +83,8 @@ gid_t real_gid, effective_gid;
        effective_uid = geteuid(); \
        real_gid = (b); \
        effective_gid = getegid(); \
-       setegid(real_gid); \
-       seteuid(real_uid); \
+       if (setegid(real_gid)<0) perr("cannot setegid"); \
+       if (seteuid(real_uid)<0) perr("cannot seteuid"); \
 }
 
 #define PRIV_START { \
@@ -103,8 +103,8 @@ gid_t real_gid, effective_gid;
        PRIV_START \
        effective_uid = (a); \
        effective_gid = (b); \
-       setregid((gid_t)-1, effective_gid); \
-       setreuid((uid_t)-1, effective_uid); \
+       if (setegid(effective_gid)<0) perr("cannot setegid"); \
+       if (seteuid(effective_uid)<0) perr("cannot seteuid"); \
        PRIV_END \
 }
 #endif