Mercurial > trustbridge
comparison cinst/nssstore_win.c @ 1010:1c1964c27b39 runafterinstall
(issue54) commit work in progress on start after installation
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 02 Sep 2014 14:25:40 +0200 |
parents | 1743895b39b8 |
children | fd85a02d771d |
comparison
equal
deleted
inserted
replaced
1004:7dff5c0c569c | 1010:1c1964c27b39 |
---|---|
37 process on login to make sure it is launched once in the | 37 process on login to make sure it is launched once in the |
38 security context of that user. | 38 security context of that user. |
39 */ | 39 */ |
40 | 40 |
41 #include <windows.h> | 41 #include <windows.h> |
42 #include <winsafer.h> | |
43 #include <sddl.h> | 42 #include <sddl.h> |
44 #include <stdio.h> | 43 #include <stdio.h> |
45 #include <stdbool.h> | 44 #include <stdbool.h> |
46 #include <userenv.h> | 45 #include <userenv.h> |
47 #include <io.h> | 46 #include <io.h> |
96 pkp_t_free (item->next); | 95 pkp_t_free (item->next); |
97 } | 96 } |
98 xfree (item); | 97 xfree (item); |
99 } | 98 } |
100 | 99 |
101 /** @brief get a restricted access token to execute nss process | |
102 * | |
103 * This function uses the Software Restriction API to obtain the | |
104 * access token for a process run als normal user. | |
105 * | |
106 * @returns A restricted handle or NULL on error. | |
107 */ | |
108 static HANDLE | |
109 get_restricted_token() | |
110 { | |
111 SAFER_LEVEL_HANDLE user_level = NULL; | |
112 HANDLE retval = NULL; | |
113 if (!SaferCreateLevel(SAFER_SCOPEID_USER, | |
114 SAFER_LEVELID_NORMALUSER, | |
115 SAFER_LEVEL_OPEN, &user_level, NULL)) | |
116 { | |
117 PRINTLASTERROR ("Failed to create user level.\n"); | |
118 return NULL; | |
119 } | |
120 | |
121 if (!SaferComputeTokenFromLevel(user_level, NULL, &retval, 0, NULL)) | |
122 { | |
123 SaferCloseLevel(user_level); | |
124 return NULL; | |
125 } | |
126 | |
127 return retval; | |
128 } | |
129 | 100 |
130 /**@brief Write strv of instructions to a handle | 101 /**@brief Write strv of instructions to a handle |
131 * | 102 * |
132 * Writes the null terminated list of instructions to | 103 * Writes the null terminated list of instructions to |
133 * the handle. | 104 * the handle. |