]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cmd: move lxc-console to API symbols only
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 12 Jan 2018 13:11:21 +0000 (14:11 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 6 Feb 2018 20:03:33 +0000 (21:03 +0100)
Closes #2073.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/tools/lxc_console.c
src/lxc/tools/tool_utils.c
src/lxc/tools/tool_utils.h

index 876cbce58cd1ba647705a042d0dec74e270ee333..f847811cb020ed34e199761e6f238d5b60c40611 100644 (file)
 #include <lxc/lxccontainer.h>
 
 #include "arguments.h"
-#include "commands.h"
-#include "error.h"
-#include "log.h"
-#include "lxc.h"
-#include "mainloop.h"
-#include "utils.h"
+#include "tool_utils.h"
 
 static char etoc(const char *expr)
 {
@@ -115,7 +110,6 @@ int main(int argc, char *argv[])
        ret = lxc_log_init(&log);
        if (ret)
                return EXIT_FAILURE;
-       lxc_log_options_no_override();
 
        /* REMOVE IN LXC 3.0 */
        setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
index 4b4dad0b444e01c59c3ee8c21518aebbc21251b0..00181ab6501e94de813d541b860efee642febb7d 100644 (file)
@@ -17,7 +17,9 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#define _GNU_SOURCE
 #define __STDC_FORMAT_MACROS /* Required for PRIu64 to work. */
+#include <ctype.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
@@ -310,6 +312,32 @@ again:
        return status;
 }
 
+int lxc_safe_uint(const char *numstr, unsigned int *converted)
+{
+       char *err = NULL;
+       unsigned long int uli;
+
+       while (isspace(*numstr))
+               numstr++;
+
+       if (*numstr == '-')
+               return -EINVAL;
+
+       errno = 0;
+       uli = strtoul(numstr, &err, 0);
+       if (errno == ERANGE && uli == ULONG_MAX)
+               return -ERANGE;
+
+       if (err == numstr || *err != '\0')
+               return -EINVAL;
+
+       if (uli > UINT_MAX)
+               return -ERANGE;
+
+       *converted = (unsigned int)uli;
+       return 0;
+}
+
 int lxc_safe_int(const char *numstr, int *converted)
 {
        char *err = NULL;
index f900f037c39a2799a994466d746b6f35a076eed0..b122e3ea16bb6326d5d50becf3efd9ac24078d9e 100644 (file)
@@ -125,6 +125,7 @@ static inline int lxc_caps_init(void) {
 
 extern int wait_for_pid(pid_t pid);
 extern int lxc_wait_for_pid_status(pid_t pid);
+extern int lxc_safe_uint(const char *numstr, unsigned int *converted);
 extern int lxc_safe_int(const char *numstr, int *converted);
 extern int lxc_safe_long(const char *numstr, long int *converted);