]> git.proxmox.com Git - mirror_lxc.git/blob - src/tests/may_control.c
src/tests: Fix container creation errors
[mirror_lxc.git] / src / tests / may_control.c
1 /* control.c
2 *
3 * Copyright © 2013 Canonical, Inc
4 * Author: Serge Hallyn <serge.hallyn@ubuntu.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "config.h"
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <lxc/lxccontainer.h>
25
26 static void usage(const char *me)
27 {
28 printf("Usage: %s name [lxcpath]\n", me);
29 exit(EXIT_SUCCESS);
30 }
31
32 int main(int argc, char *argv[])
33 {
34 const char *lxcpath = NULL, *name;
35 bool may = false;
36 struct lxc_container *c;
37
38 if (argc < 2)
39 usage(argv[0]);
40
41 name = argv[1];
42
43 if (argc == 3)
44 lxcpath = argv[2];
45
46 c = lxc_container_new(name, lxcpath);
47 if (c)
48 may = c->may_control(c);
49
50 printf("You may%s control %s\n", may ? "" : " not", name);
51 exit(may ? 0 : 1);
52 }