version 1.1.1.2, 2013/07/22 08:44:29
|
version 1.1.1.3, 2016/11/01 09:56:12
|
Line 87
|
Line 87
|
*/ |
*/ |
|
|
static const struct confinfo gConfList[] = { |
static const struct confinfo gConfList[] = { |
|
{ 0, CONSOLE_AUTH, "auth" }, |
|
{ 0, 0, NULL }, |
|
}; |
|
|
|
static const struct confinfo sConfList[] = { |
{ 0, CONSOLE_LOGGING, "logging" }, |
{ 0, CONSOLE_LOGGING, "logging" }, |
{ 0, 0, NULL }, |
{ 0, 0, NULL }, |
}; |
}; |
Line 107 ConsoleInit(Console c)
|
Line 112 ConsoleInit(Console c)
|
memset(&gConsole, 0, sizeof(gConsole)); |
memset(&gConsole, 0, sizeof(gConsole)); |
ParseAddr(DEFAULT_CONSOLE_IP, &c->addr, ALLOW_IPV4|ALLOW_IPV6); |
ParseAddr(DEFAULT_CONSOLE_IP, &c->addr, ALLOW_IPV4|ALLOW_IPV6); |
c->port = DEFAULT_CONSOLE_PORT; |
c->port = DEFAULT_CONSOLE_PORT; |
|
Enable(&c->options, CONSOLE_AUTH); |
|
|
SLIST_INIT(&c->sessions); |
SLIST_INIT(&c->sessions); |
|
|
Line 194 ConsoleStat(Context ctx, int ac, char *av[], void *arg
|
Line 200 ConsoleStat(Context ctx, int ac, char *av[], void *arg
|
} |
} |
RWLOCK_UNLOCK(c->lock); |
RWLOCK_UNLOCK(c->lock); |
|
|
|
Printf("Global options:\r\n"); |
|
OptStat(ctx, &c->options, gConfList); |
if (cs) { |
if (cs) { |
Printf("This session options:\r\n"); |
Printf("This session options:\r\n"); |
OptStat(ctx, &cs->options, gConfList); | OptStat(ctx, &cs->options, sConfList); |
} |
} |
return 0; |
return 0; |
} |
} |
Line 233 ConsoleConnect(int type, void *cookie)
|
Line 241 ConsoleConnect(int type, void *cookie)
|
cs->write = ConsoleSessionWrite; |
cs->write = ConsoleSessionWrite; |
cs->writev = ConsoleSessionWriteV; |
cs->writev = ConsoleSessionWriteV; |
cs->prompt = ConsoleSessionShowPrompt; |
cs->prompt = ConsoleSessionShowPrompt; |
cs->state = STATE_USERNAME; | if (!Enabled(&c->options, CONSOLE_AUTH)) { |
| cs->state = STATE_AUTHENTIC; |
| strcpy(cs->user.username, "root"); |
| cs->context.priv = 2; |
| } else { |
| cs->state = STATE_USERNAME; |
| } |
cs->context.cs = cs; |
cs->context.cs = cs; |
RWLOCK_WRLOCK(c->lock); |
RWLOCK_WRLOCK(c->lock); |
SLIST_INSERT_HEAD(&c->sessions, cs, next); |
SLIST_INSERT_HEAD(&c->sessions, cs, next); |
Line 793 ConsoleSetCommand(Context ctx, int ac, char *av[], voi
|
Line 807 ConsoleSetCommand(Context ctx, int ac, char *av[], voi
|
break; |
break; |
|
|
case SET_ENABLE: |
case SET_ENABLE: |
if (cs) | if (cs) { |
EnableCommand(ac, av, &cs->options, gConfList); | if (strcmp(av[0], "auth") != 0) |
| EnableCommand(ac, av, &cs->options, sConfList); |
| } else |
| EnableCommand(ac, av, &c->options, gConfList); |
break; |
break; |
|
|
case SET_DISABLE: |
case SET_DISABLE: |
if (cs) | if (cs) { |
DisableCommand(ac, av, &cs->options, gConfList); | if (strcmp(av[0], "auth") != 0) |
| DisableCommand(ac, av, &cs->options, sConfList); |
| } else |
| DisableCommand(ac, av, &c->options, gConfList); |
break; |
break; |
|
|
case SET_SELF: |
case SET_SELF: |
Line 888 UserStat(Context ctx, int ac, char *av[], void *arg)
|
Line 908 UserStat(Context ctx, int ac, char *av[], void *arg)
|
RWLOCK_RDLOCK(gUsersLock); |
RWLOCK_RDLOCK(gUsersLock); |
ghash_walk_init(gUsers, &walk); |
ghash_walk_init(gUsers, &walk); |
while ((u = ghash_walk_next(gUsers, &walk)) != NULL) { |
while ((u = ghash_walk_next(gUsers, &walk)) != NULL) { |
Printf("\tUsername: %-15s Priv:%s\r\n", u->username, | Printf("\tUsername: %-15s Priv: %s\r\n", u->username, |
((u->priv == 2)?"admin":((u->priv == 1)?"operator":"user"))); |
((u->priv == 2)?"admin":((u->priv == 1)?"operator":"user"))); |
} |
} |
RWLOCK_UNLOCK(gUsersLock); |
RWLOCK_UNLOCK(gUsersLock); |