diff options
author | lulf <lulf@FreeBSD.org> | 2010-02-02 05:57:42 +0000 |
---|---|---|
committer | lulf <lulf@FreeBSD.org> | 2010-02-02 05:57:42 +0000 |
commit | 261160bd72e886fafa189eea83e951826443c722 (patch) | |
tree | 92768e0d706894d7a40649884888d7c43c8ace45 /contrib/csup/proto.c | |
parent | 4bbdc41fe9f4d06b09d1a7d03aa1521cb317007c (diff) | |
download | FreeBSD-src-261160bd72e886fafa189eea83e951826443c722.zip FreeBSD-src-261160bd72e886fafa189eea83e951826443c722.tar.gz |
- Add support for CVSup authentication mechanisms to csup.
- Include a cpasswd script performing the same mechanisms as the cvpasswd
utility from CVSup.
PR: bin/114129
Submitted by: Petar Zhivkov Petrov <pesho.petrov -at- gmail.com>
MFC after: 1 month
Diffstat (limited to 'contrib/csup/proto.c')
-rw-r--r-- | contrib/csup/proto.c | 54 |
1 files changed, 2 insertions, 52 deletions
diff --git a/contrib/csup/proto.c b/contrib/csup/proto.c index 15c1235..166a134 100644 --- a/contrib/csup/proto.c +++ b/contrib/csup/proto.c @@ -45,6 +45,7 @@ #include <string.h> #include <unistd.h> +#include "auth.h" #include "config.h" #include "detailer.h" #include "fattr.h" @@ -74,7 +75,6 @@ static void killer_stop(struct killer *); static int proto_waitconnect(int); static int proto_greet(struct config *); static int proto_negproto(struct config *); -static int proto_login(struct config *); static int proto_fileattr(struct config *); static int proto_xchgcoll(struct config *); static struct mux *proto_mux(struct config *); @@ -251,56 +251,6 @@ bad: return (STATUS_FAILURE); } -static int -proto_login(struct config *config) -{ - struct stream *s; - char hostbuf[MAXHOSTNAMELEN]; - char *line, *login, *host, *cmd, *realm, *challenge, *msg; - int error; - - s = config->server; - error = gethostname(hostbuf, sizeof(hostbuf)); - hostbuf[sizeof(hostbuf) - 1] = '\0'; - if (error) - host = NULL; - else - host = hostbuf; - login = getlogin(); - proto_printf(s, "USER %s %s\n", login != NULL ? login : "?", - host != NULL ? host : "?"); - stream_flush(s); - line = stream_getln(s, NULL); - cmd = proto_get_ascii(&line); - realm = proto_get_ascii(&line); - challenge = proto_get_ascii(&line); - if (challenge == NULL || line != NULL) - goto bad; - if (strcmp(realm, ".") != 0 || strcmp(challenge, ".") != 0) { - lprintf(-1, "Authentication required by the server and not " - "supported by client\n"); - return (STATUS_FAILURE); - } - proto_printf(s, "AUTHMD5 . . .\n"); - stream_flush(s); - line = stream_getln(s, NULL); - cmd = proto_get_ascii(&line); - if (cmd == NULL || line == NULL) - goto bad; - if (strcmp(cmd, "OK") == 0) - return (STATUS_SUCCESS); - if (strcmp(cmd, "!") == 0) { - msg = proto_get_rest(&line); - if (msg == NULL) - goto bad; - lprintf(-1, "Server error: %s\n", msg); - return (STATUS_FAILURE); - } -bad: - lprintf(-1, "Invalid server reply to AUTHMD5\n"); - return (STATUS_FAILURE); -} - /* * File attribute support negotiation. */ @@ -601,7 +551,7 @@ proto_run(struct config *config) if (status == STATUS_SUCCESS) status = proto_negproto(config); if (status == STATUS_SUCCESS) - status = proto_login(config); + status = auth_login(config); if (status == STATUS_SUCCESS) status = proto_fileattr(config); if (status == STATUS_SUCCESS) |