Changeset 8823
- Timestamp:
- 05/03/11 10:54:48 (2 years ago)
- Location:
- branches/windows-client
- Files:
-
- 5 modified
-
projects/OrangeFS/client-service/client-service.vcxproj (modified) (1 diff)
-
src/client/windows/client-service/cert.c (modified) (5 diffs)
-
src/client/windows/client-service/client-service.h (modified) (1 diff)
-
src/client/windows/client-service/config.c (modified) (4 diffs)
-
src/client/windows/client-service/dokan-interface.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/windows-client/projects/OrangeFS/client-service/client-service.vcxproj
r8819 r8823 27 27 </ItemGroup> 28 28 <ItemGroup> 29 <ClInclude Include="..\..\..\src\client\windows\client-service\cert.h" /> 29 30 <ClInclude Include="..\..\..\src\client\windows\client-service\client-service.h" /> 30 31 <ClInclude Include="..\..\..\src\client\windows\client-service\config.h" /> -
branches/windows-client/src/client/windows/client-service/cert.c
r8822 r8823 3 3 4 4 #include <Windows.h> 5 #include <LM.h> 5 6 #include <stdio.h> 6 7 … … 12 13 #include <openssl/x509_vfy.h> 13 14 15 #include "pvfs2.h" 16 17 extern char *convert_wstring(const wchar_t *); 18 extern wchar_t *convert_mbstring(const char *); 19 14 20 /* initialize OpenSSL */ 15 21 static void openssl_init() 16 22 { 23 SSL_library_init(); 17 24 SSL_load_error_strings(); 18 25 ERR_load_BIO_strings(); … … 29 36 30 37 /* load certificate from file (PEM format) */ 31 static unsigned long load_cert_from_file(char *path, X509 **cert) 38 static unsigned long load_cert_from_file(char *path, 39 X509 **cert) 32 40 { 33 41 FILE *f; … … 48 56 49 57 /* verify certificate */ 50 static unsigned long verify_cert(X509 *cert, X509 *ca_cert) 58 static unsigned long verify_cert(X509 *cert, 59 X509 *ca_cert) 51 60 { 52 61 X509_STORE *trust_store; … … 93 102 return err; 94 103 } 104 105 /* get user profile directory */ 106 static unsigned int get_profile_dir(char *userid, 107 char *profile_dir) 108 { 109 USER_INFO_4 user_info; 110 LPCWSTR wuserid; 111 int ret; 112 char *mbstr; 113 114 /* convert to unicode */ 115 wuserid = convert_mbstring(userid); 116 if (wuserid == NULL) 117 return -1; 118 119 /* get user information */ 120 ret = NetUserGetInfo(NULL, wuserid, 4, &user_info); 121 122 if (ret == 0) 123 { 124 mbstr = convert_wstring(user_info.usri4_profile); 125 if (mbstr == NULL) 126 { 127 free(wuserid); 128 return -1; 129 } 130 131 strcpy(profile_dir, mbstr); 132 133 free(mbstr); 134 } 135 136 free(wuserid); 137 138 return ret; 139 } 140 141 /* retrieve OrangeFS credentials from cert */ 142 static unsigned int get_cert_credentials(char *userid, 143 char *cert_dir_prefix, 144 char *ca_path, 145 PVFS_credentials *credentials) 146 { 147 char cert_path[MAX_PATH]; 148 char *temp; 149 X509 *cert, *ca_cert; 150 int ret; 151 152 if (userid == NULL || credentials == NULL || 153 ca_path) 154 return -1; 155 156 /* checked for cached credentials */ 157 ret = get_cached_credentials(userid, credentials); 158 if (ret == 0) 159 { 160 /* cache hit */ 161 return 0; 162 } 163 else if (ret != 1) 164 { 165 /* error */ 166 return ret; 167 } 168 169 /* credentials not in cache... */ 170 171 /* locate the certificate and CA */ 172 if (cert_dir_prefix != NULL) 173 { 174 if ((strlen(cert_dir_prefix) + strlen(userid) + 10) > MAX_PATH) 175 { 176 DbgPrint("User %s: path to cert too long\n", userid); 177 return -1; 178 } 179 180 /* cert file is cert.pem in directory of user name */ 181 strcpy(cert_path, cert_dir_prefix); 182 strcat(cert_path, userid); 183 strcat(cert_path, "\\cert.pem"); 184 } 185 else 186 { 187 /* get profile directory */ 188 ret = get_profile_dir(userid, cert_path); 189 if (ret != 0) 190 { 191 DbgPrint("User %s: could not locate profile dir: %d\n", userid, 192 ret); 193 return ret; 194 } 195 196 if (strlen(cert_path) + 9 >= MAX_PATH) 197 { 198 DbgPrint("User %s: profile dir too long\n", userid); 199 return -1; 200 } 201 202 strcat(cert_path, "\\cert.pem"); 203 } 204 205 /* verify the certificate */ 206 ret = load_cert_from_file(cert_path, &cert); 207 if (ret != 0) 208 return ret; 209 210 ret = load_cert_from_file(ca_path, &ca_cert); 211 if (ret != 0) 212 { 213 X509_free(cert); 214 return ret; 215 } 216 217 /* read and cache credentials from certificate */ 218 219 } -
branches/windows-client/src/client/windows/client-service/client-service.h
r8782 r8823 10 10 { 11 11 char mount_point[MAX_PATH]; 12 char cert_dir_prefix[MAX_PATH]; 13 char ca_path[MAX_PATH]; 12 14 int threads; 13 15 int debug; -
branches/windows-client/src/client/windows/client-service/config.c
r8819 r8823 32 32 file_name = (char *) malloc(MAX_PATH); 33 33 malloc_flag = TRUE; 34 str cpy(file_name, exe_path);34 strncpy(file_name, exe_path, MAX_PATH-14); 35 35 strcat(file_name, "\\orangefs.cfg"); 36 36 … … 172 172 continue; 173 173 174 if (!stricmp(token, "-mount") || 175 !stricmp(token, "mount")) 174 if (!stricmp(token, "mount")) 176 175 { 177 176 /* copy the remaining portion of the line … … 186 185 strncpy(options->mount_point, token, MAX_PATH); 187 186 } 188 else if (!stricmp(token, "-threads") || 189 !stricmp(token, "threads")) 187 else if (!stricmp(token, "threads")) 190 188 { 191 189 /* … … 198 196 options->threads = atoi(token); 199 197 } 200 else if (!stricmp(token, "-user") || 201 !stricmp(token, "user")) 198 else if (!stricmp(token, "user")) 202 199 { 203 200 if (parse_user() != 0) 204 201 { 205 fprintf(stderr, " -user option: parse error\n");202 fprintf(stderr, "user option: parse error\n"); 206 203 close_config_file(config_file); 207 204 return 1; 208 205 } 209 206 } 210 else if (!stricmp(token, "-debug") || 211 !stricmp(token, "debug")) 207 else if (!stricmp(token, "cert-dir-prefix")) 208 { 209 if (strlen(line) > 16) 210 { 211 strncpy(options->cert_dir_prefix, line + 16, MAX_PATH-2); 212 options->cert_dir_prefix[MAX_PATH-2] = '\0'; 213 if (options->cert_dir_prefix[strlen(options->cert_dir_prefix)-1] != '\\') 214 strcat(options->cert_dir_prefix, "\\"); 215 } 216 else 217 { 218 fprintf(stderr, "cert-dir-prefix option: parse error\n"); 219 } 220 } 221 else if (!stricmp(token, "ca-path")) 222 { 223 if (strlen(line) > 8) 224 { 225 strncpy(options->ca_path, line + 8, MAX_PATH-2); 226 options->ca_path[MAX_PATH-2] = '\0'; 227 if (options->ca_path[strlen(options->ca_path)-1] != '\\') 228 strcat(options->ca_path, "\\"); 229 } 230 else 231 { 232 fprintf(stderr, "ca-path option: parse error\n"); 233 } 234 } 235 else if (!stricmp(token, "debug")) 212 236 { 213 237 options->debug = TRUE; -
branches/windows-client/src/client/windows/client-service/dokan-interface.c
r8819 r8823 413 413 err = GetLastError(); 414 414 DbgPrint(" LookupAccountSid failed: %u\n", err); 415 return err * -1; 415 416 } 416 417
