Changeset 5265
- Timestamp:
- 02/14/08 06:05:54 (8 months ago)
- Files:
-
- libwired/trunk/libwired/base/wi-base.c (modified) (1 diff)
- libwired/trunk/libwired/base/wi-base.h (modified) (1 diff)
- libwired/trunk/libwired/base/wi-private.h (modified) (1 diff)
- libwired/trunk/libwired/misc/wi-settings.c (modified) (4 diffs)
- libwired/trunk/libwired/system/wi-log.c (modified) (2 diffs)
- libwired/trunk/libwired/system/wi-system.c (modified) (3 diffs)
- libwired/trunk/libwired/system/wi-system.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/base/wi-base.c
r4700 r5265 186 186 #pragma mark - 187 187 188 wi_string_t * wi_full_path(wi_string_t *path) {189 if(!path)190 return NULL;191 else if(!wi_root_path)192 return path;193 else if(wi_string_has_prefix(path, WI_STR("/")))194 return path;195 else if(wi_chrooted)196 return wi_string_with_format(WI_STR("/%@"), path);197 else198 return wi_string_with_format(WI_STR("%@/%@"), wi_root_path, path);199 }200 201 202 203 #pragma mark -204 205 188 wi_hash_code_t wi_hash_cstring(const char *s, wi_uinteger_t length) { 206 189 wi_hash_code_t hash = length; libwired/trunk/libwired/base/wi-base.h
r4645 r5265 206 206 WI_EXPORT void wi_crash(void); 207 207 208 209 WI_EXPORT wi_string_t *wi_root_path;210 211 208 #endif /* WI_BASE_H */ libwired/trunk/libwired/base/wi-private.h
r4774 r5265 170 170 WI_EXPORT void * wi_thread_poolstack(wi_thread_t *); 171 171 172 173 WI_EXPORT wi_boolean_t wi_chrooted;174 175 172 #endif /* WI_PRIVATE_H */ libwired/trunk/libwired/misc/wi-settings.c
r4853 r5265 47 47 #include <wired/wi-settings.h> 48 48 #include <wired/wi-string.h> 49 #include <wired/wi-system.h> 49 50 #include <wired/wi-regexp.h> 50 51 #include <wired/wi-runtime.h> … … 145 146 wi_file_t *file; 146 147 wi_string_t *path, *string; 147 wi_boolean_t result = true; 148 149 path = wi_full_path(wi_settings_config_path); 148 149 path = wi_path_relative_to_root(wi_settings_config_path); 150 150 file = wi_file_for_reading(path); 151 151 … … 167 167 settings->line++; 168 168 169 if(wi_string_length(string) > 0 && !wi_string_has_prefix(string, WI_STR("#"))) { 170 if(!_wi_settings_parse_setting(settings, string)) 171 result = false; 172 } 169 if(wi_string_length(string) > 0 && !wi_string_has_prefix(string, WI_STR("#"))) 170 _wi_settings_parse_setting(settings, string); 173 171 } 174 172 175 173 settings->file = NULL; 176 174 177 return result;175 return true; 178 176 } 179 177 … … 348 346 wi_release(*string); 349 347 350 if(wi_string_has_prefix(value, WI_STR("/"))) 351 *string = wi_retain(value); 352 else if(settings->chroot) 353 *string = wi_string_init_with_format(wi_string_alloc(), WI_STR("/%@"), value); 354 else 355 *string = wi_string_init_with_format(wi_string_alloc(), WI_STR("%@/%@"), wi_root_path, value); 356 357 wi_string_normalize_path(*string); 348 *string = wi_retain(wi_path_relative_to_root(value)); 358 349 359 350 return true; libwired/trunk/libwired/system/wi-log.c
r5148 r5265 52 52 #include <wired/wi-private.h> 53 53 #include <wired/wi-string.h> 54 #include <wired/wi-system.h> 54 55 55 56 #define _WI_LOG_DATE_SIZE 32 … … 189 190 190 191 if(wi_log_file && wi_log_path) { 191 path = wi_string_cstring(wi_ full_path(wi_log_path));192 path = wi_string_cstring(wi_path_relative_to_root(wi_log_path)); 192 193 193 194 fp = fopen(path, "a"); libwired/trunk/libwired/system/wi-system.c
r5004 r5265 56 56 #include <wired/wi-system.h> 57 57 58 wi_boolean_t wi_change_root(void) { 58 static wi_string_t *wi_root_path; 59 static wi_boolean_t wi_chrooted = false; 60 61 62 void wi_set_root_path(wi_string_t *path) { 63 wi_retain(path); 64 wi_release(wi_root_path); 65 66 wi_root_path = path; 67 } 68 69 70 71 wi_boolean_t wi_chroot_to_root_path(void) { 59 72 tzset(); 60 73 … … 75 88 76 89 90 91 wi_string_t * wi_path_relative_to_root(wi_string_t *path) { 92 if(path && wi_root_path && !wi_string_has_prefix(path, WI_STR("/"))) { 93 if(wi_chrooted) 94 path = wi_string_with_format(WI_STR("/%@"), path); 95 else 96 path = wi_string_with_format(WI_STR("%@/%@"), wi_root_path, path); 97 } 98 99 return wi_string_by_normalizing_path(path); 100 } 101 102 103 104 #pragma mark - 77 105 78 106 void wi_switch_user(uid_t uid, gid_t gid) { … … 83 111 gid_t egid; 84 112 85 path = wi_ full_path(wi_log_path);113 path = wi_path_relative_to_root(wi_log_path); 86 114 87 115 if(path) { libwired/trunk/libwired/system/wi-system.h
r5006 r5265 36 36 #include <wired/wi-base.h> 37 37 38 WI_EXPORT wi_boolean_t wi_change_root(void); 38 WI_EXPORT void wi_set_root_path(wi_string_t *); 39 WI_EXPORT wi_boolean_t wi_chroot_to_root_path(void); 40 WI_EXPORT wi_string_t * wi_path_relative_to_root(wi_string_t *); 39 41 40 42 WI_EXPORT void wi_switch_user(uid_t, gid_t);
