From 47435af4d6907776c3073ed0da600cde1959660a Mon Sep 17 00:00:00 2001 From: ericm Date: Thu, 21 Jul 2005 17:17:36 +0000 Subject: [PATCH] land b_hd_pag: rudiment support for PAG. --- lustre/include/linux/lustre_cfg.h | 2 + lustre/include/linux/lustre_sec.h | 3 +- .../patches/pag-basic-2.6.10-fc3.patch | 85 ++++++++++++++++ lustre/kernel_patches/series/2.6-fc3-uml.series | 1 + lustre/kernel_patches/series/2.6-fc3.series | 1 + lustre/llite/llite_lib.c | 53 ++++++++-- lustre/mdc/mdc_request.c | 3 +- lustre/osc/osc_request.c | 3 +- lustre/sec/gss/sec_gss.c | 11 +- lustre/sec/sec.c | 31 +++--- lustre/utils/Makefile.am | 3 +- lustre/utils/lkinit.c | 113 +++++++++++++++++++++ lustre/utils/llmount.c | 3 + 13 files changed, 281 insertions(+), 31 deletions(-) create mode 100644 lustre/kernel_patches/patches/pag-basic-2.6.10-fc3.patch create mode 100644 lustre/utils/lkinit.c diff --git a/lustre/include/linux/lustre_cfg.h b/lustre/include/linux/lustre_cfg.h index b1cb5f2..14cde4f 100644 --- a/lustre/include/linux/lustre_cfg.h +++ b/lustre/include/linux/lustre_cfg.h @@ -245,6 +245,8 @@ struct lustre_mount_data { uint64_t lmd_remote_flag; uint32_t lmd_nllu; uint32_t lmd_nllg; + uint32_t lmd_pag; + uint32_t lmd_padding; char lmd_mds_security[16]; char lmd_oss_security[16]; char lmd_mds[64]; diff --git a/lustre/include/linux/lustre_sec.h b/lustre/include/linux/lustre_sec.h index 6fc831f..2056753 100644 --- a/lustre/include/linux/lustre_sec.h +++ b/lustre/include/linux/lustre_sec.h @@ -282,6 +282,7 @@ struct ptlrpc_sec_type { #define PTLRPC_SEC_FL_MDS 0x0001 /* outgoing from MDS */ #define PTLRPC_SEC_FL_REVERSE 0x0002 /* reverse sec */ +#define PTLRPC_SEC_FL_PAG 0x0004 /* enable PAG */ #define PTLRPC_CREDCACHE_NR 8 #define PTLRPC_CREDCACHE_MASK (PTLRPC_CREDCACHE_NR - 1) @@ -436,7 +437,7 @@ void ptlrpcs_cli_free_repbuf(struct ptlrpc_request *req); /* higher interface */ int ptlrpcs_import_get_sec(struct obd_import *imp); void ptlrpcs_import_drop_sec(struct obd_import *imp); -void ptlrpcs_import_flush_creds(struct obd_import *imp, uid_t uid); +void ptlrpcs_import_flush_current_creds(struct obd_import *imp); int ptlrpcs_req_get_cred(struct ptlrpc_request *req); void ptlrpcs_req_drop_cred(struct ptlrpc_request *req); int ptlrpcs_req_replace_dead_cred(struct ptlrpc_request *req); diff --git a/lustre/kernel_patches/patches/pag-basic-2.6.10-fc3.patch b/lustre/kernel_patches/patches/pag-basic-2.6.10-fc3.patch new file mode 100644 index 0000000..e8f1022 --- /dev/null +++ b/lustre/kernel_patches/patches/pag-basic-2.6.10-fc3.patch @@ -0,0 +1,85 @@ +--- linux-2.6.10-pag/arch/um/kernel/sys_call_table.c.pag 2005-07-15 14:18:10.000000000 -0600 ++++ linux-2.6.10-pag/arch/um/kernel/sys_call_table.c 2005-07-18 11:20:54.000000000 -0600 +@@ -306,6 +306,8 @@ + [ __NR_utimes ] (syscall_handler_t *) sys_utimes, + [ __NR_fadvise64_64 ] (syscall_handler_t *) sys_fadvise64_64, + [ __NR_vserver ] (syscall_handler_t *) sys_ni_syscall, ++ [ __NR_newpag ] (syscall_handler_t *) sys_newpag, ++ [ __NR_getpag ] (syscall_handler_t *) sys_getpag, + + ARCH_SYSCALLS + [ LAST_SYSCALL + 1 ... NR_syscalls ] = +--- linux-2.6.10-pag/arch/i386/kernel/entry.S.pag 2005-07-15 13:47:12.000000000 -0600 ++++ linux-2.6.10-pag/arch/i386/kernel/entry.S 2005-07-18 11:18:45.000000000 -0600 +@@ -907,5 +907,7 @@ + .long sys_add_key + .long sys_request_key + .long sys_keyctl ++ .long sys_newpag ++ .long sys_getpag /* 289,290 temporay added for lustre */ + + syscall_table_size=(.-sys_call_table) +--- linux-2.6.10-pag/fs/fcntl.c.pag 2005-07-15 14:23:32.000000000 -0600 ++++ linux-2.6.10-pag/fs/fcntl.c 2005-07-18 11:41:21.000000000 -0600 +@@ -421,6 +421,17 @@ + } + #endif + ++asmlinkage long sys_newpag(void) ++{ ++ get_random_bytes(¤t->pag, sizeof(current->pag)); ++ return 0; ++} ++ ++asmlinkage long sys_getpag(void) ++{ ++ return current->pag; ++} ++ + /* Table to convert sigio signal codes into poll band bitmaps */ + + static long band_table[NSIGPOLL] = { +--- linux-2.6.10-pag/include/linux/sched.h.pag 2005-07-15 13:35:27.000000000 -0600 ++++ linux-2.6.10-pag/include/linux/sched.h 2005-07-15 13:38:02.000000000 -0600 +@@ -600,6 +600,7 @@ + /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ + unsigned long min_flt, maj_flt; + /* process credentials */ ++ unsigned long pag; + uid_t uid,euid,suid,fsuid; + gid_t gid,egid,sgid,fsgid; + struct group_info *group_info; +--- linux-2.6.10-pag/include/linux/syscalls.h.pag 2005-07-15 14:09:42.000000000 -0600 ++++ linux-2.6.10-pag/include/linux/syscalls.h 2005-07-18 11:42:01.000000000 -0600 +@@ -506,4 +506,7 @@ + asmlinkage long sys_keyctl(int cmd, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5); + ++asmlinkage long sys_newpag(void); ++asmlinkage long sys_getpag(void); ++ + #endif +--- linux-2.6.10-pag/include/linux/init_task.h.pag 2005-07-15 14:39:07.000000000 -0600 ++++ linux-2.6.10-pag/include/linux/init_task.h 2005-07-15 14:41:45.000000000 -0600 +@@ -92,6 +92,7 @@ + .real_timer = { \ + .function = it_real_fn \ + }, \ ++ .pag = -1, \ + .group_info = &init_groups, \ + .cap_effective = CAP_INIT_EFF_SET, \ + .cap_inheritable = CAP_INIT_INH_SET, \ +--- linux-2.6.10-pag/include/asm-i386/unistd.h.pag 2005-07-15 13:55:46.000000000 -0600 ++++ linux-2.6.10-pag/include/asm-i386/unistd.h 2005-07-18 11:43:10.000000000 -0600 +@@ -294,8 +294,10 @@ + #define __NR_add_key 286 + #define __NR_request_key 287 + #define __NR_keyctl 288 ++#define __NR_newpag 289 ++#define __NR_getpag 290 + +-#define NR_syscalls 289 ++#define NR_syscalls 291 + + #ifndef __KERNEL_SYSCALLS_NO_ERRNO__ + /* diff --git a/lustre/kernel_patches/series/2.6-fc3-uml.series b/lustre/kernel_patches/series/2.6-fc3-uml.series index ea7fdc6..f32cf70 100644 --- a/lustre/kernel_patches/series/2.6-fc3-uml.series +++ b/lustre/kernel_patches/series/2.6-fc3-uml.series @@ -25,3 +25,4 @@ jbd-2.6.10-jcberr.patch hostfs_readdir_large.patch vfs-intent_release_umount-vanilla-2.6.10-fc3.patch vfs-umount_lustre-vanilla-2.6.10-fc3.patch +pag-basic-2.6.10-fc3.patch diff --git a/lustre/kernel_patches/series/2.6-fc3.series b/lustre/kernel_patches/series/2.6-fc3.series index 4ba55c9..1f7c36e 100644 --- a/lustre/kernel_patches/series/2.6-fc3.series +++ b/lustre/kernel_patches/series/2.6-fc3.series @@ -29,3 +29,4 @@ vfs-intent_release_umount-vanilla-2.6.10-fc3.patch vfs-umount_lustre-vanilla-2.6.10-fc3.patch export-show_task-2.6-vanilla.patch highmem-split-2.6.10-fc3.patch +pag-basic-2.6.10-fc3.patch diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 97cf2e8..ac174a5 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "llite_internal.h" kmem_cache_t *ll_file_data_slab; @@ -131,7 +132,7 @@ extern struct dentry_operations ll_d_ops; int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov, int async, char *mds_security, char *oss_security, - __u32 *nllu, __u64 *remote) + __u32 *nllu, int pag, __u64 *remote) { struct ll_sb_info *sbi = ll_s2sbi(sb); struct ptlrpc_request *request = NULL; @@ -142,6 +143,7 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov, struct obd_device *obd; struct obd_statfs osfs; struct lustre_md md; + unsigned long sec_flags; __u32 valsize; int err; ENTRY; @@ -180,6 +182,17 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov, RETURN(err); } + if (pag) { + sec_flags = PTLRPC_SEC_FL_PAG; + err = obd_set_info(obd->obd_self_export, + strlen("sec_flags"), "sec_flags", + sizeof(sec_flags), &sec_flags); + if (err) { + OBD_FREE(data, sizeof(*data)); + RETURN(err); + } + } + if (proc_lustre_fs_root) { err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb, lov, lmv); @@ -256,6 +269,17 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov, RETURN(err); } + if (pag) { + sec_flags = PTLRPC_SEC_FL_PAG; + err = obd_set_info(obd->obd_self_export, + strlen("sec_flags"), "sec_flags", + sizeof(sec_flags), &sec_flags); + if (err) { + OBD_FREE(data, sizeof(*data)); + RETURN(err); + } + } + err = obd_connect(&dt_conn, obd, &sbi->ll_sb_uuid, data, 0); if (err == -EBUSY) { CERROR("An OST (lov %s) is performing recovery, of which this" @@ -521,7 +545,7 @@ int ll_fill_super(struct super_block *sb, void *data, int silent) } err = lustre_common_fill_super(sb, lmv, lov, async, mds_sec, oss_sec, - nllu, &remote_flag); + nllu, 0, &remote_flag); EXIT; out: if (err) @@ -627,6 +651,15 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, if (rc) GOTO(out_cleanup, rc); + if (lmd->lmd_pag) { + unsigned long sec_flags = PTLRPC_SEC_FL_PAG; + rc = obd_set_info(obd->obd_self_export, + strlen("sec_flags"), "sec_flags", + sizeof(sec_flags), &sec_flags); + if (rc) + GOTO(out_cleanup, rc); + } + /* Disable initial recovery on this import */ rc = obd_set_info(obd->obd_self_export, strlen("initial_recov"), "initial_recov", @@ -812,7 +845,8 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) err = lustre_common_fill_super(sb, lmv, lov, lmd->lmd_async, lmd->lmd_mds_security, lmd->lmd_oss_security, - &lmd->lmd_nllu, &lmd->lmd_remote_flag); + &lmd->lmd_nllu, lmd->lmd_pag, + &lmd->lmd_remote_flag); if (err) GOTO(out_free, err); @@ -2226,9 +2260,11 @@ int ll_show_options(struct seq_file *m, struct vfsmount *mnt) lmd->lmd_mds_security, lmd->lmd_oss_security); } seq_printf(m, ",%s", sbi->ll_remote ? "remote" : "local"); - if (sbi->ll_remote && lmd) { + if (sbi->ll_remote && lmd) seq_printf(m, ",nllu=%u:%u", lmd->lmd_nllu, lmd->lmd_nllg); - } + + if (lmd && lmd->lmd_pag) + seq_printf(m, ",pag"); return 0; } @@ -2261,8 +2297,7 @@ int ll_get_fid(struct obd_export *exp, struct lustre_id *idp, int ll_flush_cred(struct inode *inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); - uid_t uid = current->fsuid; - int rc = 0; + int rc = 0; /* XXX to avoid adding api, we simply use set_info() interface * to notify underlying obds. set_info() is more like a ioctl() now... @@ -2270,7 +2305,7 @@ int ll_flush_cred(struct inode *inode) if (sbi->ll_md_exp) { rc = obd_set_info(sbi->ll_md_exp, strlen("flush_cred"), "flush_cred", - sizeof(uid), &uid); + 0, NULL); if (rc) return rc; } @@ -2278,7 +2313,7 @@ int ll_flush_cred(struct inode *inode) if (sbi->ll_dt_exp) { rc = obd_set_info(sbi->ll_dt_exp, strlen("flush_cred"), "flush_cred", - sizeof(uid), &uid); + 0, NULL); if (rc) return rc; } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 666782e..4992ccf 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -891,8 +891,7 @@ int mdc_set_info(struct obd_export *exp, obd_count keylen, struct client_obd *cli = &exp->exp_obd->u.cli; if (cli->cl_import) - ptlrpcs_import_flush_creds(cli->cl_import, - *((uid_t *) val)); + ptlrpcs_import_flush_current_creds(cli->cl_import); RETURN(0); } else if (keylen == strlen("async") && memcmp(key, "async", keylen) == 0) { struct client_obd *cl = &exp->exp_obd->u.cli; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 694ecba..a0d4323 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2946,8 +2946,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen, struct client_obd *cli = &exp->exp_obd->u.cli; if (cli->cl_import) - ptlrpcs_import_flush_creds(cli->cl_import, - *((uid_t *) val)); + ptlrpcs_import_flush_current_creds(cli->cl_import); RETURN(0); } diff --git a/lustre/sec/gss/sec_gss.c b/lustre/sec/gss/sec_gss.c index b395f91..ed60271 100644 --- a/lustre/sec/gss/sec_gss.c +++ b/lustre/sec/gss/sec_gss.c @@ -397,6 +397,7 @@ struct gss_sec { static rwlock_t gss_ctx_lock = RW_LOCK_UNLOCKED; struct gss_upcall_msg_data { + __u64 gum_pag; __u32 gum_uid; __u32 gum_svc; __u32 gum_nal; @@ -662,6 +663,8 @@ int gss_parse_init_downcall(struct gss_api_mech *gm, rawobj_t *buf, spin_lock_init(&ctx->gc_seq_lock); atomic_set(&ctx->gc_refcount,1); + if (simple_get_bytes(&p, &len, &gmd->gum_pag, sizeof(gmd->gum_pag))) + goto err_free_ctx; if (simple_get_bytes(&p, &len, &gmd->gum_uid, sizeof(gmd->gum_uid))) goto err_free_ctx; if (simple_get_bytes(&p, &len, &gmd->gum_svc, sizeof(gmd->gum_svc))) @@ -739,7 +742,6 @@ static int gss_cred_refresh(struct ptlrpc_cred *cred) struct dentry *dentry; char *obdname, *obdtype; wait_queue_t wait; - uid_t uid = cred->pc_uid; int res; ENTRY; @@ -759,7 +761,8 @@ static int gss_cred_refresh(struct ptlrpc_cred *cred) RETURN(-EINVAL); } - gmd.gum_uid = uid; + gmd.gum_pag = cred->pc_pag; + gmd.gum_uid = cred->pc_uid; gmd.gum_nal = import->imp_connection->c_peer.peer_ni->pni_number; gmd.gum_netid = 0; gmd.gum_nid = import->imp_connection->c_peer.peer_id.nid; @@ -782,7 +785,7 @@ static int gss_cred_refresh(struct ptlrpc_cred *cred) CDEBUG(D_SEC, "Initiate gss context %p(%u@%s)\n", container_of(cred, struct gss_cred, gc_base), - uid, import->imp_target_uuid.uuid); + cred->pc_uid, import->imp_target_uuid.uuid); again: spin_lock(&gsec->gs_lock); @@ -1552,8 +1555,8 @@ gss_pipe_downcall(struct file *filp, const char *src, size_t mlen) if (err) CERROR("parse init downcall err %d\n", err); + vcred.vc_pag = gmd.gum_pag; vcred.vc_uid = gmd.gum_uid; - vcred.vc_pag = vcred.vc_uid; /* FIXME */ cred = ptlrpcs_cred_lookup(sec, &vcred); if (!cred) { diff --git a/lustre/sec/sec.c b/lustre/sec/sec.c index 754f968..f7e832d 100644 --- a/lustre/sec/sec.c +++ b/lustre/sec/sec.c @@ -280,7 +280,7 @@ void ptlrpcs_credcache_gc(struct ptlrpc_sec *sec, * @force: flush all entries, otherwise only free ones be flushed. */ static -int flush_credcache(struct ptlrpc_sec *sec, uid_t uid, +int flush_credcache(struct ptlrpc_sec *sec, unsigned long pag, uid_t uid, int grace, int force) { struct ptlrpc_cred *cred, *n; @@ -296,8 +296,14 @@ int flush_credcache(struct ptlrpc_sec *sec, uid_t uid, pc_hash) { LASSERT(atomic_read(&cred->pc_refcount) >= 0); - if (uid != -1 && uid != cred->pc_uid) - continue; + if (sec->ps_flags & PTLRPC_SEC_FL_PAG) { + if (pag != -1 && pag != cred->pc_pag) + continue; + } else { + if (uid != -1 && uid != cred->pc_uid) + continue; + } + if (atomic_read(&cred->pc_refcount)) { busy = 1; if (!force) @@ -412,14 +418,15 @@ static struct ptlrpc_cred *get_cred(struct ptlrpc_sec *sec) struct vfs_cred vcred; LASSERT(sec); - /* XXX - * for now we simply let PAG == real uid - */ + if (sec->ps_flags & (PTLRPC_SEC_FL_MDS | PTLRPC_SEC_FL_REVERSE)) { vcred.vc_pag = 0; vcred.vc_uid = 0; } else { - vcred.vc_pag = (__u64) current->uid; + if (sec->ps_flags & PTLRPC_SEC_FL_PAG) + vcred.vc_pag = (__u64) current->pag; + else + vcred.vc_pag = (__u64) current->uid; vcred.vc_uid = current->uid; } @@ -826,7 +833,7 @@ void ptlrpcs_sec_put(struct ptlrpc_sec *sec) int ncred; if (atomic_dec_and_test(&sec->ps_refcount)) { - flush_credcache(sec, -1, 1, 1); + flush_credcache(sec, -1, -1, 1, 1); /* this spinlock is protect against ptlrpcs_cred_destroy() */ spin_lock(&sec->ps_lock); @@ -846,7 +853,7 @@ void ptlrpcs_sec_put(struct ptlrpc_sec *sec) void ptlrpcs_sec_invalidate_cache(struct ptlrpc_sec *sec) { - flush_credcache(sec, -1, 0, 1); + flush_credcache(sec, -1, -1, 0, 1); } int sec_alloc_reqbuf(struct ptlrpc_sec *sec, @@ -1075,13 +1082,13 @@ void ptlrpcs_import_drop_sec(struct obd_import *imp) EXIT; } -void ptlrpcs_import_flush_creds(struct obd_import *imp, uid_t uid) +void ptlrpcs_import_flush_current_creds(struct obd_import *imp) { LASSERT(imp); class_import_get(imp); if (imp->imp_sec) - flush_credcache(imp->imp_sec, uid, 1, 1); + flush_credcache(imp->imp_sec, current->pag, current->uid, 1, 1); class_import_put(imp); } @@ -1119,7 +1126,7 @@ EXPORT_SYMBOL(ptlrpcs_sec_put); EXPORT_SYMBOL(ptlrpcs_sec_invalidate_cache); EXPORT_SYMBOL(ptlrpcs_import_get_sec); EXPORT_SYMBOL(ptlrpcs_import_drop_sec); -EXPORT_SYMBOL(ptlrpcs_import_flush_creds); +EXPORT_SYMBOL(ptlrpcs_import_flush_current_creds); EXPORT_SYMBOL(ptlrpcs_cred_lookup); EXPORT_SYMBOL(ptlrpcs_cred_put); EXPORT_SYMBOL(ptlrpcs_req_get_cred); diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index ff22c37..623fc2e 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -15,7 +15,7 @@ bin_scripts = lfind lstripe if UTILS rootsbin_SCRIPTS = mount.lustre sbin_PROGRAMS = lctl obdio obdbarrier lload wirecheck wiretest llmount lsd_upcall -bin_PROGRAMS = lfs +bin_PROGRAMS = lfs lkinit lib_LIBRARIES = liblustreapi.a sbin_SCRIPTS = $(sbin_scripts) bin_SCRIPTS = $(bin_scripts) @@ -38,6 +38,7 @@ lload_SOURCES = lload.c obdio_SOURCES = obdio.c obdiolib.c obdiolib.h obdbarrier_SOURCES = obdbarrier.c obdiolib.c obdiolib.h lfs_SOURCES = lfs.c parser.c obd.c +lkinit_SOURCES = lkinit.c llmount_SOURCES = llmount.c llmount_LDADD = $(LIBREADLINE) $(LIBPTLCTL) diff --git a/lustre/utils/lkinit.c b/lustre/utils/lkinit.c new file mode 100644 index 0000000..78e8e3a --- /dev/null +++ b/lustre/utils/lkinit.c @@ -0,0 +1,113 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (C) 2004 Cluster File Systems, Inc. + * + * This file is part of Lustre, http://www.lustre.org. + * + * Lustre is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * Lustre is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Lustre; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include + +#ifndef __NR_newpag +#define __NR_newpag 289 +#define __NR_getpag 290 +#endif + +_syscall0(int, newpag); +_syscall0(int, getpag); + +void usage(const char *exe) +{ + printf("Usage: %s -k \"parameters_to_kinit\" command line\n", exe); + exit(1); +} + +int check_kopt(const char *opt) +{ + /* FIXME check "-c" here */ + return 0; +} + +#define CMD_BUFSIZE 4096 + +int main(int argc, char *argv[]) +{ + extern char *optarg; + int opt, i; + unsigned long pag; + char kopt[CMD_BUFSIZE]; + char kcmd[CMD_BUFSIZE]; + char cmd[CMD_BUFSIZE]; + + kopt[0] = '\0'; + cmd[0] = '\0'; + + newpag(); + pag = getpag(); + + snprintf(kcmd, CMD_BUFSIZE, "kinit -c /tmp/krb5cc_pag_%lx", pag); + + while ((opt = getopt(argc, argv, "k:")) != -1) { + switch (opt) { + case 'k': + if (check_kopt(optarg)) { + fprintf(stderr, "Can't specify cache file\n"); + return 1; + } + + snprintf(kcmd, CMD_BUFSIZE, + "kinit -c /tmp/krb5cc_pag_%lx %s", + pag, optarg); + break; + default: + usage(argv[0]); + } + } + + if (optind >= argc) { + snprintf(cmd, CMD_BUFSIZE, "/bin/sh"); + } else { + for (i = optind; i < argc; i++) { + if (i != optind) + strncat(cmd, " ", CMD_BUFSIZE); + strncat(cmd, argv[i], CMD_BUFSIZE); + } + } + + if (system(kcmd)) { + fprintf(stderr, "can't get kerberos TGT\n"); + return 1; + } + + if (system(cmd)) + fprintf(stderr, "execute error\n"); + + /* flush in-kernel credential cache */ + snprintf(cmd, CMD_BUFSIZE, "lctl flush_cred"); + if (system(cmd)) + fprintf(stderr, "failed to flush in-kernel credential\n"); + + /* flush user-space credential cache */ + snprintf(kcmd, CMD_BUFSIZE, "kdestroy -c /tmp/krb5cc_pag_%lx", pag); + system(kcmd); + + return 0; +} diff --git a/lustre/utils/llmount.c b/lustre/utils/llmount.c index b9e7a8f..bc8d4f69 100644 --- a/lustre/utils/llmount.c +++ b/lustre/utils/llmount.c @@ -124,6 +124,7 @@ init_options(struct lustre_mount_data *lmd) lmd->lmd_remote_flag = 0; lmd->lmd_nllu = NOBODY_UID; lmd->lmd_nllg = NOBODY_GID; + lmd->lmd_pag = 0; strncpy(lmd->lmd_mds_security, "null", sizeof(lmd->lmd_mds_security)); strncpy(lmd->lmd_oss_security, "null", sizeof(lmd->lmd_oss_security)); return 0; @@ -357,6 +358,8 @@ int parse_options(char * options, struct lustre_mount_data *lmd) lmd->lmd_remote_flag = OBD_CONNECT_LOCAL; } else if (!strcmp(opt, "async")) { lmd->lmd_async = 1; + } else if (!strcmp(opt, "pag")) { + lmd->lmd_pag = 1; } else { val = 1; if (!strncmp(opt, "no", 2)) { -- 1.8.3.1