diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/debug.c | 16 | ||||
| -rw-r--r-- | src/debug.h | 9 | ||||
| -rw-r--r-- | src/lockdown.c | 13 |
3 files changed, 31 insertions, 7 deletions
diff --git a/src/debug.c b/src/debug.c index 2cdeebf..b194b0d 100644 --- a/src/debug.c +++ b/src/debug.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * contains utilitary functions for debugging | 3 | * contains utilitary functions for debugging |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. | 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. |
| 6 | * Copyright (c) 2010 Martin S. All Rights Reserved. | ||
| 6 | * | 7 | * |
| 7 | * This library is free software; you can redistribute it and/or | 8 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public | 9 | * modify it under the terms of the GNU Lesser General Public |
| @@ -56,10 +57,12 @@ static void debug_print_line(const char *func, const char *file, int line, const | |||
| 56 | (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func); | 57 | (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func); |
| 57 | free (str_time); | 58 | free (str_time); |
| 58 | 59 | ||
| 59 | /* always in light green */ | 60 | /* trim ending newlines */ |
| 61 | |||
| 62 | /* print header */ | ||
| 60 | printf ("%s: ", header); | 63 | printf ("%s: ", header); |
| 61 | 64 | ||
| 62 | /* different colors according to the severity */ | 65 | /* print actual debug content */ |
| 63 | printf ("%s\n", buffer); | 66 | printf ("%s\n", buffer); |
| 64 | 67 | ||
| 65 | /* flush this output, as we need to debug */ | 68 | /* flush this output, as we need to debug */ |
| @@ -135,7 +138,7 @@ inline void debug_buffer_to_file(const char *file, const char *data, const int l | |||
| 135 | #endif | 138 | #endif |
| 136 | } | 139 | } |
| 137 | 140 | ||
| 138 | inline void debug_plist(plist_t plist) | 141 | inline void debug_plist_real(const char *func, const char *file, int line, plist_t plist) |
| 139 | { | 142 | { |
| 140 | #ifndef STRIP_DEBUG_CODE | 143 | #ifndef STRIP_DEBUG_CODE |
| 141 | if (!plist) | 144 | if (!plist) |
| @@ -144,7 +147,12 @@ inline void debug_plist(plist_t plist) | |||
| 144 | char *buffer = NULL; | 147 | char *buffer = NULL; |
| 145 | uint32_t length = 0; | 148 | uint32_t length = 0; |
| 146 | plist_to_xml(plist, &buffer, &length); | 149 | plist_to_xml(plist, &buffer, &length); |
| 147 | debug_info("plist size: %i\nbuffer :\n%s", length, buffer); | 150 | |
| 151 | /* get rid of ending newline as one is already added in the debug line */ | ||
| 152 | if (buffer[length-1] == '\n') | ||
| 153 | buffer[length-1] = '\0'; | ||
| 154 | |||
| 155 | debug_info_real(func, file, line, "printing %i bytes plist:\n%s", length, buffer); | ||
| 148 | free(buffer); | 156 | free(buffer); |
| 149 | #endif | 157 | #endif |
| 150 | } | 158 | } |
diff --git a/src/debug.h b/src/debug.h index 0a29be3..2fd0960 100644 --- a/src/debug.h +++ b/src/debug.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * contains utilitary functions for debugging | 3 | * contains utilitary functions for debugging |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. | 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. |
| 6 | * Copyright (c) 2010 Martin S. All Rights Reserved. | ||
| 6 | * | 7 | * |
| 7 | * This library is free software; you can redistribute it and/or | 8 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public | 9 | * modify it under the terms of the GNU Lesser General Public |
| @@ -27,10 +28,13 @@ | |||
| 27 | 28 | ||
| 28 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && !defined(STRIP_DEBUG_CODE) | 29 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && !defined(STRIP_DEBUG_CODE) |
| 29 | #define debug_info(...) debug_info_real (__func__, __FILE__, __LINE__, __VA_ARGS__) | 30 | #define debug_info(...) debug_info_real (__func__, __FILE__, __LINE__, __VA_ARGS__) |
| 31 | #define debug_plist(a) debug_plist_real (__func__, __FILE__, __LINE__, a) | ||
| 30 | #elif defined(__GNUC__) && __GNUC__ >= 3 && !defined(STRIP_DEBUG_CODE) | 32 | #elif defined(__GNUC__) && __GNUC__ >= 3 && !defined(STRIP_DEBUG_CODE) |
| 31 | #define debug_info(...) debug_info_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) | 33 | #define debug_info(...) debug_info_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
| 34 | #define debug_plist(a) debug_plist_real (__FUNCTION__, __FILE__, __LINE__, a) | ||
| 32 | #else | 35 | #else |
| 33 | #define debug_info(...) | 36 | #define debug_info(...) |
| 37 | #define debug_plist(a) | ||
| 34 | #endif | 38 | #endif |
| 35 | 39 | ||
| 36 | G_GNUC_INTERNAL inline void debug_info_real(const char *func, | 40 | G_GNUC_INTERNAL inline void debug_info_real(const char *func, |
| @@ -40,6 +44,9 @@ G_GNUC_INTERNAL inline void debug_info_real(const char *func, | |||
| 40 | 44 | ||
| 41 | G_GNUC_INTERNAL inline void debug_buffer(const char *data, const int length); | 45 | G_GNUC_INTERNAL inline void debug_buffer(const char *data, const int length); |
| 42 | G_GNUC_INTERNAL inline void debug_buffer_to_file(const char *file, const char *data, const int length); | 46 | G_GNUC_INTERNAL inline void debug_buffer_to_file(const char *file, const char *data, const int length); |
| 43 | G_GNUC_INTERNAL inline void debug_plist(plist_t plist); | 47 | G_GNUC_INTERNAL inline void debug_plist_real(const char *func, |
| 48 | const char *file, | ||
| 49 | int line, | ||
| 50 | plist_t plist); | ||
| 44 | 51 | ||
| 45 | #endif | 52 | #endif |
diff --git a/src/lockdown.c b/src/lockdown.c index 1befb72..8f15b3f 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -1262,9 +1262,18 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char | |||
| 1262 | if (port && ret == LOCKDOWN_E_SUCCESS) | 1262 | if (port && ret == LOCKDOWN_E_SUCCESS) |
| 1263 | *port = port_loc; | 1263 | *port = port_loc; |
| 1264 | } | 1264 | } |
| 1265 | } | 1265 | } else { |
| 1266 | else | ||
| 1267 | ret = LOCKDOWN_E_START_SERVICE_FAILED; | 1266 | ret = LOCKDOWN_E_START_SERVICE_FAILED; |
| 1267 | plist_t error_node = plist_dict_get_item(dict, "Error"); | ||
| 1268 | if (error_node && PLIST_STRING == plist_get_node_type(error_node)) { | ||
| 1269 | char *error = NULL; | ||
| 1270 | plist_get_string_val(error_node, &error); | ||
| 1271 | if (!strcmp(error, "InvalidService")) { | ||
| 1272 | ret = LOCKDOWN_E_INVALID_SERVICE; | ||
| 1273 | } | ||
| 1274 | free(error); | ||
| 1275 | } | ||
| 1276 | } | ||
| 1268 | 1277 | ||
| 1269 | plist_free(dict); | 1278 | plist_free(dict); |
| 1270 | dict = NULL; | 1279 | dict = NULL; |
