Commit 4efa4bb9 by Christian Brauner Committed by Stéphane Graber

tools/lxc_autostart: use lxc_safe_{int,long}()

parent 3b56f032
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "arguments.h" #include "arguments.h"
#include "list.h" #include "list.h"
#include "log.h" #include "log.h"
#include "utils.h"
lxc_log_define(lxc_autostart_ui, lxc); lxc_log_define(lxc_autostart_ui, lxc);
static struct lxc_list *accumulate_list(char *input, char *delimiter, struct lxc_list *str_list); static struct lxc_list *accumulate_list(char *input, char *delimiter, struct lxc_list *str_list);
...@@ -35,14 +36,31 @@ struct lxc_list *cmd_groups_list = NULL; ...@@ -35,14 +36,31 @@ struct lxc_list *cmd_groups_list = NULL;
static int my_parser(struct lxc_arguments* args, int c, char* arg) static int my_parser(struct lxc_arguments* args, int c, char* arg)
{ {
switch (c) { switch (c) {
case 'k': args->hardstop = 1; break; case 'k':
case 'L': args->list = 1; break; args->hardstop = 1;
case 'r': args->reboot = 1; break; break;
case 's': args->shutdown = 1; break; case 'L':
case 'a': args->all = 1; break; args->list = 1;
case 'A': args->ignore_auto = 1; break; break;
case 'g': cmd_groups_list = accumulate_list( arg, ",", cmd_groups_list); break; case 'r':
case 't': args->timeout = atoi(arg); break; args->reboot = 1;
break;
case 's':
args->shutdown = 1;
break;
case 'a':
args->all = 1;
break;
case 'A':
args->ignore_auto = 1;
break;
case 'g':
cmd_groups_list = accumulate_list(arg, ",", cmd_groups_list);
break;
case 't':
if (lxc_safe_long(arg, &args->timeout) < 0)
return -1;
break;
} }
return 0; return 0;
} }
...@@ -290,7 +308,9 @@ static int get_config_integer(struct lxc_container *c, char *key) { ...@@ -290,7 +308,9 @@ static int get_config_integer(struct lxc_container *c, char *key) {
return 0; return 0;
} }
ret = atoi(value); if (lxc_safe_int(value, &ret) < 0)
DEBUG("Could not parse config item.");
free(value); free(value);
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment