X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fuser_ops.c;h=e19f238b0359fddac35def6586ae2dca5bd98cd1;hb=1b71b791e56100f731d23aeec7a47c9d9ca2d7e0;hp=5c3379b13c9a5b91c000a9c1fee30f73335d3cda;hpb=365a7b93fe804fe6c618946086fc74c2c39b2dae;p=citadel.git diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 5c3379b13..e19f238b0 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -38,7 +38,6 @@ int chkpwd_read_pipe[2]; */ int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len) { - char usernamekey[USERNAME_SIZE]; struct cdbdata *cdbus; @@ -68,13 +67,14 @@ int CtdlGetUser(struct ctdluser *usbuf, char *name) return CtdlGetUserLen(usbuf, name, cutuserkey(name)); } + int CtdlLockGetCurrentUser(void) { CitContext *CCC = CC; - return CtdlGetUserLen(&CCC->user, CCC->curr_user, cutuserkey(CCC->curr_user)); } + /* * CtdlGetUserLock() - same as getuser() but locks the record */ @@ -97,17 +97,12 @@ void CtdlPutUser(struct ctdluser *usbuf) { char usernamekey[USERNAME_SIZE]; - makeuserkey(usernamekey, - usbuf->fullname, - cutuserkey(usbuf->fullname)); - + makeuserkey(usernamekey, usbuf->fullname, cutuserkey(usbuf->fullname)); usbuf->version = REV_LEVEL; - cdb_store(CDB_USERS, - usernamekey, strlen(usernamekey), - usbuf, sizeof(struct ctdluser)); - + cdb_store(CDB_USERS, usernamekey, strlen(usernamekey), usbuf, sizeof(struct ctdluser)); } + void CtdlPutCurrentUserLock() { CtdlPutUser(&CC->user); @@ -124,7 +119,6 @@ void CtdlPutUserLock(struct ctdluser *usbuf) } - /* * rename_user() - this is tricky because the user's display name is the database key * @@ -166,7 +160,7 @@ int rename_user(char *oldname, char *newname) { syslog(LOG_DEBUG, "user_ops: can not rename user \"Citadel\"."); retcode = RENAMEUSER_NOT_FOUND; } else { - syslog(LOG_DEBUG, "user_ops: renaming <%s> to <%s>\n", oldname, newname); + syslog(LOG_DEBUG, "user_ops: renaming <%s> to <%s>", oldname, newname); cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey)); safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname); CtdlPutUser(&usbuf); @@ -182,7 +176,6 @@ int rename_user(char *oldname, char *newname) { } - /* * Index-generating function used by Ctdl[Get|Set]Relationship */ @@ -233,8 +226,6 @@ void CtdlSetRelationship(visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room) { - - /* We don't use these in Citadel because they're implicit by the * index, but they must be present if the database is exported. */ @@ -245,6 +236,7 @@ void CtdlSetRelationship(visit *newvisit, put_visit(newvisit); } + /* * Locate a relationship between a user and a room */ @@ -252,7 +244,6 @@ void CtdlGetRelationship(visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room) { - char IndexBuf[32]; int IndexLen; struct cdbdata *cdbvisit; @@ -321,6 +312,7 @@ int CtdlCheckInternetMailPermission(struct ctdluser *who) { return(0); } + /* * Convenience function. */ @@ -328,8 +320,7 @@ int CtdlAccessCheck(int required_level) { if (CC->internal_pgm) return(0); if (required_level >= ac_internal) { - cprintf("%d This is not a user-level command.\n", - ERROR + HIGHER_ACCESS_REQUIRED); + cprintf("%d This is not a user-level command.\n", ERROR + HIGHER_ACCESS_REQUIRED); return(-1); } @@ -362,7 +353,6 @@ int CtdlAccessCheck(int required_level) } - /* * Is the user currently logged in an Admin? */ @@ -809,7 +799,7 @@ void start_chkpwd_daemon(void) { syslog(LOG_DEBUG, "user_ops: starting chkpwd daemon for host authentication mode"); if ((stat(file_chkpwd, &filestats)==-1) || (filestats.st_size==0)) { - printf("didn't find chkpwd daemon in %s: %s\n", file_chkpwd, strerror(errno)); + syslog(LOG_ERR, "user_ops: %s: %s", file_chkpwd, strerror(errno)); abort(); } if (pipe(chkpwd_write_pipe) != 0) { @@ -1044,11 +1034,9 @@ int create_user(const char *newusername, long len, int become_user) char buf[SIZ]; int retval; uid_t uid = (-1); - safestrncpy(username, newusername, sizeof username); strproc(username); - if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {