Allow remote connections from the command-line interface
This commit is contained in:
parent
ea55bbac5d
commit
4eeef5bb5b
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <System.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
@ -39,7 +38,7 @@ struct _Init
|
||||||
/* public */
|
/* public */
|
||||||
/* functions */
|
/* functions */
|
||||||
/* init_new */
|
/* init_new */
|
||||||
Init * init_new(char const * profile)
|
Init * init_new(AppServerOptions options, char const * profile)
|
||||||
{
|
{
|
||||||
Init * init;
|
Init * init;
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ Init * init_new(char const * profile)
|
||||||
? session_new("Init", profile, init->event) : NULL;
|
? session_new("Init", profile, init->event) : NULL;
|
||||||
/* FIXME ASO_LOCAL or ASO_REMOTE comes from the configuration file */
|
/* FIXME ASO_LOCAL or ASO_REMOTE comes from the configuration file */
|
||||||
init->appserver = (init->event != NULL)
|
init->appserver = (init->event != NULL)
|
||||||
? appserver_new_event("Init", ASO_REMOTE, init->event) : NULL;
|
? appserver_new_event("Init", options, init->event) : NULL;
|
||||||
/* FIXME handle signals (Event class?) */
|
/* FIXME handle signals (Event class?) */
|
||||||
/* error handling */
|
/* error handling */
|
||||||
if(init->event == NULL || init->appserver == NULL)
|
if(init->event == NULL || init->appserver == NULL)
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#ifndef INIT_INIT_H
|
#ifndef INIT_INIT_H
|
||||||
# define INIT_INIT_H
|
# define INIT_INIT_H
|
||||||
|
|
||||||
|
# include <System.h>
|
||||||
|
|
||||||
|
|
||||||
/* Init */
|
/* Init */
|
||||||
/* types */
|
/* types */
|
||||||
|
@ -25,7 +27,7 @@ typedef struct _Init Init;
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
Init * init_new(char const * profile);
|
Init * init_new(AppServerOptions options, char const * profile);
|
||||||
void init_delete(Init * init);
|
void init_delete(Init * init);
|
||||||
|
|
||||||
/* AppInterface */
|
/* AppInterface */
|
||||||
|
|
22
src/main.c
22
src/main.c
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <System.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
@ -27,14 +26,14 @@
|
||||||
|
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
static int _init(char const * profile);
|
static int _init(AppServerOptions options, char const * profile);
|
||||||
static int _usage(void);
|
static int _usage(void);
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
/* private */
|
/* private */
|
||||||
/* init */
|
/* init */
|
||||||
static int _init(char const * profile)
|
static int _init(AppServerOptions options, char const * profile)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Init * init;
|
Init * init;
|
||||||
|
@ -42,7 +41,7 @@ static int _init(char const * profile)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, profile);
|
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, profile);
|
||||||
#endif
|
#endif
|
||||||
if((init = init_new(profile)) == NULL)
|
if((init = init_new(options, profile)) == NULL)
|
||||||
return error_print(PACKAGE);
|
return error_print(PACKAGE);
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
@ -59,8 +58,10 @@ static int _init(char const * profile)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: " PACKAGE " -s [-P profile]\n"
|
fputs("Usage: " PACKAGE " [-L|-R] -s [-P profile]\n"
|
||||||
|
" -L Only bind to the local machine\n"
|
||||||
" -P Profile to load\n"
|
" -P Profile to load\n"
|
||||||
|
" -R Allow remote connections\n"
|
||||||
" -s Force the single-user profile\n", stderr);
|
" -s Force the single-user profile\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -71,22 +72,29 @@ int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int o;
|
int o;
|
||||||
|
AppServerOptions options = ASO_LOCAL;
|
||||||
char const * profile = NULL;
|
char const * profile = NULL;
|
||||||
char * shell[] = { "/bin/sh", NULL };
|
char * shell[] = { "/bin/sh", NULL };
|
||||||
|
|
||||||
while((o = getopt(argc, argv, "P:s")) != -1)
|
while((o = getopt(argc, argv, "LRP:s")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
{
|
{
|
||||||
|
case 'L':
|
||||||
|
options = ASO_LOCAL;
|
||||||
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
profile = optarg;
|
profile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
options = ASO_REMOTE;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
profile = "single-user";
|
profile = "single-user";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return _usage();
|
return _usage();
|
||||||
}
|
}
|
||||||
if((ret = _init(profile) != 0) && getpid() == 1)
|
if((ret = _init(options, profile) != 0) && getpid() == 1)
|
||||||
{
|
{
|
||||||
fputs(PACKAGE ": Spawning a shell\n", stderr);
|
fputs(PACKAGE ": Spawning a shell\n", stderr);
|
||||||
execve(shell[0], shell, NULL);
|
execve(shell[0], shell, NULL);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user