Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.
I was just playing with pserver, and it occurred to me that it might be nice if pserver used the currently-logged-on user by default. At the end of this mail, there is a diff for protocols/pserver.c to allow this on both Windows and UNIX. It might not work where the client is Windows and the server is UNIX (I haven't tried it), as windows has a tendency to return uppercase usernames, and UNIX systems tend to use lowercase usernames. Anthony -- Anthony Williams Software Engineer, Nortel Networks Optical Components Ltd The opinions expressed in this message are not necessarily those of my employer *** sol7/cvsnt-1.11.1.3/protocols/pserver.c Wed Feb 27 16:23:28 2002 --- cvsnt-1.11.1.3/protocols/pserver.c Mon Jun 10 17:05:13 2002 *************** *** 15,22 **** --- 15,25 ---- #include <string.h> #ifdef _WIN32 #include <winsock.h> + #include <lmcons.h> #else #include <netdb.h> + #include <pwd.h> + #include <unistd.h> #endif #ifndef MAX_PATH *************** *** 79,91 **** --- 82,121 ---- free(protocol->auth_repository); } + static const char* get_pserver_username(const cvsroot_t* current_root) + { + const char* username; + #ifdef _WIN32 + char username_buffer[UNLEN+1]; + DWORD buffer_length=UNLEN+1; + #endif + + username=current_root->username; + if(!username) + { + #ifdef _WIN32 + if(GetUserName(username_buffer,&buffer_length)) + { + username=username_buffer; + } + #else + username = getpwuid(getuid())->pw_name; + #endif + } + + return username; + } + + static int pserver_validate(const struct protocol_interface *protocol, const cvsroot_t *newroot) { + #ifdef _WIN32 if(!newroot->username) { server_error(0,"Username required"); return CVSPROTO_BADPARMS; } + #endif if(!newroot->hostname) { server_error(0,"Hostname required"); *************** *** 106,112 **** const char *begin_request = "BEGIN AUTH REQUEST"; const char *end_request = "END AUTH REQUEST"; ! if(!current_server->current_root->username || !current_server->current_root->hostname || !current_server->current_root->directory) return CVSPROTO_BADPARMS; port=pserver_get_port(protocol); --- 136,146 ---- const char *begin_request = "BEGIN AUTH REQUEST"; const char *end_request = "END AUTH REQUEST"; ! const char *username=NULL; ! ! username=get_pserver_username(current_server->current_root); ! ! if(!username || !current_server->current_root->hostname || !current_server->current_root->directory) return CVSPROTO_BADPARMS; port=pserver_get_port(protocol); *************** *** 118,124 **** } else { ! if(pserver_get_user_password(current_server->current_root->username,current_ server->current_root->hostname,current_server->current_root->port,current_se rver->current_root->directory,crypt_password,sizeof(crypt_password))) { /* Using null password - trace something out here */ server_error(0,"Empty password used - try 'cvs login' with a real password\n"); --- 152,158 ---- } else { ! if(pserver_get_user_password(username,current_server->current_root->hostname ,current_server->current_root->port,current_server->current_root->directory, crypt_password,sizeof(crypt_password))) { /* Using null password - trace something out here */ server_error(0,"Empty password used - try 'cvs login' with a real password\n"); *************** *** 132,138 **** end_request = "END VERIFICATION REQUEST"; } ! if(tcp_printf("%s\n%s\n%s\n%s\n%s\n",begin_request,current_server->current_r oot->directory,current_server->current_root->username,crypt_password,end_req uest)<0) return CVSPROTO_FAIL; return CVSPROTO_SUCCESS; } --- 166,172 ---- end_request = "END VERIFICATION REQUEST"; } ! if(tcp_printf("%s\n%s\n%s\n%s\n%s\n",begin_request,current_server->current_r oot->directory,username,crypt_password,end_request)<0) return CVSPROTO_FAIL; return CVSPROTO_SUCCESS; } *************** *** 147,155 **** int pserver_login(const struct protocol_interface *protocol, char *password) { char crypt_password[64]; /* Store username & encrypted password in password store */ pserver_crypt_password(password,crypt_password,sizeof(crypt_password)); ! if(pserver_set_user_password(current_server->current_root->username,current_ server->current_root->hostname,current_server->current_root->port,current_se rver->current_root->directory,crypt_password)) { server_error(1,"Failed to store password"); } --- 181,195 ---- int pserver_login(const struct protocol_interface *protocol, char *password) { char crypt_password[64]; + const char *username=NULL; + /* Store username & encrypted password in password store */ pserver_crypt_password(password,crypt_password,sizeof(crypt_password)); ! ! ! username=get_pserver_username(current_server->current_root); ! ! if(pserver_set_user_password(username,current_server->current_root->hostname ,current_server->current_root->port,current_server->current_root->directory, crypt_password)) { server_error(1,"Failed to store password"); } *************** *** 159,165 **** int pserver_logout(const struct protocol_interface *protocol) { ! if(pserver_set_user_password(current_server->current_root->username,current_ server->current_root->hostname,current_server->current_root->port,current_se rver->current_root->directory,NULL)) { server_error(1,"Failed to delete password"); } --- 199,209 ---- int pserver_logout(const struct protocol_interface *protocol) { ! const char *username=NULL; ! ! username=get_pserver_username(current_server->current_root); ! ! if(pserver_set_user_password(username,current_server->current_root->hostname ,current_server->current_root->port,current_server->current_root->directory, NULL)) { server_error(1,"Failed to delete password"); } _______________________________________________ Cvsnt mailing list Cvsnt at cvsnt.org http://www.cvsnt.org/cgi-bin/mailman/listinfo/cvsnt https://www.march-hare.com/cvspro/en.asp#downcvs