Eliminated the unpacking of uid in the chkpwd
authorArt Cancro <ajc@citadel.org>
Tue, 19 Jun 2007 15:23:25 +0000 (15:23 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 19 Jun 2007 15:23:25 +0000 (15:23 +0000)
binary protocol.  sizeof uid_t is now used, since it will
always be on the same host anyway.

citadel/chkpw.c
citadel/chkpwd.c
citadel/server_main.c
citadel/user_ops.c

index ac3f779ca9e128a9b4829739015efcf39a003d48..48e6c132bc05a0bf811527d60f5158370d6089c8 100644 (file)
@@ -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);
 
index a07ad18ac74d857eead2d50ed75393ce3db05f95..076138cf8b0b8326e8106dd253f8ace896d38728 100644 (file)
@@ -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)) {
index f27baeb6073ab28d9f3a5a6d7480cae3695677bf..e4c72ab42591308dbcd2cb46fe284b711e393c2e 100644 (file)
@@ -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"
index 417ef630cc3bb114553cc6571100a87899313a99..4ac224e521bdaf5c29cd8efbf8f1c4301c1dcaa9 100644 (file)
@@ -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);