| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright(c) 2018-2025, Stefan Meislinger | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include "gate/system/accounts.h" | ||
| 30 | #include "gate/results.h" | ||
| 31 | #include "gate/debugging.h" | ||
| 32 | |||
| 33 | #if defined(GATE_SYS_WIN) && !defined(GATE_SYS_WINCE) && !defined(GATE_SYS_WIN16) | ||
| 34 | # define GATE_SYSTEM_ACCOUNTS_WINLM | ||
| 35 | #elif defined(GATE_SYS_POSIX) | ||
| 36 | # define GATE_SYSTEM_ACCOUNTS_POSIX | ||
| 37 | #else | ||
| 38 | # define GATE_SYSTEM_ACCOUNTS_NOIMPL | ||
| 39 | #endif | ||
| 40 | |||
| 41 | |||
| 42 | #if defined(GATE_SYSTEM_ACCOUNTS_WINLM) | ||
| 43 | |||
| 44 | #include "gate/system/platform/netapi_tools.h" | ||
| 45 | |||
| 46 | #ifndef MAX_PREFERRED_LENGTH | ||
| 47 | #define MAX_PREFERRED_LENGTH ((DWORD) -1) | ||
| 48 | #endif | ||
| 49 | |||
| 50 | |||
| 51 | static WCHAR const* gate_account_get_local_computer(WCHAR* buffer, gate_size_t buffer_length) | ||
| 52 | { | ||
| 53 | WCHAR const* ret = NULL; | ||
| 54 | TCHAR computer_name[32]; | ||
| 55 | DWORD computer_name_len = sizeof(computer_name) / sizeof(computer_name[0]); | ||
| 56 | gate_int32_t error_code; | ||
| 57 | |||
| 58 | do | ||
| 59 | { | ||
| 60 | if (buffer_length < 4) | ||
| 61 | { | ||
| 62 | GATE_DEBUG_TRACE_MSG_VALUE("gate_account_get_local_computer() buffer too small", buffer_length); | ||
| 63 | break; | ||
| 64 | } | ||
| 65 | |||
| 66 | if (!GetComputerName(computer_name, &computer_name_len)) | ||
| 67 | { | ||
| 68 | error_code = gate_platform_get_last_error(); | ||
| 69 | GATE_DEBUG_TRACE_MSG_VALUE("gate_account_get_local_computer::GetComputerName() failed", error_code); | ||
| 70 | break; | ||
| 71 | } | ||
| 72 | |||
| 73 | buffer[0] = L'\\'; | ||
| 74 | buffer[1] = L'\\'; | ||
| 75 | gate_win32_winstr_2_utf16(computer_name, computer_name_len, &buffer[2], | ||
| 76 | buffer_length - 2); | ||
| 77 | ret = buffer; | ||
| 78 | } while (0); | ||
| 79 | return ret; | ||
| 80 | } | ||
| 81 | |||
| 82 | static gate_win32_sidstruct_t* gate_account_get_computer_sid(LPCWSTR ptr_system_name, gate_win32_sidstruct_t* ptr_sid) | ||
| 83 | { | ||
| 84 | gate_win32_sidstruct_t* ret = NULL; | ||
| 85 | DWORD net_status; | ||
| 86 | GATE_USER_MODALS_INFO_2* ptr_computer_info = NULL; | ||
| 87 | |||
| 88 | net_status = win32_netapi.NetUserModalsGet(ptr_system_name, 2, (LPBYTE*)&ptr_computer_info); | ||
| 89 | if (net_status == 0) | ||
| 90 | { | ||
| 91 | gate_win32_sid_export(ptr_computer_info->usrmod2_domain_id, ptr_sid); | ||
| 92 | win32_netapi.NetApiBufferFree(ptr_computer_info); | ||
| 93 | ret = ptr_sid; | ||
| 94 | } | ||
| 95 | return ret; | ||
| 96 | } | ||
| 97 | |||
| 98 | #define GATE_ACCOUNTS_MAX_SYSTEM_NAME 34 | ||
| 99 | |||
| 100 | static void gate_account_make_user(gate_account_user_t* user_account, gate_win32_sidstruct_t const* sid, | ||
| 101 | LPCWSTR name, LPCWSTR info, LPCWSTR descr, DWORD flags) | ||
| 102 | { | ||
| 103 | gate_mem_clear(user_account, sizeof(gate_account_user_t)); | ||
| 104 | |||
| 105 | if (sid) | ||
| 106 | { | ||
| 107 | gate_win32_sid_print(sid, user_account->id, sizeof(user_account->id)); | ||
| 108 | user_account->short_id = sid->SubAuthorities[sid->SubAuthCount - 1]; | ||
| 109 | } | ||
| 110 | gate_str_utf16_2_utf8(name, gate_str16_length(name), user_account->name, sizeof(user_account->name)); | ||
| 111 | gate_str_utf16_2_utf8(info, gate_str16_length(info), user_account->info, sizeof(user_account->info)); | ||
| 112 | gate_str_utf16_2_utf8(descr, gate_str16_length(descr), user_account->description, sizeof(user_account->description)); | ||
| 113 | if (GATE_FLAG_ENABLED(flags, UF_ACCOUNTDISABLE)) | ||
| 114 | { | ||
| 115 | user_account->flags |= GATE_ACCOUNT_USER_FLAG_DISABLED; | ||
| 116 | } | ||
| 117 | if (GATE_FLAG_ENABLED(flags, UF_LOCKOUT)) | ||
| 118 | { | ||
| 119 | user_account->flags |= GATE_ACCOUNT_USER_FLAG_LOCKED; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | static void gate_account_make_group(gate_account_group_t* group_account, gate_win32_sidstruct_t const* sid, | ||
| 123 | LPCWSTR name, LPCWSTR descr, DWORD flags) | ||
| 124 | { | ||
| 125 | GATE_UNUSED_ARG(flags); | ||
| 126 | gate_mem_clear(group_account, sizeof(gate_account_group_t)); | ||
| 127 | |||
| 128 | if (sid) | ||
| 129 | { | ||
| 130 | gate_win32_sid_print(sid, group_account->id, sizeof(group_account->id)); | ||
| 131 | group_account->short_id = sid->SubAuthorities[sid->SubAuthCount - 1]; | ||
| 132 | } | ||
| 133 | gate_str_utf16_2_utf8(name, gate_str16_length(name), group_account->name, sizeof(group_account->name)); | ||
| 134 | gate_str_utf16_2_utf8(descr, gate_str16_length(descr), group_account->description, sizeof(group_account->description)); | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | gate_result_t gate_account_enum_users(gate_account_enum_users_callback_t callback, void* param) | ||
| 139 | { | ||
| 140 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 141 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 142 | WCHAR const* ptr_system_name = NULL; | ||
| 143 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 144 | gate_win32_sidstruct_t* ptr_sid = NULL; | ||
| 145 | DWORD net_status; | ||
| 146 | DWORD next_info_index = 0; | ||
| 147 | PVOID info_buffer = NULL; | ||
| 148 | DWORD infos_returned; | ||
| 149 | GATE_NET_DISPLAY_USER* ptr_user; | ||
| 150 | gate_account_user_t user_account; | ||
| 151 | gate_bool_t continue_enum = true; | ||
| 152 | |||
| 153 | do | ||
| 154 | { | ||
| 155 | if (!load_netapi() || (NULL == win32_netapi.NetQueryDisplayInformation)) | ||
| 156 | { | ||
| 157 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 158 | break; | ||
| 159 | } | ||
| 160 | |||
| 161 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 162 | |||
| 163 | if (gate_account_get_computer_sid(ptr_system_name, &sid)) | ||
| 164 | { | ||
| 165 | sid.SubAuthorities[sid.SubAuthCount] = 0; | ||
| 166 | ++sid.SubAuthCount; | ||
| 167 | ptr_sid = &sid; | ||
| 168 | } | ||
| 169 | |||
| 170 | ret = GATE_RESULT_OK; | ||
| 171 | do | ||
| 172 | { | ||
| 173 | net_status = win32_netapi.NetQueryDisplayInformation( | ||
| 174 | ptr_system_name, 1, next_info_index, 32, MAX_PREFERRED_LENGTH, &infos_returned, &info_buffer); | ||
| 175 | if ((ERROR_MORE_DATA != net_status) && (ERROR_SUCCESS != net_status)) | ||
| 176 | { | ||
| 177 | ret = GATE_RESULT_FAILED; | ||
| 178 | break; | ||
| 179 | } | ||
| 180 | if (infos_returned == 0) | ||
| 181 | { | ||
| 182 | /* all accounts returned */ | ||
| 183 | break; | ||
| 184 | } | ||
| 185 | |||
| 186 | ptr_user = (GATE_NET_DISPLAY_USER*)info_buffer; | ||
| 187 | |||
| 188 | while (continue_enum && (infos_returned-- > 0)) | ||
| 189 | { | ||
| 190 | if (ptr_sid) | ||
| 191 | { | ||
| 192 | ptr_sid->SubAuthorities[ptr_sid->SubAuthCount - 1] = ptr_user->usri1_user_id; | ||
| 193 | } | ||
| 194 | |||
| 195 | gate_account_make_user(&user_account, ptr_sid, ptr_user->usri1_name, | ||
| 196 | ptr_user->usri1_full_name, ptr_user->usri1_comment, ptr_user->usri1_flags); | ||
| 197 | |||
| 198 | next_info_index = ptr_user->usri1_next_index; | ||
| 199 | ++ptr_user; | ||
| 200 | |||
| 201 | if (callback) | ||
| 202 | { | ||
| 203 | continue_enum = callback(&user_account, param); | ||
| 204 | } | ||
| 205 | } | ||
| 206 | win32_netapi.NetApiBufferFree(info_buffer); | ||
| 207 | } while ((net_status == ERROR_MORE_DATA) && continue_enum); | ||
| 208 | } while (0); | ||
| 209 | return ret; | ||
| 210 | } | ||
| 211 | gate_result_t gate_account_enum_groups(gate_account_enum_groups_callback_t callback, void* param) | ||
| 212 | { | ||
| 213 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 214 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 215 | WCHAR const* ptr_system_name = NULL; | ||
| 216 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 217 | DWORD sid_length = sizeof(&sid); | ||
| 218 | WCHAR referenced_domain[256]; | ||
| 219 | DWORD referenced_domain_len; | ||
| 220 | DWORD net_status; | ||
| 221 | PVOID info_buffer = NULL; | ||
| 222 | DWORD infos_returned; | ||
| 223 | DWORD infos_total = 0; | ||
| 224 | DWORD_PTR resume_handle = 0; | ||
| 225 | GATE_LOCALGROUP_INFO_1* ptr_group; | ||
| 226 | SID_NAME_USE sid_name_use; | ||
| 227 | gate_account_group_t group_account; | ||
| 228 | gate_bool_t continue_enum = true; | ||
| 229 | |||
| 230 | do | ||
| 231 | { | ||
| 232 | if (!load_netapi() || !win32_netapi.NetLocalGroupEnum || !gate_platform.AdvLookupAccountNameW) | ||
| 233 | { | ||
| 234 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 235 | break; | ||
| 236 | } | ||
| 237 | |||
| 238 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 239 | |||
| 240 | ret = GATE_RESULT_OK; | ||
| 241 | |||
| 242 | do | ||
| 243 | { | ||
| 244 | net_status = win32_netapi.NetLocalGroupEnum(ptr_system_name, 1, (LPBYTE*)&ptr_group, MAX_PREFERRED_LENGTH, &infos_returned, &infos_total, &resume_handle); | ||
| 245 | if ((ERROR_MORE_DATA != net_status) && (ERROR_SUCCESS != net_status)) | ||
| 246 | { | ||
| 247 | ret = GATE_RESULT_FAILED; | ||
| 248 | break; | ||
| 249 | } | ||
| 250 | if (infos_returned == 0) | ||
| 251 | { | ||
| 252 | break; | ||
| 253 | } | ||
| 254 | while (continue_enum && (infos_returned-- > 0)) | ||
| 255 | { | ||
| 256 | gate_mem_clear(&group_account, sizeof(group_account)); | ||
| 257 | |||
| 258 | sid_length = sizeof(sid); | ||
| 259 | referenced_domain_len = sizeof(referenced_domain) / sizeof(referenced_domain[0]); | ||
| 260 | if (gate_platform.AdvLookupAccountNameW(NULL, ptr_group->lgrpi1_name, &sid, &sid_length, | ||
| 261 | referenced_domain, &referenced_domain_len, &sid_name_use)) | ||
| 262 | { | ||
| 263 | gate_win32_sid_print(&sid, group_account.id, sizeof(group_account.id)); | ||
| 264 | if (sid.SubAuthCount > 0) | ||
| 265 | { | ||
| 266 | group_account.short_id = sid.SubAuthorities[sid.SubAuthCount - 1]; | ||
| 267 | } | ||
| 268 | } | ||
| 269 | |||
| 270 | gate_str_utf16_2_utf8(ptr_group->lgrpi1_name, gate_str16_length(ptr_group->lgrpi1_name), | ||
| 271 | group_account.name, sizeof(group_account.name)); | ||
| 272 | gate_str_utf16_2_utf8(ptr_group->lgrpi1_comment, gate_str16_length(ptr_group->lgrpi1_comment), | ||
| 273 | group_account.description, sizeof(group_account.description)); | ||
| 274 | |||
| 275 | ++ptr_group; | ||
| 276 | |||
| 277 | if (callback) | ||
| 278 | { | ||
| 279 | continue_enum = callback(&group_account, param); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | win32_netapi.NetApiBufferFree(info_buffer); | ||
| 283 | |||
| 284 | } while ((net_status == ERROR_MORE_DATA) && continue_enum); | ||
| 285 | |||
| 286 | } while (0); | ||
| 287 | return ret; | ||
| 288 | } | ||
| 289 | gate_result_t gate_account_enum_group_members(gate_account_group_t const* group, gate_account_enum_users_callback_t callback, void* param) | ||
| 290 | { | ||
| 291 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 292 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 293 | WCHAR const* ptr_system_name; | ||
| 294 | WCHAR group_name[256]; | ||
| 295 | GATE_LOCALGROUP_MEMBERS_INFO_1* ptr_member_info = NULL; | ||
| 296 | DWORD entries_read = 0; | ||
| 297 | DWORD total_entries = 0; | ||
| 298 | DWORD_PTR resume_handle = 0; | ||
| 299 | DWORD net_status = 0; | ||
| 300 | DWORD index; | ||
| 301 | gate_account_user_t user; | ||
| 302 | gate_bool_t continue_enum = true; | ||
| 303 | |||
| 304 | do | ||
| 305 | { | ||
| 306 | if (!load_netapi() || !win32_netapi.NetLocalGroupGetMembers) | ||
| 307 | { | ||
| 308 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 309 | break; | ||
| 310 | } | ||
| 311 | |||
| 312 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 313 | gate_str_utf8_2_utf16(group->name, gate_str_length(group->name), group_name, sizeof(group_name) / sizeof(group_name[0])); | ||
| 314 | ret = GATE_RESULT_OK; | ||
| 315 | do | ||
| 316 | { | ||
| 317 | net_status = win32_netapi.NetLocalGroupGetMembers(ptr_system_name, group_name, 1, | ||
| 318 | (LPBYTE*)&ptr_member_info, MAX_PREFERRED_LENGTH, &entries_read, &total_entries, &resume_handle); | ||
| 319 | if ((ERROR_MORE_DATA != net_status) && (0 != net_status)) | ||
| 320 | { | ||
| 321 | ret = GATE_RESULT_FAILED; | ||
| 322 | break; | ||
| 323 | } | ||
| 324 | |||
| 325 | for (index = 0; index < entries_read; ++index) | ||
| 326 | { | ||
| 327 | gate_mem_clear(&user, sizeof(user)); | ||
| 328 | if (SidTypeUser == ptr_member_info[index].lgrmi1_sidusage) | ||
| 329 | { | ||
| 330 | gate_account_make_user(&user, (gate_win32_sidstruct_t const*)ptr_member_info[index].lgrmi1_sid, | ||
| 331 | ptr_member_info[index].lgrmi1_name, NULL, NULL, 0); | ||
| 332 | if (!callback(&user, param)) | ||
| 333 | { | ||
| 334 | continue_enum = false; | ||
| 335 | break; | ||
| 336 | } | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | win32_netapi.NetApiBufferFree(ptr_member_info); | ||
| 341 | |||
| 342 | } while ((ERROR_MORE_DATA == net_status) && continue_enum); | ||
| 343 | } while (0); | ||
| 344 | return ret; | ||
| 345 | } | ||
| 346 | gate_result_t gate_account_enum_user_memberships(gate_account_user_t const* user, gate_account_enum_groups_callback_t callback, void* param) | ||
| 347 | { | ||
| 348 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 349 | gate_result_t result; | ||
| 350 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 351 | WCHAR const* ptr_system_name; | ||
| 352 | WCHAR user_name[256]; | ||
| 353 | GATE_LOCALGROUP_USERS_INFO_0* ptr_group_info = NULL; | ||
| 354 | DWORD entries_returned = 0; | ||
| 355 | DWORD entries_total = 0; | ||
| 356 | DWORD index; | ||
| 357 | DWORD net_status = 0; | ||
| 358 | gate_bool_t continue_enum = true; | ||
| 359 | char localgroup_name[256]; | ||
| 360 | gate_size_t localgroup_name_len; | ||
| 361 | gate_string_t localgroup_str; | ||
| 362 | gate_account_group_t group; | ||
| 363 | |||
| 364 | do | ||
| 365 | { | ||
| 366 | if (!load_netapi() || !win32_netapi.NetUserGetLocalGroups) | ||
| 367 | { | ||
| 368 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 369 | break; | ||
| 370 | } | ||
| 371 | |||
| 372 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 373 | gate_str_utf8_2_utf16(user->name, gate_str_length(user->name), user_name, sizeof(user_name) / sizeof(user_name[0])); | ||
| 374 | |||
| 375 | do | ||
| 376 | { | ||
| 377 | net_status = win32_netapi.NetUserGetLocalGroups(ptr_system_name, user_name, 0, LG_INCLUDE_INDIRECT, | ||
| 378 | (LPBYTE*)&ptr_group_info, MAX_PREFERRED_LENGTH, &entries_returned, &entries_total); | ||
| 379 | |||
| 380 | if ((ERROR_MORE_DATA != net_status) && (0 != net_status)) | ||
| 381 | { | ||
| 382 | ret = GATE_RESULT_FAILED; | ||
| 383 | break; | ||
| 384 | } | ||
| 385 | |||
| 386 | for (index = 0; index < entries_returned; ++index) | ||
| 387 | { | ||
| 388 | localgroup_name_len = gate_str_utf16_2_utf8(ptr_group_info[index].lgrui0_name, | ||
| 389 | gate_str16_length(ptr_group_info[index].lgrui0_name), | ||
| 390 | localgroup_name, sizeof(localgroup_name)); | ||
| 391 | gate_string_create_static_len(&localgroup_str, localgroup_name, localgroup_name_len); | ||
| 392 | result = gate_account_resolve_group(&localgroup_str, &group); | ||
| 393 | if (GATE_SUCCEEDED(result)) | ||
| 394 | { | ||
| 395 | if (!callback(&group, param)) | ||
| 396 | { | ||
| 397 | continue_enum = false; | ||
| 398 | break; | ||
| 399 | } | ||
| 400 | } | ||
| 401 | } | ||
| 402 | |||
| 403 | win32_netapi.NetApiBufferFree(ptr_group_info); | ||
| 404 | |||
| 405 | } while ((ERROR_MORE_DATA == net_status) && continue_enum); | ||
| 406 | |||
| 407 | ret = GATE_RESULT_OK; | ||
| 408 | } while (0); | ||
| 409 | |||
| 410 | return ret; | ||
| 411 | } | ||
| 412 | gate_result_t gate_account_get_user(gate_string_t const* user_id, gate_account_user_t* user) | ||
| 413 | { | ||
| 414 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 415 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 416 | WCHAR const* ptr_system_name = NULL; | ||
| 417 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 418 | PSID psid = NULL; | ||
| 419 | WCHAR user_name[256]; | ||
| 420 | DWORD user_name_len = sizeof(user_name) / sizeof(user_name[0]); | ||
| 421 | WCHAR domain_name[256]; | ||
| 422 | DWORD domain_name_len = sizeof(domain_name) / sizeof(domain_name[0]); | ||
| 423 | SID_NAME_USE sid_type = (SID_NAME_USE)0; | ||
| 424 | GATE_USER_INFO_2* ptr_user_info = NULL; | ||
| 425 | DWORD net_status; | ||
| 426 | LPCWSTR ptr_full_name; | ||
| 427 | LPCWSTR ptr_comment; | ||
| 428 | DWORD user_flags; | ||
| 429 | |||
| 430 | do | ||
| 431 | { | ||
| 432 | if (!load_netapi() || !gate_platform.AdvLookupAccountSidW || !win32_netapi.NetUserGetInfo) | ||
| 433 | { | ||
| 434 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 435 | break; | ||
| 436 | } | ||
| 437 | psid = gate_win32_sid_parse(gate_string_ptr(user_id, 0), (DWORD)gate_string_length(user_id), &sid); | ||
| 438 | if (!psid) | ||
| 439 | { | ||
| 440 | ret = GATE_RESULT_INVALIDARG; | ||
| 441 | break; | ||
| 442 | } | ||
| 443 | |||
| 444 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 445 | if (!gate_platform.AdvLookupAccountSidW(ptr_system_name, psid, user_name, &user_name_len, | ||
| 446 | domain_name, &domain_name_len, &sid_type)) | ||
| 447 | { | ||
| 448 | ret = GATE_RESULT_NOMATCH; | ||
| 449 | break; | ||
| 450 | } | ||
| 451 | if (sid_type != SidTypeUser) | ||
| 452 | { | ||
| 453 | ret = GATE_RESULT_NOMATCH; | ||
| 454 | break; | ||
| 455 | } | ||
| 456 | |||
| 457 | |||
| 458 | /* fill optional fields: */ | ||
| 459 | ptr_full_name = NULL; | ||
| 460 | ptr_comment = NULL; | ||
| 461 | user_flags = 0; | ||
| 462 | ptr_user_info = NULL; | ||
| 463 | |||
| 464 | net_status = win32_netapi.NetUserGetInfo(ptr_system_name, user_name, 2, (LPBYTE*)&ptr_user_info); | ||
| 465 | if (0 == net_status) | ||
| 466 | { | ||
| 467 | ptr_full_name = ptr_user_info->usri2_full_name; | ||
| 468 | ptr_comment = ptr_user_info->usri2_comment; | ||
| 469 | user_flags = ptr_user_info->usri2_flags; | ||
| 470 | } | ||
| 471 | |||
| 472 | gate_account_make_user(user, &sid, user_name, ptr_full_name, ptr_comment, user_flags); | ||
| 473 | ret = GATE_RESULT_OK; | ||
| 474 | } while (0); | ||
| 475 | |||
| 476 | if (ptr_user_info != NULL) | ||
| 477 | { | ||
| 478 | win32_netapi.NetApiBufferFree(ptr_user_info); | ||
| 479 | } | ||
| 480 | |||
| 481 | return ret; | ||
| 482 | } | ||
| 483 | gate_result_t gate_account_resolve_user(gate_string_t const* user_name, gate_account_user_t* user) | ||
| 484 | { | ||
| 485 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 486 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 487 | WCHAR const* ptr_system_name = NULL; | ||
| 488 | WCHAR account_name[256]; | ||
| 489 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 490 | gate_win32_sidstruct_t* ptr_sid = NULL; | ||
| 491 | DWORD net_status; | ||
| 492 | GATE_USER_INFO_3* ptr_user_info = NULL; | ||
| 493 | |||
| 494 | do | ||
| 495 | { | ||
| 496 | if (!load_netapi() || !win32_netapi.NetUserGetInfo) | ||
| 497 | { | ||
| 498 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 499 | break; | ||
| 500 | } | ||
| 501 | |||
| 502 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 503 | |||
| 504 | gate_str_utf8_2_utf16(user_name->str, user_name->length, account_name, sizeof(account_name) / sizeof(account_name[0])); | ||
| 505 | net_status = win32_netapi.NetUserGetInfo(ptr_system_name, account_name, 3, (LPBYTE*)&ptr_user_info); | ||
| 506 | if (0 != net_status) | ||
| 507 | { | ||
| 508 | ret = GATE_RESULT_NOTAVAILABLE; | ||
| 509 | break; | ||
| 510 | } | ||
| 511 | |||
| 512 | ret = GATE_RESULT_OK; | ||
| 513 | |||
| 514 | if (gate_account_get_computer_sid(ptr_system_name, &sid)) | ||
| 515 | { | ||
| 516 | sid.SubAuthorities[sid.SubAuthCount] = ptr_user_info->usri3_user_id; | ||
| 517 | ++sid.SubAuthCount; | ||
| 518 | ptr_sid = &sid; | ||
| 519 | } | ||
| 520 | |||
| 521 | gate_account_make_user(user, ptr_sid, ptr_user_info->usri3_name, ptr_user_info->usri3_full_name, | ||
| 522 | ptr_user_info->usri3_comment, ptr_user_info->usri3_flags); | ||
| 523 | |||
| 524 | win32_netapi.NetApiBufferFree(ptr_user_info); | ||
| 525 | } while (0); | ||
| 526 | |||
| 527 | return ret; | ||
| 528 | } | ||
| 529 | |||
| 530 | gate_result_t gate_account_get_group(gate_string_t const* group_id, gate_account_group_t* group) | ||
| 531 | { | ||
| 532 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 533 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 534 | WCHAR const* ptr_system_name = NULL; | ||
| 535 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 536 | PSID psid = NULL; | ||
| 537 | WCHAR group_name[256]; | ||
| 538 | DWORD group_name_len = sizeof(group_name) / sizeof(group_name[0]); | ||
| 539 | WCHAR domain_name[256]; | ||
| 540 | DWORD domain_name_len = sizeof(domain_name) / sizeof(domain_name[0]); | ||
| 541 | SID_NAME_USE sid_name_use; | ||
| 542 | GATE_LOCALGROUP_INFO_1* ptr_localgroup_info = NULL; | ||
| 543 | LPCWSTR ptr_comment = NULL; | ||
| 544 | DWORD net_status = 0; | ||
| 545 | |||
| 546 | |||
| 547 | do | ||
| 548 | { | ||
| 549 | if (!load_netapi() || !gate_platform.AdvLookupAccountSidW || !win32_netapi.NetLocalGroupGetInfo) | ||
| 550 | { | ||
| 551 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 552 | break; | ||
| 553 | } | ||
| 554 | |||
| 555 | psid = gate_win32_sid_parse(gate_string_ptr(group_id, 0), (DWORD)gate_string_length(group_id), &sid); | ||
| 556 | if (!psid) | ||
| 557 | { | ||
| 558 | ret = GATE_RESULT_INVALIDARG; | ||
| 559 | break; | ||
| 560 | } | ||
| 561 | |||
| 562 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 563 | if (!gate_platform.AdvLookupAccountSidW(ptr_system_name, psid, group_name, &group_name_len, | ||
| 564 | domain_name, &domain_name_len, &sid_name_use)) | ||
| 565 | { | ||
| 566 | ret = GATE_RESULT_NOMATCH; | ||
| 567 | break; | ||
| 568 | } | ||
| 569 | if ((sid_name_use != SidTypeGroup) && (sid_name_use != SidTypeAlias) && (sid_name_use != SidTypeWellKnownGroup)) | ||
| 570 | { | ||
| 571 | ret = GATE_RESULT_NOMATCH; | ||
| 572 | break; | ||
| 573 | } | ||
| 574 | |||
| 575 | ret = GATE_RESULT_OK; | ||
| 576 | ptr_comment = NULL; | ||
| 577 | |||
| 578 | net_status = win32_netapi.NetLocalGroupGetInfo(ptr_system_name, group_name, 1, (LPBYTE*)&ptr_localgroup_info); | ||
| 579 | if (0 == net_status) | ||
| 580 | { | ||
| 581 | ptr_comment = ptr_localgroup_info->lgrpi1_comment; | ||
| 582 | } | ||
| 583 | |||
| 584 | gate_account_make_group(group, &sid, group_name, ptr_comment, 0); | ||
| 585 | |||
| 586 | } while (0); | ||
| 587 | |||
| 588 | if (ptr_localgroup_info) | ||
| 589 | { | ||
| 590 | win32_netapi.NetApiBufferFree(ptr_localgroup_info); | ||
| 591 | } | ||
| 592 | return ret; | ||
| 593 | } | ||
| 594 | gate_result_t gate_account_resolve_group(gate_string_t const* group_name, gate_account_group_t* group) | ||
| 595 | { | ||
| 596 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 597 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 598 | WCHAR const* ptr_system_name = NULL; | ||
| 599 | WCHAR account_group[256]; | ||
| 600 | gate_win32_sidstruct_t sid; | ||
| 601 | DWORD sid_length = sizeof(sid); | ||
| 602 | DWORD net_status; | ||
| 603 | GATE_LOCALGROUP_INFO_1* ptr_group_info = NULL; | ||
| 604 | LPCWSTR ptr_comment = NULL; | ||
| 605 | WCHAR domain[256]; | ||
| 606 | DWORD domain_len = sizeof(domain) / sizeof(domain[0]); | ||
| 607 | SID_NAME_USE sid_name_use; | ||
| 608 | |||
| 609 | do | ||
| 610 | { | ||
| 611 | if (!load_netapi() || !gate_platform.AdvLookupAccountNameW || !win32_netapi.NetLocalGroupGetInfo) | ||
| 612 | { | ||
| 613 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 614 | break; | ||
| 615 | } | ||
| 616 | |||
| 617 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 618 | gate_str_utf8_2_utf16(group_name->str, group_name->length, account_group, sizeof(account_group) / sizeof(account_group[0])); | ||
| 619 | |||
| 620 | if (!gate_platform.AdvLookupAccountNameW(ptr_system_name, account_group, &sid, &sid_length, domain, &domain_len, &sid_name_use)) | ||
| 621 | { | ||
| 622 | ret = GATE_RESULT_NOMATCH; | ||
| 623 | break; | ||
| 624 | } | ||
| 625 | |||
| 626 | ret = GATE_RESULT_OK; | ||
| 627 | net_status = win32_netapi.NetLocalGroupGetInfo(ptr_system_name, account_group, 1, (LPBYTE*)&ptr_group_info); | ||
| 628 | if (0 == net_status) | ||
| 629 | { | ||
| 630 | ptr_comment = ptr_group_info->lgrpi1_comment; | ||
| 631 | } | ||
| 632 | |||
| 633 | gate_account_make_group(group, &sid, account_group, ptr_comment, 0); | ||
| 634 | |||
| 635 | if (ptr_group_info) | ||
| 636 | { | ||
| 637 | win32_netapi.NetApiBufferFree(ptr_group_info); | ||
| 638 | } | ||
| 639 | } while (0); | ||
| 640 | |||
| 641 | return ret; | ||
| 642 | } | ||
| 643 | gate_result_t gate_account_create_user(gate_string_t const* user_name, gate_string_t const* password) | ||
| 644 | { | ||
| 645 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 646 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 647 | WCHAR const* ptr_system_name = NULL; | ||
| 648 | WCHAR w_user_name[256] = GATE_INIT_EMPTY; | ||
| 649 | WCHAR w_user_passwd[256] = GATE_INIT_EMPTY; | ||
| 650 | GATE_USER_INFO_1 user_info_1 = GATE_INIT_EMPTY; | ||
| 651 | DWORD param_error_index = 0; | ||
| 652 | DWORD net_status; | ||
| 653 | |||
| 654 | do | ||
| 655 | { | ||
| 656 | if (!load_netapi() || !win32_netapi.NetUserAdd) | ||
| 657 | { | ||
| 658 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 659 | break; | ||
| 660 | } | ||
| 661 | |||
| 662 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 663 | gate_str_utf8_2_utf16(user_name->str, user_name->length, w_user_name, sizeof(w_user_name) / sizeof(w_user_name[0])); | ||
| 664 | gate_str_utf8_2_utf16(gate_string_ptr(password, 0), gate_string_length(password), w_user_passwd, sizeof(w_user_passwd) / sizeof(w_user_passwd[0])); | ||
| 665 | |||
| 666 | user_info_1.usri1_name = w_user_name; | ||
| 667 | user_info_1.usri1_password = password ? w_user_passwd : NULL; | ||
| 668 | user_info_1.usri1_password_age = 0; | ||
| 669 | user_info_1.usri1_priv = USER_PRIV_USER; | ||
| 670 | user_info_1.usri1_home_dir = NULL; | ||
| 671 | user_info_1.usri1_comment = NULL; | ||
| 672 | user_info_1.usri1_flags = UF_NORMAL_ACCOUNT | (password ? 0 : UF_PASSWD_NOTREQD); | ||
| 673 | user_info_1.usri1_script_path = NULL; | ||
| 674 | |||
| 675 | net_status = win32_netapi.NetUserAdd(ptr_system_name, 1, (LPBYTE)&user_info_1, ¶m_error_index); | ||
| 676 | if (net_status == 0) | ||
| 677 | { | ||
| 678 | ret = GATE_RESULT_OK; | ||
| 679 | } | ||
| 680 | else | ||
| 681 | { | ||
| 682 | ret = GATE_RESULT_FAILED; | ||
| 683 | } | ||
| 684 | } while (0); | ||
| 685 | |||
| 686 | return ret; | ||
| 687 | } | ||
| 688 | gate_result_t gate_account_delete_user(gate_account_user_t const* user) | ||
| 689 | { | ||
| 690 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 691 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 692 | WCHAR const* ptr_system_name = NULL; | ||
| 693 | WCHAR user_name[256]; | ||
| 694 | DWORD net_status; | ||
| 695 | |||
| 696 | do | ||
| 697 | { | ||
| 698 | if (!load_netapi() || !win32_netapi.NetUserDel) | ||
| 699 | { | ||
| 700 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 701 | break; | ||
| 702 | } | ||
| 703 | |||
| 704 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 705 | gate_str_utf8_2_utf16(user->name, gate_str_length(user->name), user_name, sizeof(user_name) / sizeof(user_name[0])); | ||
| 706 | |||
| 707 | net_status = win32_netapi.NetUserDel(ptr_system_name, user_name); | ||
| 708 | if (net_status == 0) | ||
| 709 | { | ||
| 710 | ret = GATE_RESULT_OK; | ||
| 711 | } | ||
| 712 | else | ||
| 713 | { | ||
| 714 | ret = GATE_RESULT_FAILED; | ||
| 715 | } | ||
| 716 | } while (0); | ||
| 717 | |||
| 718 | return ret; | ||
| 719 | } | ||
| 720 | gate_result_t gate_account_create_group(gate_string_t const* group_name) | ||
| 721 | { | ||
| 722 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 723 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 724 | WCHAR const* ptr_system_name = NULL; | ||
| 725 | WCHAR w_group_name[256]; | ||
| 726 | GATE_LOCALGROUP_INFO_0 group_info_0 = GATE_INIT_EMPTY; | ||
| 727 | DWORD param_error_index = 0; | ||
| 728 | DWORD net_status; | ||
| 729 | |||
| 730 | do | ||
| 731 | { | ||
| 732 | if (!load_netapi() || !win32_netapi.NetLocalGroupAdd) | ||
| 733 | { | ||
| 734 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 735 | break; | ||
| 736 | } | ||
| 737 | |||
| 738 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 739 | gate_str_utf8_2_utf16(group_name->str, group_name->length, w_group_name, sizeof(w_group_name) / sizeof(w_group_name[0])); | ||
| 740 | |||
| 741 | group_info_0.lgrpi0_name = w_group_name; | ||
| 742 | |||
| 743 | net_status = win32_netapi.NetLocalGroupAdd(ptr_system_name, 0, (LPBYTE)&group_info_0, ¶m_error_index); | ||
| 744 | if (net_status == 0) | ||
| 745 | { | ||
| 746 | ret = GATE_RESULT_OK; | ||
| 747 | } | ||
| 748 | else | ||
| 749 | { | ||
| 750 | ret = GATE_RESULT_FAILED; | ||
| 751 | } | ||
| 752 | } while (0); | ||
| 753 | |||
| 754 | return ret; | ||
| 755 | } | ||
| 756 | gate_result_t gate_account_delete_group(gate_account_group_t const* group) | ||
| 757 | { | ||
| 758 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 759 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 760 | WCHAR const* ptr_system_name = NULL; | ||
| 761 | WCHAR group_name[256]; | ||
| 762 | DWORD net_status; | ||
| 763 | |||
| 764 | do | ||
| 765 | { | ||
| 766 | if (!load_netapi() || !win32_netapi.NetLocalGroupDel) | ||
| 767 | { | ||
| 768 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 769 | break; | ||
| 770 | } | ||
| 771 | |||
| 772 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 773 | gate_str_utf8_2_utf16(group->name, gate_str_length(group->name), group_name, sizeof(group_name) / sizeof(group_name[0])); | ||
| 774 | |||
| 775 | net_status = win32_netapi.NetLocalGroupDel(ptr_system_name, group_name); | ||
| 776 | if (net_status == 0) | ||
| 777 | { | ||
| 778 | ret = GATE_RESULT_OK; | ||
| 779 | } | ||
| 780 | else | ||
| 781 | { | ||
| 782 | ret = GATE_RESULT_FAILED; | ||
| 783 | } | ||
| 784 | } while (0); | ||
| 785 | |||
| 786 | return ret; | ||
| 787 | } | ||
| 788 | |||
| 789 | gate_result_t gate_account_add_user_to_group(gate_account_user_t const* user, gate_account_group_t const* group) | ||
| 790 | { | ||
| 791 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 792 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 793 | WCHAR const* ptr_system_name = NULL; | ||
| 794 | WCHAR group_name[256]; | ||
| 795 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 796 | DWORD net_status; | ||
| 797 | GATE_LOCALGROUP_MEMBERS_INFO_0 member_info_0; | ||
| 798 | |||
| 799 | do | ||
| 800 | { | ||
| 801 | if (!load_netapi() || !win32_netapi.NetLocalGroupAddMembers) | ||
| 802 | { | ||
| 803 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 804 | break; | ||
| 805 | } | ||
| 806 | |||
| 807 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 808 | gate_str_utf8_2_utf16(group->name, gate_str_length(group->name), group_name, sizeof(group_name) / sizeof(group_name[0])); | ||
| 809 | |||
| 810 | gate_mem_clear(&member_info_0, sizeof(member_info_0)); | ||
| 811 | member_info_0.lgrmi0_sid = gate_win32_sid_parse(user->id, (DWORD)gate_str_length(user->id), &sid); | ||
| 812 | |||
| 813 | net_status = win32_netapi.NetLocalGroupAddMembers(ptr_system_name, group_name, 0, (LPBYTE)&member_info_0, 1); | ||
| 814 | if (net_status == 0) | ||
| 815 | { | ||
| 816 | ret = GATE_RESULT_OK; | ||
| 817 | } | ||
| 818 | else | ||
| 819 | { | ||
| 820 | ret = GATE_RESULT_FAILED; | ||
| 821 | } | ||
| 822 | } while (0); | ||
| 823 | |||
| 824 | return ret; | ||
| 825 | } | ||
| 826 | gate_result_t gate_account_remove_user_from_group(gate_account_user_t const* user, gate_account_group_t const* group) | ||
| 827 | { | ||
| 828 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 829 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 830 | WCHAR const* ptr_system_name = NULL; | ||
| 831 | WCHAR group_name[256]; | ||
| 832 | gate_win32_sidstruct_t sid = GATE_INIT_EMPTY; | ||
| 833 | DWORD net_status; | ||
| 834 | GATE_LOCALGROUP_MEMBERS_INFO_0 member_info_0; | ||
| 835 | |||
| 836 | do | ||
| 837 | { | ||
| 838 | if (!load_netapi() || !win32_netapi.NetLocalGroupDelMembers) | ||
| 839 | { | ||
| 840 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 841 | break; | ||
| 842 | } | ||
| 843 | |||
| 844 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 845 | gate_str_utf8_2_utf16(group->name, gate_str_length(group->name), group_name, sizeof(group_name) / sizeof(group_name[0])); | ||
| 846 | |||
| 847 | gate_mem_clear(&member_info_0, sizeof(member_info_0)); | ||
| 848 | member_info_0.lgrmi0_sid = gate_win32_sid_parse(user->id, (DWORD)gate_str_length(user->id), &sid); | ||
| 849 | |||
| 850 | net_status = win32_netapi.NetLocalGroupDelMembers(ptr_system_name, group_name, 0, (LPBYTE)&member_info_0, 1); | ||
| 851 | if (net_status == 0) | ||
| 852 | { | ||
| 853 | ret = GATE_RESULT_OK; | ||
| 854 | } | ||
| 855 | else | ||
| 856 | { | ||
| 857 | ret = GATE_RESULT_FAILED; | ||
| 858 | } | ||
| 859 | } while (0); | ||
| 860 | |||
| 861 | return ret; | ||
| 862 | } | ||
| 863 | |||
| 864 | static gate_string_t const gate_account_user_key_comment = GATE_STRING_INIT_STATIC("Comment"); | ||
| 865 | static gate_string_t const gate_account_user_key_full_name = GATE_STRING_INIT_STATIC("FullName"); | ||
| 866 | static gate_string_t const gate_account_user_key_home_dir = GATE_STRING_INIT_STATIC("HomeDirectory"); | ||
| 867 | static gate_string_t const gate_account_user_key_script_path = GATE_STRING_INIT_STATIC("ScriptPath"); | ||
| 868 | static gate_string_t const gate_account_user_key_script_enabled = GATE_STRING_INIT_STATIC("ScriptEnabled"); | ||
| 869 | static gate_string_t const gate_account_user_key_account_disabled = GATE_STRING_INIT_STATIC("AccountDisabled"); | ||
| 870 | static gate_string_t const gate_account_user_key_lockout = GATE_STRING_INIT_STATIC("Lockout"); | ||
| 871 | static gate_string_t const gate_account_user_key_no_password_expiration = GATE_STRING_INIT_STATIC("NoPasswordExpiration"); | ||
| 872 | static gate_string_t const gate_account_user_key_password_expired = GATE_STRING_INIT_STATIC("PasswordExpired"); | ||
| 873 | static gate_string_t const gate_account_user_key_cannot_change_password = GATE_STRING_INIT_STATIC("CannotChangePassword"); | ||
| 874 | static gate_string_t const gate_account_user_key_password_not_required = GATE_STRING_INIT_STATIC("PasswordNotRequired"); | ||
| 875 | static gate_string_t const gate_account_user_key_home_dir_required = GATE_STRING_INIT_STATIC("HomeDirectoryRequired"); | ||
| 876 | |||
| 877 | static gate_result_t gate_account_user_add_str_property(gate_property_t* prop, gate_string_t const* key, LPCWSTR str_value) | ||
| 878 | { | ||
| 879 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 880 | char str_buffer[4096]; | ||
| 881 | gate_size_t str_buffer_len; | ||
| 882 | gate_string_t str_member = GATE_STRING_INIT_EMPTY; | ||
| 883 | gate_property_t member = GATE_INIT_EMPTY; | ||
| 884 | |||
| 885 | do | ||
| 886 | { | ||
| 887 | str_buffer_len = gate_str_utf16_2_utf8(str_value, gate_str16_length(str_value), str_buffer, sizeof(str_buffer)); | ||
| 888 | |||
| 889 | if (NULL == gate_string_create(&str_member, str_buffer, str_buffer_len)) | ||
| 890 | { | ||
| 891 | ret = GATE_RESULT_OUTOFMEMORY; | ||
| 892 | break; | ||
| 893 | } | ||
| 894 | |||
| 895 | if (NULL == gate_property_create_string(&member, &str_member)) | ||
| 896 | { | ||
| 897 | ret = GATE_RESULT_OUTOFMEMORY; | ||
| 898 | break; | ||
| 899 | } | ||
| 900 | |||
| 901 | if (NULL == gate_property_member_add(prop, key, &member)) | ||
| 902 | { | ||
| 903 | ret = GATE_RESULT_OUTOFMEMORY; | ||
| 904 | break; | ||
| 905 | } | ||
| 906 | ret = GATE_RESULT_OK; | ||
| 907 | } while (0); | ||
| 908 | |||
| 909 | gate_property_destroy(&member); | ||
| 910 | gate_string_release(&str_member); | ||
| 911 | |||
| 912 | return ret; | ||
| 913 | } | ||
| 914 | static gate_result_t gate_account_user_add_bool_property(gate_property_t* prop, gate_string_t const* key, gate_bool_t bool_value) | ||
| 915 | { | ||
| 916 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 917 | gate_property_t member = GATE_INIT_EMPTY; | ||
| 918 | |||
| 919 | do | ||
| 920 | { | ||
| 921 | if (NULL == gate_property_create_bool(&member, bool_value)) | ||
| 922 | { | ||
| 923 | ret = GATE_RESULT_OUTOFMEMORY; | ||
| 924 | break; | ||
| 925 | } | ||
| 926 | |||
| 927 | if (NULL == gate_property_member_add(prop, key, &member)) | ||
| 928 | { | ||
| 929 | ret = GATE_RESULT_OUTOFMEMORY; | ||
| 930 | break; | ||
| 931 | } | ||
| 932 | ret = GATE_RESULT_OK; | ||
| 933 | } while (0); | ||
| 934 | |||
| 935 | gate_property_destroy(&member); | ||
| 936 | |||
| 937 | return ret; | ||
| 938 | } | ||
| 939 | |||
| 940 | |||
| 941 | |||
| 942 | gate_result_t gate_account_get_user_properties(gate_account_user_t const* user, gate_property_t* properties) | ||
| 943 | { | ||
| 944 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 945 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 946 | WCHAR const* ptr_system_name = NULL; | ||
| 947 | WCHAR w_user_name[256]; | ||
| 948 | GATE_USER_INFO_2* ptr_user_info = NULL; | ||
| 949 | DWORD net_status; | ||
| 950 | gate_property_t props = GATE_INIT_EMPTY; | ||
| 951 | |||
| 952 | do | ||
| 953 | { | ||
| 954 | if (!load_netapi() || !win32_netapi.NetUserGetInfo) | ||
| 955 | { | ||
| 956 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 957 | break; | ||
| 958 | } | ||
| 959 | |||
| 960 | gate_property_create_object(&props); | ||
| 961 | |||
| 962 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 963 | |||
| 964 | gate_str_utf8_2_utf16(user->name, gate_str_length(user->name), w_user_name, sizeof(w_user_name) / sizeof(w_user_name[0])); | ||
| 965 | net_status = win32_netapi.NetUserGetInfo(ptr_system_name, w_user_name, 2, (LPBYTE*)&ptr_user_info); | ||
| 966 | if (0 != net_status) | ||
| 967 | { | ||
| 968 | ret = GATE_RESULT_FAILED; | ||
| 969 | break; | ||
| 970 | } | ||
| 971 | |||
| 972 | gate_account_user_add_str_property(&props, &gate_account_user_key_comment, ptr_user_info->usri2_comment); | ||
| 973 | gate_account_user_add_str_property(&props, &gate_account_user_key_full_name, ptr_user_info->usri2_full_name); | ||
| 974 | gate_account_user_add_str_property(&props, &gate_account_user_key_home_dir, ptr_user_info->usri2_home_dir); | ||
| 975 | gate_account_user_add_str_property(&props, &gate_account_user_key_script_path, ptr_user_info->usri2_script_path); | ||
| 976 | |||
| 977 | gate_account_user_add_bool_property(&props, &gate_account_user_key_script_enabled, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_SCRIPT)); | ||
| 978 | gate_account_user_add_bool_property(&props, &gate_account_user_key_account_disabled, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_ACCOUNTDISABLE)); | ||
| 979 | gate_account_user_add_bool_property(&props, &gate_account_user_key_lockout, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_LOCKOUT)); | ||
| 980 | gate_account_user_add_bool_property(&props, &gate_account_user_key_no_password_expiration, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_DONT_EXPIRE_PASSWD)); | ||
| 981 | gate_account_user_add_bool_property(&props, &gate_account_user_key_password_expired, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_PASSWORD_EXPIRED)); | ||
| 982 | gate_account_user_add_bool_property(&props, &gate_account_user_key_cannot_change_password, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_PASSWD_CANT_CHANGE)); | ||
| 983 | gate_account_user_add_bool_property(&props, &gate_account_user_key_password_not_required, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_PASSWD_NOTREQD)); | ||
| 984 | gate_account_user_add_bool_property(&props, &gate_account_user_key_home_dir_required, GATE_FLAG_ENABLED(ptr_user_info->usri2_flags, UF_ACCOUNTDISABLE)); | ||
| 985 | |||
| 986 | if (properties) | ||
| 987 | { | ||
| 988 | gate_mem_copy(properties, &props, sizeof(props)); | ||
| 989 | gate_mem_clear(&props, sizeof(props)); | ||
| 990 | } | ||
| 991 | ret = GATE_RESULT_OK; | ||
| 992 | } while (0); | ||
| 993 | |||
| 994 | if (ptr_user_info != NULL) | ||
| 995 | { | ||
| 996 | win32_netapi.NetApiBufferFree(ptr_user_info); | ||
| 997 | } | ||
| 998 | gate_property_destroy(&props); | ||
| 999 | return ret; | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | static void gate_account_update_flag(DWORD* flag_var, DWORD flag_bit, gate_bool_t value) | ||
| 1003 | { | ||
| 1004 | if (value) | ||
| 1005 | { | ||
| 1006 | *flag_var |= flag_bit; | ||
| 1007 | } | ||
| 1008 | else | ||
| 1009 | { | ||
| 1010 | *flag_var &= ~flag_bit; | ||
| 1011 | } | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | gate_result_t gate_account_set_user_property(gate_account_user_t const* user, gate_string_t const* key, gate_property_t const* value) | ||
| 1015 | { | ||
| 1016 | gate_result_t ret = GATE_RESULT_FAILED; | ||
| 1017 | WCHAR system_name[GATE_ACCOUNTS_MAX_SYSTEM_NAME] = GATE_INIT_EMPTY; | ||
| 1018 | WCHAR const* ptr_system_name = NULL; | ||
| 1019 | WCHAR w_user_name[256] = GATE_INIT_EMPTY; | ||
| 1020 | gate_string_t prop_str_value = GATE_STRING_INIT_EMPTY; | ||
| 1021 | gate_bool_t prop_bool_value = false; | ||
| 1022 | WCHAR w_value[4096] = GATE_INIT_EMPTY; | ||
| 1023 | GATE_USER_INFO_2* ptr_user_info = NULL; | ||
| 1024 | DWORD net_status; | ||
| 1025 | DWORD param_error_index = 0; | ||
| 1026 | |||
| 1027 | do | ||
| 1028 | { | ||
| 1029 | if (!load_netapi() || !win32_netapi.NetUserGetInfo || !win32_netapi.NetUserSetInfo) | ||
| 1030 | { | ||
| 1031 | ret = GATE_RESULT_NOTSUPPORTED; | ||
| 1032 | break; | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | ptr_system_name = gate_account_get_local_computer(system_name, sizeof(system_name) / sizeof(system_name[0])); | ||
| 1036 | |||
| 1037 | gate_str_utf8_2_utf16(user->name, gate_str_length(user->name), w_user_name, sizeof(w_user_name) / sizeof(w_user_name[0])); | ||
| 1038 | net_status = win32_netapi.NetUserGetInfo(ptr_system_name, w_user_name, 2, (LPBYTE*)&ptr_user_info); | ||
| 1039 | if (0 != net_status) | ||
| 1040 | { | ||
| 1041 | ret = GATE_RESULT_FAILED; | ||
| 1042 | break; | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | ret = GATE_RESULT_INVALIDARG; | ||
| 1046 | |||
| 1047 | switch (gate_property_get_type(value)) | ||
| 1048 | { | ||
| 1049 | case GATE_PROPERTY_TYPE_STRING: | ||
| 1050 | { | ||
| 1051 | ret = gate_property_get_string(value, &prop_str_value); | ||
| 1052 | GATE_BREAK_IF_FAILED(ret); | ||
| 1053 | gate_str_utf8_2_utf16(prop_str_value.str, prop_str_value.length, w_value, sizeof(w_value) / sizeof(w_value[0])); | ||
| 1054 | |||
| 1055 | if (gate_string_equals(key, &gate_account_user_key_comment)) { ptr_user_info->usri2_comment = w_value; } | ||
| 1056 | else if (gate_string_equals(key, &gate_account_user_key_full_name)) { ptr_user_info->usri2_full_name = w_value; } | ||
| 1057 | else if (gate_string_equals(key, &gate_account_user_key_home_dir)) { ptr_user_info->usri2_home_dir = w_value; } | ||
| 1058 | else if (gate_string_equals(key, &gate_account_user_key_script_path)) { ptr_user_info->usri2_script_path = w_value; } | ||
| 1059 | else { ret = GATE_RESULT_INVALIDARG; } | ||
| 1060 | |||
| 1061 | break; | ||
| 1062 | } | ||
| 1063 | case GATE_PROPERTY_TYPE_BOOL: | ||
| 1064 | { | ||
| 1065 | ret = gate_property_get_bool(value, &prop_bool_value); | ||
| 1066 | GATE_BREAK_IF_FAILED(ret); | ||
| 1067 | |||
| 1068 | if (gate_string_equals(key, &gate_account_user_key_script_enabled)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_SCRIPT, prop_bool_value); } | ||
| 1069 | else if (gate_string_equals(key, &gate_account_user_key_account_disabled)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_ACCOUNTDISABLE, prop_bool_value); } | ||
| 1070 | else if (gate_string_equals(key, &gate_account_user_key_lockout)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_LOCKOUT, prop_bool_value); } | ||
| 1071 | else if (gate_string_equals(key, &gate_account_user_key_no_password_expiration)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_DONT_EXPIRE_PASSWD, prop_bool_value); } | ||
| 1072 | else if (gate_string_equals(key, &gate_account_user_key_password_expired)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_PASSWORD_EXPIRED, prop_bool_value); } | ||
| 1073 | else if (gate_string_equals(key, &gate_account_user_key_cannot_change_password)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_PASSWD_CANT_CHANGE, prop_bool_value); } | ||
| 1074 | else if (gate_string_equals(key, &gate_account_user_key_password_not_required)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_PASSWD_NOTREQD, prop_bool_value); } | ||
| 1075 | else if (gate_string_equals(key, &gate_account_user_key_home_dir_required)) { gate_account_update_flag(&ptr_user_info->usri2_flags, UF_ACCOUNTDISABLE, prop_bool_value); } | ||
| 1076 | else { ret = GATE_RESULT_INVALIDARG; } | ||
| 1077 | |||
| 1078 | break; | ||
| 1079 | } | ||
| 1080 | default: | ||
| 1081 | { | ||
| 1082 | break; | ||
| 1083 | } | ||
| 1084 | } | ||
| 1085 | GATE_BREAK_IF_FAILED(ret); | ||
| 1086 | |||
| 1087 | net_status = win32_netapi.NetUserSetInfo(ptr_system_name, w_user_name, 2, (LPBYTE)ptr_user_info, ¶m_error_index); | ||
| 1088 | if (0 != net_status) | ||
| 1089 | { | ||
| 1090 | ret = GATE_RESULT_FAILED; | ||
| 1091 | break; | ||
| 1092 | } | ||
| 1093 | |||
| 1094 | ret = GATE_RESULT_OK; | ||
| 1095 | } while (0); | ||
| 1096 | |||
| 1097 | if (ptr_user_info != NULL) | ||
| 1098 | { | ||
| 1099 | win32_netapi.NetApiBufferFree(ptr_user_info); | ||
| 1100 | } | ||
| 1101 | gate_string_release(&prop_str_value); | ||
| 1102 | return ret; | ||
| 1103 | } | ||
| 1104 | |||
| 1105 | |||
| 1106 | |||
| 1107 | #endif /* GATE_SYSTEM_ACCOUNTS_WINLM */ | ||
| 1108 | |||
| 1109 | #if defined(GATE_SYSTEM_ACCOUNTS_POSIX) | ||
| 1110 | |||
| 1111 | #include "gate/platforms.h" | ||
| 1112 | #include "gate/processes.h" | ||
| 1113 | #include "gate/debugging.h" | ||
| 1114 | |||
| 1115 | 45 | static gate_result_t gate_account_build_user(uid_t uid, gate_account_user_t* user) | |
| 1116 | { | ||
| 1117 | gate_result_t result; | ||
| 1118 | gate_posix_user_info_t user_info; | ||
| 1119 | |||
| 1120 | 45 | gate_mem_clear(&user_info, sizeof(user_info)); | |
| 1121 | 45 | gate_mem_clear(user, sizeof(gate_account_user_t)); | |
| 1122 | |||
| 1123 | 45 | user->short_id = (gate_uint64_t)uid; | |
| 1124 | 45 | gate_str_print_uint(user->id, sizeof(user->id), uid, 0); | |
| 1125 | |||
| 1126 | 45 | result = gate_posix_get_user_info(uid, &user_info); | |
| 1127 |
1/2✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
|
45 | if (GATE_SUCCEEDED(result)) |
| 1128 | { | ||
| 1129 | 45 | gate_str_print_text(user->name, sizeof(user->name), user_info.name, gate_str_length(user_info.name)); | |
| 1130 | 45 | gate_str_print_text(user->info, sizeof(user->info), user_info.gecos, gate_str_length(user_info.gecos)); | |
| 1131 | } | ||
| 1132 | 45 | return result; | |
| 1133 | } | ||
| 1134 | |||
| 1135 | 127 | static gate_result_t gate_account_build_group(gid_t gid, gate_account_group_t* group) | |
| 1136 | { | ||
| 1137 | gate_result_t result; | ||
| 1138 | gate_posix_group_info_t group_info; | ||
| 1139 | 127 | gate_mem_clear(&group_info, sizeof(group_info)); | |
| 1140 | 127 | gate_mem_clear(group, sizeof(gate_account_group_t)); | |
| 1141 | |||
| 1142 | 127 | group->short_id = (gate_uint64_t)gid; | |
| 1143 | 127 | gate_str_print_uint(group->id, sizeof(group->id), gid, 0); | |
| 1144 | |||
| 1145 | 127 | result = gate_posix_get_usergroup_info(gid, &group_info); | |
| 1146 |
1/2✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
|
127 | if (GATE_SUCCEEDED(result)) |
| 1147 | { | ||
| 1148 | 127 | gate_str_print_text(group->name, sizeof(group->name), group_info.name, gate_str_length(group_info.name)); | |
| 1149 | } | ||
| 1150 | 127 | return result; | |
| 1151 | } | ||
| 1152 | |||
| 1153 | 2 | gate_result_t gate_account_enum_users(gate_account_enum_users_callback_t callback, void* param) | |
| 1154 | { | ||
| 1155 | 2 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1156 | uid_t uids[1024]; | ||
| 1157 | gate_size_t uids_received; | ||
| 1158 | gate_size_t index; | ||
| 1159 | gate_account_user_t user; | ||
| 1160 | |||
| 1161 | do | ||
| 1162 | { | ||
| 1163 | 2 | uids_received = gate_posix_enum_users(uids, sizeof(uids) / sizeof(uids[0])); | |
| 1164 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 2 times.
|
44 | for (index = 0; index != uids_received; ++index) |
| 1165 | { | ||
| 1166 | 42 | gate_account_build_user(uids[index], &user); | |
| 1167 | |||
| 1168 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
|
42 | if (!callback(&user, param)) |
| 1169 | { | ||
| 1170 | ✗ | break; | |
| 1171 | } | ||
| 1172 | } | ||
| 1173 | 2 | ret = GATE_RESULT_OK; | |
| 1174 | } while (0); | ||
| 1175 | |||
| 1176 | 2 | return ret; | |
| 1177 | } | ||
| 1178 | 2 | gate_result_t gate_account_enum_groups(gate_account_enum_groups_callback_t callback, void* param) | |
| 1179 | { | ||
| 1180 | 2 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1181 | gid_t gids[1024]; | ||
| 1182 | gate_size_t gids_received; | ||
| 1183 | gate_size_t index; | ||
| 1184 | gate_account_group_t group; | ||
| 1185 | |||
| 1186 | do | ||
| 1187 | { | ||
| 1188 | 2 | gids_received = gate_posix_enum_groups(gids, sizeof(gids) / sizeof(gids[0])); | |
| 1189 |
2/2✓ Branch 0 taken 82 times.
✓ Branch 1 taken 2 times.
|
84 | for (index = 0; index != gids_received; ++index) |
| 1190 | { | ||
| 1191 | 82 | gate_account_build_group(gids[index], &group); | |
| 1192 | |||
| 1193 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 82 times.
|
82 | if (!callback(&group, param)) |
| 1194 | { | ||
| 1195 | ✗ | break; | |
| 1196 | } | ||
| 1197 | } | ||
| 1198 | 2 | ret = GATE_RESULT_OK; | |
| 1199 | } while (0); | ||
| 1200 | |||
| 1201 | 2 | return ret; | |
| 1202 | } | ||
| 1203 | 82 | gate_result_t gate_account_enum_group_members(gate_account_group_t const* group, gate_account_enum_users_callback_t callback, void* param) | |
| 1204 | { | ||
| 1205 | 82 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1206 | 82 | gid_t gid = (gid_t)group->short_id; | |
| 1207 | 82 | gate_posix_group_info_t group_info = GATE_INIT_EMPTY; | |
| 1208 | gate_size_t index; | ||
| 1209 | 82 | gate_account_user_t user = GATE_INIT_EMPTY; | |
| 1210 | |||
| 1211 | do | ||
| 1212 | { | ||
| 1213 | 82 | ret = gate_posix_get_usergroup_info(gid, &group_info); | |
| 1214 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
|
82 | GATE_BREAK_IF_FAILED(ret); |
| 1215 | |||
| 1216 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
|
82 | for (index = 0; index < group_info.members_count; ++index) |
| 1217 | { | ||
| 1218 | ✗ | gate_account_build_user(group_info.members[index], &user); | |
| 1219 | |||
| 1220 | ✗ | if (!callback(&user, param)) | |
| 1221 | { | ||
| 1222 | ✗ | break; | |
| 1223 | } | ||
| 1224 | } | ||
| 1225 | 82 | ret = GATE_RESULT_OK; | |
| 1226 | } while (0); | ||
| 1227 | |||
| 1228 | 82 | return ret; | |
| 1229 | } | ||
| 1230 | 42 | gate_result_t gate_account_enum_user_memberships(gate_account_user_t const* user, gate_account_enum_groups_callback_t callback, void* param) | |
| 1231 | { | ||
| 1232 | 42 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1233 | 42 | uid_t uid = (uid_t)user->short_id; | |
| 1234 | 42 | gate_posix_user_info_t user_info = GATE_INIT_EMPTY; | |
| 1235 | 42 | gate_account_group_t group = GATE_INIT_EMPTY; | |
| 1236 | |||
| 1237 | do | ||
| 1238 | { | ||
| 1239 | 42 | ret = gate_posix_get_user_info(uid, &user_info); | |
| 1240 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
|
42 | GATE_BREAK_IF_FAILED(ret); |
| 1241 | |||
| 1242 | 42 | gate_account_build_group(user_info.gid, &group); | |
| 1243 | |||
| 1244 | 42 | callback(&group, param); | |
| 1245 | 42 | ret = GATE_RESULT_OK; | |
| 1246 | |||
| 1247 | } while (0); | ||
| 1248 | 42 | return ret; | |
| 1249 | } | ||
| 1250 | 1 | gate_result_t gate_account_get_user(gate_string_t const* user_id, gate_account_user_t* user) | |
| 1251 | { | ||
| 1252 | 1 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1253 | 1 | gate_uint64_t ui64 = (gate_uint64_t)-1; | |
| 1254 | do | ||
| 1255 | { | ||
| 1256 | 1 | gate_str_parse_uint64(user_id->str, user_id->length, &ui64); | |
| 1257 | |||
| 1258 | 1 | ret = gate_account_build_user((uid_t)ui64, user); | |
| 1259 | } while (0); | ||
| 1260 | 1 | return ret; | |
| 1261 | } | ||
| 1262 | 2 | gate_result_t gate_account_resolve_user(gate_string_t const* user_name, gate_account_user_t* user) | |
| 1263 | { | ||
| 1264 | 2 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1265 | 2 | char user_str[128] = GATE_INIT_EMPTY; | |
| 1266 | gate_posix_user_info_t user_info; | ||
| 1267 | |||
| 1268 | do | ||
| 1269 | { | ||
| 1270 | 2 | gate_string_to_buffer(user_name, user_str, sizeof(user_str)); | |
| 1271 | |||
| 1272 | 2 | ret = gate_posix_resolve_user_info(user_str, &user_info); | |
| 1273 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret); |
| 1274 | |||
| 1275 | 2 | gate_account_build_user(user_info.uid, user); | |
| 1276 | } while (0); | ||
| 1277 | 2 | return ret; | |
| 1278 | } | ||
| 1279 | 1 | gate_result_t gate_account_get_group(gate_string_t const* group_id, gate_account_group_t* group) | |
| 1280 | { | ||
| 1281 | 1 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1282 | 1 | gate_uint64_t ui64 = (gate_uint64_t)-1; | |
| 1283 | do | ||
| 1284 | { | ||
| 1285 | 1 | gate_str_parse_uint64(group_id->str, group_id->length, &ui64); | |
| 1286 | |||
| 1287 | 1 | ret = gate_account_build_group((uid_t)ui64, group); | |
| 1288 | } while (0); | ||
| 1289 | 1 | return ret; | |
| 1290 | } | ||
| 1291 | 2 | gate_result_t gate_account_resolve_group(gate_string_t const* group_name, gate_account_group_t* group) | |
| 1292 | { | ||
| 1293 | 2 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 1294 | 2 | char group_str[128] = GATE_INIT_EMPTY; | |
| 1295 | gate_posix_group_info_t group_info; | ||
| 1296 | |||
| 1297 | do | ||
| 1298 | { | ||
| 1299 | 2 | gate_string_to_buffer(group_name, group_str, sizeof(group_str)); | |
| 1300 | |||
| 1301 | 2 | ret = gate_posix_resolve_usergroup_info(group_str, &group_info); | |
| 1302 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret); |
| 1303 | |||
| 1304 | 2 | gate_account_build_group(group_info.gid, group); | |
| 1305 | } while (0); | ||
| 1306 | 2 | return ret; | |
| 1307 | } | ||
| 1308 | 1 | gate_result_t gate_account_create_user(gate_string_t const* user_name, gate_string_t const* password) | |
| 1309 | { | ||
| 1310 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/sbin/useradd"); | ||
| 1311 | static gate_string_t const arg_home = GATE_STRING_INIT_STATIC("--create-home"); | ||
| 1312 | static gate_string_t const arg_password = GATE_STRING_INIT_STATIC("--password"); | ||
| 1313 | |||
| 1314 | gate_string_t args[4]; | ||
| 1315 | gate_size_t args_count; | ||
| 1316 | 1 | int exit_code = 0; | |
| 1317 | gate_result_t result; | ||
| 1318 | 1 | gate_stringstream_t* proc_output = gate_stringstream_create(256); | |
| 1319 | |||
| 1320 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (NULL == proc_output) |
| 1321 | { | ||
| 1322 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 1323 | } | ||
| 1324 | |||
| 1325 | 1 | gate_mem_copy(&args[0], &arg_home, sizeof(gate_string_t)); | |
| 1326 | 1 | gate_mem_copy(&args[1], user_name, sizeof(gate_string_t)); | |
| 1327 | 1 | args_count = 2; | |
| 1328 | |||
| 1329 | 1 | result = gate_process_run(&prog, args, args_count, NULL, NULL, 0, 0, (gate_stream_t*)proc_output, &exit_code); | |
| 1330 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(GATE_SUCCEEDED(result)) |
| 1331 | { | ||
| 1332 | 1 | GATE_DEBUG_TRACE_MSG_VALUE("useradd", exit_code); | |
| 1333 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | result = exit_code == 0 ? GATE_RESULT_OK : GATE_RESULT_FAILED; |
| 1334 | } | ||
| 1335 | 1 | gate_object_release(proc_output); | |
| 1336 | 1 | return result; | |
| 1337 | } | ||
| 1338 | 1 | gate_result_t gate_account_delete_user(gate_account_user_t const* user) | |
| 1339 | { | ||
| 1340 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/sbin/userdel"); | ||
| 1341 | static gate_string_t const arg_force = GATE_STRING_INIT_STATIC("--force"); | ||
| 1342 | static gate_string_t const arg_remove = GATE_STRING_INIT_STATIC("--remove"); | ||
| 1343 | |||
| 1344 | gate_string_t args[4]; | ||
| 1345 | gate_size_t args_count; | ||
| 1346 | 1 | int exit_code = 0; | |
| 1347 | gate_result_t result; | ||
| 1348 | 1 | gate_stringstream_t* proc_output = gate_stringstream_create(256); | |
| 1349 | |||
| 1350 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (NULL == proc_output) |
| 1351 | { | ||
| 1352 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 1353 | } | ||
| 1354 | |||
| 1355 | |||
| 1356 | 1 | gate_mem_copy(&args[0], &arg_force, sizeof(gate_string_t)); | |
| 1357 | 1 | gate_mem_copy(&args[1], &arg_remove, sizeof(gate_string_t)); | |
| 1358 | 1 | gate_string_create_static(&args[2], user->name); | |
| 1359 | 1 | args_count = 3; | |
| 1360 | |||
| 1361 | 1 | result = gate_process_run(&prog, args, args_count, NULL, NULL, 0, 0, (gate_stream_t*)proc_output, &exit_code); | |
| 1362 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(GATE_SUCCEEDED(result)) |
| 1363 | { | ||
| 1364 | 1 | GATE_DEBUG_TRACE_MSG_VALUE("userdel", exit_code); | |
| 1365 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | result = exit_code == 0 ? GATE_RESULT_OK : GATE_RESULT_FAILED; |
| 1366 | } | ||
| 1367 | 1 | gate_object_release(proc_output); | |
| 1368 | 1 | return result; | |
| 1369 | } | ||
| 1370 | 1 | gate_result_t gate_account_create_group(gate_string_t const* group_name) | |
| 1371 | { | ||
| 1372 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/sbin/groupadd"); | ||
| 1373 | |||
| 1374 | gate_string_t args[4]; | ||
| 1375 | gate_size_t args_count; | ||
| 1376 | 1 | int exit_code = 0; | |
| 1377 | gate_result_t result; | ||
| 1378 | 1 | gate_stringstream_t* proc_output = gate_stringstream_create(256); | |
| 1379 | |||
| 1380 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (NULL == proc_output) |
| 1381 | { | ||
| 1382 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 1383 | } | ||
| 1384 | |||
| 1385 | 1 | gate_mem_copy(&args[0], group_name, sizeof(gate_string_t)); | |
| 1386 | 1 | args_count = 1; | |
| 1387 | |||
| 1388 | 1 | result = gate_process_run(&prog, args, args_count, NULL, NULL, 0, 0, (gate_stream_t*)proc_output, &exit_code); | |
| 1389 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(GATE_SUCCEEDED(result)) |
| 1390 | { | ||
| 1391 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | result = exit_code == 0 ? GATE_RESULT_OK : GATE_RESULT_FAILED; |
| 1392 | } | ||
| 1393 | 1 | gate_object_release(proc_output); | |
| 1394 | 1 | return result; | |
| 1395 | } | ||
| 1396 | 1 | gate_result_t gate_account_delete_group(gate_account_group_t const* group) | |
| 1397 | { | ||
| 1398 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/sbin/groupdel"); | ||
| 1399 | |||
| 1400 | gate_string_t args[4]; | ||
| 1401 | gate_size_t args_count; | ||
| 1402 | 1 | int exit_code = 0; | |
| 1403 | gate_result_t result; | ||
| 1404 | 1 | gate_stringstream_t* proc_output = gate_stringstream_create(256); | |
| 1405 | |||
| 1406 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (NULL == proc_output) |
| 1407 | { | ||
| 1408 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 1409 | } | ||
| 1410 | |||
| 1411 | 1 | gate_string_create_static(&args[0], group->name); | |
| 1412 | 1 | args_count = 1; | |
| 1413 | |||
| 1414 | 1 | result = gate_process_run(&prog, args, args_count, NULL, NULL, 0, 0, (gate_stream_t*)proc_output, &exit_code); | |
| 1415 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(GATE_SUCCEEDED(result)) |
| 1416 | { | ||
| 1417 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | result = exit_code == 0 ? GATE_RESULT_OK : GATE_RESULT_FAILED; |
| 1418 | } | ||
| 1419 | 1 | gate_object_release(proc_output); | |
| 1420 | 1 | return result; | |
| 1421 | } | ||
| 1422 | 1 | gate_result_t gate_account_add_user_to_group(gate_account_user_t const* user, gate_account_group_t const* group) | |
| 1423 | { | ||
| 1424 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/sbin/usermod"); | ||
| 1425 | static gate_string_t const arg_append = GATE_STRING_INIT_STATIC("--append"); | ||
| 1426 | static gate_string_t const arg_groups = GATE_STRING_INIT_STATIC("--groups"); | ||
| 1427 | |||
| 1428 | gate_string_t args[4]; | ||
| 1429 | gate_size_t args_count; | ||
| 1430 | int exit_code; | ||
| 1431 | gate_result_t result; | ||
| 1432 | 1 | gate_stringstream_t* proc_output = gate_stringstream_create(256); | |
| 1433 | |||
| 1434 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (NULL == proc_output) |
| 1435 | { | ||
| 1436 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 1437 | } | ||
| 1438 | |||
| 1439 | 1 | gate_mem_copy(&args[0], &arg_append, sizeof(gate_string_t)); | |
| 1440 | 1 | gate_mem_copy(&args[1], &arg_groups, sizeof(gate_string_t)); | |
| 1441 | 1 | gate_string_create_static(&args[2], group->name); | |
| 1442 | 1 | gate_string_create_static(&args[3], user->name); | |
| 1443 | 1 | args_count = 4; | |
| 1444 | |||
| 1445 | 1 | result = gate_process_run(&prog, args, args_count, NULL, NULL, 0, 0, (gate_stream_t*)proc_output, &exit_code); | |
| 1446 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(GATE_SUCCEEDED(result)) |
| 1447 | { | ||
| 1448 | 1 | GATE_DEBUG_TRACE_MSG_VALUE("usermod(append-group)", exit_code); | |
| 1449 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | result = exit_code == 0 ? GATE_RESULT_OK : GATE_RESULT_FAILED; |
| 1450 | } | ||
| 1451 | 1 | gate_object_release(proc_output); | |
| 1452 | 1 | return result; | |
| 1453 | } | ||
| 1454 | 1 | gate_result_t gate_account_remove_user_from_group(gate_account_user_t const* user, gate_account_group_t const* group) | |
| 1455 | { | ||
| 1456 | /* | ||
| 1457 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/sbin/usermod"); | ||
| 1458 | static gate_string_t const arg_remove = GATE_STRING_INIT_STATIC("--remove"); | ||
| 1459 | static gate_string_t const arg_groups = GATE_STRING_INIT_STATIC("--groups"); | ||
| 1460 | */ | ||
| 1461 | static gate_string_t const prog = GATE_STRING_INIT_STATIC("/usr/bin/gpasswd"); | ||
| 1462 | static gate_string_t const arg_remove = GATE_STRING_INIT_STATIC("--delete"); | ||
| 1463 | |||
| 1464 | gate_string_t args[4]; | ||
| 1465 | gate_size_t args_count; | ||
| 1466 | int exit_code; | ||
| 1467 | gate_result_t result; | ||
| 1468 | 1 | gate_stringstream_t* proc_output = gate_stringstream_create(256); | |
| 1469 | |||
| 1470 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (NULL == proc_output) |
| 1471 | { | ||
| 1472 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 1473 | } | ||
| 1474 | |||
| 1475 | /* | ||
| 1476 | gate_mem_copy(&args[0], &arg_remove, sizeof(gate_string_t)); | ||
| 1477 | gate_mem_copy(&args[1], &arg_groups, sizeof(gate_string_t)); | ||
| 1478 | gate_string_create_static(&args[2], group->name); | ||
| 1479 | gate_string_create_static(&args[3], user->name); | ||
| 1480 | args_count = 4; | ||
| 1481 | */ | ||
| 1482 | 1 | gate_mem_copy(&args[0], &arg_remove, sizeof(gate_string_t)); | |
| 1483 | 1 | gate_string_create_static(&args[1], user->name); | |
| 1484 | 1 | gate_string_create_static(&args[2], group->name); | |
| 1485 | 1 | args_count = 3; | |
| 1486 | |||
| 1487 | 1 | result = gate_process_run(&prog, args, args_count, NULL, NULL, 0, 0, (gate_stream_t*)proc_output, &exit_code); | |
| 1488 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(GATE_SUCCEEDED(result)) |
| 1489 | { | ||
| 1490 | 1 | GATE_DEBUG_TRACE_MSG_VALUE("usermod(remove-group)", exit_code); | |
| 1491 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | result = exit_code == 0 ? GATE_RESULT_OK : GATE_RESULT_FAILED; |
| 1492 | } | ||
| 1493 | 1 | gate_object_release(proc_output); | |
| 1494 | 1 | return result; | |
| 1495 | } | ||
| 1496 | 21 | gate_result_t gate_account_get_user_properties(gate_account_user_t const* user, gate_property_t* properties) | |
| 1497 | { | ||
| 1498 | 21 | gate_property_create_object(properties); | |
| 1499 | /* TODO: Implementation */ | ||
| 1500 | 21 | return GATE_RESULT_OK; | |
| 1501 | } | ||
| 1502 | ✗ | gate_result_t gate_account_set_user_property(gate_account_user_t const* user, gate_string_t const* key, gate_property_t const* value) | |
| 1503 | { | ||
| 1504 | /* TODO: Implementation */ | ||
| 1505 | ✗ | return GATE_RESULT_NOTIMPLEMENTED; | |
| 1506 | } | ||
| 1507 | |||
| 1508 | |||
| 1509 | |||
| 1510 | #endif /* GATE_SYSTEM_ACCOUNTS_POSIX */ | ||
| 1511 | |||
| 1512 | |||
| 1513 | #if defined(GATE_SYSTEM_ACCOUNTS_NO_IMPL) | ||
| 1514 | |||
| 1515 | gate_result_t gate_account_enum_users(gate_account_enum_users_callback_t callback, void* param) | ||
| 1516 | { | ||
| 1517 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1518 | } | ||
| 1519 | gate_result_t gate_account_enum_groups(gate_account_enum_groups_callback_t callback, void* param) | ||
| 1520 | { | ||
| 1521 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1522 | } | ||
| 1523 | gate_result_t gate_account_enum_group_members(gate_account_group_t const* group, gate_account_enum_users_callback_t callback, void* param) | ||
| 1524 | { | ||
| 1525 | (void)group; | ||
| 1526 | (void)callback; | ||
| 1527 | (void)param; | ||
| 1528 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1529 | } | ||
| 1530 | gate_result_t gate_account_enum_user_memberships(gate_account_group_t const* user, gate_account_enum_groups_callback_t callback, void* param) | ||
| 1531 | { | ||
| 1532 | (void)user; | ||
| 1533 | (void)callback; | ||
| 1534 | (void)param; | ||
| 1535 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1536 | } | ||
| 1537 | gate_result_t gate_account_get_user(gate_string_t const* user_id, gate_account_user_t* user) | ||
| 1538 | { | ||
| 1539 | (void)user_id; | ||
| 1540 | (void)user; | ||
| 1541 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1542 | } | ||
| 1543 | gate_result_t gate_account_resolve_user(gate_string_t const* user_name, gate_account_user_t* user) | ||
| 1544 | { | ||
| 1545 | (void)user_name; | ||
| 1546 | (void)user; | ||
| 1547 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1548 | } | ||
| 1549 | gate_result_t gate_account_get_group(gate_string_t const* group_id, gate_account_group_t* group) | ||
| 1550 | { | ||
| 1551 | (void)group_id; | ||
| 1552 | (void)group; | ||
| 1553 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1554 | } | ||
| 1555 | gate_result_t gate_account_resolve_group(gate_string_t const* group_name, gate_account_group_t* group) | ||
| 1556 | { | ||
| 1557 | (void)group_name; | ||
| 1558 | (void)group; | ||
| 1559 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1560 | } | ||
| 1561 | gate_result_t gate_account_create_user(gate_string_t const* user_name, char const* password) | ||
| 1562 | { | ||
| 1563 | (void)user_name; | ||
| 1564 | (void)password; | ||
| 1565 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1566 | } | ||
| 1567 | gate_result_t gate_account_delete_user(gate_account_user_t const* user) | ||
| 1568 | { | ||
| 1569 | (void)user; | ||
| 1570 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1571 | } | ||
| 1572 | gate_result_t gate_account_create_group(gate_string_t const* group_name) | ||
| 1573 | { | ||
| 1574 | (void)group_name; | ||
| 1575 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1576 | } | ||
| 1577 | gate_result_t gate_account_delete_group(gate_account_group_t const* group) | ||
| 1578 | { | ||
| 1579 | (void)group; | ||
| 1580 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1581 | } | ||
| 1582 | |||
| 1583 | gate_result_t gate_account_add_user_to_group(gate_account_user_t const* user, gate_account_group_t const* group) | ||
| 1584 | { | ||
| 1585 | (void)user; | ||
| 1586 | (void)group; | ||
| 1587 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1588 | } | ||
| 1589 | gate_result_t gate_account_remove_user_from_group(gate_account_user_t const* user, gate_account_group_t const* group) | ||
| 1590 | { | ||
| 1591 | (void)user; | ||
| 1592 | (void)group; | ||
| 1593 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1594 | } | ||
| 1595 | gate_result_t gate_account_get_user_properties(gate_account_user_t const* user, gate_property_t* properties) | ||
| 1596 | { | ||
| 1597 | (void)user; | ||
| 1598 | (void)properties; | ||
| 1599 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1600 | } | ||
| 1601 | gate_result_t gate_account_set_user_property(gate_account_user_t const* user, gate_string_t const* key, gate_property_t const* value); | ||
| 1602 | { | ||
| 1603 | (void)user; | ||
| 1604 | (void)key; | ||
| 1605 | (void)value; | ||
| 1606 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1607 | } | ||
| 1608 | |||
| 1609 | #endif /* GATE_SYSTEM_ACCOUNTS_POSIX */ | ||
| 1610 | |||
| 1611 | |||
| 1612 | #ifdef GATE_SYSTEM_ACCOUNTS_NOIMPL | ||
| 1613 | |||
| 1614 | gate_result_t gate_account_enum_users(gate_account_enum_users_callback_t callback, void* param) | ||
| 1615 | { | ||
| 1616 | (void)callback; | ||
| 1617 | (void)param; | ||
| 1618 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1619 | } | ||
| 1620 | gate_result_t gate_account_enum_groups(gate_account_enum_groups_callback_t callback, void* param) | ||
| 1621 | { | ||
| 1622 | (void)callback; | ||
| 1623 | (void)param; | ||
| 1624 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1625 | } | ||
| 1626 | gate_result_t gate_account_enum_group_members(gate_account_group_t const* group, gate_account_enum_users_callback_t callback, void* param) | ||
| 1627 | { | ||
| 1628 | (void)group; | ||
| 1629 | (void)callback; | ||
| 1630 | (void)param; | ||
| 1631 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1632 | } | ||
| 1633 | gate_result_t gate_account_enum_user_memberships(gate_account_user_t const* user, gate_account_enum_groups_callback_t callback, void* param) | ||
| 1634 | { | ||
| 1635 | (void)user; | ||
| 1636 | (void)callback; | ||
| 1637 | (void)param; | ||
| 1638 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1639 | } | ||
| 1640 | gate_result_t gate_account_get_user(gate_string_t const* user_id, gate_account_user_t* user) | ||
| 1641 | { | ||
| 1642 | (void)user_id; | ||
| 1643 | (void)user; | ||
| 1644 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1645 | } | ||
| 1646 | gate_result_t gate_account_resolve_user(gate_string_t const* user_name, gate_account_user_t* user) | ||
| 1647 | { | ||
| 1648 | (void)user_name; | ||
| 1649 | (void)user; | ||
| 1650 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1651 | } | ||
| 1652 | gate_result_t gate_account_get_group(gate_string_t const* group_id, gate_account_group_t* group) | ||
| 1653 | { | ||
| 1654 | (void)group_id; | ||
| 1655 | (void)group; | ||
| 1656 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1657 | } | ||
| 1658 | gate_result_t gate_account_resolve_group(gate_string_t const* group_name, gate_account_group_t* group) | ||
| 1659 | { | ||
| 1660 | (void)group_name; | ||
| 1661 | (void)group; | ||
| 1662 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1663 | } | ||
| 1664 | gate_result_t gate_account_create_user(gate_string_t const* user_name, gate_string_t const* password) | ||
| 1665 | { | ||
| 1666 | (void)user_name; | ||
| 1667 | (void)password; | ||
| 1668 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1669 | } | ||
| 1670 | gate_result_t gate_account_delete_user(gate_account_user_t const* user) | ||
| 1671 | { | ||
| 1672 | (void)user; | ||
| 1673 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1674 | } | ||
| 1675 | gate_result_t gate_account_create_group(gate_string_t const* group_name) | ||
| 1676 | { | ||
| 1677 | (void)group_name; | ||
| 1678 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1679 | } | ||
| 1680 | gate_result_t gate_account_delete_group(gate_account_group_t const* group) | ||
| 1681 | { | ||
| 1682 | (void)group; | ||
| 1683 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1684 | } | ||
| 1685 | gate_result_t gate_account_add_user_to_group(gate_account_user_t const* user, gate_account_group_t const* group) | ||
| 1686 | { | ||
| 1687 | (void)user; | ||
| 1688 | (void)group; | ||
| 1689 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1690 | } | ||
| 1691 | gate_result_t gate_account_remove_user_from_group(gate_account_user_t const* user, gate_account_group_t const* group) | ||
| 1692 | { | ||
| 1693 | (void)user; | ||
| 1694 | (void)group; | ||
| 1695 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1696 | } | ||
| 1697 | gate_result_t gate_account_get_user_properties(gate_account_user_t const* user, gate_property_t* properties) | ||
| 1698 | { | ||
| 1699 | (void)user; | ||
| 1700 | (void)properties; | ||
| 1701 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1702 | } | ||
| 1703 | gate_result_t gate_account_set_user_property(gate_account_user_t const* user, gate_string_t const* key, gate_property_t const* value) | ||
| 1704 | { | ||
| 1705 | (void)user; | ||
| 1706 | (void)key; | ||
| 1707 | (void)value; | ||
| 1708 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 1709 | } | ||
| 1710 | |||
| 1711 | |||
| 1712 | #endif /* GATE_SYSTEM_ACCOUNTS_NOIMPL */ | ||
| 1713 | |||
| 1714 |