From 826a38d67f663f93844309e91778f036903dcce4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 9 Jul 2017 23:34:01 -0400 Subject: [PATCH] Editing of account email addresses using the new server commands in WebCit-classic. This completes the transition. --- webcit/crypto.c | 2 +- webcit/ical_dezonify.c | 2 +- webcit/static/t/aide/edituser/detailview.html | 8 ++ webcit/tcp_sockets.c | 10 +-- webcit/useredit.c | 81 +++++++++++++++++-- webcit/webserver.c | 8 +- 6 files changed, 95 insertions(+), 16 deletions(-) diff --git a/webcit/crypto.c b/webcit/crypto.c index 6925dfa8f..427b4d93e 100644 --- a/webcit/crypto.c +++ b/webcit/crypto.c @@ -85,7 +85,7 @@ void init_ssl(void) for (a = 0; a < CRYPTO_num_locks(); a++) { SSLCritters[a] = malloc(sizeof(pthread_mutex_t)); if (!SSLCritters[a]) { - syslog(LOG_EMERG, + syslog(LOG_ERR, "citserver: can't allocate memory!!\n"); /** Nothing's been initialized, just die */ ShutDownWebcit(); diff --git a/webcit/ical_dezonify.c b/webcit/ical_dezonify.c index 935ae74dc..537bcc3e1 100644 --- a/webcit/ical_dezonify.c +++ b/webcit/ical_dezonify.c @@ -28,7 +28,7 @@ icaltimezone *get_default_icaltimezone(void) { zone = icaltimezone_get_utc_timezone(); } if (!zone) { - syslog(LOG_EMERG, "Unable to load UTC time zone!\n"); + syslog(LOG_ERR, "Unable to load UTC time zone!\n"); } return zone; } diff --git a/webcit/static/t/aide/edituser/detailview.html b/webcit/static/t/aide/edituser/detailview.html index a8da87fd6..b5695ddd8 100644 --- a/webcit/static/t/aide/edituser/detailview.html +++ b/webcit/static/t/aide/edituser/detailview.html @@ -28,6 +28,14 @@ > + + + " maxlength="63"> + + + + " maxlength="512"> + diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index 2f969242e..f8705872c 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1987-2012 by the citadel.org team + * Copyright (c) 1987-2017 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. @@ -293,12 +293,12 @@ void FlushReadBuf (void) pche = pch + len; if (WCC->ReadPos != pche) { - syslog(LOG_EMERG, + syslog(LOG_ERR, "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", (long)(pche - WCC->ReadPos), pche ); - syslog(LOG_EMERG, + syslog(LOG_ERR, "--------------------------------------------------------------------------------\n" "Whole buf: [%s]\n" "--------------------------------------------------------------------------------\n", @@ -901,13 +901,13 @@ retry: } if (b < 0) { - syslog(LOG_EMERG, "Can't bind: %s\n", strerror(errno)); + syslog(LOG_ERR, "Can't bind: %s\n", strerror(errno)); close(s); return (-WC_EXIT_BIND); } if (listen(s, queue_len) < 0) { - syslog(LOG_EMERG, "Can't listen: %s\n", strerror(errno)); + syslog(LOG_ERR, "Can't listen: %s\n", strerror(errno)); close(s); return (-WC_EXIT_BIND); } diff --git a/webcit/useredit.c b/webcit/useredit.c index e0ac08f01..af6a02276 100644 --- a/webcit/useredit.c +++ b/webcit/useredit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996-2012 by the citadel.org team + * Copyright (c) 1996-2017 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. @@ -40,6 +40,10 @@ typedef struct _UserListEntry { unsigned int Flags; int DaysTillPurge; int HasBio; + + StrBuf *PrimaryEmail; + StrBuf *OtherEmails; + } UserListEntry; @@ -53,6 +57,8 @@ UserListEntry* NewUserListOneEntry(StrBuf *SerializedUser, const char *Pos) ul = (UserListEntry*) malloc(sizeof(UserListEntry)); ul->UserName = NewStrBuf(); ul->Passvoid = NewStrBuf(); + ul->PrimaryEmail = NewStrBuf(); + ul->OtherEmails = NewStrBuf(); StrBufExtract_NextToken(ul->UserName, SerializedUser, &Pos, '|'); StrBufExtract_NextToken(ul->Passvoid, SerializedUser, &Pos, '|'); @@ -72,6 +78,8 @@ void DeleteUserListEntry(void *vUserList) if (!ul) return; FreeStrBuf(&ul->UserName); FreeStrBuf(&ul->Passvoid); + FreeStrBuf(&ul->PrimaryEmail); + FreeStrBuf(&ul->OtherEmails); free(ul); } @@ -86,6 +94,8 @@ UserListEntry* NewUserListEntry(StrBuf *SerializedUserList) ul = (UserListEntry*) malloc(sizeof(UserListEntry)); ul->UserName = NewStrBuf(); ul->Passvoid = NewStrBuf(); + ul->PrimaryEmail = NewStrBuf(); + ul->OtherEmails = NewStrBuf(); StrBufExtract_NextToken(ul->UserName, SerializedUserList, &Pos, '|'); ul->AccessLevel = StrBufExtractNext_int( SerializedUserList, &Pos, '|'); @@ -302,9 +312,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP) Done = 0; while (!Done) { len = StrBuf_ServGetln(Buf); - if ((len <0) || - ((len == 3) && - !strcmp(ChrPtr(Buf), "000"))) + if ((len <0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) { Done = 1; break; @@ -340,6 +348,18 @@ void tmplput_USERLIST_Password(StrBuf *Target, WCTemplputParams *TP) StrBufAppendTemplate(Target, TP, ul->Passvoid, 0); } +void tmplput_USERLIST_PrimaryEmail(StrBuf *Target, WCTemplputParams *TP) +{ + UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST); + StrBufAppendTemplate(Target, TP, ul->PrimaryEmail, 0); +} + +void tmplput_USERLIST_OtherEmails(StrBuf *Target, WCTemplputParams *TP) +{ + UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST); + StrBufAppendTemplate(Target, TP, ul->OtherEmails, 0); +} + void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, WCTemplputParams *TP) { UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST); @@ -643,6 +663,7 @@ void display_edituser(const char *supplied_username, int is_new) { UserListEntry* UL; StrBuf *Buf; char username[256]; + int i = 0; if (supplied_username != NULL) { safestrncpy(username, supplied_username, sizeof username); @@ -669,6 +690,24 @@ void display_edituser(const char *supplied_username, int is_new) { delete_user(username); } else if (UL != NULL) { + + serv_printf("AGEA %s", username); + StrBuf_ServGetln(Buf); + if (GetServerStatusMsg(Buf, NULL, 1, 2) == 1) { + while(StrBuf_ServGetln(Buf) , strcmp(ChrPtr(Buf), "000")) { + if (i == 0) { + StrBufAppendPrintf(UL->PrimaryEmail, "%s", ChrPtr(Buf)); + } + if (i > 1) { + StrBufAppendPrintf(UL->OtherEmails, ","); + } + if (i > 0) { + StrBufAppendPrintf(UL->OtherEmails, "%s", ChrPtr(Buf)); + } + ++i; + } + } + WCTemplputParams SubTP; memset(&SubTP, 0, sizeof(WCTemplputParams)); SubTP.Filter.ContextType = CTX_USERLIST; @@ -716,6 +755,7 @@ void edituser(void) { } } + /* Send the new account parameters */ serv_printf("ASUP %s|%s|%d|%s|%s|%s|%s|%s|%s|", username, bstr("password"), @@ -729,6 +769,36 @@ void edituser(void) { ); StrBuf_ServGetln(Buf); GetServerStatusMsg(Buf, NULL, 1, 2); + + /* Send the new email addresses. First make up a delimited list... */ + char all_the_emails[512]; + snprintf(all_the_emails, sizeof all_the_emails, "%s,%s", bstr("primaryemail"), bstr("otheremails")); + + /* Replace any commas, semicolons, or spaces with newlines */ + char *pos; + for (pos=all_the_emails; *pos!=0; ++pos) { + if ((*pos == ',') || (*pos == ';') || (*pos == ' ')) *pos = '\n' ; + } + + /* Remove any naughty inappropriate whitespace */ + striplt(all_the_emails); + while (pos = strstr(all_the_emails, "\n,"), (pos != NULL)) { + strcpy(pos, pos+1); + } + while (pos = strstr(all_the_emails, ",\n"), (pos != NULL)) { + strcpy(pos+1, pos+2); + } + while (pos = strstr(all_the_emails, "\n\n"), (pos != NULL)) { + strcpy(pos+1, pos+2); + } + + /* Now send it to the server. */ + serv_printf("ASEA %s", username); + StrBuf_ServGetln(Buf); + if (GetServerStatusMsg(Buf, NULL, 1, 2) == 4) { + serv_printf("%s\n000", all_the_emails); + } + FreeStrBuf(&Buf); } @@ -830,7 +900,8 @@ InitModule_USEREDIT RegisterNamespace("USERLIST:LASTLOGON:NO", 0, 0, tmplput_USERLIST_LastLogonNo, NULL, CTX_USERLIST); RegisterNamespace("USERLIST:NLOGONS", 0, 0, tmplput_USERLIST_nLogons, NULL, CTX_USERLIST); RegisterNamespace("USERLIST:NPOSTS", 0, 0, tmplput_USERLIST_nPosts, NULL, CTX_USERLIST); - + RegisterNamespace("USERLIST:PRIMARYEMAIL", 0, 1, tmplput_USERLIST_PrimaryEmail, NULL, CTX_USERLIST); + RegisterNamespace("USERLIST:OTHEREMAILS", 0, 1, tmplput_USERLIST_OtherEmails, NULL, CTX_USERLIST); RegisterNamespace("USERLIST:FLAGS", 0, 0, tmplput_USERLIST_Flags, NULL, CTX_USERLIST); RegisterNamespace("USERLIST:DAYSTILLPURGE", 0, 0, tmplput_USERLIST_DaysTillPurge, NULL, CTX_USERLIST); diff --git a/webcit/webserver.c b/webcit/webserver.c index 0ea5e3fe8..e0e6e403b 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996-2016 by the citadel.org team + * Copyright (c) 1996-2017 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. @@ -234,7 +234,7 @@ int main(int argc, char **argv) /* Tell 'em who's in da house */ syslog(LOG_NOTICE, "%s", PACKAGE_STRING); - syslog(LOG_NOTICE, "Copyright (C) 1996-2016 by the citadel.org team"); + syslog(LOG_NOTICE, "Copyright (C) 1996-2017 by the citadel.org team"); syslog(LOG_NOTICE, " "); syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or"); syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3."); @@ -283,7 +283,7 @@ int main(int argc, char **argv) * wcsession struct to which the thread is currently bound. */ if (pthread_key_create(&MyConKey, NULL) != 0) { - syslog(LOG_EMERG, "Can't create TSD key: %s", strerror(errno)); + syslog(LOG_ERR, "Can't create TSD key: %s", strerror(errno)); } InitialiseSemaphores(); @@ -295,7 +295,7 @@ int main(int argc, char **argv) */ #ifdef HAVE_OPENSSL if (pthread_key_create(&ThreadSSL, NULL) != 0) { - syslog(LOG_EMERG, "Can't create TSD key: %s", strerror(errno)); + syslog(LOG_ERR, "Can't create TSD key: %s", strerror(errno)); } #endif -- 2.30.2