From: Rick Bird Date: Tue, 19 Apr 2011 06:24:05 +0000 (-0400) Subject: Added --user= option to netmush to automatically login without X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=062139301a49fef3a5ed30354be9b7f23bcb48d5;p=cobramush.git Added --user= option to netmush to automatically login without password checking to any valid user. --- diff --git a/src/bsd.c b/src/bsd.c index 337b50b..b643541 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -403,6 +403,7 @@ void reopen_logs(void); void load_reboot_db(void); static bool in_suid_root_mode = 0; static char *pidfile = NULL; +static char *console_user = NULL; /* For defining a user to autmatically log into with console */ static char **saved_argv = NULL; int file_watch_init(void); @@ -461,6 +462,7 @@ main(int argc, char **argv) FILE *id; #endif FILE *newerr; + char *eq; bool detach_session = 1; struct module_entry_t *m; void (*handle)(); @@ -508,8 +510,28 @@ main(int argc, char **argv) detach_session = 0; console_input = dup(STDIN_FILENO); console_output = dup(STDOUT_FILENO); - } else if (strncmp(argv[n], "--pid-file", 10) == 0) { - char *eq; + } else if(strncmp(argv[n], "--user",6) == 0) { + fprintf(stderr, "USING USER OPTION\n"); + if ((eq = strchr(argv[n], '='))) { + console_user = eq + 1; + console_mode = 1; + detach_session = 0; + console_input = dup(STDIN_FILENO); + console_output = dup(STDOUT_FILENO); + } else { + if (n + 1 >= argc) { + fprintf(stderr, "%s: --user needs a user to log into.\n", argv[0]); + return EXIT_FAILURE; + } + console_user = argv[n + 1]; + n++; + /* Assume console mode & non-session */ + console_mode = 1; + detach_session = 0; + console_input = dup(STDIN_FILENO); + console_output = dup(STDOUT_FILENO); + } + } else if (strncmp(argv[n], "--pid-file", 10) == 0) { if ((eq = strchr(argv[n], '='))) pidfile = eq + 1; else { @@ -1658,6 +1680,7 @@ initializesock(int s, int os, char *addr, char *ip, int use_ssl __attribute__ ((__unused__))) { DESC *d; + dbref console_player; int n; d = (DESC *) mush_malloc(sizeof(DESC), "descriptor"); @@ -1726,7 +1749,24 @@ initializesock(int s, int os, char *addr, char *ip, int use_ssl } #endif test_telnet(d); - welcome_user(d); + if(console_user) { + console_player = lookup_player(console_user); + if(console_player != NOTHING) { + d->player = console_player; + d->connected = 2; + d->doing[0] = '\0'; + d->connected_at = mudtime; + ModTime(console_player) = (time_t) 0; + set_flag_internal(console_player, "CONNECTED"); + orator = console_player; + check_last(console_player, d->addr, d->ip); /* set Last, Lastsite, give paycheck */ + strcpy(global_eval_context.ccom, ""); + } else + fprintf(stderr, "No such player"); + } + if(d->player == 0) + welcome_user(d); + for(n = 0; n < MAX_SNOOPS; n++) d->snooper[n] = -1; return d;