]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/may_control.c
tests: use busybox in lxc-test-usernic.in
[mirror_lxc.git] / src / tests / may_control.c
CommitLineData
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
20#include <stdio.h>
21#include <stdlib.h>
22#include <lxc/lxccontainer.h>
23
0b98289e 24static void usage(const char *me)
b494d2dd
SH
25{
26 printf("Usage: %s name [lxcpath]\n", me);
57017714 27 exit(EXIT_SUCCESS);
b494d2dd
SH
28}
29
30int main(int argc, char *argv[])
31{
0b98289e 32 const char *lxcpath = NULL, *name;
b494d2dd
SH
33 bool may = false;
34 struct lxc_container *c;
35
36 if (argc < 2)
37 usage(argv[0]);
fe142896 38
b494d2dd 39 name = argv[1];
fe142896 40
b494d2dd
SH
41 if (argc == 3)
42 lxcpath = argv[2];
fe142896 43
b494d2dd
SH
44 c = lxc_container_new(name, lxcpath);
45 if (c)
46 may = c->may_control(c);
fe142896 47
b494d2dd
SH
48 printf("You may%s control %s\n", may ? "" : " not", name);
49 exit(may ? 0 : 1);
50}