1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/unistd.h>
31 #define __NR_newpag 289
32 #define __NR_getpag 290
35 _syscall0(int, newpag);
36 _syscall0(int, getpag);
38 void usage(const char *exe)
40 printf("Usage: %s -k \"parameters_to_kinit\" command line\n", exe);
44 int check_kopt(const char *opt)
46 /* FIXME check "-c" here */
50 #define CMD_BUFSIZE 4096
52 int main(int argc, char *argv[])
57 char kopt[CMD_BUFSIZE];
58 char kcmd[CMD_BUFSIZE];
59 char cmd[CMD_BUFSIZE];
65 fprintf(stderr, "root user don't want to use lkinit\n");
72 snprintf(kcmd, CMD_BUFSIZE, "kinit -c /tmp/krb5cc_pag_%lx", pag);
74 while ((opt = getopt(argc, argv, "k:")) != -1) {
77 if (check_kopt(optarg)) {
78 fprintf(stderr, "Can't specify cache file\n");
82 snprintf(kcmd, CMD_BUFSIZE,
83 "kinit -c /tmp/krb5cc_pag_%lx %s",
92 snprintf(cmd, CMD_BUFSIZE, "/bin/sh");
94 for (i = optind; i < argc; i++) {
96 strncat(cmd, " ", CMD_BUFSIZE);
97 strncat(cmd, argv[i], CMD_BUFSIZE);
102 fprintf(stderr, "can't get kerberos TGT\n");
107 fprintf(stderr, "execute error\n");
109 /* flush in-kernel credential cache */
110 snprintf(cmd, CMD_BUFSIZE, "lfs flushctx");
112 fprintf(stderr, "failed to flush in-kernel credential\n");
114 /* flush user-space credential cache */
115 snprintf(kcmd, CMD_BUFSIZE, "kdestroy -c /tmp/krb5cc_pag_%lx", pag);