Changeset 8840
- Timestamp:
- 05/19/11 17:30:51 (2 years ago)
- Location:
- branches/windows-client/src/client/windows/client-service
- Files:
-
- 5 modified
-
cert.c (modified) (6 diffs)
-
config.c (modified) (11 diffs)
-
config.h (modified) (1 diff)
-
service-main.c (modified) (8 diffs)
-
user-cache.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/windows-client/src/client/windows/client-service/cert.c
r8839 r8840 228 228 } 229 229 230 /* get user profile directory */231 static unsigned int get_ profile_dir(char *userid,232 char *profile_dir)233 { 234 LPUSER_INFO_ 4user_info;230 /* get user home directory */ 231 static unsigned int get_home_dir(char *userid, 232 char *home_dir) 233 { 234 LPUSER_INFO_11 user_info; 235 235 LPWSTR wuserid; 236 236 int ret; … … 243 243 244 244 /* get user information */ 245 ret = NetUserGetInfo(NULL, wuserid, 4, (LPBYTE *) &user_info);245 ret = NetUserGetInfo(NULL, wuserid, 11, (LPBYTE *) &user_info); 246 246 247 247 if (ret == 0) 248 248 { 249 mbstr = convert_wstring(user_info->usri 4_profile);249 mbstr = convert_wstring(user_info->usri11_home_dir); 250 250 if (mbstr == NULL) 251 251 { … … 254 254 } 255 255 256 strncpy(profile_dir, mbstr, MAX_PATH); 257 258 free(mbstr); 256 strncpy(home_dir, mbstr, MAX_PATH); 257 258 if (mbstr != NULL) 259 free(mbstr); 259 260 260 261 NetApiBufferFree(user_info); … … 294 295 295 296 /* locate the certificates and CA */ 296 if ( goptions->cert_dir_prefix != NULL)297 if (strlen(goptions->cert_dir_prefix) > 0) 297 298 { 298 299 if ((strlen(goptions->cert_dir_prefix) + strlen(userid) + 8) > MAX_PATH) … … 309 310 { 310 311 /* get profile directory */ 311 ret = get_ profile_dir(userid, cert_dir);312 ret = get_home_dir(userid, cert_dir); 312 313 if (ret != 0) 313 314 { … … 328 329 329 330 strcpy(cert_pattern, cert_dir); 330 strcat(cert_pattern, " cert.*");331 strcat(cert_pattern, "\\cert.*"); 331 332 h_find = FindFirstFile(cert_pattern, &find_data); 332 333 if (h_find == INVALID_HANDLE_VALUE) -
branches/windows-client/src/client/windows/client-service/config.c
r8839 r8840 14 14 extern struct qhash_table user_cache; 15 15 16 FILE *open_config_file() 16 static FILE *open_config_file(char *error_msg, 17 unsigned int error_msg_len) 17 18 { 18 19 FILE *f = NULL; 19 char *file_name , exe_path[MAX_PATH], *p;20 char *file_name = NULL, exe_path[MAX_PATH], *p; 20 21 DWORD ret = 0, malloc_flag = FALSE; 21 22 … … 41 42 { 42 43 ret = GetLastError(); 43 fprintf(stderr, "GetModuleFileName failed: %u\n", ret);44 _snprintf(error_msg, error_msg_len, "GetModuleFileName failed: %u\n", ret); 44 45 } 45 46 } … … 50 51 51 52 if (f == NULL) 52 fprintf(stderr, "Fatal: could not open file %s\n",53 _snprintf(error_msg, error_msg_len, "Fatal: could not open configuration file %s\n", 53 54 file_name == NULL ? "(null)" : file_name); 54 55 … … 59 60 } 60 61 61 void close_config_file(FILE *f)62 static void close_config_file(FILE *f) 62 63 { 63 64 fclose(f); … … 145 146 } 146 147 147 int get_config(PORANGEFS_OPTIONS options) 148 int get_config(PORANGEFS_OPTIONS options, 149 char *error_msg, 150 unsigned int error_msg_len) 148 151 { 149 152 FILE *config_file; 150 153 char line[256], copy[256], *token; 151 152 config_file = open_config_file(); 154 int ret = 0; 155 156 config_file = open_config_file(error_msg, error_msg_len); 153 157 if (config_file == NULL) 154 158 /* config file is required */ … … 204 208 if (token == NULL) 205 209 { 206 fprintf(stderr, "user-mode option must be list, certificate, or ldap\n");207 close_config_file(config_file);208 return 1;210 _snprintf(error_msg, error_msg_len, "user-mode option must be list, certificate, or ldap\n"); 211 ret = 1; 212 goto get_config_exit; 209 213 } 210 214 if (!stricmp(token, "list")) … … 222 226 else 223 227 { 224 fprintf(stderr, "user-mode option must be list, certificate, or ldap\n");225 close_config_file(config_file);226 return 1;228 _snprintf(error_msg, error_msg_len, "user-mode option must be list, certificate, or ldap\n"); 229 ret = 1; 230 goto get_config_exit; 227 231 } 228 232 } … … 231 235 if (options->user_mode == USER_MODE_NONE) 232 236 { 233 fprintf(stderr, "user option: specify 'user-mode list' above user option\n");234 close_config_file(config_file);235 return 1;237 _snprintf(error_msg, error_msg_len, "user option: specify 'user-mode list' above user option\n"); 238 ret = 1; 239 goto get_config_exit; 236 240 } 237 241 else if (options->user_mode != USER_MODE_LIST) 238 242 { 239 fprintf(stderr, "user option: not legal with current user mode\n");240 close_config_file(config_file);241 return 1;243 _snprintf(error_msg, error_msg_len, "user option: not legal with current user mode\n"); 244 ret = 1; 245 goto get_config_exit; 242 246 } 243 247 244 248 if (parse_user() != 0) 245 249 { 246 fprintf(stderr, "user option: parse error\n");247 close_config_file(config_file);248 return 1;250 _snprintf(error_msg, error_msg_len, "user option: parse error\n"); 251 ret = 1; 252 goto get_config_exit; 249 253 } 250 254 } … … 260 264 else 261 265 { 262 fprintf(stderr, "cert-dir-prefix option: parse error\n"); 266 _snprintf(error_msg, error_msg_len, "cert-dir-prefix option: parse error\n"); 267 ret = 1; 268 goto get_config_exit; 263 269 } 264 270 } … … 272 278 else 273 279 { 274 fprintf(stderr, "ca-path option: parse error\n"); 280 _snprintf(error_msg, error_msg_len, "ca-path option: parse error\n"); 281 ret = 1; 282 goto get_config_exit; 275 283 } 276 284 } … … 280 288 } 281 289 else 282 fprintf(stderr, "Unknown option %s\n", token); 283 } 284 } 290 _snprintf(error_msg, error_msg_len, "Unknown option %s\n", token); 291 } 292 } 293 294 if (options->user_mode == USER_MODE_NONE) 295 { 296 _snprintf(error_msg, error_msg_len, "Must specify user-mode (list, certificate or ldap)\n"); 297 ret = 1; 298 goto get_config_exit; 299 } 300 301 if (options->user_mode == USER_MODE_CERT && 302 strlen(options->ca_path) == 0) 303 { 304 _snprintf(error_msg, error_msg_len, "Must specify ca-path with certificate mode\n"); 305 ret = 1; 306 } 307 308 get_config_exit: 285 309 286 310 close_config_file(config_file); 287 311 288 if (options->user_mode == USER_MODE_NONE) 289 { 290 fprintf(stderr, "Must specify user-mode (list, certificate or ldap)\n"); 291 return 1; 292 } 293 294 return 0; 312 return ret; 295 313 } -
branches/windows-client/src/client/windows/client-service/config.h
r8718 r8840 7 7 #include "client-service.h" 8 8 9 int get_config(PORANGEFS_OPTIONS options); 9 int get_config(PORANGEFS_OPTIONS options, 10 char *error_msg, 11 unsigned int error_msg_len); 10 12 11 13 #endif -
branches/windows-client/src/client/windows/client-service/service-main.c
r8839 r8840 301 301 PORANGEFS_OPTIONS options; 302 302 int ret; 303 char error_msg[512]; 303 304 304 305 /* allocate options */ … … 314 315 315 316 /* read from config file */ 316 ret = get_config(options );317 ret = get_config(options, error_msg, 512); 317 318 318 319 /* point global options */ … … 329 330 if (ret != 0) 330 331 { 331 service_debug("Could not parse config file: check user options\n"); 332 service_debug(error_msg); 333 service_debug("Could not parse config file: exiting\n"); 332 334 close_service_log(); 333 335 return; … … 543 545 DWORD err = 0; 544 546 char mount_point[256]; 547 char error_msg[512]; 545 548 546 549 SERVICE_TABLE_ENTRY dispatch_table[2] = … … 602 605 603 606 /* get options from config file */ 604 if (get_config(options) != 0) 605 return 1; 607 if (get_config(options, error_msg, 512) != 0) 608 { 609 fprintf(stderr, error_msg); 610 err = 1; 611 goto main_exit; 612 } 606 613 607 614 /* point goptions */ … … 623 630 { 624 631 fprintf(stderr, "Drive already in use\n"); 625 return -1; 632 err = 1; 633 goto main_exit; 626 634 } 627 635 … … 631 639 { 632 640 fprintf(stderr, "User cache thread did not start: %u\n", err); 633 free(options); 634 return err; 641 goto main_exit; 635 642 } 636 643 … … 646 653 cache_thread_stop(); 647 654 655 main_exit: 656 648 657 qhash_destroy_and_finalize(user_cache, struct user_entry, hash_link, free); 649 658 -
branches/windows-client/src/client/windows/client-service/user-cache.c
r8839 r8840 135 135 { 136 136 head = qhash_search_at_index(user_cache, i); 137 qhash_for_each_safe(link, temp, head) 138 { 139 entry = qhash_entry(link, struct user_entry, hash_link); 140 if (entry->expires != 0 && entry->expires < now) 141 { 142 DbgPrint("user_cache_thread: removing %s\n", entry->user_name); 143 qhash_del(link); 144 free(entry); 137 if (head != NULL) 138 { 139 qhash_for_each_safe(link, temp, head) 140 { 141 entry = qhash_entry(link, struct user_entry, hash_link); 142 if (entry->expires != 0 && entry->expires < now) 143 { 144 DbgPrint("user_cache_thread: removing %s\n", entry->user_name); 145 qhash_del(link); 146 free(entry); 147 } 145 148 } 146 149 }
