]> git.saurik.com Git - apple/xnu.git/blobdiff - tools/tests/darwintests/settimeofday_29193041.c
xnu-4570.51.1.tar.gz
[apple/xnu.git] / tools / tests / darwintests / settimeofday_29193041.c
index ae6d68b8826c47f0837aa86f5e601d7744a853cf..6bb495ddb0e8ac180642633c069030191af01b8a 100644 (file)
@@ -15,8 +15,6 @@
 #include <uuid/uuid.h>
 #endif
 
-#define EXIT_FAIL() exit((__LINE__ % 255) + 1)
-
 /*
  * This test expects the entitlement or root privileges for a process to
  * set the time using settimeofday syscall.
 
 #define DAY 86400 //1 day in sec
 
-/*
- * To run without root privileges
- * <rdar://problem/28315048> libdarwintest should run leaks even without root
- */
-static void drop_priv(void){
-       /* determine the less-privileged UID and GID */
-
-       unsigned long lower_uid = 0;
-       unsigned long lower_gid = 0;
-
-#if CONFIG_EMBEDDED
-       struct passwd *pw = getpwnam("mobile");
-       if (!pw) {
-               printf("child: error: get_pwname(\"mobile\") failed %d: %s\n", errno, strerror(errno));
-               EXIT_FAIL();
-       }
-
-       lower_uid = pw->pw_uid;
-       lower_gid = pw->pw_gid;
-#else
-       char *sudo_gid_str = getenv("SUDO_GID");
-       if (!sudo_gid_str) {
-               printf("child: error: SUDO_GID environment variable unset (not run under sudo)\n");
-               EXIT_FAIL();
-       }
-
-       char *sudo_uid_str = getenv("SUDO_UID");
-       if (!sudo_uid_str) {
-               printf("child: error: SUDO_UID environment variable unset (not run under sudo)\n");
-               EXIT_FAIL();
-       }
-
-       char *end = sudo_gid_str;
-       lower_gid = strtoul(sudo_gid_str, &end, 10);
-       if (sudo_gid_str == end && sudo_gid_str[0] != '\0') {
-               printf("child: error: SUDO_GID (%s) could not be converted to an integer\n", sudo_gid_str);
-               EXIT_FAIL();
-       }
-       if (lower_gid == 0) {
-               printf("child: error: less-privileged GID invalid\n");
-               EXIT_FAIL();
-       }
-
-       end = sudo_uid_str;
-       lower_uid = strtoul(sudo_uid_str, &end, 10);
-       if (sudo_uid_str == end && sudo_uid_str[0] != '\0') {
-               printf("child: error: SUDO_UID (%s) could not be converted to an integer\n", sudo_uid_str);
-               EXIT_FAIL();
-       }
-       if (lower_gid == 0) {
-               printf("child: error: less-privileged UID invalid\n");
-               EXIT_FAIL();
-       }
-#endif
-
-       if (setgid(lower_gid) == -1) {
-               printf("child: error: could not change group to %lu\n", lower_gid);
-               EXIT_FAIL();
-       }
-       if (setuid(lower_uid) == -1) {
-               printf("child: error: could not change user to %lu\n", lower_uid);
-               EXIT_FAIL();
-       }
-}
-
 T_DECL(settime_32089962_not_entitled_root,
        "Verify that root privileges can allow to change the time",
-       T_META_ASROOT(true), T_META_CHECK_LEAKS(NO))
+       T_META_ASROOT(true), T_META_CHECK_LEAKS(false))
 {
        struct timeval settimeofdaytime;
        struct timeval adj_time;
@@ -120,15 +53,13 @@ T_DECL(settime_32089962_not_entitled_root,
 
 T_DECL(settime_32089962_not_entitled_not_root,
        "Verify that the \"com.apple.settime\" entitlement can allow to change the time",
-       T_META_ASROOT(false), T_META_CHECK_LEAKS(NO))
+       T_META_ASROOT(false), T_META_CHECK_LEAKS(false))
 {
        struct timeval settimeofdaytime;
        struct timeval adj_time;
        struct timex ntptime;
        int res;
 
-       drop_priv();
-
        if (geteuid() == 0){
                 T_SKIP("settimeofday_29193041 test requires no root privileges to run.");
         }
@@ -159,7 +90,7 @@ T_DECL(settime_32089962_not_entitled_not_root,
 
 T_DECL(settimeofday_29193041_not_entitled_root,
        "Verify that root privileges can allow to change the time",
-       T_META_ASROOT(true), T_META_CHECK_LEAKS(NO))
+       T_META_ASROOT(true), T_META_CHECK_LEAKS(false))
 {
        struct timeval time;
        long new_time;
@@ -189,13 +120,11 @@ T_DECL(settimeofday_29193041_not_entitled_root,
 
 T_DECL(settimeofday_29193041_not_entitled_not_root,
        "Verify that the \"com.apple.settime\" entitlement can allow to change the time",
-       T_META_ASROOT(false), T_META_CHECK_LEAKS(NO))
+       T_META_ASROOT(false), T_META_CHECK_LEAKS(false))
 {
        struct timeval time;
        long new_time;
 
-       drop_priv();
-
        if (geteuid() == 0){
                 T_SKIP("settimeofday_29193041 test requires no root privileges to run.");
         }