Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
5ea2d901
Commit
5ea2d901
authored
Jun 02, 2015
by
Salvador Fandino
Committed by
Mike Gabriel
Jul 04, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite SetupUnixSocket to use ListenConnectionUnix
parent
c5a2cf82
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
70 deletions
+20
-70
Loop.cpp
nxcomp/Loop.cpp
+20
-70
No files found.
nxcomp/Loop.cpp
View file @
5ea2d901
...
...
@@ -3954,90 +3954,40 @@ int SetupUnixSocket()
// Open UNIX domain socket for display.
//
unixFD
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
PF_UNSPEC
);
if
(
unixFD
==
-
1
)
{
if
(
!
control
->
TempPath
)
{
#ifdef PANIC
*
logofs
<<
"Loop: PANIC! Call to socket failed for UNIX domain"
<<
". Error is "
<<
EGET
()
<<
" '"
<<
ESTR
()
<<
"'.
\n
"
<<
logofs_flush
;
*
logofs
<<
"Loop: PANIC! Temporal path is null.
\n
"
<<
logofs_flush
;
#endif
cerr
<<
"Error"
<<
": Call to socket failed for UNIX domain"
<<
". Error is "
<<
EGET
()
<<
" '"
<<
ESTR
()
<<
"'.
\n
"
;
cerr
<<
"Error"
<<
": Temporal path is null.
\n
"
;
HandleCleanup
();
}
sockaddr_un
unixAddr
;
unixAddr
.
sun_family
=
AF_UNIX
;
unsigned
int
required
=
snprintf
(
unixSocketName
,
DEFAULT_STRING_LENGTH
,
"%s/.X11-unix"
,
control
->
TempPath
)
;
if
(
required
<
sizeof
(
unixSocketName
))
{
char
dirName
[
DEFAULT_STRING_LENGTH
];
// No need to execute the following actions conditionally
mkdir
(
unixSocketName
,
(
0777
|
S_ISVTX
));
chmod
(
unixSocketName
,
(
0777
|
S_ISVTX
));
snprintf
(
dirName
,
DEFAULT_STRING_LENGTH
-
1
,
"%s/.X11-unix"
,
control
->
TempPath
);
required
=
snprintf
(
unixSocketName
,
DEFAULT_STRING_LENGTH
,
"%s/.X11-unix/X%d"
,
control
->
TempPath
,
proxyPort
);
if
(
required
<
sizeof
(
unixSocketName
))
{
*
(
dirName
+
DEFAULT_STRING_LENGTH
-
1
)
=
'\0'
;
struct
stat
dirStat
;
if
((
stat
(
dirName
,
&
dirStat
)
==
-
1
)
&&
(
EGET
()
==
ENOENT
))
{
mkdir
(
dirName
,
(
0777
|
S_ISVTX
));
chmod
(
dirName
,
(
0777
|
S_ISVTX
));
unixFD
=
ListenConnectionUnix
(
unixSocketName
,
"x11"
);
if
(
unixFD
>=
0
)
chmod
(
unixSocketName
,
0777
);
return
unixFD
;
}
}
snprintf
(
unixSocketName
,
DEFAULT_STRING_LENGTH
-
1
,
"%s/X%d"
,
dirName
,
proxyPort
);
unixSocketName
[
0
]
=
'\0'
;
// Just in case!
strncpy
(
unixAddr
.
sun_path
,
unixSocketName
,
108
);
#ifdef TEST
*
logofs
<<
"Loop: Assuming Unix socket with name '"
<<
unixAddr
.
sun_path
<<
"'.
\n
"
<<
logofs_flush
;
#ifdef PANIC
*
logofs
<<
"Loop: PANIC! path for unix socket is too long.
\n
"
<<
logofs_flush
;
#endif
*
(
unixAddr
.
sun_path
+
107
)
=
'\0'
;
if
(
bind
(
unixFD
,
(
sockaddr
*
)
&
unixAddr
,
sizeof
(
unixAddr
))
==
-
1
)
{
#ifdef PANIC
*
logofs
<<
"Loop: PANIC! Call to bind failed for UNIX domain socket "
<<
unixSocketName
<<
". Error is "
<<
EGET
()
<<
" '"
<<
ESTR
()
<<
"'.
\n
"
<<
logofs_flush
;
#endif
cerr
<<
"Error"
<<
": Call to bind failed for UNIX domain socket "
<<
unixSocketName
<<
". Error is "
<<
EGET
()
<<
" '"
<<
ESTR
()
<<
"'.
\n
"
;
HandleCleanup
();
}
if
(
listen
(
unixFD
,
8
)
==
-
1
)
{
#ifdef PANIC
*
logofs
<<
"Loop: PANIC! Call to listen failed for UNIX domain socket "
<<
unixSocketName
<<
". Error is "
<<
EGET
()
<<
" '"
<<
ESTR
()
<<
"'.
\n
"
<<
logofs_flush
;
#endif
cerr
<<
"Error"
<<
": Call to listen failed for UNIX domain socket "
<<
unixSocketName
<<
". Error is "
<<
EGET
()
<<
" '"
<<
ESTR
()
<<
"'.
\n
"
;
HandleCleanup
();
}
//
// Let any local user to gain access to socket.
//
chmod
(
unixSocketName
,
0777
);
return
1
;
cerr
<<
"Error"
<<
": path for Unix socket is too long.
\n
"
;
HandleCleanup
();
}
//
...
...
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