3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "lib/vserver.h"
30 #include <sys/types.h>
36 { "help", no_argument, 0, CMD_HELP },
37 { "version", no_argument, 0, CMD_VERSION },
41 char const CMDLINE_OPTIONS_SHORT[] = "Rc:";
44 showHelp(int fd, char const *cmd, int res)
46 WRITE_MSG(fd, "Usage: ");
49 " -c <ctx|vserver> [-R] [--] <file>+\n\n"
51 " -R ... recurse through directories\n"
52 " -c ... assign the given context/vserver to the file(s)\n"
53 "Please report bugs to " PACKAGE_BUGREPORT "\n");
61 "chxid " VERSION " -- assigns a context to a file\n"
62 "This program is part of " PACKAGE_STRING "\n\n"
63 "Copyright (C) 2004 Enrico Scholz\n"
64 VERSION_COPYRIGHT_DISCLAIMER);
69 setFile(char const *name, char const * display_name, struct stat const *exp_st)
72 int fd = open(name, O_RDONLY);
80 !checkForRace(fd, name, exp_st))
83 if (vc_X_set_filecontext(fd, global_args->ctx)==-1) {
84 //perror("vc_X_set_filecontext()");
97 handleFile(char const *name, char const * display_name,
98 struct stat const *exp_st)
100 if (S_ISLNK(exp_st->st_mode)) return true;
102 return setFile(name, display_name, exp_st);
106 fixupParams(struct Arguments UNUSED *args, int argc)
109 WRITE_MSG(2, "No filename given; use '--help' for more information\n");
113 if (args->ctx_str==0) {
114 WRITE_MSG(2, "No context given; use '--help' for more information\n");
118 args->ctx = resolveCtx(args->ctx_str);