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.
33 #include <liblustre.h>
34 #include <linux/lustre_idl.h>
35 #include <linux/obd.h>
36 #include <linux/lustre_mds.h>
40 * 0: fail to insert (found identical)
43 int insert_sort(gid_t *groups, int size, gid_t grp)
48 for (i = 0; i < size; i++) {
55 for (; i <= size; i++) {
63 int get_groups_local(uid_t uid, gid_t *gid, int *ngroups, gid_t **groups)
72 maxgroups = sysconf(_SC_NGROUPS_MAX);
73 *groups = malloc(maxgroups * sizeof(gid_t));
83 while ((gr = getgrent())) {
86 for (i = 0; gr->gr_mem[i]; i++) {
87 if (strcmp(gr->gr_mem[i], pw->pw_name))
89 size += insert_sort(*groups, size, gr->gr_gid);
92 if (size == maxgroups)
100 int main (int argc, char **argv)
102 char *pathname = "/proc/fs/lustre/mds/lsd_downcall";
104 struct lsd_downcall_args ioc_data;
107 printf("bad parameter\n");
111 ioc_data.uid = atoi(argv[1]);
113 fd = open(pathname, O_WRONLY);
116 printf("can't open device %s\n", pathname);
120 ioc_data.err = get_groups_local(ioc_data.uid, &ioc_data.gid,
121 &ioc_data.ngroups, &ioc_data.groups);
123 /* FIXME get these from config file */
124 ioc_data.allow_setuid = 1;
125 ioc_data.allow_setgid = 1;
126 ioc_data.allow_setgrp = 1;
128 rc = write(fd, &ioc_data, sizeof(ioc_data));
129 return (rc != sizeof(ioc_data));