From d53e0310b330ebd29c7939c9198716c576fe369c Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Thu, 19 Mar 2009 04:02:32 +0000 Subject: [PATCH] DEVEL15-linux-key-alloc-changes-20090318 LICENSE IPL10 FIXES 124507 Fix the old configure test for key_alloc for the task argument - we can't just rely on the number of arguments anymore. Wish this could be done without using -Werror. Add an additional test for the struct cred argument (cherry picked from commit bf9dc554b366b08ce0bef62ce242c94371938000) --- acinclude.m4 | 1 + src/afs/LINUX/osi_groups.c | 11 +++++++++-- src/cf/linux-test4.m4 | 27 +++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 7577beac03..f26c97d765 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -936,6 +936,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_REFRIGERATOR LINUX_LINUX_KEYRING_SUPPORT LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK + LINUX_KEY_ALLOC_NEEDS_CRED LINUX_DO_SYNC_READ LINUX_GENERIC_FILE_AIO_READ LINUX_INIT_WORK_HAS_DATA diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index ebbdb7ba25..8dc3e1ab3d 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -247,11 +247,16 @@ install_session_keyring(struct task_struct *task, struct key *keyring) not_in_quota = KEY_ALLOC_IN_QUOTA; sprintf(desc, "_ses.%u", task->tgid); -#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK +#if defined(KEY_ALLOC_NEEDS_STRUCT_TASK) keyring = key_alloc(__key_type_keyring, desc, task_uid(task), task_gid(task), task, (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, not_in_quota); +#elif defined(KEY_ALLOC_NEEDS_CRED) + keyring = key_alloc(__key_type_keyring, desc, + task_uid(task), task_gid(task), current_cred(), + (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, + not_in_quota); #else keyring = key_alloc(__key_type_keyring, desc, task_uid(task), task_gid(task), @@ -346,8 +351,10 @@ setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, perm = KEY_POS_VIEW | KEY_POS_SEARCH; perm |= KEY_USR_VIEW | KEY_USR_SEARCH; -#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK +#if defined(KEY_ALLOC_NEEDS_STRUCT_TASK) key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, current, perm, 1); +#elif defined(KEY_ALLOC_NEEDS_CRED) + key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, current_cred(), perm, 1); #else key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, perm, 1); #endif diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index a7dc33eed8..1bae59e796 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -781,18 +781,41 @@ request_key(NULL, NULL, NULL); AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK], [ AC_MSG_CHECKING([if key_alloc() takes a struct task *]) AC_CACHE_VAL([ac_cv_key_alloc_needs_struct_task], [ + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -Werror" AC_TRY_KBUILD( [#include #include ], -[(void) key_alloc(NULL, NULL, 0, 0, NULL, 0, 0);], +[struct task *t; +(void) key_alloc(NULL, NULL, 0, 0, t, 0, 0);], ac_cv_key_alloc_needs_struct_task=yes, - ac_cv_key_alloc_needs_struct_task=no)]) + ac_cv_key_alloc_needs_struct_task=no) + CPPFLAGS="$save_CPPFLAGS"]) AC_MSG_RESULT($ac_cv_key_alloc_needs_struct_task) if test "x$ac_cv_key_alloc_needs_struct_task" = "xyes"; then AC_DEFINE([KEY_ALLOC_NEEDS_STRUCT_TASK], 1, [define if key_alloc takes a struct task *]) fi]) +AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_CRED], [ + AC_MSG_CHECKING([if key_alloc() takes credentials]) + AC_CACHE_VAL([ac_cv_key_alloc_needs_cred], [ + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -Werror" + AC_TRY_KBUILD( +[#include +#include +], +[struct cred *c = NULL; +(void) key_alloc(NULL, NULL, 0, 0, c, 0, 0);], + ac_cv_key_alloc_needs_cred=yes, + ac_cv_key_alloc_needs_cred=no) + CPPFLAGS="$save_CPPFLAGS"]) + AC_MSG_RESULT($ac_cv_key_alloc_needs_cred) + if test "x$ac_cv_key_alloc_needs_cred" = "xyes"; then + AC_DEFINE([KEY_ALLOC_NEEDS_CRED], 1, [define if key_alloc takes credentials]) + fi]) + AC_DEFUN([LINUX_DO_SYNC_READ], [ AC_MSG_CHECKING([for linux do_sync_read()]) AC_CACHE_VAL([ac_cv_linux_do_sync_read], [