Check for task_max_priority RPC
* config.h.in: add #undef for HAVE_MACH_TASK_MAX_PRIORITY.
* sysdeps/mach/configure.ac: use mach_RPC_CHECK to check for
task_max_priority RPC in mach_host.defs.
* sysdeps/mach/configure: regenerate file.
Use task_max_priority when setpriority is called by root
* sysdeps/mach/hurd/setpriority.c: clamp the prio argument
to the range [-NZERO, NZERO-1] and use task_max_priority
when called by root.
Message-ID: <
8e806c83d8d7b59b2894b4944e4ad82477ecc3cd.
1779316637.git.dnietoc@gmail.com>
/* Mach specific: define if the `vm_set_size_limit' RPC is available. */
#undef HAVE_MACH_VM_SET_SIZE_LIMIT
+/* Mach specific: define if the `task_max_priority' RPC is available. */
+#undef HAVE_MACH_TASK_MAX_PRIORITY
+
/* Mach/i386 specific: define if the `i386_io_perm_*' RPCs are available. */
#undef HAVE_I386_IO_PERM_MODIFY
fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for task_max_priority in mach_host.defs" >&5
+printf %s "checking for task_max_priority in mach_host.defs... " >&6; }
+if test ${libc_cv_mach_rpc_task_max_priority+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <mach/mach_host.defs>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP_TRADITIONAL "task_max_priority" >/dev/null 2>&1
+then :
+ libc_cv_mach_rpc_task_max_priority=yes
+else case e in #(
+ e) libc_cv_mach_rpc_task_max_priority=no ;;
+esac
+fi
+rm -rf conftest*
+ ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mach_rpc_task_max_priority" >&5
+printf "%s\n" "$libc_cv_mach_rpc_task_max_priority" >&6; }
+if test $libc_cv_mach_rpc_task_max_priority = yes; then
+ printf "%s\n" "#define HAVE_MACH_TASK_MAX_PRIORITY 1" >>confdefs.h
+
+fi
+
ac_fn_c_check_header_preproc "$LINENO" "mach/machine/ndr_def.h" "ac_cv_header_mach_machine_ndr_def_h"
if test "x$ac_cv_header_mach_machine_ndr_def_h" = xyes
HAVE_MACH_VM_SET_SIZE_LIMIT)
mach_RPC_CHECK(gnumach.defs, vm_get_size_limit,
HAVE_MACH_VM_GET_SIZE_LIMIT)
+mach_RPC_CHECK(mach_host.defs, task_max_priority,
+ HAVE_MACH_TASK_MAX_PRIORITY)
AC_CHECK_HEADER(mach/machine/ndr_def.h, [dnl
DEFINES="$DEFINES -DNDR_DEF_HEADER='<mach/machine/ndr_def.h>'"], [dnl
0, 1);
}
#else
- prierr = __task_priority (task, NICE_TO_MACH_PRIORITY (prio), 1);
+ do {
+#ifdef HAVE_MACH_TASK_MAX_PRIORITY
+ mach_port_t host = MACH_PORT_NULL;
+ error_t priverr = __get_privileged_ports (&host, NULL);
+ if (!priverr)
+ {
+ prierr = __task_max_priority (host, task, NICE_TO_MACH_PRIORITY (prio), 1, 1);
+ __mach_port_deallocate (__mach_task_self (), host);
+ if (prierr != MIG_BAD_ID)
+ break;
+ }
+#endif
+ prierr = __task_priority (task, NICE_TO_MACH_PRIORITY (prio), 1);
+ } while (0);
#endif
__mach_port_deallocate (__mach_task_self (), task);
switch (prierr)
{
+ case KERN_NO_ACCESS:
case KERN_FAILURE:
++nacces;
break;