Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
462d348e
Commit
462d348e
authored
Dec 06, 2016
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpcrt4/tests: Register an exception with the firewall to avoid a dialog.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
048a80ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
1 deletion
+146
-1
Makefile.in
dlls/rpcrt4/tests/Makefile.in
+1
-1
server.c
dlls/rpcrt4/tests/server.c
+145
-0
No files found.
dlls/rpcrt4/tests/Makefile.in
View file @
462d348e
TESTDLL
=
rpcrt4.dll
IMPORTS
=
ole32 rpcrt4 secur32 advapi32
IMPORTS
=
ole
aut32 ole
32 rpcrt4 secur32 advapi32
EXTRAIDLFLAGS
=
--prefix-server
=
s_
C_SRCS
=
\
...
...
dlls/rpcrt4/tests/server.c
View file @
462d348e
...
...
@@ -18,10 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <windows.h>
#include <ole2.h>
#include <oleauto.h>
#include <secext.h>
#include <rpcdce.h>
#include <initguid.h>
#include <netfw.h>
#include "wine/test.h"
#include "server.h"
#include "server_defines.h"
...
...
@@ -1755,14 +1759,142 @@ server(void)
}
}
static
BOOL
is_process_elevated
(
void
)
{
HANDLE
token
;
if
(
OpenProcessToken
(
GetCurrentProcess
(),
TOKEN_QUERY
,
&
token
))
{
TOKEN_ELEVATION_TYPE
type
;
DWORD
size
;
BOOL
ret
;
ret
=
GetTokenInformation
(
token
,
TokenElevationType
,
&
type
,
sizeof
(
type
),
&
size
);
CloseHandle
(
token
);
return
(
ret
&&
type
==
TokenElevationTypeFull
);
}
return
FALSE
;
}
static
BOOL
is_firewall_enabled
(
void
)
{
HRESULT
hr
,
init
;
INetFwMgr
*
mgr
=
NULL
;
INetFwPolicy
*
policy
=
NULL
;
INetFwProfile
*
profile
=
NULL
;
VARIANT_BOOL
enabled
=
VARIANT_FALSE
;
init
=
CoInitializeEx
(
0
,
COINIT_APARTMENTTHREADED
);
hr
=
CoCreateInstance
(
&
CLSID_NetFwMgr
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_INetFwMgr
,
(
void
**
)
&
mgr
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
INetFwMgr_get_LocalPolicy
(
mgr
,
&
policy
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
INetFwPolicy_get_CurrentProfile
(
policy
,
&
profile
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
INetFwProfile_get_FirewallEnabled
(
profile
,
&
enabled
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
done:
if
(
policy
)
INetFwPolicy_Release
(
policy
);
if
(
profile
)
INetFwProfile_Release
(
profile
);
if
(
mgr
)
INetFwMgr_Release
(
mgr
);
if
(
SUCCEEDED
(
init
))
CoUninitialize
();
return
(
enabled
==
VARIANT_TRUE
);
}
enum
firewall_op
{
APP_ADD
,
APP_REMOVE
};
static
HRESULT
set_firewall
(
enum
firewall_op
op
)
{
static
const
WCHAR
testW
[]
=
{
'r'
,
'p'
,
'c'
,
'r'
,
't'
,
'4'
,
'_'
,
't'
,
'e'
,
's'
,
't'
,
0
};
HRESULT
hr
,
init
;
INetFwMgr
*
mgr
=
NULL
;
INetFwPolicy
*
policy
=
NULL
;
INetFwProfile
*
profile
=
NULL
;
INetFwAuthorizedApplication
*
app
=
NULL
;
INetFwAuthorizedApplications
*
apps
=
NULL
;
BSTR
name
,
image
=
SysAllocStringLen
(
NULL
,
MAX_PATH
);
if
(
!
GetModuleFileNameW
(
NULL
,
image
,
MAX_PATH
))
{
SysFreeString
(
image
);
return
E_FAIL
;
}
init
=
CoInitializeEx
(
0
,
COINIT_APARTMENTTHREADED
);
hr
=
CoCreateInstance
(
&
CLSID_NetFwMgr
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_INetFwMgr
,
(
void
**
)
&
mgr
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
INetFwMgr_get_LocalPolicy
(
mgr
,
&
policy
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
INetFwPolicy_get_CurrentProfile
(
policy
,
&
profile
);
if
(
hr
!=
S_OK
)
goto
done
;
INetFwProfile_get_AuthorizedApplications
(
profile
,
&
apps
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
CoCreateInstance
(
&
CLSID_NetFwAuthorizedApplication
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_INetFwAuthorizedApplication
,
(
void
**
)
&
app
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
INetFwAuthorizedApplication_put_ProcessImageFileName
(
app
,
image
);
if
(
hr
!=
S_OK
)
goto
done
;
name
=
SysAllocString
(
testW
);
hr
=
INetFwAuthorizedApplication_put_Name
(
app
,
name
);
SysFreeString
(
name
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
goto
done
;
if
(
op
==
APP_ADD
)
hr
=
INetFwAuthorizedApplications_Add
(
apps
,
app
);
else
if
(
op
==
APP_REMOVE
)
hr
=
INetFwAuthorizedApplications_Remove
(
apps
,
image
);
else
hr
=
E_INVALIDARG
;
done:
if
(
app
)
INetFwAuthorizedApplication_Release
(
app
);
if
(
apps
)
INetFwAuthorizedApplications_Release
(
apps
);
if
(
policy
)
INetFwPolicy_Release
(
policy
);
if
(
profile
)
INetFwProfile_Release
(
profile
);
if
(
mgr
)
INetFwMgr_Release
(
mgr
);
if
(
SUCCEEDED
(
init
))
CoUninitialize
();
SysFreeString
(
image
);
return
hr
;
}
START_TEST
(
server
)
{
ULONG
size
=
0
;
int
argc
;
char
**
argv
;
BOOL
firewall_enabled
=
is_firewall_enabled
();
InitFunctionPointers
();
if
(
firewall_enabled
&&
!
is_process_elevated
())
{
trace
(
"no privileges, skipping tests to avoid firewall dialog
\n
"
);
return
;
}
ok
(
!
GetUserNameExA
(
NameSamCompatible
,
NULL
,
&
size
),
"GetUserNameExA
\n
"
);
domain_and_user
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
ok
(
GetUserNameExA
(
NameSamCompatible
,
domain_and_user
,
&
size
),
"GetUserNameExA
\n
"
);
...
...
@@ -1783,7 +1915,20 @@ START_TEST(server)
RpcEndExcept
}
else
{
if
(
firewall_enabled
)
{
HRESULT
hr
=
set_firewall
(
APP_ADD
);
if
(
hr
!=
S_OK
)
{
skip
(
"can't authorize app in firewall %08x
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
domain_and_user
);
return
;
}
}
server
();
if
(
firewall_enabled
)
set_firewall
(
APP_REMOVE
);
}
HeapFree
(
GetProcessHeap
(),
0
,
domain_and_user
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment