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.
24 #include <lib/vserver.h>
29 #define ENSC_WRAPPERS_VSERVER 1
32 #define CMD_HELP 0x1000
33 #define CMD_VERSION 0x1001
34 #define CMD_XID 0x2000
35 #define CMD_SET 0x2001
36 #define CMD_CAP 0x2002
37 #define CMD_FLAG 0x2003
38 #define CMD_SECURE 0x2004
40 int wrapper_exit_code = 1;
44 { "help", no_argument, 0, CMD_HELP },
45 { "version", no_argument, 0, CMD_VERSION },
46 { "xid", required_argument, 0, CMD_XID },
47 { "set", no_argument, 0, CMD_SET },
48 { "cap", required_argument, 0, CMD_CAP },
49 { "flag", required_argument, 0, CMD_FLAG },
50 { "secure", no_argument, 0, CMD_SECURE },
56 struct vc_ctx_flags flags;
57 struct vc_ctx_flags caps;
61 showHelp(int fd, char const *cmd, int res)
63 WRITE_MSG(fd, "Usage:\n ");
66 " --set [--xid <xid>] [--cap [~!]<cap>] [--flag [~!]<flag>] [--secure] -- [<program> <args>*]\n"
68 "Please report bugs to " PACKAGE_BUGREPORT "\n");
77 "vattribute " VERSION " -- sets attributes of vservers\n"
78 "This program is part of " PACKAGE_STRING "\n\n"
79 "Copyright (C) 2004 Enrico Scholz\n"
80 VERSION_COPYRIGHT_DISCLAIMER);
85 setFlags(char const UNUSED *str, struct vc_ctx_flags UNUSED * flags)
91 setCaps(char const UNUSED *str, struct vc_ctx_flags UNUSED * caps)
97 setSecure(struct vc_ctx_flags UNUSED * flags,
98 struct vc_ctx_flags UNUSED * caps)
104 int main(int argc, char *argv[])
106 struct Arguments args = {
108 .flags = { .flagword = 0, .mask = 0 },
109 .caps = { .flagword = 0, .mask = 0 },
113 int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
117 case CMD_HELP : showHelp(1, argv[0], 0);
118 case CMD_VERSION : showVersion();
119 case CMD_SET : break; // default op currently
120 case CMD_XID : args.xid = atoi(optarg); break;
121 case CMD_FLAG : setFlags(optarg, &args.flags); break;
122 case CMD_CAP : setCaps(optarg, &args.caps); break;
123 case CMD_SECURE : setSecure(&args.flags, &args.caps); break;
125 WRITE_MSG(2, "Try '");
126 WRITE_STR(2, argv[0]);
127 WRITE_MSG(2, " --help\" for more information.\n");
133 if (args.xid==VC_NOCTX) args.xid = Evc_get_task_xid(0);
135 if (vc_set_flags(args.xid,&args.flags)==-1)
136 perror("vc_set_flags()");
137 // else if (vc_set_caps(xid, &args.caps)==-1)
138 // perror("vc_set_caps()");