37 L
"management-forget-disconnect",
39 L
"management-query-passwords",
40 L
"management-query-proxy",
42 L
"management-up-down",
53 static BOOL
IsUserInGroup(PSID sid,
const PTOKEN_GROUPS groups,
const WCHAR *group_name);
65 const WCHAR *config_file = NULL;
66 const WCHAR *config_dir = NULL;
69 if (PathIsRelativeW(fname) )
71 swprintf(tmp, _countof(tmp), L
"%ls\\%ls", workdir, fname);
81 if (wcsncmp(config_dir, config_file, wcslen(config_dir)) == 0
82 && wcsstr(config_file + wcslen(config_dir), L
"..") == NULL)
119 PSID admin_sid = NULL;
120 DWORD sid_size = SECURITY_MAX_SID_SIZE;
124 DWORD dlen = _countof(domain);
126 admin_sid = malloc(sid_size);
132 b = CreateWellKnownSid(WinBuiltinAdministratorsSid, NULL, admin_sid, &sid_size);
135 b = LookupAccountSidW(NULL, admin_sid, name, &nlen, domain, &dlen, &snu);
150 const WCHAR *admin_group[2];
156 SID_NAME_USE sid_type;
159 if (!LookupAccountSidW(NULL, sid, username, &len, domain, &len, &sid_type))
169 admin_group[0] = sysadmin_group;
177 admin_group[1] = ovpn_admin_group;
180 for (
int i = 0; i < 2; ++i)
185 MsgToEventLog(
M_INFO, TEXT(
"Authorizing user '%ls@%ls' by virtue of membership in group '%ls'"),
186 username, domain, admin_group[i]);
204 PTOKEN_GROUPS groups = NULL;
207 if (!GetTokenInformation(token, TokenGroups, groups, buf_size, &buf_size)
208 && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
210 groups = malloc(buf_size);
216 else if (!GetTokenInformation(token, TokenGroups, groups, buf_size, &buf_size))
236 DWORD dlen = _countof(domain);
238 if (!LookupAccountName(NULL, name, sid, &sid_size, domain, &dlen, &su))
258 IsUserInGroup(PSID sid,
const PTOKEN_GROUPS token_groups,
const WCHAR *group_name)
261 DWORD_PTR resume = 0;
263 BYTE grp_sid[SECURITY_MAX_SID_SIZE];
267 if (token_groups &&
LookupSID(group_name, (PSID) grp_sid, _countof(grp_sid)))
269 for (DWORD i = 0; i < token_groups->GroupCount; ++i)
271 if (EqualSid((PSID) grp_sid, token_groups->Groups[i].Sid))
286 LOCALGROUP_MEMBERS_INFO_0 *members = NULL;
287 err = NetLocalGroupGetMembers(NULL, group_name, 0, (LPBYTE *) &members,
288 MAX_PREFERRED_LENGTH, &nread, &nmax, &resume);
289 if ((err != NERR_Success && err != ERROR_MORE_DATA))
294 for (DWORD i = 0; i < nread && !ret; ++i)
296 ret = EqualSid(members[i].lgrmi0_sid, sid);
298 NetApiBufferFree(members);
300 }
while (err == ERROR_MORE_DATA && nloop++ < 100);
302 if (err != NERR_Success && err != NERR_GroupNotFound)
321 if (wcscmp(
argv[0], L
"--config") == 0