~proot/proot/trunk

« back to all changes in this revision

Viewing changes to src/cli/proot.h

  • Committer: GitHub
  • Author(s): jopasserat
  • Date: 2017-10-15 18:17:16 UTC
  • mfrom: (746.1.14)
  • Revision ID: git-v1:0bf2ee17daafeeadfed079cec97fe1ac781e696a
Merge pull request #116 from proot-me/port_mapper

Implement port mapping feature in PRoot to relocate services running on privileged ports or avoid port clash for applications running within PRoot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
static int handle_option_k(Tracee *tracee, const Cli *cli, const char *value);
59
59
static int handle_option_0(Tracee *tracee, const Cli *cli, const char *value);
60
60
static int handle_option_i(Tracee *tracee, const Cli *cli, const char *value);
 
61
static int handle_option_p(Tracee *tracee, const Cli *cli, const char *value);
 
62
static int handle_option_n(Tracee *tracee, const Cli *cli, const char *value);
61
63
static int handle_option_R(Tracee *tracee, const Cli *cli, const char *value);
62
64
static int handle_option_S(Tracee *tracee, const Cli *cli, const char *value);
63
65
static int handle_option_kill_on_exit(Tracee *tracee, const Cli *cli, const char *value);
226
228
\tgroup appear as if they were owned by uid and gid instead.\n\
227
229
\tNote that the -0 option is the same as -i 0:0.",
228
230
        },
 
231
        { .class = "Extension options",
 
232
          .arguments = {
 
233
                { .name = "-p", .separator = ' ', .value = "string" },
 
234
                { .name = "--port", .separator = '=', .value = "string" },
 
235
                { .name = NULL, .separator = '\0', .value = NULL } },
 
236
          .handler = handle_option_p,
 
237
          .description = "Map ports to others with the syntax as *string* \"port_in:port_out\".",
 
238
          .detail = "\tThis option makes PRoot intercept bind and connect system calls,\n\
 
239
\tand change the port they use. The port map is specified\n\
 
240
\twith the syntax: -b *port_in*:*port_out*. For example,\n\
 
241
\tan application that runs a MySQL server binding to 5432 wants\n\
 
242
\tto cohabit with other similar application, but doesn't have an\n\
 
243
\toption to change its port. PRoot can be used here to modify\n\
 
244
\tthis port: proot -p 5432:5433 myapplication. With this command,\n\
 
245
\tthe MySQL server will be bound to the port 5433.\n\
 
246
\tThis command can be repeated multiple times to map multiple ports.",
 
247
        },
 
248
        { .class = "Extension options",
 
249
          .arguments = {
 
250
                { .name = "-n", .separator = '\0', .value = NULL },
 
251
                { .name = "--netcoop", .separator = '\0', .value = NULL },
 
252
                { .name = NULL, .separator = '\0', .value = NULL } },
 
253
          .handler = handle_option_n,
 
254
          .description = "Enable the network cooperation mode.",
 
255
          .detail = "\tThis option makes PRoot intercept bind() system calls and\n\
 
256
\tchange the port they are binding to to 0. With this, the system will\n\
 
257
\tallocate an available port. Each time this is done, a new entry is added\n\
 
258
\tto the port mapping entries, so that corresponding connect() system calls\n\
 
259
\tuse the same resulting port. This network \"cooperation\" makes it possible\n\
 
260
\tto run multiple instances of a same program without worrying about the same ports\n\
 
261
\tbeing used twice.",
 
262
        },
229
263
        { .class = "Alias options",
230
264
          .arguments = {
231
265
                { .name = "-R", .separator = ' ', .value = "path" },