/*
* Server functions which perform operations on user objects.
*
- * Copyright (c) 1987-2017 by the citadel.org team
+ * Copyright (c) 1987-2019 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
/*
- * cmd_info() - tell the client about this server
+ * cmd_info() - Identify this server and its capabilities to the client
*/
void cmd_info(char *cmdbuf) {
cprintf("%d Server info:\n", LISTING_FOLLOWS);
*/
void cmd_iden(char *argbuf)
{
- CitContext *CCC = MyContext();
int dev_code;
int cli_code;
int rev_level;
from_host[sizeof from_host - 1] = 0;
if (num_parms(argbuf)>=5) extract_token(from_host, argbuf, 4, '|', sizeof from_host);
- CCC->cs_clientdev = dev_code;
- CCC->cs_clienttyp = cli_code;
- CCC->cs_clientver = rev_level;
- safestrncpy(CCC->cs_clientname, desc, sizeof CCC->cs_clientname);
- CCC->cs_clientname[31] = 0;
-
- /* For local sockets and public clients, trust the hostname supplied by the client */
- if ( (CCC->is_local_socket) || (CtdlIsPublicClient()) ) {
- safestrncpy(CCC->cs_host, from_host, sizeof CCC->cs_host);
- CCC->cs_host[sizeof CCC->cs_host - 1] = 0;
- CCC->cs_addr[0] = 0;
+ CC->cs_clientdev = dev_code;
+ CC->cs_clienttyp = cli_code;
+ CC->cs_clientver = rev_level;
+ safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname);
+ CC->cs_clientname[31] = 0;
+
+ /* For local sockets, allow the client to supply the user's origin address */
+ if ((CC->is_local_client) || (!IsEmptyStr(CC->cs_addr) && (!strcmp(CC->cs_addr, "127.0.0.1")) || (!strcmp(CC->cs_addr, "::1")))) {
+ safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
+ CC->cs_host[sizeof CC->cs_host - 1] = 0;
+ CC->cs_addr[0] = 0;
}
syslog(LOG_NOTICE, "session: client %d/%d/%01d.%02d (%s) from %s",
(rev_level / 100),
(rev_level % 100),
desc,
- CCC->cs_host
+ CC->cs_host
);
cprintf("%d Ok\n",CIT_OK);
}
cprintf("%d Session terminated.\n", CIT_OK);
}
else {
- cprintf("%d You are not allowed to do that.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
+ cprintf("%d You are not allowed to do that.\n", ERROR + HIGHER_ACCESS_REQUIRED);
}
}
else {
void cmd_time(char *argbuf)
{
- time_t tv;
- struct tm tmp;
-
- tv = time(NULL);
- localtime_r(&tv, &tmp);
-
- /* timezone and daylight global variables are not portable. */
+ time_t tv;
+ struct tm tmp;
+
+ tv = time(NULL);
+ localtime_r(&tv, &tmp);
+
+ /* timezone and daylight global variables are not portable. */
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
- cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst, server_startup_time);
+ cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst, server_startup_time);
#else
- cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst, server_startup_time);
+ cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst, server_startup_time);
#endif
}