* and in the global address book).
*/
int vcard_upload_beforesave(struct CtdlMessage *msg) {
+ struct CitContext *CCC = CC;
char *ptr;
char *s;
char buf[SIZ];
int yes_my_citadel_config = 0;
int yes_any_vcard_room = 0;
- if (!CC->logged_in) return(0); /* Only do this if logged in. */
+ if (!CCC->logged_in) return(0); /* Only do this if logged in. */
/* Is this some user's "My Citadel Config" room? */
- if ( (CC->room.QRflags && QR_MAILBOX)
- && (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) {
+ if (((CCC->room.QRflags & QR_MAILBOX) != 0) &&
+ (!strcasecmp(&CCC->room.QRname[11], USERCONFIGROOM)) ) {
/* Yes, we want to do this */
yes_my_citadel_config = 1;
#ifdef VCARD_SAVES_BY_AIDES_ONLY
/* Prevent non-aides from performing registration changes */
- if (CC->user.axlevel < AxAideU) {
+ if (CCC->user.axlevel < AxAideU) {
return(1);
}
#endif
}
/* Is this a room with an address book in it? */
- if (CC->room.QRdefaultview == VIEW_ADDRESSBOOK) {
+ if (CCC->room.QRdefaultview == VIEW_ADDRESSBOOK) {
yes_any_vcard_room = 1;
}
if (v == NULL) return(0); /* no vCards were found in this message */
/* If users cannot create their own accounts, they cannot re-register either. */
- if ( (yes_my_citadel_config) && (config.c_disable_newu) && (CC->user.axlevel < AxAideU) ) {
+ if ( (yes_my_citadel_config) && (config.c_disable_newu) && (CCC->user.axlevel < AxAideU) ) {
return(1);
}
* delete the old one. First, figure out which user
* is being re-registered...
*/
- what_user = atol(CC->room.QRname);
+ what_user = atol(CCC->room.QRname);
- if (what_user == CC->user.usernum) {
+ if (what_user == CCC->user.usernum) {
/* It's the logged in user. That was easy. */
- memcpy(&usbuf, &CC->user, sizeof(struct ctdluser));
+ memcpy(&usbuf, &CCC->user, sizeof(struct ctdluser));
}
else if (CtdlGetUserByNumber(&usbuf, what_user) == 0) {
* vCard in the user's config room at all times.
*
*/
- CtdlDeleteMessages(CC->room.QRname, NULL, 0, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$");
+ CtdlDeleteMessages(CCC->room.QRname, NULL, 0, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$");
/* Make the author of the message the name of the user. */
if (msg->cm_fields['A'] != NULL) {
* address book).
*/
int vcard_upload_aftersave(struct CtdlMessage *msg) {
+ struct CitContext *CCC = CC;
char *ptr;
int linelen;
long I;
char roomname[ROOMNAMELEN];
if (msg->cm_format_type != 4) return(0);
- if (!CC->logged_in) return(0); /* Only do this if logged in. */
+ if (!CCC->logged_in) return(0); /* Only do this if logged in. */
/* We're interested in user config rooms only. */
- if ( (strlen(CC->room.QRname) >= 12) && (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) {
+ if ( (strlen(CCC->room.QRname) >= 12) && (!strcasecmp(&CCC->room.QRname[11], USERCONFIGROOM)) ) {
is_UserConf = 1; /* It's someone's config room */
}
- CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCONFIGROOM);
- if (!strcasecmp(CC->room.QRname, roomname)) {
+ CtdlMailboxName(roomname, sizeof roomname, &CCC->user, USERCONFIGROOM);
+ if (!strcasecmp(CCC->room.QRname, roomname)) {
is_UserConf = 1;
is_MY_UserConf = 1; /* It's MY config room */
}
- if (!strcasecmp(CC->room.QRname, ADDRESS_BOOK_ROOM)) {
+ if (!strcasecmp(CCC->room.QRname, ADDRESS_BOOK_ROOM)) {
is_GAB = 1; /* It's the Global Address Book */
}
ptr = msg->cm_fields['M'];
if (ptr == NULL) return(0);
- NewStrBufDupAppendFlush(&CC->StatusMessage, NULL, NULL, 0);
+ NewStrBufDupAppendFlush(&CCC->StatusMessage, NULL, NULL, 0);
- StrBufPrintf(CC->StatusMessage, "%d\n", LISTING_FOLLOWS);
+ StrBufPrintf(CCC->StatusMessage, "%d\n", LISTING_FOLLOWS);
while (ptr != NULL) {
/* Store our Internet return address in memory */
if (is_MY_UserConf) {
v = vcard_load(msg->cm_fields['M']);
- extract_inet_email_addrs(CC->cs_inet_email, sizeof CC->cs_inet_email,
- CC->cs_inet_other_emails, sizeof CC->cs_inet_other_emails,
+ extract_inet_email_addrs(CCC->cs_inet_email, sizeof CCC->cs_inet_email,
+ CCC->cs_inet_other_emails, sizeof CCC->cs_inet_other_emails,
v, 1);
- extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
+ extract_friendly_name(CCC->cs_inet_fn, sizeof CCC->cs_inet_fn, v);
vcard_free(v);
}
* But if the user was an Aide or was edited by an Aide then we can
* Assume they don't need validating.
*/
- if (CC->user.axlevel >= AxAideU) {
- CtdlGetUserLock(&CC->user, CC->curr_user);
- CC->user.flags |= US_REGIS;
- CtdlPutUserLock(&CC->user);
+ if (CCC->user.axlevel >= AxAideU) {
+ CtdlGetUserLock(&CCC->user, CCC->curr_user);
+ CCC->user.flags |= US_REGIS;
+ CtdlPutUserLock(&CCC->user);
return (0);
}
set_mm_valid();
/* ...which also means we need to flag the user */
- CtdlGetUserLock(&CC->user, CC->curr_user);
- CC->user.flags |= (US_REGIS|US_NEEDVALID);
- CtdlPutUserLock(&CC->user);
+ CtdlGetUserLock(&CCC->user, CCC->curr_user);
+ CCC->user.flags |= (US_REGIS|US_NEEDVALID);
+ CtdlPutUserLock(&CCC->user);
return(0);
}
* and return an empty vCard.
*/
struct vCard *vcard_get_user(struct ctdluser *u) {
+ struct CitContext *CCC = CC;
char hold_rm[ROOMNAMELEN];
char config_rm[ROOMNAMELEN];
struct CtdlMessage *msg = NULL;
struct vCard *v;
long VCmsgnum;
- strcpy(hold_rm, CC->room.QRname); /* save current room */
+ strcpy(hold_rm, CCC->room.QRname); /* save current room */
CtdlMailboxName(config_rm, sizeof config_rm, u, USERCONFIGROOM);
- if (CtdlGetRoom(&CC->room, config_rm) != 0) {
- CtdlGetRoom(&CC->room, hold_rm);
+ if (CtdlGetRoom(&CCC->room, config_rm) != 0) {
+ CtdlGetRoom(&CCC->room, hold_rm);
return vcard_new();
}
VCmsgnum = (-1);
CtdlForEachMessage(MSGS_LAST, 1, NULL, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$",
NULL, vcard_gu_backend, (void *)&VCmsgnum );
- CtdlGetRoom(&CC->room, hold_rm); /* return to saved room */
+ CtdlGetRoom(&CCC->room, hold_rm); /* return to saved room */
if (VCmsgnum < 0L) return vcard_new();
* and enters the vCard into the user's configuration.
*/
void cmd_regi(char *argbuf) {
+ struct CitContext *CCC = CC;
int a,b,c;
char buf[SIZ];
struct vCard *my_vcard;
unbuffer_output();
- if (!(CC->logged_in)) {
+ if (!(CCC->logged_in)) {
cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
return;
}
/* If users cannot create their own accounts, they cannot re-register either. */
- if ( (config.c_disable_newu) && (CC->user.axlevel < AxAideU) ) {
+ if ( (config.c_disable_newu) && (CCC->user.axlevel < AxAideU) ) {
cprintf("%d Self-service registration is not allowed here.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
}
- my_vcard = vcard_get_user(&CC->user);
+ my_vcard = vcard_get_user(&CCC->user);
strcpy(tmpaddr, "");
strcpy(tmpcity, "");
strcpy(tmpstate, "");
snprintf(tmpaddress, sizeof tmpaddress, ";;%s;%s;%s;%s;%s",
tmpaddr, tmpcity, tmpstate, tmpzip, tmpcountry);
vcard_set_prop(my_vcard, "adr", tmpaddress, 0);
- vcard_write_user(&CC->user, my_vcard);
+ vcard_write_user(&CCC->user, my_vcard);
vcard_free(my_vcard);
}
*/
void cmd_greg(char *argbuf)
{
+ struct CitContext *CCC = CC;
struct ctdluser usbuf;
struct vCard *v;
char *s;
extract_token(who, argbuf, 0, '|', sizeof who);
- if (!(CC->logged_in)) {
+ if (!(CCC->logged_in)) {
cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
return;
}
- if (!strcasecmp(who,"_SELF_")) strcpy(who,CC->curr_user);
+ if (!strcasecmp(who,"_SELF_")) strcpy(who,CCC->curr_user);
- if ((CC->user.axlevel < AxAideU) && (strcasecmp(who,CC->curr_user))) {
+ if ((CCC->user.axlevel < AxAideU) && (strcasecmp(who,CCC->curr_user))) {
cprintf("%d Higher access required.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
return;
*/
void cmd_gvsn(char *argbuf)
{
+ struct CitContext *CCC = CC;
+
if (CtdlAccessCheck(ac_logged_in)) return;
cprintf("%d valid screen names:\n", LISTING_FOLLOWS);
- cprintf("%s\n", CC->user.fullname);
- if ( (!IsEmptyStr(CC->cs_inet_fn)) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) {
- cprintf("%s\n", CC->cs_inet_fn);
+ cprintf("%s\n", CCC->user.fullname);
+ if ( (!IsEmptyStr(CCC->cs_inet_fn)) && (strcasecmp(CCC->user.fullname, CCC->cs_inet_fn)) ) {
+ cprintf("%s\n", CCC->cs_inet_fn);
}
cprintf("000\n");
}
*/
void cmd_gvea(char *argbuf)
{
+ struct CitContext *CCC = CC;
int num_secondary_emails = 0;
int i;
char buf[256];
if (CtdlAccessCheck(ac_logged_in)) return;
cprintf("%d valid email addresses:\n", LISTING_FOLLOWS);
- if (!IsEmptyStr(CC->cs_inet_email)) {
- cprintf("%s\n", CC->cs_inet_email);
+ if (!IsEmptyStr(CCC->cs_inet_email)) {
+ cprintf("%s\n", CCC->cs_inet_email);
}
- if (!IsEmptyStr(CC->cs_inet_other_emails)) {
- num_secondary_emails = num_tokens(CC->cs_inet_other_emails, '|');
+ if (!IsEmptyStr(CCC->cs_inet_other_emails)) {
+ num_secondary_emails = num_tokens(CCC->cs_inet_other_emails, '|');
for (i=0; i<num_secondary_emails; ++i) {
- extract_token(buf, CC->cs_inet_other_emails,i,'|',sizeof CC->cs_inet_other_emails);
+ extract_token(buf, CCC->cs_inet_other_emails,i,'|',sizeof CCC->cs_inet_other_emails);
cprintf("%s\n", buf);
}
}
if (rv == -1)
syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]",
filename, strerror(errno));
+ rv = chmod(filename, 0600);
+ if (rv == -1)
+ syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]",
+ filename, strerror(errno));
}
/* for postfix tcpdict */