]>
Commit | Line | Data |
---|---|---|
b494d2dd SH |
1 | /* control.c |
2 | * | |
8cd80b50 | 3 | * Copyright © 2013 Canonical, Inc |
b494d2dd SH |
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 | ||
e49c56d6 CB |
20 | #include "config.h" |
21 | ||
b494d2dd SH |
22 | #include <stdio.h> |
23 | #include <stdlib.h> | |
24 | #include <lxc/lxccontainer.h> | |
25 | ||
0b98289e | 26 | static void usage(const char *me) |
b494d2dd SH |
27 | { |
28 | printf("Usage: %s name [lxcpath]\n", me); | |
57017714 | 29 | exit(EXIT_SUCCESS); |
b494d2dd SH |
30 | } |
31 | ||
32 | int main(int argc, char *argv[]) | |
33 | { | |
0b98289e | 34 | const char *lxcpath = NULL, *name; |
b494d2dd SH |
35 | bool may = false; |
36 | struct lxc_container *c; | |
37 | ||
38 | if (argc < 2) | |
39 | usage(argv[0]); | |
fe142896 | 40 | |
b494d2dd | 41 | name = argv[1]; |
fe142896 | 42 | |
b494d2dd SH |
43 | if (argc == 3) |
44 | lxcpath = argv[2]; | |
fe142896 | 45 | |
b494d2dd SH |
46 | c = lxc_container_new(name, lxcpath); |
47 | if (c) | |
48 | may = c->may_control(c); | |
fe142896 | 49 | |
b494d2dd SH |
50 | printf("You may%s control %s\n", may ? "" : " not", name); |
51 | exit(may ? 0 : 1); | |
52 | } |