From df4369884b613dbd63f2f1a5466ccdbd0048531c Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 19 Jun 2007 15:23:25 +0000 Subject: [PATCH] Eliminated the unpacking of uid in the chkpwd binary protocol. sizeof uid_t is now used, since it will always be on the same host anyway. --- citadel/chkpw.c | 3 +-- citadel/chkpwd.c | 3 +-- citadel/server_main.c | 1 + citadel/user_ops.c | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/citadel/chkpw.c b/citadel/chkpw.c index ac3f779ca..48e6c132b 100644 --- a/citadel/chkpw.c +++ b/citadel/chkpw.c @@ -26,8 +26,7 @@ static int validpw(uid_t uid, const char *pass) { char buf[256]; - snprintf(buf, sizeof buf, "%016d", uid); - write(chkpwd_write_pipe[1], buf, 16); + write(chkpwd_write_pipe[1], &uid, sizeof(uid_t)); write(chkpwd_write_pipe[1], pass, 256); read(chkpwd_read_pipe[0], buf, 4); diff --git a/citadel/chkpwd.c b/citadel/chkpwd.c index a07ad18ac..076138cf8 100644 --- a/citadel/chkpwd.c +++ b/citadel/chkpwd.c @@ -26,8 +26,7 @@ int main(void) char buf[SIZ]; while (1) { - read(0, buf, 16); /* uid */ - uid = atoi(buf); + read(0, &uid, sizeof(uid_t)); /* uid */ read(0, buf, 256); /* password */ if (validate_password(uid, buf)) { diff --git a/citadel/server_main.c b/citadel/server_main.c index f27baeb60..e4c72ab42 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -53,6 +53,7 @@ #include "config.h" #include "control.h" #include "database.h" +#include "user_ops.h" #include "housekeeping.h" #include "tools.h" #include "citadel_dirs.c" diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 417ef630c..4ac224e52 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -592,8 +592,7 @@ static int validpw(uid_t uid, const char *pass) lprintf(CTDL_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid); begin_critical_section(S_CHKPWD); - snprintf(buf, sizeof buf, "%016d", uid); - write(chkpwd_write_pipe[1], buf, 16); + write(chkpwd_write_pipe[1], &uid, sizeof(uid_t)); write(chkpwd_write_pipe[1], pass, 256); read(chkpwd_read_pipe[0], buf, 4); end_critical_section(S_CHKPWD); -- 2.39.2