FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
rstudio/src/cpp/server/ServerOptions.cpp at master · usersbin/rstudio · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
usersbin
/
rstudio
Public
forked from
rstudio/rstudio
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
rstudio
/
src
/
cpp
/
server
/
ServerOptions.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
214 lines (185 loc) · 7.26 KB
Breadcrumbs
rstudio
/
src
/
cpp
/
server
/
ServerOptions.cpp
Copy path
File metadata and controls
214 lines (185 loc) · 7.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
* ServerOptions.cpp
*
* Copyright (C) 2009-11 by RStudio, Inc.
*
* This program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
#
include
<
server/ServerOptions.hpp
>
#
include
<
core/ProgramStatus.hpp
>
#
include
<
core/ProgramOptions.hpp
>
#
include
<
core/FilePath.hpp
>
#
include
<
core/system/System.hpp
>
#
include
<
server/util/system/System.hpp
>
#
include
<
server/util/system/User.hpp
>
#
include
"
ServerAppArmor.hpp
"
#
include
"
config.h
"
using
namespace
core
;
namespace
server
{
namespace
{
const
char
*
const
kDefaultProgramUser
=
"
rstudio-server
"
;
void
resolvePath
(
const
FilePath& installPath, std::string* pPath)
{
if
(!pPath->
empty
())
*pPath = installPath.
complete
(*pPath).
absolutePath
();
}
}
//
anonymous namespace
Options&
options
()
{
static
Options instance ;
return
instance ;
}
ProgramStatus
Options::read
(
int
argc,
char
*
const
argv[])
{
using
namespace
boost
::program_options
;
//
compute install path
FilePath installPath;
Error error =
core::system::installPath
(
"
..
"
, argc, argv, &installPath);
if
(error)
{
LOG_ERROR_MESSAGE
(
"
Unable to determine install path:
"
+error.
summary
());
return
ProgramStatus::exitFailure
();
}
//
verify installation flag
options_description
verify
(
"
verify
"
);
verify.
add_options
()
(
"
verify-installation
"
,
value<
bool
>(&verifyInstallation_)->
default_value
(
false
),
"
verify the current installation
"
);
//
special program offline option (based on file existence at
//
startup for easy bash script enable/disable of offline state)
serverOffline_ =
FilePath
(
"
/etc/rstudio/offline
"
).
exists
();
//
program - name and execution
options_description
server
(
"
server
"
);
server.
add_options
()
(
"
server-working-dir
"
,
value<std::string>(&serverWorkingDir_)->
default_value
(
"
/
"
),
"
program working directory
"
)
(
"
server-user
"
,
value<std::string>(&serverUser_)->
default_value
(
kDefaultProgramUser
),
"
program user
"
)
(
"
server-daemonize
"
,
value<
bool
>(&serverDaemonize_)->
default_value
(
1
),
"
run program as daemon
"
)
(
"
server-app-armor-enabled
"
,
value<
bool
>(&serverAppArmorEnabled_)->
default_value
(
1
),
"
is app armor enabled for this session
"
);
//
www - web server options
options_description
www
(
"
www
"
) ;
www.
add_options
()
(
"
www-address
"
,
value<std::string>(&wwwAddress_)->
default_value
(
"
0.0.0.0
"
),
"
server address
"
)
(
"
www-port
"
,
value<std::string>(&wwwPort_)->
default_value
(
"
8787
"
),
"
port to listen on
"
)
(
"
www-local-path
"
,
value<std::string>(&wwwLocalPath_)->
default_value
(
"
www
"
),
"
www files path
"
)
(
"
www-thread-pool-size
"
,
value<
int
>(&wwwThreadPoolSize_)->
default_value
(
2
),
"
thread pool size
"
);
//
rsession
options_description
rsession
(
"
rsession
"
);
rsession.
add_options
()
(
"
rsession-which-r
"
,
value<std::string>(&rsessionWhichR_)->
default_value
(
"
"
),
"
path to main R program (e.g. /usr/bin/R)
"
)
(
"
rsession-path
"
,
value<std::string>(&rsessionPath_)->
default_value
(
"
bin/rsession
"
),
"
path to rsession executable
"
)
(
"
rldpath-path
"
,
value<std::string>(&rldpathPath_)->
default_value
(
"
bin/r-ldpath
"
),
"
path to r-ldpath script
"
)
(
"
rsession-ld-library-path
"
,
value<std::string>(&rsessionLdLibraryPath_)->
default_value
(
"
"
),
"
default LD_LIBRARY_PATH for rsession
"
)
(
"
rsession-config-file
"
,
value<std::string>(&rsessionConfigFile_)->
default_value
(
"
"
),
"
path to rsession config file
"
)
(
"
rsession-memory-limit-mb
"
,
value<
int
>(&rsessionMemoryLimitMb_)->
default_value
(
0
),
"
rsession memory limit (mb)
"
)
(
"
rsession-stack-limit-mb
"
,
value<
int
>(&rsessionStackLimitMb_)->
default_value
(
0
),
"
rsession stack limit (mb)
"
)
(
"
rsession-process-limit
"
,
value<
int
>(&rsessionUserProcessLimit_)->
default_value
(
0
),
"
rsession user process limit
"
);
//
still read depracated options (so we don't break config files)
bool
deprecatedAuthPamRequiresPriv;
options_description
auth
(
"
auth
"
);
auth.
add_options
()
(
"
auth-validate-users
"
,
value<
bool
>(&authValidateUsers_)->
default_value
(
true
),
"
validate that authenticated users exist on the target system
"
)
(
"
auth-required-user-group
"
,
value<std::string>(&authRequiredUserGroup_)->
default_value
(
"
"
),
"
limit to users belonging to the specified group
"
)
(
"
auth-pam-helper-path
"
,
value<std::string>(&authPamHelperPath_)->
default_value
(
"
bin/rserver-pam
"
),
"
path to PAM helper binary
"
)
(
"
auth-pam-requires-priv
"
,
value<
bool
>(&deprecatedAuthPamRequiresPriv)->
default_value
(
true
),
"
deprecated: will always be true
"
);
//
define program options
FilePath
defaultConfigPath
(
"
/etc/rstudio/rserver.conf
"
);
std::string configFile = defaultConfigPath.
exists
() ?
defaultConfigPath.
absolutePath
() :
"
"
;
program_options::OptionsDescription
optionsDesc
(
"
rserver
"
, configFile);
optionsDesc.
commandLine
.
add
(verify).
add
(server).
add
(www).
add
(rsession).
add
(auth);
optionsDesc.
configFile
.
add
(server).
add
(www).
add
(rsession).
add
(auth);
//
read options
ProgramStatus status =
core::program_options::read
(optionsDesc, argc, argv);
if
(status.
exit
())
return
status;
//
if specified, confirm that the program user exists. however, if the
//
program user is the default and it doesn't exist then allow that to pass,
//
this just means that the user did a simple make install and hasn't setup
//
an rserver user yet. in this case the program will run as root
if
(!serverUser_.
empty
())
{
//
if we aren't running as root then forget the programUser
if
(!
util::system::realUserIsRoot
())
{
serverUser_ =
"
"
;
}
//
if there is a program user specified and it doesn't exist....
else
if
(!
util::system::user::exists
(serverUser_))
{
if
(serverUser_ ==
kDefaultProgramUser
)
{
//
administrator hasn't created an rserver system account yet
//
so run as root
serverUser_ =
"
"
;
}
else
{
LOG_ERROR_MESSAGE
(
"
Server user
"
+ serverUser_ +
"
does not exist
"
);
return
ProgramStatus::exitFailure
();
}
}
}
//
if app armor is enabled do a further check to see whether
//
the profile exists. if it doesn't then disable it
if
(serverAppArmorEnabled_)
{
if
(!
FilePath
(
"
/etc/apparmor.d/rstudio-server
"
).
exists
())
serverAppArmorEnabled_ =
false
;
}
//
convert relative paths by completing from the system installation
//
path (this allows us to be relocatable)
resolvePath
(installPath, &wwwLocalPath_);
resolvePath
(installPath, &authPamHelperPath_);
resolvePath
(installPath, &rsessionPath_);
resolvePath
(installPath, &rldpathPath_);
resolvePath
(installPath, &rsessionConfigFile_);
//
return status
return
status;
}
}
//
namespace server
Back
|
FazBrowse Home
|
New Git URL