* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
lxc_log_define(lxc_confile, lxc);
-static int config_personality(const char *, char *, struct lxc_conf *);
-static int config_pts(const char *, char *, struct lxc_conf *);
-static int config_tty(const char *, char *, struct lxc_conf *);
-static int config_ttydir(const char *, char *, struct lxc_conf *);
+static int config_personality(const char *, const char *, struct lxc_conf *);
+static int config_pts(const char *, const char *, struct lxc_conf *);
+static int config_tty(const char *, const char *, struct lxc_conf *);
+static int config_ttydir(const char *, const char *, struct lxc_conf *);
#if HAVE_APPARMOR
-static int config_aa_profile(const char *, char *, struct lxc_conf *);
+static int config_aa_profile(const char *, const char *, struct lxc_conf *);
#endif
-static int config_cgroup(const char *, char *, struct lxc_conf *);
-static int config_mount(const char *, char *, struct lxc_conf *);
-static int config_rootfs(const char *, char *, struct lxc_conf *);
-static int config_rootfs_mount(const char *, char *, struct lxc_conf *);
-static int config_pivotdir(const char *, char *, struct lxc_conf *);
-static int config_utsname(const char *, char *, struct lxc_conf *);
-static int config_hook(const char *key, char *value, struct lxc_conf *lxc_conf);
-static int config_network_type(const char *, char *, struct lxc_conf *);
-static int config_network_flags(const char *, char *, struct lxc_conf *);
-static int config_network_link(const char *, char *, struct lxc_conf *);
-static int config_network_name(const char *, char *, struct lxc_conf *);
-static int config_network_veth_pair(const char *, char *, struct lxc_conf *);
-static int config_network_macvlan_mode(const char *, char *, struct lxc_conf *);
-static int config_network_hwaddr(const char *, char *, struct lxc_conf *);
-static int config_network_vlan_id(const char *, char *, struct lxc_conf *);
-static int config_network_mtu(const char *, char *, struct lxc_conf *);
-static int config_network_ipv4(const char *, char *, struct lxc_conf *);
-static int config_network_ipv4_gateway(const char *, char *, struct lxc_conf *);
-static int config_network_script(const char *, char *, struct lxc_conf *);
-static int config_network_ipv6(const char *, char *, struct lxc_conf *);
-static int config_network_ipv6_gateway(const char *, char *, struct lxc_conf *);
-static int config_cap_drop(const char *, char *, struct lxc_conf *);
-static int config_console(const char *, char *, struct lxc_conf *);
-static int config_seccomp(const char *, char *, struct lxc_conf *);
-static int config_includefile(const char *, char *, struct lxc_conf *);
-static int config_network_nic(const char *, char *, struct lxc_conf *);
-static int config_autodev(const char *, char *, struct lxc_conf *);
+static int config_cgroup(const char *, const char *, struct lxc_conf *);
+static int config_mount(const char *, const char *, struct lxc_conf *);
+static int config_rootfs(const char *, const char *, struct lxc_conf *);
+static int config_rootfs_mount(const char *, const char *, struct lxc_conf *);
+static int config_pivotdir(const char *, const char *, struct lxc_conf *);
+static int config_utsname(const char *, const char *, struct lxc_conf *);
+static int config_hook(const char *, const char *, struct lxc_conf *lxc_conf);
+static int config_network_type(const char *, const char *, struct lxc_conf *);
+static int config_network_flags(const char *, const char *, struct lxc_conf *);
+static int config_network_link(const char *, const char *, struct lxc_conf *);
+static int config_network_name(const char *, const char *, struct lxc_conf *);
+static int config_network_veth_pair(const char *, const char *, struct lxc_conf *);
+static int config_network_macvlan_mode(const char *, const char *, struct lxc_conf *);
+static int config_network_hwaddr(const char *, const char *, struct lxc_conf *);
+static int config_network_vlan_id(const char *, const char *, struct lxc_conf *);
+static int config_network_mtu(const char *, const char *, struct lxc_conf *);
+static int config_network_ipv4(const char *, const char *, struct lxc_conf *);
+static int config_network_ipv4_gateway(const char *, const char *, struct lxc_conf *);
+static int config_network_script(const char *, const char *, struct lxc_conf *);
+static int config_network_ipv6(const char *, const char *, struct lxc_conf *);
+static int config_network_ipv6_gateway(const char *, const char *, struct lxc_conf *);
+static int config_cap_drop(const char *, const char *, struct lxc_conf *);
+static int config_console(const char *, const char *, struct lxc_conf *);
+static int config_seccomp(const char *, const char *, struct lxc_conf *);
+static int config_includefile(const char *, const char *, struct lxc_conf *);
+static int config_network_nic(const char *, const char *, struct lxc_conf *);
+static int config_autodev(const char *, const char *, struct lxc_conf *);
static struct lxc_config_t config[] = {
{ "lxc.pivotdir", config_pivotdir },
{ "lxc.utsname", config_utsname },
{ "lxc.hook.pre-start", config_hook },
- { "lxc.hook.pre-mount", config_hook },
+ { "lxc.hook.pre-mount", config_hook },
{ "lxc.hook.mount", config_hook },
{ "lxc.hook.start", config_hook },
{ "lxc.hook.post-stop", config_hook },
* comes an integer, find the right callback (by rewriting
* the key), and call it.
*/
-static int config_network_nic(const char *key, char *value,
+static int config_network_nic(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
char *copy = strdup(key), *p;
return ret;
}
-static int config_network_type(const char *key, char *value,
+static int config_network_type(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_list *network = &lxc_conf->network;
return netdev;
}
-extern int lxc_list_nicconfigs(struct lxc_conf *c, char *key, char *retv, int inlen)
+extern int lxc_list_nicconfigs(struct lxc_conf *c, const char *key,
+ char *retv, int inlen)
{
struct lxc_netdev *netdev;
int fulllen = 0, len;
return netdev;
}
-static int network_ifname(char **valuep, char *value)
+static int network_ifname(char **valuep, const char *value)
{
if (strlen(value) >= IFNAMSIZ) {
ERROR("interface name '%s' too long (>%d)\n",
# define MACVLAN_MODE_BRIDGE 4
#endif
-static int macvlan_mode(int *valuep, char *value)
+static int macvlan_mode(int *valuep, const char *value)
{
struct mc_mode {
char *name;
return -1;
}
-static int config_network_flags(const char *key, char *value,
+static int config_network_flags(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_network_link(const char *key, char *value,
+static int config_network_link(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return network_ifname(&netdev->link, value);
}
-static int config_network_name(const char *key, char *value,
+static int config_network_name(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return network_ifname(&netdev->name, value);
}
-static int config_network_veth_pair(const char *key, char *value,
+static int config_network_veth_pair(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return network_ifname(&netdev->priv.veth_attr.pair, value);
}
-static int config_network_macvlan_mode(const char *key, char *value,
+static int config_network_macvlan_mode(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return macvlan_mode(&netdev->priv.macvlan_attr.mode, value);
}
-static int config_network_hwaddr(const char *key, char *value,
+static int config_network_hwaddr(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_network_vlan_id(const char *key, char *value,
+static int config_network_vlan_id(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_network_mtu(const char *key, char *value,
+static int config_network_mtu(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_network_ipv4(const char *key, char *value,
+static int config_network_ipv4(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
lxc_list_init(list);
list->elem = inetdev;
- addr = value;
+ addr = strdupa(value);
cursor = strstr(addr, " ");
if (cursor) {
return 0;
}
-static int config_network_ipv4_gateway(const char *key, char *value,
+static int config_network_ipv4_gateway(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_network_ipv6(const char *key, char *value,
+static int config_network_ipv6(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
struct lxc_inet6dev *inet6dev;
struct lxc_list *list;
- char *slash;
+ char *slash,*valdup;
char *netmask;
netdev = network_netdev(key, value, &lxc_conf->network);
lxc_list_init(list);
list->elem = inet6dev;
+ valdup = strdupa(value);
inet6dev->prefix = 64;
- slash = strstr(value, "/");
+ slash = strstr(valdup, "/");
if (slash) {
*slash = '\0';
netmask = slash + 1;
return 0;
}
-static int config_network_ipv6_gateway(const char *key, char *value,
+static int config_network_ipv6_gateway(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_network_script(const char *key, char *value,
+static int config_network_script(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
struct lxc_netdev *netdev;
return 0;
}
-static int config_seccomp(const char *key, char *value,
+static int config_seccomp(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
char *path;
return 0;
}
-static int config_hook(const char *key, char *value,
+static int config_hook(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
char *copy = strdup(value);
return -1;
}
-static int config_personality(const char *key, char *value,
+static int config_personality(const char *key, const const char *value,
struct lxc_conf *lxc_conf)
{
signed long personality = lxc_config_parse_arch(value);
return 0;
}
-static int config_pts(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_pts(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
int maxpts = atoi(value);
return 0;
}
-static int config_tty(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_tty(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
int nbtty = atoi(value);
return 0;
}
-static int config_ttydir(const char *key, char *value,
+static int config_ttydir(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
char *path;
}
#if HAVE_APPARMOR
-static int config_aa_profile(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_aa_profile(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
char *path;
}
#endif
-static int config_autodev(const char *key, char *value,
+static int config_autodev(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
int v = atoi(value);
return 0;
}
-static int config_cgroup(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_cgroup(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
char *token = "lxc.cgroup.";
char *subkey;
return config_path_item(key, value, lxc_conf, &lxc_conf->fstab);
}
-static int config_mount(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_mount(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
char *fstab_token = "lxc.mount";
char *token = "lxc.mount.entry";
return 0;
}
-static int config_cap_drop(const char *key, char *value,
+static int config_cap_drop(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
char *dropcaps, *dropptr, *sptr, *token;
return ret;
}
-static int config_console(const char *key, char *value,
+static int config_console(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
char *path;
return 0;
}
-static int config_includefile(const char *key, char *value,
+static int config_includefile(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
return lxc_config_read(value, lxc_conf);
}
-static int config_rootfs(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_rootfs(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
return config_path_item(key, value, lxc_conf, &lxc_conf->rootfs.path);
}
-static int config_rootfs_mount(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_rootfs_mount(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
return config_path_item(key, value, lxc_conf, &lxc_conf->rootfs.mount);
}
-static int config_pivotdir(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_pivotdir(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
return config_path_item(key, value, lxc_conf, &lxc_conf->rootfs.pivot);
}
-static int config_utsname(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int config_utsname(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
{
struct utsname *utsname;
* If you ask for 'lxc.cgroup", then all cgroup entries will be printed,
* in 'lxc.cgroup.subsystem.key = value' format.
*/
-static int lxc_get_cgroup_entry(struct lxc_conf *c, char *retv, int inlen, char *key)
+static int lxc_get_cgroup_entry(struct lxc_conf *c, char *retv, int inlen,
+ const char *key)
{
int fulllen = 0, len;
int all = 0;
return fulllen;
}
-static int lxc_get_item_hooks(struct lxc_conf *c, char *retv, int inlen, char *key)
+static int lxc_get_item_hooks(struct lxc_conf *c, char *retv, int inlen,
+ const char *key)
{
char *subkey;
int len, fulllen = 0, found = -1;
* things like veth.pair return '' if invalid (i.e. if called for vlan
* type).
*/
-static int lxc_get_item_nic(struct lxc_conf *c, char *retv, int inlen, char *key)
+static int lxc_get_item_nic(struct lxc_conf *c, char *retv, int inlen,
+ const char *key)
{
char *p1;
int len, fulllen = 0;
return fulllen;
}
-int lxc_get_config_item(struct lxc_conf *c, char *key, char *retv, int inlen)
+int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
+ int inlen)
{
char *v = NULL;
return strlen(v);
}
-int lxc_clear_config_item(struct lxc_conf *c, char *key)
+int lxc_clear_config_item(struct lxc_conf *c, const char *key)
{
if (strcmp(key, "lxc.network") == 0)
return lxc_clear_config_network(c);