From 1a6d4c162a38e5ff95014c140fba379cce7d7e08 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Tue, 12 Oct 2010 21:05:45 -0400 Subject: [PATCH] Linux: fix aklog -setpag to work with ktc_SetTokenEx The bit of code that allows aklog -setpag to work with recent linux needed to be moved along with the change from ktc_SetToken to ktc_SetTokenEx. While we're in this bit of code, make it depend on the definition of the syscall in the user space headers instead of relying on a kernel configure test. Change-Id: I0e556b514986b5d06daabcff67ecd51b0e4becdd Reviewed-on: http://gerrit.openafs.org/2976 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- acinclude.m4 | 1 - src/auth/ktc.c | 22 +++++++++++++--------- src/cf/linux-test4.m4 | 10 ---------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 25a013eff..70b27fdc2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -886,7 +886,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_POSIX_TEST_LOCK_CONFLICT_ARG LINUX_KERNEL_SOCK_CREATE LINUX_EXPORTS_KEY_TYPE_KEYRING - LINUX_KEYS_HAVE_SESSION_TO_PARENT LINUX_NEED_RHCONFIG LINUX_RECALC_SIGPENDING_ARG_TYPE LINUX_EXPORTS_TASKLIST_LOCK diff --git a/src/auth/ktc.c b/src/auth/ktc.c index 3478a009e..a4ee59770 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -57,10 +57,13 @@ #include "token.h" -#if defined(LINUX_KEYRING_SUPPORT) && defined(HAVE_SESSION_TO_PARENT) +#if defined(AFS_LINUX26_ENV) #include +#if defined(SYS_keyctl) +/* Open code this value to avoid a dependency on keyutils */ #define KEYCTL_SESSION_TO_PARENT 18 #endif +#endif /* For malloc() */ #include @@ -310,14 +313,6 @@ SetToken(struct ktc_principal *aserver, struct ktc_token *atoken, } #else /* NO_AFS_CLIENT */ code = PIOCTL(0, VIOCSETTOK, &iob, 0); -#if defined(LINUX_KEYRING_SUPPORT) && defined(HAVE_SESSION_TO_PARENT) - /* - * If we're using keyring based PAGs and the SESSION_TO_PARENT keyctl - * is available, use it to copy the session keyring to the parent process - */ - if (flags & AFS_SETTOK_SETPAG) - syscall(SYS_keyctl, KEYCTL_SESSION_TO_PARENT); -#endif #endif /* NO_AFS_CLIENT */ if (code) return KTC_PIOCTLFAIL; @@ -383,6 +378,15 @@ ktc_SetTokenEx(struct ktc_setTokenData *token) { if (code) return KTC_PIOCTLFAIL; +#if defined(AFS_LINUX26_ENV) && defined(SYS_keyctl) + else + /* + * If we're using keyring based PAGs and the SESSION_TO_PARENT keyctl + * is available, use it to copy the session keyring to the parent process + */ + if (token->flags & AFS_SETTOK_SETPAG) + syscall(SYS_keyctl, KEYCTL_SESSION_TO_PARENT); +#endif return 0; } diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 2a198aa51..424bedfb7 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -528,16 +528,6 @@ AC_DEFUN([LINUX_EXPORTS_KEY_TYPE_KEYRING], [ ]) -AC_DEFUN([LINUX_KEYS_HAVE_SESSION_TO_PARENT], [ - AC_CHECK_LINUX_BUILD([for KEYCTL_SESSION_TO_PARENT], - [ac_cv_linux_have_session_to_parent], - [#include ], - [int i = KEYCTL_SESSION_TO_PARENT;], - [HAVE_SESSION_TO_PARENT], - [define if keyctl has the KEYCTL_SESSION_TO_PARENT function]) -]) - - AC_DEFUN([LINUX_HAVE_TRY_TO_FREEZE], [ AC_CHECK_LINUX_BUILD([for try_to_freeze], [ac_cv_linux_have_try_to_freeze], -- 2.39.5