Changeset 6157
- Timestamp:
- 09/25/08 15:33:11 (4 months ago)
- Files:
-
- branches/P7/wired/wired/main.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/P7/wired/wired/main.c
r6150 r6157 89 89 wi_array_t *arguments; 90 90 wi_pool_t *pool; 91 wi_string_t *string, *root_path ;91 wi_string_t *string, *root_path, *user, *group; 92 92 const char **xargv; 93 93 uint32_t uid, gid; 94 94 int ch, facility; 95 wi_boolean_t test_config, daemonize ;95 wi_boolean_t test_config, daemonize, change_directory, switch_user; 96 96 97 97 wi_initialize(); … … 111 111 test_config = false; 112 112 daemonize = true; 113 change_directory = true; 114 switch_user = true; 113 115 wi_settings_config_path = wi_string_init_with_cstring(wi_string_alloc(), WD_CONFIG_PATH); 114 116 wd_config_path = wi_string_init_with_cstring(wi_string_alloc(), WD_CONFIG_PATH); … … 116 118 root_path = WI_STR(WD_ROOT); 117 119 118 while((ch = getopt(argc, (char * const *) argv, "46Dd:f:hi:L:ls:tuVvX ")) != -1) {120 while((ch = getopt(argc, (char * const *) argv, "46Dd:f:hi:L:ls:tuVvXx")) != -1) { 119 121 switch(ch) { 120 122 case '4': … … 186 188 daemonize = false; 187 189 break; 188 190 191 case 'x': 192 daemonize = false; 193 change_directory = false; 194 switch_user = false; 195 break; 196 189 197 case '?': 190 198 case 'h': … … 224 232 wi_release(arguments); 225 233 226 if(!wi_chdir(root_path)) 227 wi_log_err(WI_STR("Could not change directory to %@: %m"), root_path); 234 if(change_directory) { 235 if(!wi_fs_change_directory(root_path)) 236 wi_log_err(WI_STR("Could not change directory to %@: %m"), root_path); 237 } 228 238 229 239 wi_log_open(); … … 257 267 wi_log_info(WI_STR("Starting Wired version %s (%u)"), WD_VERSION, WI_REVISION); 258 268 259 uid = wi_config_uid_for_name(wd_config, WI_STR("user")); 260 gid = wi_config_uid_for_name(wd_config, WI_STR("group")); 261 262 wi_switch_user(uid, gid); 269 if(switch_user) { 270 uid = wi_config_uid_for_name(wd_config, WI_STR("user")); 271 gid = wi_config_uid_for_name(wd_config, WI_STR("group")); 272 273 wi_switch_user(uid, gid); 274 } 275 276 user = wi_user_name(); 277 group = wi_group_name(); 278 279 if(user && group) { 280 wi_log_info(WI_STR("Operating as user %@ (%d), group %@ (%d)"), 281 user, wi_user_id(), group, wi_group_id()); 282 } else { 283 wi_log_info(WI_STR("Operating as user %d, group %d"), 284 wi_user_id(), wi_group_id()); 285 } 286 263 287 wd_signals_init(); 264 288 wd_block_signals();
