Mercurial > trustbridge
comparison cinst/nssstore_win.c @ 369:78eec57bc133
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 15 Apr 2014 09:44:54 +0200 |
parents | d10d9bc2e84f |
children | cbd0c1c20b30 |
comparison
equal
deleted
inserted
replaced
368:f9c98f9e9f76 | 369:78eec57bc133 |
---|---|
156 */ | 156 */ |
157 | 157 |
158 cmd_line_len = wcslen (lpApplicationName) + wcslen(selection_file) + 1; | 158 cmd_line_len = wcslen (lpApplicationName) + wcslen(selection_file) + 1; |
159 lpCommandLine = xmalloc (cmd_line_len * sizeof(wchar_t)); | 159 lpCommandLine = xmalloc (cmd_line_len * sizeof(wchar_t)); |
160 | 160 |
161 wcscpy (lpCommandLine, lpApplicationName); | 161 wcscpy_s (lpCommandLine, cmd_line_len, lpApplicationName); |
162 wcscat (lpCommandLine, selection_file); | 162 wcscat_s (lpCommandLine, cmd_line_len, selection_file); |
163 | 163 |
164 success = CreateProcessAsUserW (hToken, | 164 success = CreateProcessAsUserW (hToken, |
165 lpApplicationName, | 165 lpApplicationName, |
166 lpCommandLine, /* Commandline */ | 166 lpCommandLine, /* Commandline */ |
167 NULL, /* Process attributes. Take hToken */ | 167 NULL, /* Process attributes. Take hToken */ |
199 /**@brief Create a directory with restricted access rights | 199 /**@brief Create a directory with restricted access rights |
200 * | 200 * |
201 * This creates a security attributes structure that restricts | 201 * This creates a security attributes structure that restricts |
202 * write access to the Administrators group but allows everyone to read files | 202 * write access to the Administrators group but allows everyone to read files |
203 * in that directory. | 203 * in that directory. |
204 * Basically a very complicated vetrsion of mkdir path -m 604 | 204 * Basically a very complicated version of mkdir path -m 644 |
205 * | 205 * |
206 * If the directory exists the permissions of that directory are checked if | 206 * If the directory exists the permissions of that directory are checked if |
207 * they are acceptable and true or false is returned accordingly. | 207 * they are acceptable and true or false is returned accordingly. |
208 * | 208 * |
209 * Code based on msdn example: | 209 * Code based on msdn example: |
363 if (!elevated) | 363 if (!elevated) |
364 { | 364 { |
365 /* TODO */ | 365 /* TODO */ |
366 } | 366 } |
367 | 367 |
368 #if 0 | 368 result = SHGetKnownFolderPath (&FOLDERID_ProgramData, /* Get program data dir */ |
369 result = SHGetKnownFolderPath (FOLDERID_ProgramData, /* Get program data dir */ | |
370 KF_FLAG_CREATE | /* Create if it does not exist */ | 369 KF_FLAG_CREATE | /* Create if it does not exist */ |
371 KF_FLAG_INIT, /* Initialize it if created */ | 370 KF_FLAG_INIT, /* Initialize it if created */ |
372 -1, /* Get it for the default user */ | 371 INVALID_HANDLE_VALUE, /* Get it for the default user */ |
373 &folder_name); | 372 &folder_name); |
374 #endif | |
375 /* TODO figure out how to do this with mingw */ | |
376 result = S_OK; | |
377 folder_name = L"C:\\ProgramData"; | |
378 | 373 |
379 if (result != S_OK) | 374 if (result != S_OK) |
380 { | 375 { |
381 PRINTLASTERROR ("Failed to get folder path"); | 376 PRINTLASTERROR ("Failed to get folder path"); |
382 return NULL; | 377 return NULL; |
392 ERRORPRINTF ("Path too long.\n"); | 387 ERRORPRINTF ("Path too long.\n"); |
393 return NULL; | 388 return NULL; |
394 } | 389 } |
395 | 390 |
396 path = xmalloc (path_len * sizeof (wchar_t)); | 391 path = xmalloc (path_len * sizeof (wchar_t)); |
397 if (wcscpy (path, folder_name) != 0) | 392 if (wcscpy_s (path, path_len, folder_name) != 0) |
398 { | 393 { |
399 ERRORPRINTF ("Failed to copy folder name.\n"); | 394 ERRORPRINTF ("Failed to copy folder name.\n"); |
400 #if 0 | 395 |
401 CoTaskMemFree (folder_name); | 396 CoTaskMemFree (folder_name); |
402 #endif | 397 |
403 return NULL; | 398 return NULL; |
404 } | 399 } |
405 | 400 |
406 #if 0 | 401 #if 0 |
407 CoTaskMemFree (folder_name); | 402 CoTaskMemFree (folder_name); |
408 #endif | 403 #endif |
409 | 404 |
410 if (wcscat (path, L"\\") != 0) | 405 if (wcscat_s (path, path_len, L"\\") != 0) |
411 { | 406 { |
412 ERRORPRINTF ("Failed to cat dirsep.\n"); | 407 ERRORPRINTF ("Failed to cat dirsep.\n"); |
413 xfree(path); | 408 xfree(path); |
414 return NULL; | 409 return NULL; |
415 } | 410 } |
416 | 411 |
417 if (wcscat (path, APPNAME) != 0) | 412 if (wcscat_s (path, path_len, APPNAME) != 0) |
418 { | 413 { |
419 ERRORPRINTF ("Failed to cat appname.\n"); | 414 ERRORPRINTF ("Failed to cat appname.\n"); |
420 xfree(path); | 415 xfree(path); |
421 return NULL; | 416 return NULL; |
422 } | 417 } |
430 ERRORPRINTF ("Failed to create directory\n"); | 425 ERRORPRINTF ("Failed to create directory\n"); |
431 xfree(path); | 426 xfree(path); |
432 return NULL; | 427 return NULL; |
433 } | 428 } |
434 | 429 |
435 if (wcscat (path, L"\\") != 0) | 430 if (wcscat_s (path, path_len, L"\\") != 0) |
436 { | 431 { |
437 ERRORPRINTF ("Failed to cat dirsep.\n"); | 432 ERRORPRINTF ("Failed to cat dirsep.\n"); |
438 xfree(path); | 433 xfree(path); |
439 return NULL; | 434 return NULL; |
440 } | 435 } |
441 | 436 |
442 if (wcscat (path, SELECTION_FILE_NAME) != 0) | 437 if (wcscat_s (path, path_len, SELECTION_FILE_NAME) != 0) |
443 { | 438 { |
444 ERRORPRINTF ("Failed to cat filename.\n"); | 439 ERRORPRINTF ("Failed to cat filename.\n"); |
445 xfree(path); | 440 xfree(path); |
446 return NULL; | 441 return NULL; |
447 } | 442 } |