comparison cinst/nssstore_win.c @ 905:698b6a9bd75e

Fix coding style for C code astyle --style=gnu --indent=spaces=2
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 13 Aug 2014 15:49:47 +0200
parents 797aa8d9c785
children 427e2e18b8c8
comparison
equal deleted inserted replaced
904:f89b41fa7048 905:698b6a9bd75e
69 69
70 /**@def The registry key to look for user profile directories */ 70 /**@def The registry key to look for user profile directories */
71 #define PROFILE_LIST L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList" 71 #define PROFILE_LIST L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList"
72 #define RUNONCE_PATH L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce" 72 #define RUNONCE_PATH L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce"
73 73
74 struct profile_key_path { 74 struct profile_key_path
75 {
75 char *sid; 76 char *sid;
76 char *hive_path; 77 char *hive_path;
77 struct profile_key_path *next; 78 struct profile_key_path *next;
78 }; 79 };
79 80
116 { 117 {
117 PRINTLASTERROR ("Failed to create user level.\n"); 118 PRINTLASTERROR ("Failed to create user level.\n");
118 return NULL; 119 return NULL;
119 } 120 }
120 121
121 if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL)) 122 if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL))
122 { 123 {
123 SaferCloseLevel(user_level); 124 SaferCloseLevel(user_level);
124 return NULL; 125 return NULL;
125 } 126 }
126 127
127 return retval; 128 return retval;
128 } 129 }
129 130
130 /**@brief Write strv of instructions to a handle 131 /**@brief Write strv of instructions to a handle
131 * 132 *
132 * Writes the null terminated list of instructions to 133 * Writes the null terminated list of instructions to
225 http://www.sepago.de/e/holger/2010/07/20/how-long-can-a-registry-key-name-really-be 226 http://www.sepago.de/e/holger/2010/07/20/how-long-can-a-registry-key-name-really-be
226 the actual limit is 256 + \0 thus we create a buffer for 257 wchar_t's*/ 227 the actual limit is 256 + \0 thus we create a buffer for 257 wchar_t's*/
227 wchar_t key_name[257], 228 wchar_t key_name[257],
228 *current_user_sid = NULL; 229 *current_user_sid = NULL;
229 pkp_t *retval = NULL, 230 pkp_t *retval = NULL,
230 *cur_item = NULL; 231 *cur_item = NULL;
231 bool error = true; 232 bool error = true;
232 PSID current_user = NULL; 233 PSID current_user = NULL;
233 234
234 ret = RegOpenKeyExW (HKEY_LOCAL_MACHINE, PROFILE_LIST, 0, 235 ret = RegOpenKeyExW (HKEY_LOCAL_MACHINE, PROFILE_LIST, 0,
235 KEY_READ, &profile_list); 236 KEY_READ, &profile_list);
374 } 375 }
375 376
376 /* installdir + dirsep + quotes + process name + space + quotes + selection_file 377 /* installdir + dirsep + quotes + process name + space + quotes + selection_file
377 + NULL */ 378 + NULL */
378 cmd_line_len = wcslen (w_inst_dir) + 1 + 2 + wcslen (NSS_APP_NAME) + 379 cmd_line_len = wcslen (w_inst_dir) + 1 + 2 + wcslen (NSS_APP_NAME) +
379 + 1 + 2 + wcslen(selection_file) + 1; 380 + 1 + 2 + wcslen(selection_file) + 1;
380 retval = xmalloc (cmd_line_len * sizeof(wchar_t)); 381 retval = xmalloc (cmd_line_len * sizeof(wchar_t));
381 382
382 wcscpy_s (retval, cmd_line_len, L"\""); 383 wcscpy_s (retval, cmd_line_len, L"\"");
383 wcscat_s (retval, cmd_line_len, w_inst_dir); 384 wcscat_s (retval, cmd_line_len, w_inst_dir);
384 wcscat_s (retval, cmd_line_len, L"\\"); 385 wcscat_s (retval, cmd_line_len, L"\\");
506 */ 507 */
507 static void 508 static void
508 register_proccesses_for_others (wchar_t *selection_file) 509 register_proccesses_for_others (wchar_t *selection_file)
509 { 510 {
510 pkp_t *pkplist = locate_other_hives(), 511 pkp_t *pkplist = locate_other_hives(),
511 *cur = NULL; 512 *cur = NULL;
512 wchar_t *run_command = NULL; 513 wchar_t *run_command = NULL;
513 514
514 if (pkplist == NULL) 515 if (pkplist == NULL)
515 { 516 {
516 DEBUGPRINTF ("No hives found."); 517 DEBUGPRINTF ("No hives found.");
545 { 546 {
546 /* This is somewhat expected if the registry is not located 547 /* This is somewhat expected if the registry is not located
547 in the standard location or already loaded. Try to access 548 in the standard location or already loaded. Try to access
548 the loaded registry in that case*/ 549 the loaded registry in that case*/
549 wchar_t *user_key = NULL, 550 wchar_t *user_key = NULL,
550 *w_sid = NULL; 551 *w_sid = NULL;
551 size_t user_key_len = 0; 552 size_t user_key_len = 0;
552 553
553 SetLastError((DWORD)ret); 554 SetLastError((DWORD)ret);
554 PRINTLASTERROR ("Failed to load hive. Trying to access already loaded hive."); 555 PRINTLASTERROR ("Failed to load hive. Trying to access already loaded hive.");
555 556
815 goto done; 816 goto done;
816 } 817 }
817 818
818 /* Initialize a security descriptor */ 819 /* Initialize a security descriptor */
819 descriptor = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, 820 descriptor = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
820 SECURITY_DESCRIPTOR_MIN_LENGTH); 821 SECURITY_DESCRIPTOR_MIN_LENGTH);
821 if (descriptor == NULL) 822 if (descriptor == NULL)
822 { 823 {
823 PRINTLASTERROR("Failed to allocate descriptor."); 824 PRINTLASTERROR("Failed to allocate descriptor.");
824 goto done; 825 goto done;
825 } 826 }
890 */ 891 */
891 wchar_t * 892 wchar_t *
892 write_selection_file (char **to_install, char **to_remove) 893 write_selection_file (char **to_install, char **to_remove)
893 { 894 {
894 wchar_t *folder_name = NULL, 895 wchar_t *folder_name = NULL,
895 *path = NULL; 896 *path = NULL;
896 HRESULT result = E_FAIL; 897 HRESULT result = E_FAIL;
897 HANDLE hFile = NULL; 898 HANDLE hFile = NULL;
898 size_t path_len; 899 size_t path_len;
899 900
900 result = SHGetKnownFolderPath (&FOLDERID_ProgramData, /* Get program data dir */ 901 result = SHGetKnownFolderPath (&FOLDERID_ProgramData, /* Get program data dir */

http://wald.intevation.org/projects/trustbridge/